build: update parfait spec with a parfait-agent package
[pcp.git] / src / pmview / barobj.h
blob99ebbf7c4303b093df6ca7907eeabe80b9bc5327
1 /*
2 * Copyright (c) 1995 Silicon Graphics, Inc. All Rights Reserved.
3 * Copyright (c) 2009 Aconex. All Rights Reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
15 #ifndef _BAROBJ_H_
16 #define _BAROBJ_H_
18 #include "barmod.h"
19 #include "modobj.h"
20 #include "metriclist.h"
21 #include <QStringList>
23 class SoNode;
24 class SoTranslation;
25 class Text;
27 class BarObj : public ModObj
29 public:
31 enum LabelDir { away, towards };
32 enum LabelSide { left, right, above, below, numSides };
34 protected:
36 ViewObj::Shape _shape;
37 BarMod::Direction _dir;
38 BarMod::Modulation _mod;
39 BarMod::Grouping _group;
40 int _width;
41 int _depth;
42 int _xSpace;
43 int _zSpace;
44 int _labelSpace;
45 BarMod *_bars;
46 LabelDir _metDir;
47 QStringList *_metLabels;
48 LabelDir _instDir;
49 QStringList *_instLabels;
50 float _margins[numSides];
51 float _labelColor[3];
53 public:
55 virtual ~BarObj();
57 BarObj(ViewObj::Shape shape,
58 BarMod::Direction dir,
59 BarMod::Modulation mod,
60 BarMod::Grouping group,
61 bool baseFlag,
62 const DefaultObj &defaults,
63 int x, int y,
64 int cols = 1, int rows = 1,
65 BaseObj::Alignment align = BaseObj::center);
67 virtual int width() const
68 { return _width; }
69 virtual int depth() const
70 { return _depth; }
71 Shape shape() const
72 { return _shape; }
73 BarMod::Direction dir() const
74 { return _dir; }
75 BarMod::Modulation mod() const
76 { return _mod; }
77 int numMetricLabels() const
78 { return _metLabels->size(); }
79 LabelDir metricLabelDir() const
80 { return _metDir; }
81 int numInstLabels() const
82 { return _instLabels->size(); }
83 LabelDir instLabelDir() const
84 { return _instDir; }
86 void addMetric(const char *metric, double scale, const char *label)
87 { if (_metrics.add(metric, scale) >= 0) _metLabels->append(label); }
89 void addMetricLabel(const char *label)
90 { _metLabels->append(label); }
91 void addInstLabel(const char *label)
92 { _instLabels->append(label); }
94 virtual void finishedAdd();
96 // Local change
97 int &xSpace()
98 { return _xSpace; }
99 int &zSpace()
100 { return _zSpace; }
101 LabelDir &metricLabelDir()
102 { return _metDir; }
103 LabelDir &instLabelDir()
104 { return _instDir; }
106 virtual void setTran(float xTran, float zTran, int width, int depth);
108 virtual const char* name() const;
110 virtual void display(QTextStream& os) const;
112 friend QTextStream& operator<<(QTextStream& os, BarObj const& rhs);
114 private:
116 Text ** calcLabels(const QStringList &labels, LabelSide side,
117 int numLabels);
118 SoNode *doLabels(Text **text, LabelSide side, int numLabels);
120 BarObj();
121 BarObj(BarObj const&);
122 BarObj const& operator=(BarObj const &);
125 #endif /* _BAROBJ_H_ */