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