0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / Aspect / Aspect_ColorScale.cxx
CommitLineData
b311480e 1// Created on: 2004-06-22
2// Created by: STV
973c2be1 3// Copyright (c) 2004-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
d5f74e42 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
973c2be1 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
7fd59977 15
7fd59977 16
42cf5bc1 17#include <Aspect_ColorScale.hxx>
7fd59977 18#include <Aspect_SequenceOfColor.hxx>
19#include <Aspect_TypeOfColorScaleData.hxx>
20#include <Aspect_TypeOfColorScalePosition.hxx>
42cf5bc1 21#include <Precision.hxx>
22#include <Quantity_Color.hxx>
23#include <Standard_Type.hxx>
7fd59977 24#include <TCollection_AsciiString.hxx>
25#include <TCollection_ExtendedString.hxx>
26#include <TColStd_SequenceOfExtendedString.hxx>
27
7fd59977 28#include <stdio.h>
7fd59977 29Aspect_ColorScale::Aspect_ColorScale()
30: MMgt_TShared(),
31myMin( 0.0 ),
32myMax( 1.0 ),
7fd59977 33myTitle( "" ),
7fd59977 34myFormat( "%.4g" ),
eafb234b 35myInterval( 10 ),
7fd59977 36myColorType( Aspect_TOCSD_AUTO ),
37myLabelType( Aspect_TOCSD_AUTO ),
2f6cb3ac 38myAtBorder( Standard_True ),
39myReversed( Standard_False ),
7fd59977 40myLabelPos( Aspect_TOCSP_RIGHT ),
41myTitlePos( Aspect_TOCSP_CENTER ),
2f6cb3ac 42myXPos( 0 ),
43myYPos( 0 ),
44myWidth( 0.2 ),
45myHeight( 1 ),
7fd59977 46myTextHeight(20)
47{
48}
49
50Standard_Real Aspect_ColorScale::GetMin() const
51{
52 return myMin;
53}
54
55Standard_Real Aspect_ColorScale::GetMax() const
56{
57 return myMax;
58}
59
71215351 60void Aspect_ColorScale::GetRange (Standard_Real& theMin, Standard_Real& theMax) const
7fd59977 61{
71215351 62 theMin = myMin;
63 theMax = myMax;
7fd59977 64}
65
66Aspect_TypeOfColorScaleData Aspect_ColorScale::GetLabelType() const
67{
68 return myLabelType;
69}
70
71Aspect_TypeOfColorScaleData Aspect_ColorScale::GetColorType() const
72{
73 return myColorType;
74}
75
76Standard_Integer Aspect_ColorScale::GetNumberOfIntervals() const
77{
78 return myInterval;
79}
80
81TCollection_ExtendedString Aspect_ColorScale::GetTitle() const
82{
83 return myTitle;
84}
85
86TCollection_AsciiString Aspect_ColorScale::GetFormat() const
87{
88 return myFormat;
89}
90
71215351 91TCollection_ExtendedString Aspect_ColorScale::GetLabel (const Standard_Integer theIndex) const
7fd59977 92{
71215351 93 if (GetLabelType() == Aspect_TOCSD_USER)
94 {
95 if (theIndex < 0
96 || theIndex >= myLabels.Length())
97 {
98 return "";
99 }
100
101 return myLabels.Value (theIndex + 1);
102 }
103
104 const Standard_Real aVal = GetNumber (theIndex);
105 const TCollection_AsciiString aFormat = Format();
106 Standard_Character aBuf[1024];
107 sprintf (aBuf, aFormat.ToCString(), aVal);
108 return TCollection_ExtendedString (aBuf);
7fd59977 109}
110
71215351 111Quantity_Color Aspect_ColorScale::GetColor (const Standard_Integer theIndex) const
7fd59977 112{
71215351 113 if (GetColorType() == Aspect_TOCSD_USER)
114 {
115 if (theIndex < 0
116 || theIndex >= myColors.Length())
117 {
118 return Quantity_Color();
119 }
120
121 return myColors.Value (theIndex + 1);
122 }
123 return Quantity_Color (HueFromValue (theIndex, 0, GetNumberOfIntervals() - 1), 1.0, 1.0, Quantity_TOC_HLS);
7fd59977 124}
125
71215351 126void Aspect_ColorScale::GetLabels (TColStd_SequenceOfExtendedString& theLabels) const
7fd59977 127{
71215351 128 theLabels.Clear();
129 for (Standard_Integer i = 1; i <= myLabels.Length(); i++)
130 theLabels.Append (myLabels.Value (i));
7fd59977 131}
132
71215351 133void Aspect_ColorScale::GetColors (Aspect_SequenceOfColor& theColors) const
7fd59977 134{
71215351 135 theColors.Clear();
136 for (Standard_Integer i = 1; i <= myColors.Length(); i++)
137 theColors.Append (myColors.Value (i));
7fd59977 138}
139
140Aspect_TypeOfColorScalePosition Aspect_ColorScale::GetLabelPosition() const
141{
142 return myLabelPos;
143}
144
145Aspect_TypeOfColorScalePosition Aspect_ColorScale::GetTitlePosition() const
146{
147 return myTitlePos;
148}
149
150Standard_Boolean Aspect_ColorScale::IsReversed() const
151{
152 return myReversed;
153}
154
155Standard_Boolean Aspect_ColorScale::IsLabelAtBorder() const
156{
157 return myAtBorder;
158}
159
71215351 160void Aspect_ColorScale::SetMin (const Standard_Real theMin)
7fd59977 161{
71215351 162 SetRange (theMin, GetMax());
7fd59977 163}
164
71215351 165void Aspect_ColorScale::SetMax (const Standard_Real theMax)
7fd59977 166{
71215351 167 SetRange (GetMin(), theMax);
7fd59977 168}
169
71215351 170void Aspect_ColorScale::SetRange (const Standard_Real theMin, const Standard_Real theMax)
7fd59977 171{
71215351 172 if (myMin == theMin && myMax == theMax)
7fd59977 173 return;
174
71215351 175 myMin = Min( theMin, theMax );
176 myMax = Max( theMin, theMax );
7fd59977 177
71215351 178 if (GetColorType() == Aspect_TOCSD_AUTO)
7fd59977 179 UpdateColorScale();
180}
181
71215351 182void Aspect_ColorScale::SetLabelType (const Aspect_TypeOfColorScaleData theType)
7fd59977 183{
71215351 184 if (myLabelType == theType)
7fd59977 185 return;
186
71215351 187 myLabelType = theType;
7fd59977 188 UpdateColorScale();
189}
190
71215351 191void Aspect_ColorScale::SetColorType (const Aspect_TypeOfColorScaleData theType)
7fd59977 192{
71215351 193 if (myColorType == theType)
7fd59977 194 return;
195
71215351 196 myColorType = theType;
7fd59977 197 UpdateColorScale();
198}
199
71215351 200void Aspect_ColorScale::SetNumberOfIntervals (const Standard_Integer theNum)
7fd59977 201{
71215351 202 if (myInterval == theNum || theNum < 1)
7fd59977 203 return;
204
71215351 205 myInterval = theNum;
7fd59977 206 UpdateColorScale();
207}
208
71215351 209void Aspect_ColorScale::SetTitle (const TCollection_ExtendedString& theTitle)
7fd59977 210{
71215351 211 if (myTitle == theTitle)
7fd59977 212 return;
213
71215351 214 myTitle = theTitle;
7fd59977 215 UpdateColorScale();
216}
217
71215351 218void Aspect_ColorScale::SetFormat (const TCollection_AsciiString& theFormat)
7fd59977 219{
71215351 220 if (myFormat == theFormat)
7fd59977 221 return;
222
71215351 223 myFormat = theFormat;
224 if (GetLabelType() == Aspect_TOCSD_AUTO)
7fd59977 225 UpdateColorScale();
226}
227
71215351 228void Aspect_ColorScale::SetLabel (const TCollection_ExtendedString& theLabel, const Standard_Integer theIndex)
7fd59977 229{
230 Standard_Boolean changed = Standard_False;
71215351 231 Standard_Integer i = theIndex < 0 ? myLabels.Length() + 1 : theIndex + 1;
232 if (i <= myLabels.Length()) {
233 changed = myLabels.Value (i) != theLabel;
234 myLabels.SetValue (i, theLabel);
7fd59977 235 }
236 else {
237 changed = Standard_True;
71215351 238 while (i > myLabels.Length())
239 myLabels.Append (TCollection_ExtendedString());
240 myLabels.SetValue (i, theLabel);
7fd59977 241 }
71215351 242 if (changed)
7fd59977 243 UpdateColorScale();
244}
245
71215351 246void Aspect_ColorScale::SetColor (const Quantity_Color& theColor, const Standard_Integer theIndex)
7fd59977 247{
248 Standard_Boolean changed = Standard_False;
71215351 249 Standard_Integer i = theIndex < 0 ? myColors.Length() + 1 : theIndex + 1;
250 if (i <= myColors.Length()) {
251 changed = myColors.Value (i) != theColor;
252 myColors.SetValue (i, theColor);
7fd59977 253 }
254 else {
255 changed = Standard_True;
256 while ( i > myColors.Length() )
71215351 257 myColors.Append (Quantity_Color());
258 myColors.SetValue (i, theColor);
7fd59977 259 }
71215351 260 if (changed)
7fd59977 261 UpdateColorScale();
262}
263
71215351 264void Aspect_ColorScale::SetLabels (const TColStd_SequenceOfExtendedString& theSeq)
7fd59977 265{
266 myLabels.Clear();
71215351 267 for (Standard_Integer i = 1; i <= theSeq.Length(); i++)
268 myLabels.Append (theSeq.Value (i));
7fd59977 269}
270
71215351 271void Aspect_ColorScale::SetColors (const Aspect_SequenceOfColor& theSeq)
7fd59977 272{
273 myColors.Clear();
71215351 274 for (Standard_Integer i = 1; i <= theSeq.Length(); i++)
275 myColors.Append (theSeq.Value (i));
7fd59977 276}
277
71215351 278void Aspect_ColorScale::SetLabelPosition (const Aspect_TypeOfColorScalePosition thePos)
7fd59977 279{
71215351 280 if (myLabelPos == thePos)
7fd59977 281 return;
282
71215351 283 myLabelPos = thePos;
7fd59977 284 UpdateColorScale();
285}
286
71215351 287void Aspect_ColorScale::SetTitlePosition (const Aspect_TypeOfColorScalePosition thePos)
7fd59977 288{
71215351 289 if (myTitlePos == thePos)
7fd59977 290 return;
291
71215351 292 myTitlePos = thePos;
7fd59977 293 UpdateColorScale();
294}
295
71215351 296void Aspect_ColorScale::SetReversed (const Standard_Boolean theReverse)
7fd59977 297{
71215351 298 if (myReversed == theReverse)
7fd59977 299 return;
300
71215351 301 myReversed = theReverse;
7fd59977 302 UpdateColorScale();
303}
304
71215351 305void Aspect_ColorScale::SetLabelAtBorder (const Standard_Boolean theOn)
7fd59977 306{
71215351 307 if (myAtBorder == theOn)
7fd59977 308 return;
309
71215351 310 myAtBorder = theOn;
7fd59977 311 UpdateColorScale();
312}
313
71215351 314void Aspect_ColorScale::GetPosition (Standard_Real& theX, Standard_Real& theY) const
7fd59977 315{
71215351 316 theX = myXPos;
317 theY = myYPos;
7fd59977 318}
319
320Standard_Real Aspect_ColorScale::GetXPosition() const
321{
322 return myXPos;
323}
324
325Standard_Real Aspect_ColorScale::GetYPosition() const
326{
327 return myYPos;
328}
329
71215351 330void Aspect_ColorScale::SetPosition (const Standard_Real theX, const Standard_Real theY)
7fd59977 331{
71215351 332 if (myXPos == theX && myYPos == theY)
7fd59977 333 return;
334
71215351 335 myXPos = theX;
336 myYPos = theY;
7fd59977 337
338 UpdateColorScale();
339}
340
71215351 341void Aspect_ColorScale::SetXPosition (const Standard_Real theX)
7fd59977 342{
71215351 343 SetPosition (theX, GetYPosition());
7fd59977 344}
345
71215351 346void Aspect_ColorScale::SetYPosition (const Standard_Real theY)
7fd59977 347{
71215351 348 SetPosition (GetXPosition(), theY);
7fd59977 349}
350
71215351 351void Aspect_ColorScale::GetSize (Standard_Real& theWidth, Standard_Real& theHeight) const
7fd59977 352{
71215351 353 theWidth = myWidth;
354 theHeight = myHeight;
7fd59977 355}
356
357Standard_Real Aspect_ColorScale::GetWidth() const
358{
359 return myWidth;
360}
361
362Standard_Real Aspect_ColorScale::GetHeight() const
363{
364 return myHeight;
365}
366
71215351 367void Aspect_ColorScale::SetSize (const Standard_Real theWidth, const Standard_Real theHeight)
7fd59977 368{
71215351 369 if (myWidth == theWidth && myHeight == theHeight)
7fd59977 370 return;
371
71215351 372 myWidth = theWidth;
373 myHeight = theHeight;
7fd59977 374
375 UpdateColorScale();
376}
377
71215351 378void Aspect_ColorScale::SetWidth (const Standard_Real theWidth)
7fd59977 379{
71215351 380 SetSize (theWidth, GetHeight());
7fd59977 381}
382
71215351 383void Aspect_ColorScale::SetHeight (const Standard_Real theHeight)
7fd59977 384{
71215351 385 SetSize (GetWidth(), theHeight);
7fd59977 386}
387
71215351 388void Aspect_ColorScale::SizeHint (Standard_Integer& theWidth, Standard_Integer& theHeight) const
7fd59977 389{
390 Standard_Integer num = GetNumberOfIntervals();
391
392 Standard_Integer spacer = 5;
393 Standard_Integer textWidth = 0;
71215351 394 Standard_Integer textHeight = TextHeight ("");
7fd59977 395 Standard_Integer colorWidth = 20;
396
71215351 397 if (GetLabelPosition() != Aspect_TOCSP_NONE)
398 for (Standard_Integer idx = 0; idx < num; idx++)
399 textWidth = Max (textWidth, TextWidth (GetLabel (idx + 1)));
7fd59977 400
401 Standard_Integer scaleWidth = 0;
402 Standard_Integer scaleHeight = 0;
403
404 Standard_Integer titleWidth = 0;
405 Standard_Integer titleHeight = 0;
406
71215351 407 if (IsLabelAtBorder()) {
7fd59977 408 num++;
71215351 409 if (GetTitle().Length())
7fd59977 410 titleHeight += 10;
411 }
412
413 scaleWidth = colorWidth + textWidth + ( textWidth ? 3 : 2 ) * spacer;
414 scaleHeight = (Standard_Integer)( 1.5 * ( num + 1 ) * textHeight );
415
71215351 416 if (GetTitle().Length()) {
417 titleHeight = TextHeight (GetTitle()) + spacer;
418 titleWidth = TextWidth (GetTitle()) + 10;
7fd59977 419 }
420
71215351 421 theWidth = Max (titleWidth, scaleWidth);
422 theHeight = scaleHeight + titleHeight;
7fd59977 423}
424
71215351 425void Aspect_ColorScale::DrawScale ( const Quantity_Color& theBgColor,
426 const Standard_Integer theX, const Standard_Integer theY,
427 const Standard_Integer theWidth, const Standard_Integer theHeight)
7fd59977 428{
71215351 429 if (!BeginPaint())
7fd59977 430 return;
431
432 Standard_Integer num = GetNumberOfIntervals();
433 Aspect_TypeOfColorScalePosition labPos = GetLabelPosition();
434
435 Standard_Integer spacer = 5;
436 Standard_Integer textWidth = 0;
71215351 437 Standard_Integer textHeight = TextHeight ("");
7fd59977 438
439 Standard_Boolean drawLabel = GetLabelPosition() != Aspect_TOCSP_NONE;
440
441 TCollection_ExtendedString aTitle = GetTitle();
442
7fd59977 443 Standard_Integer titleHeight = 0;
444
71215351 445 Standard_Integer aGray = (Standard_Integer)(255 * ( theBgColor.Red() * 11 + theBgColor.Green() * 16 + theBgColor.Blue() * 5 ) / 32);
446 Quantity_Color aFgColor (aGray < 128 ? Quantity_NOC_WHITE : Quantity_NOC_BLACK);
7fd59977 447
448 // Draw title
71215351 449 if (aTitle.Length()) {
450 titleHeight = TextHeight (aTitle) + 2 * spacer;
451 PaintText (aTitle, theX + spacer, theY + spacer, aFgColor);
7fd59977 452 }
453
454 Standard_Boolean reverse = IsReversed();
455
456 Aspect_SequenceOfColor colors;
457 TColStd_SequenceOfExtendedString labels;
71215351 458 for (int idx = 0; idx < num; idx++) {
459 if (reverse) {
460 colors.Append (GetColor (idx));
461 labels.Append (GetLabel (idx));
7fd59977 462 }
463 else {
71215351 464 colors.Prepend (GetColor (idx));
465 labels.Prepend (GetLabel (idx));
7fd59977 466 }
467 }
468
71215351 469 if (IsLabelAtBorder()) {
470 if (reverse)
471 labels.Append (GetLabel (num));
7fd59977 472 else
71215351 473 labels.Prepend (GetLabel (num));
7fd59977 474 }
475
71215351 476 if (drawLabel)
477 for (Standard_Integer i = 1; i <= labels.Length(); i++)
478 textWidth = Max (textWidth, TextWidth (labels.Value (i)));
7fd59977 479
480 Standard_Integer lab = labels.Length();
481
71215351 482 Standard_Real spc = ( theHeight - ( ( Min (lab, 2) + Abs (lab - num - 1) ) * textHeight ) - titleHeight );
483 Standard_Real val = spc != 0 ? 1.0 * ( lab - Min (lab, 1) ) * textHeight / spc : 0;
7fd59977 484 Standard_Real iPart;
71215351 485 Standard_Real fPart = modf (val, &iPart);
7fd59977 486 Standard_Integer filter = (Standard_Integer)iPart + ( fPart != 0 ? 1 : 0 );
487
71215351 488 Standard_Real step = 1.0 * ( theHeight - ( lab - num + Abs (lab - num - 1) ) * textHeight - titleHeight ) / num;
7fd59977 489
490 Standard_Integer ascent = 0;
71215351 491 Standard_Integer colorWidth = Max (5, Min (20, theWidth - textWidth - 3 * spacer));
492 if (labPos == Aspect_TOCSP_CENTER || !drawLabel)
493 colorWidth = theWidth - 2 * spacer;
7fd59977 494
495 // Draw colors
71215351 496 Standard_Integer x = theX + spacer;
497 if (labPos == Aspect_TOCSP_LEFT)
7fd59977 498 x += textWidth + ( textWidth ? 1 : 0 ) * spacer;
499
71215351 500 Standard_Real offset = 1.0 * textHeight / 2 * ( lab - num + Abs (lab - num - 1) ) + titleHeight;
501 for (Standard_Integer ci = 1; ci <= colors.Length() && step > 0; ci++ ) {
502 Standard_Integer y = (Standard_Integer)( theY + ( ci - 1 )* step + offset);
503 Standard_Integer h = (Standard_Integer)( theY + ( ci ) * step + offset ) - y;
504 PaintRect (x, y, colorWidth, h, colors.Value (ci), Standard_True);
7fd59977 505 }
506
71215351 507 if (step > 0)
508 PaintRect (x - 1, (Standard_Integer)(theY + offset - 1), colorWidth + 2, (Standard_Integer)(colors.Length() * step + 2), aFgColor);
7fd59977 509
510 // Draw labels
71215351 511 offset = 1.0 * Abs (lab - num - 1) * ( step - textHeight ) / 2 + 1.0 * Abs (lab - num - 1) * textHeight / 2;
7fd59977 512 offset += titleHeight;
71215351 513 if (drawLabel && labels.Length() && filter > 0) {
7fd59977 514 Standard_Integer i1 = 0;
515 Standard_Integer i2 = lab - 1;
71215351 516 Standard_Integer last1 (i1), last2 (i2);
517 x = theX + spacer;
7fd59977 518 switch ( labPos ) {
8cb69787 519 case Aspect_TOCSP_NONE:
520 case Aspect_TOCSP_LEFT:
521 break;
7fd59977 522 case Aspect_TOCSP_CENTER:
523 x += ( colorWidth - textWidth ) / 2;
524 break;
525 case Aspect_TOCSP_RIGHT:
526 x += colorWidth + spacer;
527 break;
528 }
71215351 529 while (i2 - i1 >= filter || ( i2 == 0 && i1 == 0 )) {
7fd59977 530 Standard_Integer pos1 = i1;
531 Standard_Integer pos2 = lab - 1 - i2;
71215351 532 if (filter && !( pos1 % filter )) {
533 PaintText (labels.Value (i1 + 1), x, (Standard_Integer)( theY + i1 * step + ascent + offset ), aFgColor);
534 last1 = i1;
7fd59977 535 }
71215351 536 if (filter && !( pos2 % filter )) {
537 PaintText (labels.Value (i2 + 1), x, (Standard_Integer)( theY + i2 * step + ascent + offset ), aFgColor);
538 last2 = i2;
7fd59977 539 }
540 i1++;
541 i2--;
542 }
543 Standard_Integer pos = i1;
544 Standard_Integer i0 = -1;
71215351 545 while (pos <= i2 && i0 == -1) {
546 if (filter && !( pos % filter ) && Abs (pos - last1) >= filter && Abs (pos - last2) >= filter)
547 i0 = pos;
7fd59977 548 pos++;
549 }
550
71215351 551 if (i0 != -1)
552 PaintText (labels.Value (i0 + 1), x, (Standard_Integer)( theY + i0 * step + ascent + offset ), aFgColor);
7fd59977 553 }
554
555 EndPaint();
556}
557
558Standard_Boolean Aspect_ColorScale::BeginPaint()
559{
560 return Standard_True;
561}
562
563Standard_Boolean Aspect_ColorScale::EndPaint()
564{
565 return Standard_True;
566}
567
568void Aspect_ColorScale::UpdateColorScale()
569{
570}
571
572TCollection_AsciiString Aspect_ColorScale::Format() const
573{
574 return GetFormat();
575}
576
71215351 577Standard_Real Aspect_ColorScale::GetNumber (const Standard_Integer theIndex) const
7fd59977 578{
579 Standard_Real aNum = 0;
71215351 580 if (GetNumberOfIntervals() > 0)
581 aNum = GetMin() + theIndex * ( Abs (GetMax() - GetMin()) / GetNumberOfIntervals() );
7fd59977 582 return aNum;
583}
584
71215351 585Standard_Integer Aspect_ColorScale::HueFromValue (const Standard_Integer theValue,
586 const Standard_Integer theMin, const Standard_Integer theMax)
7fd59977 587{
71215351 588 Standard_Integer minLimit (0), maxLimit (230);
7fd59977 589
590 Standard_Integer aHue = maxLimit;
71215351 591 if (theMin != theMax)
592 aHue = (Standard_Integer)( maxLimit - ( maxLimit - minLimit ) * ( theValue - theMin ) / ( theMax - theMin ) );
7fd59977 593
71215351 594 aHue = Min (Max (minLimit, aHue), maxLimit);
7fd59977 595
596 return aHue;
597}
598
599Standard_Integer Aspect_ColorScale::GetTextHeight() const {
600 return myTextHeight;
601}
602
71215351 603void Aspect_ColorScale::SetTextHeight (const Standard_Integer theHeight) {
604 myTextHeight = theHeight;
7fd59977 605 UpdateColorScale ();
606}
607
608
71215351 609Standard_Boolean Aspect_ColorScale::FindColor (const Standard_Real theValue,
610 Quantity_Color& theColor) const
7fd59977 611{
71215351 612 return FindColor (theValue, myMin, myMax, myInterval, theColor);
7fd59977 613}
614
615
71215351 616Standard_Boolean Aspect_ColorScale::FindColor (const Standard_Real theValue,
617 const Standard_Real theMin,
618 const Standard_Real theMax,
619 const Standard_Integer theColorsCount,
620 Quantity_Color& theColor)
7fd59977 621{
71215351 622 if(theValue<theMin || theValue>theMax || theMax<theMin)
7fd59977 623 return Standard_False;
624
625 else
626 {
627 Standard_Real IntervNumber = 0;
71215351 628 if(Abs (theMax-theMin) > Precision::Approximation())
629 IntervNumber = Floor (Standard_Real( theColorsCount ) * ( theValue - theMin ) / ( theMax - theMin ));
7fd59977 630
71215351 631 Standard_Integer Interv = Standard_Integer (IntervNumber);
7fd59977 632
71215351 633 theColor = Quantity_Color (HueFromValue (Interv, 0, theColorsCount - 1), 1.0, 1.0, Quantity_TOC_HLS);
7fd59977 634
635 return Standard_True;
636 }
637}