summaryrefslogtreecommitdiff
path: root/src/pmview/barmod.h
blob: 073f7ce9d7d8c658e819197eb593b093a28a15d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/*
 * Copyright (c) 1997 Silicon Graphics, Inc.  All Rights Reserved.
 * Copyright (c) 2009 Aconex.  All Rights Reserved.
 * 
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * for more details.
 */
#ifndef _BARMOD_H_
#define _BARMOD_H_

#include "colorscale.h"
#include "modulate.h"
#include <QtCore/QVector>

class SoBaseColor;
class SoScale;
class SoNode;
class SoTranslation;
class Launch;

struct BarBlock {
    SoSeparator		*_sep;
    SoBaseColor		*_color;
    SoScale		*_scale;
    SoTranslation	*_tran;
    Modulate::State	_state;
    bool		_selected;
};

typedef QVector<BarBlock> BarBlockList;

class BarMod : public Modulate
{
public:

    enum Direction      { instPerCol, instPerRow };
    enum Modulation     { yScale, color, colYScale };    
    enum Grouping	{ groupByRow, groupByCol, groupByMetric, groupByInst };

private:

    static const char theBarId;

    BarBlockList	_blocks;
    Direction		_dir;
    Modulation		_mod;
    Grouping		_group;
    ColorScale		_colScale;
    int			_selectCount;
    int			_infoValue;
    int			_infoMetric;
    int			_infoInst;
    float		_xScale;
    float		_yScale;
    float		_zScale;
    int			_width;
    int			_depth;
    int			_cols;
    int			_rows;

public:

    virtual ~BarMod();

    BarMod(MetricList *list,
	   SoNode *obj,
	   BarMod::Direction dir,
	   BarMod::Grouping group,
	   float xScale, float yScale, float zScale,
	   float xSpace, float zSpace);

    BarMod(MetricList *list,
	   const ColorScale &colScale,
	   SoNode *obj,
	   BarMod::Direction dir,
	   BarMod::Modulation mod,
	   BarMod::Grouping group,
	   float xScale, float yScale, float zScale,
	   float xSpace, float zSpace);

    Direction	dir() const
	{ return _dir; }
    int		width() const
	{ return _width; }
    int		depth() const
	{ return _depth; }
    int		numBars() const
	{ return _blocks.size(); }
    int		rows() const
	{ return _rows; }
    int		cols() const
	{ return _cols; }

    virtual void refresh(bool fetchFlag);

    virtual void selectAll();
    virtual int select(SoPath *);
    virtual int remove(SoPath *);

    virtual void selectInfo(SoPath *);
    virtual void removeInfo(SoPath *);

    virtual void infoText(QString &str, bool) const;

    virtual void launch(Launch &launch, bool) const;

    virtual void dump(QTextStream &) const;

    void regenerate(float xScale, float zScale, float xSpace, float zSpace);

    const char *dirStr() const;
    const char *modStr() const;

private:

    BarMod();
    BarMod(const BarMod &);
    const BarMod &operator=(const BarMod &);
    // Never defined

    void generate(SoNode *obj, float xSpace, float zSpace);
    void findBlock(SoPath *path, int &metric, int &inst, 
		   int &value, bool idMetric = true);
};

#endif /* _BARMOD_H_ */