1 -- Created on: 2004-06-22
3 -- Copyright (c) 2004-2014 OPEN CASCADE SAS
5 -- This file is part of Open CASCADE Technology software library.
7 -- This library is free software; you can redistribute it and/or modify it under
8 -- the terms of the GNU Lesser General Public License version 2.1 as published
9 -- by the Free Software Foundation, with special exception defined in the file
10 -- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 -- distribution for complete text of the license and disclaimer of any warranty.
13 -- Alternatively, this file may be used under the terms of Open CASCADE
14 -- commercial license or contractual agreement.
16 deferred class ColorScale from Aspect inherits TShared from MMgt
17 ---Purpose: Defines a color scale for viewer.
20 TypeOfColorScaleData from Aspect,
21 TypeOfColorScalePosition from Aspect,
22 SequenceOfColor from Aspect,
24 AsciiString from TCollection,
25 ExtendedString from TCollection,
26 SequenceOfExtendedString from TColStd
32 FindColor( me; theValue : Real from Standard;
33 theColor : in out Color from Quantity ) returns Boolean from Standard;
34 ---Purpose: Calculate color according passed value; returns true if value is in range or false, if isn't
37 FindColor( myclass; theValue : Real from Standard;
38 theMin, theMax : Real from Standard;
39 theColorsCount : Integer from Standard;
40 theColor : in out Color from Quantity ) returns Boolean from Standard;
43 returns Real from Standard;
44 ---Purpose: Returns minimal value of color scale;
47 returns Real from Standard;
48 ---Purpose: Returns maximal value of color scale;
50 GetRange(me; theMin : in out Real from Standard;
51 theMax : in out Real from Standard);
52 ---Purpose: Returns minimal and maximal values of color scale;
55 returns TypeOfColorScaleData from Aspect;
56 ---Purpose: Returns the type of labels;
57 --- Aspect_TOCSD_AUTO - labels as boundary values for intervals
58 --- Aspect_TOCSD_USER - user specified label is used
61 returns TypeOfColorScaleData from Aspect;
62 ---Purpose: Returns the type of colors;
63 --- Aspect_TOCSD_AUTO - value between Red and Blue
64 --- Aspect_TOCSD_USER - user specified color from color map
66 GetNumberOfIntervals(me)
67 returns Integer from Standard;
68 ---Purpose: Returns the number of color scale intervals;
71 returns ExtendedString from TCollection;
72 ---Purpose: Returns the color scale title string;
75 returns AsciiString from TCollection;
76 ---Purpose: Returns the format for numbers.
77 -- The same like format for function printf().
78 -- Used if GetLabelType() is TOCSD_AUTO;
80 GetLabel(me; theIndex : Integer from Standard)
81 returns ExtendedString from TCollection;
82 ---Purpose: Returns the user specified label with index <anIndex>.
83 -- Returns empty string if label not defined.
85 GetColor(me; theIndex : Integer from Standard)
86 returns Color from Quantity;
87 ---Purpose: Returns the user specified color from color map with index <anIndex>.
88 -- Returns default color if index out of range in color map.
90 GetLabels(me; theLabels : in out SequenceOfExtendedString from TColStd);
91 ---Purpose: Returns the user specified labels.
93 GetColors(me; theColors : in out SequenceOfColor from Aspect);
94 ---Purpose: Returns the user specified colors.
97 returns TypeOfColorScalePosition from Aspect;
98 ---Purpose: Returns the position of labels concerning color filled rectangles.
101 returns TypeOfColorScalePosition from Aspect;
102 ---Purpose: Returns the position of color scale title.
105 returns Boolean from Standard;
106 ---Purpose: Returns true if the labels and colors used in reversed order.
109 returns Boolean from Standard;
110 ---Purpose: Returns true if the labels placed at border of color filled rectangles.
112 SetMin(me : mutable; theMin : Real from Standard);
113 ---Purpose: Sets the minimal value of color scale.
115 SetMax(me : mutable; theMax : Real from Standard);
116 ---Purpose: Sets the maximal value of color scale.
118 SetRange(me : mutable; theMin : Real from Standard;
119 theMax : Real from Standard);
120 ---Purpose: Sets the minimal and maximal value of color scale.
122 SetLabelType(me : mutable; theType : TypeOfColorScaleData from Aspect);
123 ---Purpose: Sets the type of labels.
124 -- Aspect_TOCSD_AUTO - labels as boundary values for intervals
125 -- Aspect_TOCSD_USER - user specified label is used
127 SetColorType(me : mutable; theType : TypeOfColorScaleData from Aspect);
128 ---Purpose: Sets the type of colors.
129 -- Aspect_TOCSD_AUTO - value between Red and Blue
130 -- Aspect_TOCSD_USER - user specified color from color map
132 SetNumberOfIntervals(me : mutable; theNum : Integer from Standard);
133 ---Purpose: Sets the number of color scale intervals.
135 SetTitle(me : mutable; theTitle : ExtendedString from TCollection);
136 ---Purpose: Sets the color scale title string.
138 SetFormat(me : mutable; theFormat : AsciiString from TCollection);
139 ---Purpose: Sets the color scale auto label format specification.
141 SetLabel(me : mutable; theLabel : ExtendedString from TCollection;
142 anIndex : Integer from Standard = -1);
143 ---Purpose: Sets the color scale label at index. Index started from 1.
145 SetColor(me : mutable; theColor : Color from Quantity;
146 theIndex : Integer from Standard = -1);
147 ---Purpose: Sets the color scale color at index. Index started from 1.
149 SetLabels(me : mutable; theSeq : SequenceOfExtendedString from TColStd);
150 ---Purpose: Sets the color scale labels.
152 SetColors(me : mutable; theSeq : SequenceOfColor from Aspect);
153 ---Purpose: Sets the color scale colors.
155 SetLabelPosition(me : mutable; thePos : TypeOfColorScalePosition from Aspect);
156 ---Purpose: Sets the color scale labels position concerning color filled rectangles.
158 SetTitlePosition(me : mutable; thePos : TypeOfColorScalePosition from Aspect);
159 ---Purpose: Sets the color scale title position.
161 SetReversed(me : mutable; theReverse : Boolean from Standard);
162 ---Purpose: Sets true if the labels and colors used in reversed order.
164 SetLabelAtBorder(me : mutable; theOn : Boolean from Standard);
165 ---Purpose: Sets true if the labels placed at border of color filled rectangles.
167 --- Size and position management
168 --- Size and position are values relative to view size (between 0 and 1)
170 GetSize(me; theWidth : in out Real from Standard;
171 theHeight : in out Real from Standard);
172 ---Purpose: Returns the size of color scale.
175 returns Real from Standard;
176 ---Purpose: Returns the width of color scale.
179 returns Real from Standard;
180 ---Purpose: Returns the height of color scale.
182 SetSize(me : mutable; theWidth : Real from Standard;
183 theHeight : Real from Standard);
184 ---Purpose: Sets the size of color scale.
186 SetWidth(me : mutable; theWidth : Real from Standard);
187 ---Purpose: Sets the width of color scale.
189 SetHeight(me : mutable; theHeight : Real from Standard);
190 ---Purpose: Sets the height of color scale.
192 GetPosition(me; theX : in out Real from Standard;
193 theY : in out Real from Standard);
194 ---Purpose: Returns the position of color scale.
197 returns Real from Standard;
198 ---Purpose: Returns the X position of color scale.
201 returns Real from Standard;
202 ---Purpose: Returns the height of color scale.
204 SetPosition(me : mutable; theX : Real from Standard;
205 theY : Real from Standard);
206 ---Purpose: Sets the position of color scale.
208 SetXPosition(me : mutable; theX : Real from Standard);
209 ---Purpose: Sets the X position of color scale.
211 SetYPosition(me : mutable; theY : Real from Standard);
212 ---Purpose: Sets the Y position of color scale.
215 returns Integer from Standard;
216 ---Purpose: Returns the height of text of color scale.
218 SetTextHeight(me: mutable; theHeight : Integer from Standard);
219 ---Purpose: Sets the height of text of color scale.
221 ---Category: Protected
225 returns ColorScale from Aspect
227 ---Purpose: Default constructor.
229 SizeHint(me; theWidth : in out Integer from Standard;
230 theHeight : in out Integer from Standard)
232 ---Purpose: Returns the size of color scale.
233 -- @param theWidth [out] the width of color scale.
234 -- @param theHeight [out] the height of color scale.
237 UpdateColorScale(me : mutable)
238 is virtual protected;
239 ---Purpose: updates color scale parameters.
241 DrawScale(me : mutable; theBgColor : Color from Quantity;
242 theX, theY, theWidth, theHeight : Integer from Standard)
244 ---Purpose: Draws color scale.
245 -- @param theBgColor [in] background color
246 -- @param theX [in] the X coordinate of color scale position.
247 -- @param theY [in] the Y coordinate of color scale position.
248 -- @param theWidth [in] the width of color scale.
249 -- @param theHeight [in] the height of color scale.
251 BeginPaint(me : mutable)
252 returns Boolean from Standard
253 is virtual protected;
255 EndPaint(me : mutable)
256 returns Boolean from Standard
257 is virtual protected;
259 PaintRect(me : mutable; theX, theY, theWidth, theHeight : Integer from Standard;
260 theColor : Color from Quantity;
261 theFilled : Boolean from Standard = Standard_False)
263 ---Purpose: Draws a rectangle.
264 -- @param theX [in] the X coordinate of rectangle position.
265 -- @param theY [in] the Y coordinate of rectangle position.
266 -- @param theWidth [in] the width of rectangle.
267 -- @param theHeight [in] the height of rectangle.
268 -- @param theColor [in] the color of rectangle.
269 -- @param theFilled [in] defines if rectangle must be filled.
271 PaintText(me : mutable; theText : ExtendedString from TCollection;
272 theX, theY : Integer from Standard;
273 theColor : Color from Quantity)
275 ---Purpose: Draws a text.
276 -- @param theText [in] the text to draw.
277 -- @param theX [in] the X coordinate of text position.
278 -- @param theY [in] the Y coordinate of text position.
279 -- @param theColor [in] the color of text.
281 TextWidth(me; theText : ExtendedString from TCollection)
282 returns Integer from Standard
284 ---Purpose: Returns the width of text.
285 -- @param theText [in] the text of which to calculate width.
287 TextHeight(me; theText : ExtendedString from TCollection)
288 returns Integer from Standard
290 ---Purpose: Returns the height of text.
291 -- @param theText [in] the text of which to calculate height.
296 returns AsciiString from TCollection
298 ---Purpose: Returns the format of text.
300 GetNumber(me; theIndex : Integer from Standard)
301 returns Real from Standard
303 ---Purpose: Returns the value of given interval.
305 HueFromValue(myclass; theValue : Integer from Standard;
306 theMin : Integer from Standard;
307 theMax : Integer from Standard)
308 returns Integer from Standard
310 ---Purpose: Returns the color's hue for the given value in the given interval.
311 -- @param theValue [in] the current value of interval.
312 -- @param theMin [in] the min value of interval.
313 -- @param theMax [in] the max value of interval.
317 myMin, myMax : Real from Standard;
318 myTitle : ExtendedString from TCollection;
319 myFormat : AsciiString from TCollection;
320 myInterval : Integer from Standard;
321 myColorType : TypeOfColorScaleData from Aspect;
322 myLabelType : TypeOfColorScaleData from Aspect;
324 myAtBorder : Boolean from Standard;
325 myReversed : Boolean from Standard;
327 myColors : SequenceOfColor from Aspect;
328 myLabels : SequenceOfExtendedString from TColStd;
330 myLabelPos : TypeOfColorScalePosition from Aspect;
331 myTitlePos : TypeOfColorScalePosition from Aspect;
333 myXPos, myYPos : Real from Standard;
334 myWidth, myHeight : Real from Standard;
336 myTextHeight : Integer from Standard;