File indexing completed on 2026-07-26 09:15:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef _AIS_ViewCube_HeaderFile
0017 #define _AIS_ViewCube_HeaderFile
0018
0019 #include <AIS_InteractiveObject.hxx>
0020 #include <Graphic3d_Camera.hxx>
0021 #include <Graphic3d_Vec2.hxx>
0022 #include <Prs3d_DatumParts.hxx>
0023 #include <Prs3d_ShadingAspect.hxx>
0024 #include <Prs3d_TextAspect.hxx>
0025 #include <SelectMgr_EntityOwner.hxx>
0026 #include <V3d_TypeOfOrientation.hxx>
0027 #include <Select3D_SensitivePrimitiveArray.hxx>
0028
0029 class AIS_AnimationCamera;
0030 class AIS_ViewCubeOwner;
0031 class Graphic3d_ArrayOfTriangles;
0032 class V3d_View;
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060 class AIS_ViewCube : public AIS_InteractiveObject
0061 {
0062 DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
0063 public:
0064
0065 Standard_EXPORT static bool IsBoxSide(V3d_TypeOfOrientation theOrient);
0066
0067
0068 Standard_EXPORT static bool IsBoxEdge(V3d_TypeOfOrientation theOrient);
0069
0070
0071 Standard_EXPORT static bool IsBoxCorner(V3d_TypeOfOrientation theOrient);
0072
0073 public:
0074
0075 Standard_EXPORT AIS_ViewCube();
0076
0077
0078 const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
0079
0080
0081 void SetViewAnimation(const Handle(AIS_AnimationCamera)& theAnimation)
0082 {
0083 myViewAnimation = theAnimation;
0084 }
0085
0086
0087
0088 Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
0089
0090
0091
0092
0093 void SetAutoStartAnimation(bool theToEnable) { myToAutoStartAnim = theToEnable; }
0094
0095
0096 Standard_Boolean IsFixedAnimationLoop() const { return myIsFixedAnimation; }
0097
0098
0099 void SetFixedAnimationLoop(bool theToEnable) { myIsFixedAnimation = theToEnable; }
0100
0101
0102
0103 Standard_EXPORT void ResetStyles();
0104
0105 protected:
0106
0107 Standard_EXPORT void setDefaultAttributes();
0108
0109
0110 Standard_EXPORT void setDefaultHighlightAttributes();
0111
0112 public:
0113
0114 Standard_Real Size() const { return mySize; }
0115
0116
0117
0118 Standard_EXPORT void SetSize(Standard_Real theValue, Standard_Boolean theToAdaptAnother = true);
0119
0120
0121 Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
0122
0123
0124 void SetBoxFacetExtension(Standard_Real theValue)
0125 {
0126 if (Abs(myBoxFacetExtension - theValue) > Precision::Confusion())
0127 {
0128 myBoxFacetExtension = theValue;
0129 SetToUpdate();
0130 }
0131 }
0132
0133
0134 Standard_Real AxesPadding() const { return myAxesPadding; }
0135
0136
0137 void SetAxesPadding(Standard_Real theValue)
0138 {
0139 if (Abs(myAxesPadding - theValue) > Precision::Confusion())
0140 {
0141 myAxesPadding = theValue;
0142 SetToUpdate();
0143 }
0144 }
0145
0146
0147 Standard_Real BoxEdgeGap() const { return myBoxEdgeGap; }
0148
0149
0150 void SetBoxEdgeGap(Standard_Real theValue)
0151 {
0152 if (Abs(myBoxEdgeGap - theValue) > Precision::Confusion())
0153 {
0154 myBoxEdgeGap = theValue;
0155 SetToUpdate();
0156 }
0157 }
0158
0159
0160 Standard_Real BoxEdgeMinSize() const { return myBoxEdgeMinSize; }
0161
0162
0163 void SetBoxEdgeMinSize(Standard_Real theValue)
0164 {
0165 if (Abs(myBoxEdgeMinSize - theValue) > Precision::Confusion())
0166 {
0167 myBoxEdgeMinSize = theValue;
0168 SetToUpdate();
0169 }
0170 }
0171
0172
0173 Standard_Real BoxCornerMinSize() const { return myCornerMinSize; }
0174
0175
0176 void SetBoxCornerMinSize(Standard_Real theValue)
0177 {
0178 if (Abs(myCornerMinSize - theValue) > Precision::Confusion())
0179 {
0180 myCornerMinSize = theValue;
0181 SetToUpdate();
0182 }
0183 }
0184
0185
0186
0187 Standard_Real RoundRadius() const { return myRoundRadius; }
0188
0189
0190
0191 Standard_EXPORT void SetRoundRadius(const Standard_Real theValue);
0192
0193
0194 Standard_Real AxesRadius() const { return myAxesRadius; }
0195
0196
0197 void SetAxesRadius(const Standard_Real theRadius)
0198 {
0199 if (Abs(myAxesRadius - theRadius) > Precision::Confusion())
0200 {
0201 myAxesRadius = theRadius;
0202 SetToUpdate();
0203 }
0204 }
0205
0206
0207 Standard_Real AxesConeRadius() const { return myAxesConeRadius; }
0208
0209
0210 void SetAxesConeRadius(Standard_Real theRadius)
0211 {
0212 if (Abs(myAxesConeRadius - theRadius) > Precision::Confusion())
0213 {
0214 myAxesConeRadius = theRadius;
0215 SetToUpdate();
0216 }
0217 }
0218
0219
0220 Standard_Real AxesSphereRadius() const { return myAxesSphereRadius; }
0221
0222
0223 void SetAxesSphereRadius(Standard_Real theRadius)
0224 {
0225 if (Abs(myAxesSphereRadius - theRadius) > Precision::Confusion())
0226 {
0227 myAxesSphereRadius = theRadius;
0228 SetToUpdate();
0229 }
0230 }
0231
0232
0233 Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
0234
0235
0236 void SetDrawAxes(Standard_Boolean theValue)
0237 {
0238 if (myToDisplayAxes != theValue)
0239 {
0240 myToDisplayAxes = theValue;
0241 SetToUpdate();
0242 }
0243 }
0244
0245
0246 Standard_Boolean ToDrawEdges() const { return myToDisplayEdges; }
0247
0248
0249 void SetDrawEdges(Standard_Boolean theValue)
0250 {
0251 if (myToDisplayEdges != theValue)
0252 {
0253 myToDisplayEdges = theValue;
0254 SetToUpdate();
0255 }
0256 }
0257
0258
0259 Standard_Boolean ToDrawVertices() const { return myToDisplayVertices; }
0260
0261
0262 void SetDrawVertices(Standard_Boolean theValue)
0263 {
0264 if (myToDisplayVertices != theValue)
0265 {
0266 myToDisplayVertices = theValue;
0267 SetToUpdate();
0268 }
0269 }
0270
0271
0272 Standard_Boolean IsYup() const { return myIsYup; }
0273
0274
0275 Standard_EXPORT void SetYup(Standard_Boolean theIsYup,
0276 Standard_Boolean theToUpdateLabels = Standard_True);
0277
0278 public:
0279
0280 const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
0281
0282
0283 const Handle(Prs3d_ShadingAspect)& BoxEdgeStyle() const { return myBoxEdgeAspect; }
0284
0285
0286 const Handle(Prs3d_ShadingAspect)& BoxCornerStyle() const { return myBoxCornerAspect; }
0287
0288
0289 const Quantity_Color& BoxColor() const { return myDrawer->ShadingAspect()->Color(); }
0290
0291
0292
0293 void SetBoxColor(const Quantity_Color& theColor)
0294 {
0295 if (!myDrawer->ShadingAspect()->Color().IsEqual(theColor)
0296 || !myBoxEdgeAspect->Color().IsEqual(theColor)
0297 || !myBoxCornerAspect->Color().IsEqual(theColor))
0298 {
0299 myDrawer->ShadingAspect()->SetColor(theColor);
0300 myBoxEdgeAspect->SetColor(theColor);
0301 myBoxCornerAspect->SetColor(theColor);
0302 SynchronizeAspects();
0303 }
0304 }
0305
0306
0307 Standard_Real BoxTransparency() const { return myDrawer->ShadingAspect()->Transparency(); }
0308
0309
0310
0311 void SetBoxTransparency(Standard_Real theValue)
0312 {
0313 if (Abs(myDrawer->ShadingAspect()->Transparency() - theValue) > Precision::Confusion()
0314 || Abs(myBoxEdgeAspect->Transparency() - theValue) > Precision::Confusion()
0315 || Abs(myBoxCornerAspect->Transparency() - theValue) > Precision::Confusion())
0316 {
0317 myDrawer->ShadingAspect()->SetTransparency(theValue);
0318 myBoxEdgeAspect->SetTransparency(theValue);
0319 myBoxCornerAspect->SetTransparency(theValue);
0320 SynchronizeAspects();
0321 }
0322 }
0323
0324
0325 const Quantity_Color& InnerColor() const
0326 {
0327 return myDrawer->ShadingAspect()->Color(Aspect_TOFM_BACK_SIDE);
0328 }
0329
0330
0331
0332 void SetInnerColor(const Quantity_Color& theColor)
0333 {
0334 myDrawer->ShadingAspect()->SetColor(theColor, Aspect_TOFM_BACK_SIDE);
0335 SynchronizeAspects();
0336 }
0337
0338
0339
0340 TCollection_AsciiString BoxSideLabel(V3d_TypeOfOrientation theSide) const
0341 {
0342 const TCollection_AsciiString* aLabel = myBoxSideLabels.Seek(theSide);
0343 return aLabel != NULL ? *aLabel : TCollection_AsciiString();
0344 }
0345
0346
0347 void SetBoxSideLabel(const V3d_TypeOfOrientation theSide, const TCollection_AsciiString& theLabel)
0348 {
0349 if (!IsBoxSide(theSide))
0350 {
0351 throw Standard_ProgramError("AIS_ViewCube::SetBoxSideLabel(), invalid enumeration value");
0352 }
0353 myBoxSideLabels.Bind(theSide, theLabel);
0354 SetToUpdate();
0355 }
0356
0357
0358 const Quantity_Color& TextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
0359
0360
0361
0362 void SetTextColor(const Quantity_Color& theColor)
0363 {
0364 myDrawer->TextAspect()->SetColor(theColor);
0365 SynchronizeAspects();
0366 }
0367
0368
0369
0370 const TCollection_AsciiString& Font() const { return myDrawer->TextAspect()->Aspect()->Font(); }
0371
0372
0373
0374 void SetFont(const TCollection_AsciiString& theFont)
0375 {
0376 myDrawer->TextAspect()->Aspect()->SetFont(theFont);
0377 SynchronizeAspects();
0378 }
0379
0380
0381 Standard_Real FontHeight() const { return myDrawer->TextAspect()->Height(); }
0382
0383
0384
0385 void SetFontHeight(Standard_Real theValue)
0386 {
0387 if (Abs(myDrawer->TextAspect()->Height() - theValue) > Precision::Confusion())
0388 {
0389 myDrawer->TextAspect()->SetHeight(theValue);
0390 SetToUpdate();
0391 }
0392 }
0393
0394
0395
0396 TCollection_AsciiString AxisLabel(Prs3d_DatumParts theAxis) const
0397 {
0398 const TCollection_AsciiString* aLabel = myAxesLabels.Seek(theAxis);
0399 return aLabel != NULL ? *aLabel : TCollection_AsciiString();
0400 }
0401
0402
0403 void SetAxesLabels(const TCollection_AsciiString& theX,
0404 const TCollection_AsciiString& theY,
0405 const TCollection_AsciiString& theZ)
0406 {
0407 myAxesLabels.Bind(Prs3d_DatumParts_XAxis, theX);
0408 myAxesLabels.Bind(Prs3d_DatumParts_YAxis, theY);
0409 myAxesLabels.Bind(Prs3d_DatumParts_ZAxis, theZ);
0410 SetToUpdate();
0411 }
0412
0413 public:
0414
0415
0416 virtual void SetColor(const Quantity_Color& theColor) Standard_OVERRIDE { SetBoxColor(theColor); }
0417
0418
0419 virtual void UnsetColor() Standard_OVERRIDE
0420 {
0421 myDrawer->ShadingAspect()->SetColor(Quantity_NOC_WHITE);
0422 myBoxEdgeAspect->SetColor(Quantity_NOC_GRAY30);
0423 myBoxCornerAspect->SetColor(Quantity_NOC_GRAY30);
0424 SynchronizeAspects();
0425 }
0426
0427
0428
0429 virtual void SetTransparency(const Standard_Real theValue) Standard_OVERRIDE
0430 {
0431 SetBoxTransparency(theValue);
0432 }
0433
0434
0435 virtual void UnsetTransparency() Standard_OVERRIDE { SetBoxTransparency(0.0f); }
0436
0437
0438 virtual void SetMaterial(const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
0439 {
0440 myDrawer->ShadingAspect()->SetMaterial(theMat);
0441 myBoxEdgeAspect->SetMaterial(theMat);
0442 myBoxCornerAspect->SetMaterial(theMat);
0443 SynchronizeAspects();
0444 }
0445
0446
0447 virtual void UnsetMaterial() Standard_OVERRIDE
0448 {
0449 Graphic3d_MaterialAspect aMat(Graphic3d_NameOfMaterial_UserDefined);
0450 aMat.SetColor(Quantity_NOC_WHITE);
0451 aMat.SetAmbientColor(Quantity_NOC_GRAY60);
0452 myDrawer->ShadingAspect()->SetMaterial(aMat);
0453 myBoxEdgeAspect->SetMaterial(aMat);
0454 myBoxEdgeAspect->SetColor(Quantity_NOC_GRAY30);
0455 myBoxCornerAspect->SetMaterial(aMat);
0456 myBoxCornerAspect->SetColor(Quantity_NOC_GRAY30);
0457 SynchronizeAspects();
0458 }
0459
0460 public:
0461
0462 Standard_EXPORT Standard_Real Duration() const;
0463
0464
0465
0466 Standard_EXPORT void SetDuration(Standard_Real theValue);
0467
0468
0469
0470
0471 Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; }
0472
0473
0474
0475 void SetResetCamera(Standard_Boolean theToReset) { myToResetCameraUp = theToReset; }
0476
0477
0478
0479 Standard_Boolean ToFitSelected() const { return myToFitSelected; }
0480
0481
0482 void SetFitSelected(Standard_Boolean theToFitSelected) { myToFitSelected = theToFitSelected; }
0483
0484
0485 Standard_EXPORT Standard_Boolean HasAnimation() const;
0486
0487
0488
0489 Standard_EXPORT virtual void StartAnimation(const Handle(AIS_ViewCubeOwner)& theOwner);
0490
0491
0492
0493
0494 Standard_EXPORT virtual Standard_Boolean UpdateAnimation(const Standard_Boolean theToUpdate);
0495
0496
0497 Standard_EXPORT virtual void HandleClick(const Handle(AIS_ViewCubeOwner)& theOwner);
0498
0499 protected:
0500
0501
0502 Standard_EXPORT Standard_Boolean updateAnimation();
0503
0504
0505
0506
0507 Standard_EXPORT virtual void viewFitAll(const Handle(V3d_View)& theView,
0508 const Handle(Graphic3d_Camera)& theCamera);
0509
0510 protected:
0511
0512 virtual void onAfterAnimation() {}
0513
0514
0515 virtual void onAnimationFinished() {}
0516
0517 public:
0518
0519 virtual Standard_Boolean AcceptDisplayMode(const Standard_Integer theMode) const Standard_OVERRIDE
0520 {
0521 return theMode == 0;
0522 }
0523
0524
0525 virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE
0526 {
0527 return Handle(SelectMgr_EntityOwner)();
0528 }
0529
0530
0531
0532
0533
0534
0535 Standard_EXPORT virtual void Compute(const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0536 const Handle(Prs3d_Presentation)& thePrs,
0537 const Standard_Integer theMode = 0) Standard_OVERRIDE;
0538
0539
0540
0541
0542
0543 Standard_EXPORT virtual void ComputeSelection(const Handle(SelectMgr_Selection)& theSelection,
0544 const Standard_Integer theMode) Standard_OVERRIDE;
0545
0546
0547
0548 virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
0549
0550
0551
0552 virtual void ClearSelected() Standard_OVERRIDE {}
0553
0554
0555
0556
0557
0558 Standard_EXPORT virtual void HilightOwnerWithColor(
0559 const Handle(PrsMgr_PresentationManager)& thePM,
0560 const Handle(Prs3d_Drawer)& theStyle,
0561 const Handle(SelectMgr_EntityOwner)& theOwner) Standard_OVERRIDE;
0562
0563
0564 Standard_EXPORT virtual void HilightSelected(const Handle(PrsMgr_PresentationManager)& thePM,
0565 const SelectMgr_SequenceOfOwner& theSeq)
0566 Standard_OVERRIDE;
0567
0568
0569
0570 virtual void UnsetAttributes() Standard_OVERRIDE
0571 {
0572 setDefaultAttributes();
0573 SetToUpdate();
0574 }
0575
0576
0577 virtual void UnsetHilightAttributes() Standard_OVERRIDE
0578 {
0579 myHilightDrawer.Nullify();
0580 setDefaultHighlightAttributes();
0581 SetToUpdate();
0582 }
0583
0584 protected:
0585
0586
0587
0588
0589
0590
0591
0592 Standard_EXPORT virtual void createBoxPartTriangles(
0593 const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0594 Standard_Integer& theNbNodes,
0595 Standard_Integer& theNbTris,
0596 V3d_TypeOfOrientation theDir) const;
0597
0598
0599
0600
0601
0602
0603
0604
0605 Standard_EXPORT virtual void createBoxSideTriangles(
0606 const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0607 Standard_Integer& theNbNodes,
0608 Standard_Integer& theNbTris,
0609 V3d_TypeOfOrientation theDir) const;
0610
0611
0612
0613
0614
0615
0616
0617
0618 Standard_EXPORT virtual void createBoxEdgeTriangles(
0619 const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0620 Standard_Integer& theNbNodes,
0621 Standard_Integer& theNbTris,
0622 V3d_TypeOfOrientation theDir) const;
0623
0624
0625
0626
0627
0628
0629
0630
0631 Standard_EXPORT virtual void createBoxCornerTriangles(
0632 const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0633 Standard_Integer& theNbNodes,
0634 Standard_Integer& theNbTris,
0635 V3d_TypeOfOrientation theDir) const;
0636
0637 protected:
0638
0639
0640
0641
0642
0643
0644
0645
0646
0647 Standard_EXPORT static void createRoundRectangleTriangles(
0648 const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0649 Standard_Integer& theNbNodes,
0650 Standard_Integer& theNbTris,
0651 const gp_XY& theSize,
0652 Standard_Real theRadius,
0653 const gp_Trsf& theTrsf);
0654
0655 protected:
0656 NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString>
0657 myBoxSideLabels;
0658 NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString>
0659 myAxesLabels;
0660 Handle(Prs3d_ShadingAspect) myBoxEdgeAspect;
0661 Handle(Prs3d_ShadingAspect) myBoxCornerAspect;
0662
0663 Standard_Real mySize;
0664 Standard_Real myBoxEdgeMinSize;
0665 Standard_Real myBoxEdgeGap;
0666 Standard_Real myBoxFacetExtension;
0667 Standard_Real myAxesPadding;
0668
0669 Standard_Real myAxesRadius;
0670 Standard_Real myAxesConeRadius;
0671 Standard_Real myAxesSphereRadius;
0672 Standard_Real myCornerMinSize;
0673 Standard_Real myRoundRadius;
0674 Standard_Boolean myToDisplayAxes;
0675 Standard_Boolean myToDisplayEdges;
0676 Standard_Boolean myToDisplayVertices;
0677 Standard_Boolean myIsYup;
0678
0679
0680 protected:
0681 Handle(AIS_AnimationCamera) myViewAnimation;
0682 Handle(Graphic3d_Camera) myStartState;
0683 Handle(Graphic3d_Camera) myEndState;
0684 Standard_Boolean myToAutoStartAnim;
0685 Standard_Boolean myIsFixedAnimation;
0686 Standard_Boolean myToFitSelected;
0687
0688 Standard_Boolean myToResetCameraUp;
0689
0690 };
0691
0692
0693
0694 class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
0695 {
0696 DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
0697 public:
0698
0699 AIS_ViewCubeOwner(const Handle(AIS_ViewCube)& theObject,
0700 V3d_TypeOfOrientation theOrient,
0701 Standard_Integer thePriority = 5)
0702 : SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)theObject, thePriority),
0703 myMainOrient(theOrient)
0704 {
0705 myFromDecomposition = true;
0706 }
0707
0708
0709
0710 virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE { return Standard_True; }
0711
0712
0713 V3d_TypeOfOrientation MainOrientation() const { return myMainOrient; }
0714
0715
0716 virtual Standard_Boolean HandleMouseClick(const Graphic3d_Vec2i& thePoint,
0717 Aspect_VKeyMouse theButton,
0718 Aspect_VKeyFlags theModifiers,
0719 bool theIsDoubleClick) Standard_OVERRIDE
0720 {
0721 (void)thePoint;
0722 (void)theButton;
0723 (void)theModifiers;
0724 (void)theIsDoubleClick;
0725 AIS_ViewCube* aCubePrs = dynamic_cast<AIS_ViewCube*>(mySelectable);
0726 aCubePrs->HandleClick(this);
0727 return Standard_True;
0728 }
0729
0730 protected:
0731 V3d_TypeOfOrientation myMainOrient;
0732 };
0733
0734
0735 class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray
0736 {
0737 DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray)
0738 public:
0739
0740 Standard_EXPORT AIS_ViewCubeSensitive(const Handle(SelectMgr_EntityOwner)& theOwner,
0741 const Handle(Graphic3d_ArrayOfTriangles)& theTris);
0742
0743
0744 Standard_EXPORT virtual Standard_Boolean Matches(SelectBasics_SelectingVolumeManager& theMgr,
0745 SelectBasics_PickResult& thePickResult)
0746 Standard_OVERRIDE;
0747
0748 protected:
0749
0750 Standard_EXPORT bool isValidRay(const SelectBasics_SelectingVolumeManager& theMgr) const;
0751 };
0752
0753 #endif