OpenCOVER
coColorBar.h
Go to the documentation of this file.
1/* This file is part of COVISE.
2
3 You can use it under the terms of the GNU Lesser General Public License
4 version 2.1 or later, see lgpl-2.1.txt.
5
6 * License: LGPL 2+ */
7
8// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
9// class coColorBar
10//
11// derived from coMenuItem
12// colorbar is a window containing a texture and labels
13//
14// Initial version: 2002-01, dr
15// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
16// (C) 2002 by Vircinity IT Consulting
17// +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
18
19#ifndef _CO_COLOR_BAR_H_
20#define _CO_COLOR_BAR_H_
21
22#define MAX_LABELS 18
23
24#include <OpenVRUI/coMenuItem.h>
25#include <util/coTypes.h>
26#include <vector>
27
28namespace vrui
29{
30class coLabel;
31class coRowContainer;
32class coTexturedBackground;
33class coColoredBackground;
34}
35
36namespace opencover
37{
38
42class PLUGIN_UTILEXPORT coColorBar : public vrui::coMenuItem
43{
44private:
45 vrui::coColoredBackground *background_;
46
47 // topspacer and texture in vertical row container
50 vrui::coRowContainer *textureAndVspace_;
51
52 // hspacers and labels in horiz containers, all labels in vert container
53 vrui::coLabel *labels_[MAX_LABELS];
54 vrui::coLabel *speciesLabel_ = nullptr;
56 vrui::coRowContainer *labelAndHspaces_[MAX_LABELS];
58 vrui::coRowContainer *allLabels_;
59
60 // horiz container around textureAndVspacer and all labels
61 vrui::coRowContainer *textureAndLabels_;
62 // vert container around textureAndLabels_ and species label
63 vrui::coRowContainer *everything_ = nullptr;
64
65 int numLabels_; // number of labels, max
66 float labelValues_[MAX_LABELS]; // numerical values of labels
67 char format_str_[32]; // precision of float values
68
69 int numColors_;
70 float min_, max_;
71 std::vector<unsigned char> image_, tickImage_;
72 std::string name_; // the name of the colors module for example Colors_1
73 std::string species_;
74
75 void makeImage(int numColors, const float *r, const float *g, const float *b, const float *a);
76 void makeTickImage();
77 void makeLabelValues();
78
79public:
92 coColorBar(const std::string &name, const std::string &species, float min, float max, int numColors, const float *r, const float *g, const float *b, const float *a, bool inMenu=true);
93
96
106 void update(float min, float max, int numColors, const float *r, const float *g, const float *b, const float *a);
107
111 const char *getName() const override;
112
113 virtual vrui::coUIElement *getUIElement() override;
114
116 virtual const char *getClassName() const override;
118 virtual bool isOfClassName(const char *) const override;
119};
120}
121
122#endif
#define MAX_LABELS
Definition: coColorBar.h:22
Definition: ARToolKit.h:33
collaborative interface manager
Definition: coVRCommunication.h:41
Definition: coColorBar.h:43
const char * getName() const override
virtual vrui::coUIElement * getUIElement() override
coColorBar(const std::string &name, const std::string &species, float min, float max, int numColors, const float *r, const float *g, const float *b, const float *a, bool inMenu=true)
~coColorBar()
destructor
void update(float min, float max, int numColors, const float *r, const float *g, const float *b, const float *a)
virtual const char * getClassName() const override
get the Element's classname
virtual bool isOfClassName(const char *) const override
check if the Element or any ancestor is this classname
Definition: coColoredBackground.h:24
Definition: coLabel.h:26
Definition: coMenuItem.h:45
Container class that aligns its children in a row.
Definition: coRowContainer.h:19
Definition: coTexturedBackground.h:62
Definition: coUIElement.h:53