Overture  Version 25
ColourBar.h
Go to the documentation of this file.
1 // $Id: ColourBar.h,v 1.1 2004/06/20 16:54:47 henshaw Exp $
2 //
3 // The Overture Colour Bar class
4 // -- encapsulates the code that used to sit in
5 // GL_GraphicsInterface::drawColourBar
6 // -- used by GL_GraphicsInterface: contour, streamLines, plotPoints
7 //
8 //
9 // **pf
10 //
11 #ifndef COLOUR_BAR_H
12 #define COLOUR_BAR_H
13 
15 class GraphicsParameters;
16 class CBGraphicsParameters; // AP: This doesn't seem to be used???
17 
18 class ColourBar
19 {
20 public:
22  {
28  useOldColourBar, //default, while debugging the new ColourBar
33  };
35  {
39  };
40 
41 
43  GraphicsParameters* gparams = NULL );
44  ~ColourBar();
45 
47  void setGraphicsParameters(GraphicsParameters *parameters);
48 
49  void draw(const int & numberOfContourLevels,
50  RealArray & contourLevels,
51  GUITypes::real uMin,
52  GUITypes::real uMax);
53 
54  void update( );
55 
56  //this next function is called by the GL_GraphicsInterface::draw
57  void positionInWindow(GUITypes::real leftSide, GUITypes::real rightSide, GUITypes::real bottom, GUITypes::real top);
58 
59 
60 
61 private:
62 
63 
65  GraphicsParameters* _gparameters;
66 
67  //..make copy & operator= private --> not accessible
68  ColourBar( const ColourBar &X);
69  ColourBar& operator=( const ColourBar &x);
70 
71  //..parameters
72  GUITypes::real pi;
73 
74  ColourBarPosition colourBarPosition;
75  GUITypes::real colourBarWidth;
76  GUITypes::real colourBarLength;
77 
78  GUITypes::real colourBarCenter[2];
79 
80  GUITypes::real colourBarAngle;
81  GUITypes::real colourBarCurvature;
82  GUITypes::real colourBarOffsetFromPlot;
83 
84  ColourBarLabelOption colourBarLabelOption;
85  bool colourBarLabelOnRight;
86  GUITypes::real colourBarLabelAngle;
87  int colourBarRelativeAngle;
88  GUITypes::real colourBarLabelNormalOffset;
89  GUITypes::real colourBarLabelTangentialOffset;
90  int colourBarNumberOfIntervals;
91  int colourBarMaximumNumberOfLabels;
92  GUITypes::real colourBarLabelScaling;
93  int colourBarThickLineInterval;
94 
95 
96 
97  //..draw parameters, set by setupDraw();
98  bool isHorizontalBar;
99  bool horizontalLabels;
100  int currentWindow;
101  GUITypes::real leftSide, rightSide, top, bottom;
102  GUITypes::real xLeft, xRight, yTop, yBottom;
103 
104  GUITypes::real uMin, uMax;
105  int numberOfIntervals;
106  int numberOfContourLevels;
107  RealArray* pContourLevels;
108 
109  GUITypes::real barBase; // base coordinate (yBottom for VERT, xLeft for HORIZ)
110  GUITypes::real barLength;
111 // GUITypes::real barStep; // increments from barBase, to get barLength in numberOfIntervals
112 
113  //..label data
114  int skipLabel;
115  GUITypes::real labelSize;
116  int labelDrawFlag;
117 
118  //..line widths
119  GUITypes::real lineWidthScaleFactor;
120  GUITypes::real sizeLineWidth ;
121  GUITypes::real sizeMinorContourWidth;
122  GUITypes::real sizeMajorContourWidth;
123  GUITypes::real sizeAxisNumberSize;
124 
125  //..colour bar user data & convenience parameters
126  enum LabelOrientation {labelHorizontal=0, labelVertical, labelCustomOrientation};
127  LabelOrientation labelOrientation;
128 
129 
130  //
131  //..utilities ---------------------------------------------------------------------
132  //
133  bool preCheck();
134  void setupDraw( const int & numberOfContourLevels_, RealArray & contourLevels_,
135  GUITypes::real uMin, GUITypes::real uMax);
136  void drawBar();
137  void drawBarLines();
138  void drawLabels();
139 
140  void showAdvancedDialog(const aString &prefix, GUIState &advancedGUI);
141 
142  void setLabelOrientation( int labelOrientation_ );
143  int getLabelOrientation( int &labelOrientation_ );
144 
145 // bool useOldColourBar();
146 
147  //utility for drawColourBar **pf
148  static inline GUITypes::real
149  computeBarLabelOffset( const int & numberOfContourLevels,
150  RealArray & contourLevels,
151  GUITypes::real uMin, GUITypes::real uMax,
152  GUITypes::real barLength, int i, GUITypes::real indexOffset =0. );
153 
154  void barLabel( GUITypes::real value, GUITypes::real xPos, GUITypes::real yPos, GUITypes::real angle);
155 
156  void computeBarQuad( GUITypes::real r, GUITypes::real &xa, GUITypes::real &ya, GUITypes::real &xb, GUITypes::real &yb);
157  void computeBarLevelLine( GUITypes::real r,
159  void getCenterLine( GUITypes::real r, GUITypes::real &x, GUITypes::real &y, GUITypes::real &nx, GUITypes::real &ny,
160  GUITypes::real &tx, GUITypes::real &ty);
161 
162  GUITypes::real computeContourLineWidth( int i );
163 
164  void rotateAndTranslate( GUITypes::real angle, GUITypes::real x0, GUITypes::real y0, GUITypes::real &x, GUITypes::real &y);
165  void computeLabelPosition( int i, GUITypes::real & alpha, GUITypes::real &xPos, GUITypes::real & yPos, GUITypes::real&labelAngle);
166  void stretchToScreenCoordinates( GUITypes::real &xa, GUITypes::real &ya);
168 
169  GUITypes::real minimumWindowLength(GUITypes::real left,GUITypes::real right,GUITypes::real top,GUITypes::real bottom);
170  GUITypes::real maximumWindowLength(GUITypes::real left,GUITypes::real right,GUITypes::real top,GUITypes::real bottom);
171 
172  //..old versions
173 public:
174  //void draw_old(const int & numberOfContourLevels_,
175  // RealArray & contourLevels_,
176  // real uMin_,
177  // real uMax_);
178  //void update_old();
179 
180 protected: //
181  //void setupDraw_old( const int & numberOfContourLevels_, RealArray & contourLevels_,
182 // real uMin, real uMax);
183  // void drawBar_old();
184  //void drawBarLines_old();
185  //void drawLabels_old();
186 
187  //void showAdvancedDialog_old(const aString &prefix );
188  //..junk, but keeping around just in case
189  void update_junk();
190 
191 };
192 
193 #endif