7a324550 |
1 | // Created on: 2015-02-03 |
2 | // Copyright (c) 2015 OPEN CASCADE SAS |
42cf5bc1 |
3 | // |
4 | // This file is part of Open CASCADE Technology software library. |
5 | // |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
11 | // |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
14 | |
7a324550 |
15 | #ifndef _AIS_ColorScale_HeaderFile |
16 | #define _AIS_ColorScale_HeaderFile |
42cf5bc1 |
17 | |
7a324550 |
18 | #include <AIS_InteractiveObject.hxx> |
42cf5bc1 |
19 | #include <Aspect_TypeOfColorScaleData.hxx> |
7a324550 |
20 | #include <Aspect_TypeOfColorScalePosition.hxx> |
42cf5bc1 |
21 | #include <Aspect_SequenceOfColor.hxx> |
7a324550 |
22 | #include <Standard.hxx> |
23 | #include <Standard_DefineHandle.hxx> |
24 | #include <TCollection_ExtendedString.hxx> |
42cf5bc1 |
25 | #include <TColStd_SequenceOfExtendedString.hxx> |
42cf5bc1 |
26 | |
1b9f3f67 |
27 | class AIS_ColorScale; |
28 | DEFINE_STANDARD_HANDLE(AIS_ColorScale, AIS_InteractiveObject) |
180f89a2 |
29 | //! Class for drawing a custom color scale. |
30 | //! |
31 | //! The color scale consists of rectangular color bar (composed of fixed |
32 | //! number of color intervals), optional labels, and title. |
33 | //! The labels can be positioned either at the boundaries of the intervals, |
34 | //! or at the middle of each interval. |
35 | //! Colors and labels can be either defined automatically or set by the user. |
36 | //! Automatic labels are calculated from numerical limits of the scale, |
37 | //! its type (logarithmic or plain), and formatted by specified format string. |
4b3d6eb1 |
38 | class AIS_ColorScale : public AIS_InteractiveObject |
39 | { |
40 | DEFINE_STANDARD_RTTIEXT(AIS_ColorScale, AIS_InteractiveObject) |
41 | public: |
42 | |
43 | //! Calculate color according passed value; returns true if value is in range or false, if isn't |
44 | Standard_EXPORT static Standard_Boolean FindColor (const Standard_Real theValue, |
45 | const Standard_Real theMin, |
46 | const Standard_Real theMax, |
47 | const Standard_Integer theColorsCount, |
48 | const Graphic3d_Vec3d& theColorHlsMin, |
49 | const Graphic3d_Vec3d& theColorHlsMax, |
50 | Quantity_Color& theColor); |
42cf5bc1 |
51 | |
4b3d6eb1 |
52 | //! Calculate color according passed value; returns true if value is in range or false, if isn't |
53 | static Standard_Boolean FindColor (const Standard_Real theValue, |
54 | const Standard_Real theMin, |
55 | const Standard_Real theMax, |
56 | const Standard_Integer theColorsCount, |
57 | Quantity_Color& theColor) |
58 | { |
59 | return FindColor (theValue, theMin, theMax, theColorsCount, |
60 | Graphic3d_Vec3d (230.0, 1.0, 1.0), |
61 | Graphic3d_Vec3d (0.0, 1.0, 1.0), |
62 | theColor); |
63 | } |
64 | |
65 | //! Shift hue into valid range. |
66 | //! Lightness and Saturation should be specified in valid range [0.0, 1.0], |
67 | //! however Hue might be given out of Quantity_Color range to specify desired range for interpolation. |
68 | static Standard_Real hueToValidRange (const Standard_Real theHue) |
69 | { |
70 | Standard_Real aHue = theHue; |
71 | while (aHue < 0.0) { aHue += 360.0; } |
72 | while (aHue > 360.0) { aHue -= 360.0; } |
73 | return aHue; |
74 | } |
42cf5bc1 |
75 | |
76 | public: |
77 | |
7a324550 |
78 | //! Default constructor. |
79 | Standard_EXPORT AIS_ColorScale(); |
80 | |
42cf5bc1 |
81 | //! Calculate color according passed value; returns true if value is in range or false, if isn't |
82 | Standard_EXPORT Standard_Boolean FindColor (const Standard_Real theValue, Quantity_Color& theColor) const; |
7a324550 |
83 | |
4b3d6eb1 |
84 | //! Returns minimal value of color scale, 0.0 by default. |
85 | Standard_Real GetMin() const { return myMin; } |
24a88697 |
86 | |
42cf5bc1 |
87 | //! Sets the minimal value of color scale. |
4b3d6eb1 |
88 | void SetMin (const Standard_Real theMin) { SetRange (theMin, GetMax()); } |
89 | |
90 | //! Returns maximal value of color scale, 1.0 by default. |
91 | Standard_Real GetMax() const { return myMax; } |
7a324550 |
92 | |
42cf5bc1 |
93 | //! Sets the maximal value of color scale. |
4b3d6eb1 |
94 | void SetMax (const Standard_Real theMax) { SetRange (GetMin(), theMax); } |
95 | |
96 | //! Returns minimal and maximal values of color scale, 0.0 to 1.0 by default. |
97 | void GetRange (Standard_Real& theMin, Standard_Real& theMax) const |
98 | { |
99 | theMin = myMin; |
100 | theMax = myMax; |
101 | } |
7a324550 |
102 | |
42cf5bc1 |
103 | //! Sets the minimal and maximal value of color scale. |
4b3d6eb1 |
104 | //! Note that values order will be ignored - the minimum and maximum values will be swapped if needed. |
105 | //! ::SetReversed() should be called to swap displaying order. |
42cf5bc1 |
106 | Standard_EXPORT void SetRange (const Standard_Real theMin, const Standard_Real theMax); |
7a324550 |
107 | |
4b3d6eb1 |
108 | //! Returns the hue angle corresponding to minimum value, 230 by default (blue). |
109 | Standard_Real HueMin() const { return myColorHlsMin[0]; } |
110 | |
111 | //! Returns the hue angle corresponding to maximum value, 0 by default (red). |
112 | Standard_Real HueMax() const { return myColorHlsMax[0]; } |
113 | |
114 | //! Returns the hue angle range corresponding to minimum and maximum values, 230 to 0 by default (blue to red). |
115 | void HueRange (Standard_Real& theMinAngle, |
116 | Standard_Real& theMaxAngle) const |
117 | { |
118 | theMinAngle = myColorHlsMin[0]; |
119 | theMaxAngle = myColorHlsMax[0]; |
120 | } |
121 | |
122 | //! Sets hue angle range corresponding to minimum and maximum values. |
123 | //! The valid angle range is [0, 360], see Quantity_Color and Quantity_TOC_HLS for more details. |
124 | void SetHueRange (const Standard_Real theMinAngle, |
125 | const Standard_Real theMaxAngle) |
126 | { |
127 | myColorHlsMin[0] = theMinAngle; |
128 | myColorHlsMax[0] = theMaxAngle; |
129 | } |
130 | |
131 | //! Returns color range corresponding to minimum and maximum values, blue to red by default. |
132 | void ColorRange (Quantity_Color& theMinColor, |
133 | Quantity_Color& theMaxColor) const |
134 | { |
135 | theMinColor.SetValues (hueToValidRange (myColorHlsMin[0]), myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS); |
35cbf341 |
136 | theMaxColor.SetValues (hueToValidRange (myColorHlsMax[0]), myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS); |
4b3d6eb1 |
137 | } |
138 | |
139 | //! Sets color range corresponding to minimum and maximum values. |
140 | void SetColorRange (const Quantity_Color& theMinColor, |
141 | const Quantity_Color& theMaxColor) |
142 | { |
143 | theMinColor.Values (myColorHlsMin[0], myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS); |
144 | theMaxColor.Values (myColorHlsMax[0], myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS); |
145 | } |
146 | |
147 | //! Returns the type of labels, Aspect_TOCSD_AUTO by default. |
148 | //! Aspect_TOCSD_AUTO - labels as boundary values for intervals |
149 | //! Aspect_TOCSD_USER - user specified label is used |
150 | Aspect_TypeOfColorScaleData GetLabelType() const { return myLabelType; } |
151 | |
42cf5bc1 |
152 | //! Sets the type of labels. |
153 | //! Aspect_TOCSD_AUTO - labels as boundary values for intervals |
154 | //! Aspect_TOCSD_USER - user specified label is used |
4b3d6eb1 |
155 | void SetLabelType (const Aspect_TypeOfColorScaleData theType) { myLabelType = theType; } |
156 | |
157 | //! Returns the type of colors, Aspect_TOCSD_AUTO by default. |
158 | //! Aspect_TOCSD_AUTO - value between Red and Blue |
159 | //! Aspect_TOCSD_USER - user specified color from color map |
160 | Aspect_TypeOfColorScaleData GetColorType() const { return myColorType; } |
7a324550 |
161 | |
42cf5bc1 |
162 | //! Sets the type of colors. |
163 | //! Aspect_TOCSD_AUTO - value between Red and Blue |
164 | //! Aspect_TOCSD_USER - user specified color from color map |
4b3d6eb1 |
165 | void SetColorType (const Aspect_TypeOfColorScaleData theType) { myColorType = theType; } |
166 | |
167 | //! Returns the number of color scale intervals, 10 by default. |
168 | Standard_Integer GetNumberOfIntervals() const { return myNbIntervals; } |
7a324550 |
169 | |
42cf5bc1 |
170 | //! Sets the number of color scale intervals. |
171 | Standard_EXPORT void SetNumberOfIntervals (const Standard_Integer theNum); |
7a324550 |
172 | |
4b3d6eb1 |
173 | //! Returns the color scale title string, empty string by default. |
174 | const TCollection_ExtendedString& GetTitle() const { return myTitle; } |
175 | |
42cf5bc1 |
176 | //! Sets the color scale title string. |
4b3d6eb1 |
177 | void SetTitle (const TCollection_ExtendedString& theTitle) { myTitle = theTitle; } |
178 | |
179 | //! Returns the format for numbers, "%.4g" by default. |
180 | //! The same like format for function printf(). |
181 | //! Used if GetLabelType() is TOCSD_AUTO; |
182 | const TCollection_AsciiString& GetFormat() const { return myFormat; } |
183 | |
184 | //! Returns the format of text. |
185 | const TCollection_AsciiString& Format() const { return myFormat; } |
7a324550 |
186 | |
42cf5bc1 |
187 | //! Sets the color scale auto label format specification. |
4b3d6eb1 |
188 | void SetFormat (const TCollection_AsciiString& theFormat) { myFormat = theFormat; } |
7a324550 |
189 | |
4b3d6eb1 |
190 | //! Returns the user specified label with index theIndex. |
180f89a2 |
191 | //! Index is in range from 1 to GetNumberOfIntervals() or to |
192 | //! GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. |
4b3d6eb1 |
193 | //! Returns empty string if label not defined. |
194 | Standard_EXPORT TCollection_ExtendedString GetLabel (const Standard_Integer theIndex) const; |
195 | |
196 | //! Returns the user specified color from color map with index (starts at 1). |
197 | //! Returns default color if index is out of range in color map. |
198 | Standard_EXPORT Quantity_Color GetIntervalColor (const Standard_Integer theIndex) const; |
7a324550 |
199 | |
180f89a2 |
200 | //! Sets the color of the specified interval. |
4b3d6eb1 |
201 | //! Note that list is automatically resized to include specified index. |
202 | //! @param theColor color value to set |
203 | //! @param theIndex index in range [1, GetNumberOfIntervals()]; |
204 | //! appended to the end of list if -1 is specified |
180f89a2 |
205 | Standard_EXPORT void SetIntervalColor (const Quantity_Color& theColor, const Standard_Integer theIndex); |
7a324550 |
206 | |
4b3d6eb1 |
207 | //! Returns the user specified labels. |
208 | Standard_EXPORT void GetLabels (TColStd_SequenceOfExtendedString& theLabels) const; |
209 | |
210 | //! Returns the user specified labels. |
211 | const TColStd_SequenceOfExtendedString& Labels() const { return myLabels; } |
212 | |
42cf5bc1 |
213 | //! Sets the color scale labels. |
4b3d6eb1 |
214 | //! The length of the sequence should be equal to GetNumberOfIntervals() or to GetNumberOfIntervals() + 1 if IsLabelAtBorder() is true. |
215 | //! If length of the sequence does not much the number of intervals, |
216 | //! then these labels will be considered as "free" and will be located |
217 | //! at the virtual intervals corresponding to the number of labels |
218 | //! (with flag IsLabelAtBorder() having the same effect as in normal case). |
42cf5bc1 |
219 | Standard_EXPORT void SetLabels (const TColStd_SequenceOfExtendedString& theSeq); |
7a324550 |
220 | |
4b3d6eb1 |
221 | //! Returns the user specified colors. |
222 | Standard_EXPORT void GetColors (Aspect_SequenceOfColor& theColors) const; |
223 | |
224 | //! Returns the user specified colors. |
225 | const Aspect_SequenceOfColor& GetColors() const { return myColors; } |
226 | |
42cf5bc1 |
227 | //! Sets the color scale colors. |
180f89a2 |
228 | //! The length of the sequence should be equal to GetNumberOfIntervals(). |
42cf5bc1 |
229 | Standard_EXPORT void SetColors (const Aspect_SequenceOfColor& theSeq); |
7a324550 |
230 | |
14b741b0 |
231 | //! Populates colors scale by colors of the same lightness value in CIE Lch |
232 | //! color space, distributed by hue, with perceptually uniform differences |
233 | //! between consequent colors. |
234 | //! See MakeUniformColors() for description of parameters. |
235 | void SetUniformColors (Standard_Real theLightness, |
236 | Standard_Real theHueFrom, Standard_Real theHueTo) |
237 | { |
238 | SetColors (MakeUniformColors (myNbIntervals, theLightness, theHueFrom, theHueTo)); |
239 | SetColorType (Aspect_TOCSD_USER); |
240 | } |
241 | |
242 | //! Generates sequence of colors of the same lightness value in CIE Lch |
243 | //! color space (see #Quantity_TOC_CIELch), with hue values in the specified range. |
244 | //! The colors are distributed across the range such as to have perceptually |
245 | //! same difference between neighbour colors. |
246 | //! For each color, maximal chroma value fitting in sRGB gamut is used. |
247 | //! |
248 | //! @param theNbColors - number of colors to generate |
249 | //! @param theLightness - lightness to be used (0 is black, 100 is white, 32 is |
250 | //! lightness of pure blue) |
251 | //! @param theHueFrom - hue value at the start of the scale |
252 | //! @param theHueTo - hue value defining the end of the scale |
253 | //! |
254 | //! Hue value can be out of the range [0, 360], interpreted as modulo 360. |
255 | //! The colors of the scale will be in the order of increasing hue if |
256 | //! theHueTo > theHueFrom, and decreasing otherwise. |
257 | Standard_EXPORT static Aspect_SequenceOfColor |
258 | MakeUniformColors (Standard_Integer theNbColors, Standard_Real theLightness, |
259 | Standard_Real theHueFrom, Standard_Real theHueTo); |
260 | |
4b3d6eb1 |
261 | //! Returns the position of labels concerning color filled rectangles, Aspect_TOCSP_RIGHT by default. |
262 | Aspect_TypeOfColorScalePosition GetLabelPosition() const { return myLabelPos; } |
263 | |
180f89a2 |
264 | //! Sets the color scale labels position relative to color bar. |
4b3d6eb1 |
265 | void SetLabelPosition (const Aspect_TypeOfColorScalePosition thePos) { myLabelPos = thePos; } |
266 | |
267 | //! Returns the position of color scale title, Aspect_TOCSP_LEFT by default. |
268 | Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; } |
7a324550 |
269 | |
42cf5bc1 |
270 | //! Sets the color scale title position. |
4b3d6eb1 |
271 | Standard_DEPRECATED("AIS_ColorScale::SetTitlePosition() has no effect!") |
272 | void SetTitlePosition (const Aspect_TypeOfColorScalePosition thePos) { myTitlePos = thePos; } |
273 | |
274 | //! Returns TRUE if the labels and colors used in reversed order, FALSE by default. |
275 | //! - Normal, bottom-up order with Minimal value on the Bottom and Maximum value on Top. |
276 | //! - Reversed, top-down order with Maximum value on the Bottom and Minimum value on Top. |
277 | Standard_Boolean IsReversed() const { return myIsReversed; } |
7a324550 |
278 | |
42cf5bc1 |
279 | //! Sets true if the labels and colors used in reversed order. |
4b3d6eb1 |
280 | void SetReversed (const Standard_Boolean theReverse) { myIsReversed = theReverse; } |
7a324550 |
281 | |
4b3d6eb1 |
282 | //! Return TRUE if color transition between neighbor intervals |
283 | //! should be linearly interpolated, FALSE by default. |
284 | Standard_Boolean IsSmoothTransition() const { return myIsSmooth; } |
7a324550 |
285 | |
4b3d6eb1 |
286 | //! Setup smooth color transition. |
287 | void SetSmoothTransition (const Standard_Boolean theIsSmooth) { myIsSmooth = theIsSmooth; } |
288 | |
289 | //! Returns TRUE if the labels are placed at border of color intervals, TRUE by default. |
290 | //! The automatically generated label will show value exactly on the current position: |
291 | //! - value connecting two neighbor intervals (TRUE) |
292 | //! - value in the middle of interval (FALSE) |
293 | Standard_Boolean IsLabelAtBorder() const { return myIsLabelAtBorder; } |
24a88697 |
294 | |
4b3d6eb1 |
295 | //! Sets true if the labels are placed at border of color intervals (TRUE by default). |
296 | //! If set to False, labels will be drawn at color intervals rather than at borders. |
297 | void SetLabelAtBorder (const Standard_Boolean theOn) { myIsLabelAtBorder = theOn; } |
7a324550 |
298 | |
4b3d6eb1 |
299 | //! Returns TRUE if the color scale has logarithmic intervals, FALSE by default. |
300 | Standard_Boolean IsLogarithmic() const { return myIsLogarithmic; } |
7a324550 |
301 | |
4b3d6eb1 |
302 | //! Sets true if the color scale has logarithmic intervals. |
303 | void SetLogarithmic (const Standard_Boolean isLogarithmic) { myIsLogarithmic = isLogarithmic; } |
304 | |
305 | //! Sets the color scale label at index. |
306 | //! Note that list is automatically resized to include specified index. |
307 | //! @param theLabel new label text |
308 | //! @param theIndex index in range [1, GetNumberOfIntervals()] or [1, GetNumberOfIntervals() + 1] if IsLabelAtBorder() is true; |
309 | //! label is appended to the end of list if negative index is specified |
310 | Standard_EXPORT void SetLabel (const TCollection_ExtendedString& theLabel, const Standard_Integer theIndex); |
311 | |
312 | //! Returns the size of color bar, 0 and 0 by default |
313 | //! (e.g. should be set by user explicitly before displaying). |
314 | void GetSize (Standard_Integer& theBreadth, Standard_Integer& theHeight) const |
315 | { |
316 | theBreadth = myBreadth; |
317 | theHeight = myHeight; |
318 | } |
b4b2ecca |
319 | |
180f89a2 |
320 | //! Sets the size of color bar. |
4b3d6eb1 |
321 | void SetSize (const Standard_Integer theBreadth, const Standard_Integer theHeight) |
322 | { |
323 | myBreadth = theBreadth; |
324 | myHeight = theHeight; |
325 | } |
326 | |
327 | //! Returns the breadth of color bar, 0 by default |
328 | //! (e.g. should be set by user explicitly before displaying). |
329 | Standard_Integer GetBreadth() const { return myBreadth; } |
7a324550 |
330 | |
180f89a2 |
331 | //! Sets the width of color bar. |
4b3d6eb1 |
332 | void SetBreadth (const Standard_Integer theBreadth) { myBreadth = theBreadth; } |
333 | |
334 | //! Returns the height of color bar, 0 by default |
335 | //! (e.g. should be set by user explicitly before displaying). |
336 | Standard_Integer GetHeight() const { return myHeight; } |
7a324550 |
337 | |
180f89a2 |
338 | //! Sets the height of color bar. |
4b3d6eb1 |
339 | void SetHeight (const Standard_Integer theHeight) { myHeight = theHeight; } |
b4b2ecca |
340 | |
4b3d6eb1 |
341 | //! Returns the bottom-left position of color scale, 0x0 by default. |
342 | void GetPosition (Standard_Real& theX, Standard_Real& theY) const |
343 | { |
344 | theX = myXPos; |
345 | theY = myYPos; |
346 | } |
7a324550 |
347 | |
4b3d6eb1 |
348 | //! Sets the position of color scale. |
349 | void SetPosition (const Standard_Integer theX, const Standard_Integer theY) |
350 | { |
351 | myXPos = theX; |
352 | myYPos = theY; |
353 | } |
7a324550 |
354 | |
4b3d6eb1 |
355 | //! Returns the left position of color scale, 0 by default. |
356 | Standard_Integer GetXPosition() const { return myXPos; } |
7a324550 |
357 | |
4b3d6eb1 |
358 | //! Sets the left position of color scale. |
359 | void SetXPosition (const Standard_Integer theX) { myXPos = theX; } |
7a324550 |
360 | |
4b3d6eb1 |
361 | //! Returns the bottom position of color scale, 0 by default. |
362 | Standard_Integer GetYPosition() const { return myYPos; } |
7a324550 |
363 | |
4b3d6eb1 |
364 | //! Sets the bottom position of color scale. |
365 | void SetYPosition (const Standard_Integer theY) { myYPos = theY; } |
7a324550 |
366 | |
4b3d6eb1 |
367 | //! Returns the font height of text labels, 20 by default. |
368 | Standard_Integer GetTextHeight() const { return myTextHeight; } |
7a324550 |
369 | |
42cf5bc1 |
370 | //! Sets the height of text of color scale. |
4b3d6eb1 |
371 | void SetTextHeight (const Standard_Integer theHeight) { myTextHeight = theHeight; } |
372 | |
373 | public: |
7a324550 |
374 | |
42cf5bc1 |
375 | //! Returns the width of text. |
376 | //! @param theText [in] the text of which to calculate width. |
7a324550 |
377 | Standard_EXPORT Standard_Integer TextWidth (const TCollection_ExtendedString& theText) const; |
378 | |
42cf5bc1 |
379 | //! Returns the height of text. |
380 | //! @param theText [in] the text of which to calculate height. |
7a324550 |
381 | Standard_EXPORT Standard_Integer TextHeight (const TCollection_ExtendedString& theText) const; |
42cf5bc1 |
382 | |
4b3d6eb1 |
383 | Standard_EXPORT void TextSize (const TCollection_ExtendedString& theText, |
384 | const Standard_Integer theHeight, |
385 | Standard_Integer& theWidth, |
386 | Standard_Integer& theAscent, |
387 | Standard_Integer& theDescent) const; |
42cf5bc1 |
388 | |
4b3d6eb1 |
389 | public: |
42cf5bc1 |
390 | |
4b3d6eb1 |
391 | //! Return true if specified display mode is supported. |
392 | virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; } |
42cf5bc1 |
393 | |
4b3d6eb1 |
394 | //! Compute presentation. |
395 | Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& thePresentationManager, |
396 | const Handle(Prs3d_Presentation)& thePresentation, |
397 | const Standard_Integer theMode) Standard_OVERRIDE; |
42cf5bc1 |
398 | |
4b3d6eb1 |
399 | //! Compute selection - not implemented for color scale. |
400 | virtual void ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/, |
401 | const Standard_Integer /*aMode*/) Standard_OVERRIDE {} |
7a324550 |
402 | |
403 | private: |
404 | |
42cf5bc1 |
405 | //! Returns the size of color scale. |
406 | //! @param theWidth [out] the width of color scale. |
407 | //! @param theHeight [out] the height of color scale. |
7a324550 |
408 | void SizeHint (Standard_Integer& theWidth, Standard_Integer& theHeight) const; |
42cf5bc1 |
409 | |
180f89a2 |
410 | //! Returns the upper value of given interval, or minimum for theIndex = 0. |
411 | Standard_Real GetIntervalValue (const Standard_Integer theIndex) const; |
7a324550 |
412 | |
4b3d6eb1 |
413 | //! Returns the color for the given value in the given interval. |
414 | //! @param theValue [in] the current value of interval |
415 | //! @param theMin [in] the min value of interval |
416 | //! @param theMax [in] the max value of interval |
417 | Quantity_Color colorFromValue (const Standard_Real theValue, |
418 | const Standard_Real theMin, |
419 | const Standard_Real theMax) const; |
420 | |
421 | //! Initialize text aspect for drawing the labels. |
422 | void updateTextAspect(); |
423 | |
424 | //! Simple alias for Prs3d_Text::Draw(). |
425 | //! @param theGroup [in] presentation group |
426 | //! @param theText [in] text to draw |
427 | //! @param theX [in] X coordinate of text position |
428 | //! @param theY [in] Y coordinate of text position |
429 | //! @param theVertAlignment [in] text vertical alignment |
430 | void drawText (const Handle(Graphic3d_Group)& theGroup, |
431 | const TCollection_ExtendedString& theText, |
432 | const Standard_Integer theX, const Standard_Integer theY, |
433 | const Graphic3d_VerticalTextAlignment theVertAlignment); |
434 | |
435 | //! Determine the maximum text label width in pixels. |
436 | Standard_Integer computeMaxLabelWidth (const TColStd_SequenceOfExtendedString& theLabels) const; |
437 | |
438 | //! Draw labels. |
2a332745 |
439 | void drawLabels (const Handle(Graphic3d_Group)& theGroup, |
4b3d6eb1 |
440 | const TColStd_SequenceOfExtendedString& theLabels, |
441 | const Standard_Integer theBarBottom, |
442 | const Standard_Integer theBarHeight, |
443 | const Standard_Integer theMaxLabelWidth, |
444 | const Standard_Integer theColorBreadth); |
445 | |
446 | //! Draw a color bar. |
447 | void drawColorBar (const Handle(Prs3d_Presentation)& thePrs, |
448 | const Standard_Integer theBarBottom, |
449 | const Standard_Integer theBarHeight, |
450 | const Standard_Integer theMaxLabelWidth, |
451 | const Standard_Integer theColorBreadth); |
452 | |
453 | //! Draw a frame. |
454 | //! @param theX [in] the X coordinate of frame position. |
455 | //! @param theY [in] the Y coordinate of frame position. |
456 | //! @param theWidth [in] the width of frame. |
457 | //! @param theHeight [in] the height of frame. |
458 | //! @param theColor [in] the color of frame. |
459 | void drawFrame (const Handle(Prs3d_Presentation)& thePrs, |
460 | const Standard_Integer theX, const Standard_Integer theY, |
461 | const Standard_Integer theWidth, const Standard_Integer theHeight, |
462 | const Quantity_Color& theColor); |
7a324550 |
463 | |
464 | private: |
42cf5bc1 |
465 | |
4b3d6eb1 |
466 | Standard_Real myMin; //!< values range - minimal value |
467 | Standard_Real myMax; //!< values range - maximal value |
468 | Graphic3d_Vec3d myColorHlsMin; //!< HLS color corresponding to minimum value |
469 | Graphic3d_Vec3d myColorHlsMax; //!< HLS color corresponding to maximum value |
470 | TCollection_ExtendedString myTitle; //!< optional title string |
471 | TCollection_AsciiString myFormat; //!< sprintf() format for generating label from value |
472 | Standard_Integer myNbIntervals; //!< number of intervals |
473 | Aspect_TypeOfColorScaleData myColorType; //!< color type |
474 | Aspect_TypeOfColorScaleData myLabelType; //!< label type |
475 | Standard_Boolean myIsLabelAtBorder; //!< at border |
476 | Standard_Boolean myIsReversed; //!< flag indicating reversed order |
477 | Standard_Boolean myIsLogarithmic; //!< flag indicating logarithmic scale |
478 | Standard_Boolean myIsSmooth; //!< flag indicating smooth transition between the colors |
479 | Aspect_SequenceOfColor myColors; //!< sequence of custom colors |
480 | TColStd_SequenceOfExtendedString myLabels; //!< sequence of custom text labels |
481 | Aspect_TypeOfColorScalePosition myLabelPos; //!< label position relative to the color scale |
482 | Aspect_TypeOfColorScalePosition myTitlePos; //!< title position |
483 | Standard_Integer myXPos; //!< left position |
484 | Standard_Integer myYPos; //!< bottom position |
485 | Standard_Integer myBreadth; //!< color scale breadth |
486 | Standard_Integer myHeight; //!< height of the color scale |
487 | Standard_Integer mySpacing; //!< extra spacing between element |
488 | Standard_Integer myTextHeight; //!< label font height |
489 | |
42cf5bc1 |
490 | }; |
4b3d6eb1 |
491 | |
7a324550 |
492 | #endif |