Warning, file /include/opencascade/AIS_ColorScale.hxx was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef _AIS_ColorScale_HeaderFile
0016 #define _AIS_ColorScale_HeaderFile
0017
0018 #include <AIS_InteractiveObject.hxx>
0019 #include <Aspect_TypeOfColorScaleData.hxx>
0020 #include <Aspect_TypeOfColorScalePosition.hxx>
0021 #include <Quantity_Color.hxx>
0022 #include <NCollection_Sequence.hxx>
0023 #include <Standard.hxx>
0024 #include <Standard_DefineHandle.hxx>
0025 #include <TCollection_ExtendedString.hxx>
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036 class AIS_ColorScale : public AIS_InteractiveObject
0037 {
0038 DEFINE_STANDARD_RTTIEXT(AIS_ColorScale, AIS_InteractiveObject)
0039 public:
0040
0041 Standard_EXPORT static bool FindColor(const double theValue,
0042 const double theMin,
0043 const double theMax,
0044 const int theColorsCount,
0045 const NCollection_Vec3<double>& theColorHlsMin,
0046 const NCollection_Vec3<double>& theColorHlsMax,
0047 Quantity_Color& theColor);
0048
0049
0050 static bool FindColor(const double theValue,
0051 const double theMin,
0052 const double theMax,
0053 const int theColorsCount,
0054 Quantity_Color& theColor)
0055 {
0056 return FindColor(theValue,
0057 theMin,
0058 theMax,
0059 theColorsCount,
0060 NCollection_Vec3<double>(230.0, 1.0, 1.0),
0061 NCollection_Vec3<double>(0.0, 1.0, 1.0),
0062 theColor);
0063 }
0064
0065
0066
0067
0068
0069 static double hueToValidRange(const double theHue)
0070 {
0071 double aHue = theHue;
0072 while (aHue < 0.0)
0073 {
0074 aHue += 360.0;
0075 }
0076 while (aHue > 360.0)
0077 {
0078 aHue -= 360.0;
0079 }
0080 return aHue;
0081 }
0082
0083 public:
0084
0085 Standard_EXPORT AIS_ColorScale();
0086
0087
0088 Standard_EXPORT bool FindColor(const double theValue, Quantity_Color& theColor) const;
0089
0090
0091 double GetMin() const { return myMin; }
0092
0093
0094 void SetMin(const double theMin) { SetRange(theMin, GetMax()); }
0095
0096
0097 double GetMax() const { return myMax; }
0098
0099
0100 void SetMax(const double theMax) { SetRange(GetMin(), theMax); }
0101
0102
0103 void GetRange(double& theMin, double& theMax) const
0104 {
0105 theMin = myMin;
0106 theMax = myMax;
0107 }
0108
0109
0110
0111
0112
0113 Standard_EXPORT void SetRange(const double theMin, const double theMax);
0114
0115
0116 double HueMin() const { return myColorHlsMin[0]; }
0117
0118
0119 double HueMax() const { return myColorHlsMax[0]; }
0120
0121
0122
0123 void HueRange(double& theMinAngle, double& theMaxAngle) const
0124 {
0125 theMinAngle = myColorHlsMin[0];
0126 theMaxAngle = myColorHlsMax[0];
0127 }
0128
0129
0130
0131 void SetHueRange(const double theMinAngle, const double theMaxAngle)
0132 {
0133 myColorHlsMin[0] = theMinAngle;
0134 myColorHlsMax[0] = theMaxAngle;
0135 }
0136
0137
0138 void ColorRange(Quantity_Color& theMinColor, Quantity_Color& theMaxColor) const
0139 {
0140 theMinColor.SetValues(hueToValidRange(myColorHlsMin[0]),
0141 myColorHlsMin[1],
0142 myColorHlsMin[2],
0143 Quantity_TOC_HLS);
0144 theMaxColor.SetValues(hueToValidRange(myColorHlsMax[0]),
0145 myColorHlsMax[1],
0146 myColorHlsMax[2],
0147 Quantity_TOC_HLS);
0148 }
0149
0150
0151 void SetColorRange(const Quantity_Color& theMinColor, const Quantity_Color& theMaxColor)
0152 {
0153 theMinColor.Values(myColorHlsMin[0], myColorHlsMin[1], myColorHlsMin[2], Quantity_TOC_HLS);
0154 theMaxColor.Values(myColorHlsMax[0], myColorHlsMax[1], myColorHlsMax[2], Quantity_TOC_HLS);
0155 }
0156
0157
0158
0159
0160 Aspect_TypeOfColorScaleData GetLabelType() const { return myLabelType; }
0161
0162
0163
0164
0165 void SetLabelType(const Aspect_TypeOfColorScaleData theType) { myLabelType = theType; }
0166
0167
0168
0169
0170 Aspect_TypeOfColorScaleData GetColorType() const { return myColorType; }
0171
0172
0173
0174
0175 void SetColorType(const Aspect_TypeOfColorScaleData theType) { myColorType = theType; }
0176
0177
0178 int GetNumberOfIntervals() const { return myNbIntervals; }
0179
0180
0181 Standard_EXPORT void SetNumberOfIntervals(const int theNum);
0182
0183
0184 const TCollection_ExtendedString& GetTitle() const { return myTitle; }
0185
0186
0187 void SetTitle(const TCollection_ExtendedString& theTitle) { myTitle = theTitle; }
0188
0189
0190
0191
0192 const TCollection_AsciiString& GetFormat() const { return myFormat; }
0193
0194
0195 const TCollection_AsciiString& Format() const { return myFormat; }
0196
0197
0198 void SetFormat(const TCollection_AsciiString& theFormat) { myFormat = theFormat; }
0199
0200
0201
0202
0203
0204 Standard_EXPORT TCollection_ExtendedString GetLabel(const int theIndex) const;
0205
0206
0207
0208 Standard_EXPORT Quantity_Color GetIntervalColor(const int theIndex) const;
0209
0210
0211
0212
0213
0214
0215 Standard_EXPORT void SetIntervalColor(const Quantity_Color& theColor, const int theIndex);
0216
0217
0218 Standard_EXPORT void GetLabels(NCollection_Sequence<TCollection_ExtendedString>& theLabels) const;
0219
0220
0221 const NCollection_Sequence<TCollection_ExtendedString>& Labels() const { return myLabels; }
0222
0223
0224
0225
0226
0227
0228
0229 Standard_EXPORT void SetLabels(const NCollection_Sequence<TCollection_ExtendedString>& theSeq);
0230
0231
0232 Standard_EXPORT void GetColors(NCollection_Sequence<Quantity_Color>& theColors) const;
0233
0234
0235 const NCollection_Sequence<Quantity_Color>& GetColors() const { return myColors; }
0236
0237
0238
0239 Standard_EXPORT void SetColors(const NCollection_Sequence<Quantity_Color>& theSeq);
0240
0241
0242
0243
0244
0245 void SetUniformColors(double theLightness, double theHueFrom, double theHueTo)
0246 {
0247 SetColors(MakeUniformColors(myNbIntervals, theLightness, theHueFrom, theHueTo));
0248 SetColorType(Aspect_TOCSD_USER);
0249 }
0250
0251
0252
0253
0254
0255
0256
0257
0258
0259
0260
0261
0262
0263
0264
0265
0266 Standard_EXPORT static NCollection_Sequence<Quantity_Color> MakeUniformColors(int theNbColors,
0267 double theLightness,
0268 double theHueFrom,
0269 double theHueTo);
0270
0271
0272
0273 Aspect_TypeOfColorScalePosition GetLabelPosition() const { return myLabelPos; }
0274
0275
0276 void SetLabelPosition(const Aspect_TypeOfColorScalePosition thePos) { myLabelPos = thePos; }
0277
0278
0279 Aspect_TypeOfColorScalePosition GetTitlePosition() const { return myTitlePos; }
0280
0281
0282 Standard_DEPRECATED("AIS_ColorScale::SetTitlePosition() has no effect!")
0283 void SetTitlePosition(const Aspect_TypeOfColorScalePosition thePos) { myTitlePos = thePos; }
0284
0285
0286
0287
0288 bool IsReversed() const { return myIsReversed; }
0289
0290
0291 void SetReversed(const bool theReverse) { myIsReversed = theReverse; }
0292
0293
0294
0295 bool IsSmoothTransition() const { return myIsSmooth; }
0296
0297
0298 void SetSmoothTransition(const bool theIsSmooth) { myIsSmooth = theIsSmooth; }
0299
0300
0301
0302
0303
0304 bool IsLabelAtBorder() const { return myIsLabelAtBorder; }
0305
0306
0307
0308 void SetLabelAtBorder(const bool theOn) { myIsLabelAtBorder = theOn; }
0309
0310
0311 bool IsLogarithmic() const { return myIsLogarithmic; }
0312
0313
0314 void SetLogarithmic(const bool isLogarithmic) { myIsLogarithmic = isLogarithmic; }
0315
0316
0317
0318
0319
0320
0321
0322 Standard_EXPORT void SetLabel(const TCollection_ExtendedString& theLabel, const int theIndex);
0323
0324
0325
0326 void GetSize(int& theBreadth, int& theHeight) const
0327 {
0328 theBreadth = myBreadth;
0329 theHeight = myHeight;
0330 }
0331
0332
0333 void SetSize(const int theBreadth, const int theHeight)
0334 {
0335 myBreadth = theBreadth;
0336 myHeight = theHeight;
0337 }
0338
0339
0340
0341 int GetBreadth() const { return myBreadth; }
0342
0343
0344 void SetBreadth(const int theBreadth) { myBreadth = theBreadth; }
0345
0346
0347
0348 int GetHeight() const { return myHeight; }
0349
0350
0351 void SetHeight(const int theHeight) { myHeight = theHeight; }
0352
0353
0354 void GetPosition(double& theX, double& theY) const
0355 {
0356 theX = myXPos;
0357 theY = myYPos;
0358 }
0359
0360
0361 void SetPosition(const int theX, const int theY)
0362 {
0363 myXPos = theX;
0364 myYPos = theY;
0365 }
0366
0367
0368 int GetXPosition() const { return myXPos; }
0369
0370
0371 void SetXPosition(const int theX) { myXPos = theX; }
0372
0373
0374 int GetYPosition() const { return myYPos; }
0375
0376
0377 void SetYPosition(const int theY) { myYPos = theY; }
0378
0379
0380 int GetTextHeight() const { return myTextHeight; }
0381
0382
0383 void SetTextHeight(const int theHeight) { myTextHeight = theHeight; }
0384
0385 public:
0386
0387
0388 Standard_EXPORT int TextWidth(const TCollection_ExtendedString& theText) const;
0389
0390
0391
0392 Standard_EXPORT int TextHeight(const TCollection_ExtendedString& theText) const;
0393
0394 Standard_EXPORT void TextSize(const TCollection_ExtendedString& theText,
0395 const int theHeight,
0396 int& theWidth,
0397 int& theAscent,
0398 int& theDescent) const;
0399
0400 public:
0401
0402 bool AcceptDisplayMode(const int theMode) const override { return theMode == 0; }
0403
0404
0405 Standard_EXPORT void Compute(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0406 const occ::handle<Prs3d_Presentation>& thePresentation,
0407 const int theMode) override;
0408
0409
0410 void ComputeSelection(const occ::handle<SelectMgr_Selection>& ,
0411 const int ) override
0412 {
0413 }
0414
0415 private:
0416
0417
0418
0419 void SizeHint(int& theWidth, int& theHeight) const;
0420
0421
0422 double GetIntervalValue(const int theIndex) const;
0423
0424
0425
0426
0427
0428 Quantity_Color colorFromValue(const double theValue,
0429 const double theMin,
0430 const double theMax) const;
0431
0432
0433 void updateTextAspect();
0434
0435
0436
0437
0438
0439
0440
0441 void drawText(const occ::handle<Graphic3d_Group>& theGroup,
0442 const TCollection_ExtendedString& theText,
0443 const int theX,
0444 const int theY,
0445 const Graphic3d_VerticalTextAlignment theVertAlignment);
0446
0447
0448 int computeMaxLabelWidth(const NCollection_Sequence<TCollection_ExtendedString>& theLabels) const;
0449
0450
0451 void drawLabels(const occ::handle<Graphic3d_Group>& theGroup,
0452 const NCollection_Sequence<TCollection_ExtendedString>& theLabels,
0453 const int theBarBottom,
0454 const int theBarHeight,
0455 const int theMaxLabelWidth,
0456 const int theColorBreadth);
0457
0458
0459 void drawColorBar(const occ::handle<Prs3d_Presentation>& thePrs,
0460 const int theBarBottom,
0461 const int theBarHeight,
0462 const int theMaxLabelWidth,
0463 const int theColorBreadth);
0464
0465
0466
0467
0468
0469
0470
0471 void drawFrame(const occ::handle<Prs3d_Presentation>& thePrs,
0472 const int theX,
0473 const int theY,
0474 const int theWidth,
0475 const int theHeight,
0476 const Quantity_Color& theColor);
0477
0478 private:
0479 double myMin;
0480 double myMax;
0481
0482 NCollection_Vec3<double> myColorHlsMin;
0483 NCollection_Vec3<double> myColorHlsMax;
0484 TCollection_ExtendedString myTitle;
0485 TCollection_AsciiString myFormat;
0486 int myNbIntervals;
0487 Aspect_TypeOfColorScaleData myColorType;
0488 Aspect_TypeOfColorScaleData myLabelType;
0489 bool myIsLabelAtBorder;
0490 bool myIsReversed;
0491 bool myIsLogarithmic;
0492 bool myIsSmooth;
0493 NCollection_Sequence<Quantity_Color> myColors;
0494 NCollection_Sequence<TCollection_ExtendedString> myLabels;
0495 Aspect_TypeOfColorScalePosition myLabelPos;
0496
0497 Aspect_TypeOfColorScalePosition myTitlePos;
0498 int myXPos;
0499 int myYPos;
0500 int myBreadth;
0501 int myHeight;
0502 int mySpacing;
0503 int myTextHeight;
0504 };
0505
0506 #endif