OpenCOVER
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
27 namespace vrui
28 {
29 class coLabel;
30 class coRowContainer;
31 class coTexturedBackground;
32 class coColoredBackground;
33 }
34 
35 namespace opencover
36 {
37 
41 class PLUGIN_UTILEXPORT coColorBar : public vrui::coMenuItem
42 {
43 private:
44  vrui::coColoredBackground *background_;
45 
46  // topspacer and texture in vertical row container
49  vrui::coRowContainer *textureAndVspace_;
50 
51  // hspacers and labels in horiz containers, all labels in vert container
52  vrui::coLabel *labels_[MAX_LABELS];
54  vrui::coRowContainer *labelAndHspaces_[MAX_LABELS];
55  vrui::coRowContainer *allLabels_;
56 
57  // horiz conatiner around textureAndVspacer and all labels
58  vrui::coRowContainer *textureAndLabels_;
59 
60  int numLabels_; // number of labels, max
61  float labelValues_[MAX_LABELS]; // numerical values of labels
62  char format_str_[32]; // precision of float values
63 
64  int numColors_;
65  float min_, max_;
66  unsigned char *image_, *tickImage_;
67  char *name_; // the name of the colors module for example Colors_1
68 
69  void makeImage(int numColors, float *r, float *g, float *b, float *a);
70  void makeTickImage();
71  void makeLabelValues();
72 
73 public:
86  coColorBar(const char *name, char *species, float min, float max, int numColors, float *r, float *g, float *b, float *a);
87 
89  ~coColorBar();
90 
100  void update(float min, float max, int numColors, float *r, float *g, float *b, float *a);
101 
105  const char *getName()
106  {
107  return name_;
108  };
109 
110  virtual vrui::coUIElement *getUIElement();
111 
113  virtual const char *getClassName() const;
115  virtual bool isOfClassName(char *);
116 };
117 }
118 
119 #endif
Definition: coTexturedBackground.h:59
const char * getName()
Definition: coColorBar.h:105
Definition: coLabel.h:25
#define MAX_LABELS
Definition: coColorBar.h:22
Definition: coColorBar.h:41
Definition: coUIElement.h:52
Definition: coColoredBackground.h:23
Container class that aligns its children in a row.
Definition: coRowContainer.h:18
Definition: coMenuItem.h:44