File indexing completed on 2025-01-18 10:02:56
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 class AIS_ViewCube : public AIS_InteractiveObject
0060 {
0061 DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
0062 public:
0063
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
0076 Standard_EXPORT AIS_ViewCube();
0077
0078
0079 const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
0080
0081
0082 void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
0083
0084
0085 Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
0086
0087
0088
0089
0090 void SetAutoStartAnimation (bool theToEnable) { myToAutoStartAnim = theToEnable; }
0091
0092
0093 Standard_Boolean IsFixedAnimationLoop() const { return myIsFixedAnimation; }
0094
0095
0096 void SetFixedAnimationLoop (bool theToEnable) { myIsFixedAnimation = theToEnable; }
0097
0098
0099
0100 Standard_EXPORT void ResetStyles();
0101
0102 protected:
0103
0104
0105 Standard_EXPORT void setDefaultAttributes();
0106
0107
0108 Standard_EXPORT void setDefaultHighlightAttributes();
0109
0110 public:
0111
0112
0113 Standard_Real Size() const { return mySize; }
0114
0115
0116
0117 Standard_EXPORT void SetSize (Standard_Real theValue,
0118 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
0281 const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
0282
0283
0284 const Handle(Prs3d_ShadingAspect)& BoxEdgeStyle() const { return myBoxEdgeAspect; }
0285
0286
0287 const Handle(Prs3d_ShadingAspect)& BoxCornerStyle() const { return myBoxCornerAspect; }
0288
0289
0290 const Quantity_Color& BoxColor() const { return myDrawer->ShadingAspect()->Color(); }
0291
0292
0293
0294 void SetBoxColor (const Quantity_Color& theColor)
0295 {
0296 if (!myDrawer->ShadingAspect()->Color().IsEqual (theColor)
0297 || !myBoxEdgeAspect ->Color().IsEqual (theColor)
0298 || !myBoxCornerAspect->Color().IsEqual (theColor))
0299 {
0300 myDrawer->ShadingAspect()->SetColor (theColor);
0301 myBoxEdgeAspect->SetColor (theColor);
0302 myBoxCornerAspect->SetColor (theColor);
0303 SynchronizeAspects();
0304 }
0305 }
0306
0307
0308 Standard_Real BoxTransparency() const { return myDrawer->ShadingAspect()->Transparency(); }
0309
0310
0311
0312 void SetBoxTransparency (Standard_Real theValue)
0313 {
0314 if (Abs (myDrawer->ShadingAspect()->Transparency() - theValue) > Precision::Confusion()
0315 || Abs (myBoxEdgeAspect ->Transparency() - theValue) > Precision::Confusion()
0316 || Abs (myBoxCornerAspect->Transparency() - theValue) > Precision::Confusion())
0317 {
0318 myDrawer->ShadingAspect()->SetTransparency (theValue);
0319 myBoxEdgeAspect->SetTransparency (theValue);
0320 myBoxCornerAspect->SetTransparency (theValue);
0321 SynchronizeAspects();
0322 }
0323 }
0324
0325
0326 const Quantity_Color& InnerColor() const { return myDrawer->ShadingAspect()->Color (Aspect_TOFM_BACK_SIDE); }
0327
0328
0329
0330 void SetInnerColor (const Quantity_Color& theColor)
0331 {
0332 myDrawer->ShadingAspect()->SetColor (theColor, Aspect_TOFM_BACK_SIDE);
0333 SynchronizeAspects();
0334 }
0335
0336
0337
0338 TCollection_AsciiString BoxSideLabel (V3d_TypeOfOrientation theSide) const
0339 {
0340 const TCollection_AsciiString* aLabel = myBoxSideLabels.Seek (theSide);
0341 return aLabel != NULL ? *aLabel : TCollection_AsciiString();
0342 }
0343
0344
0345 void SetBoxSideLabel (const V3d_TypeOfOrientation theSide,
0346 const TCollection_AsciiString& theLabel)
0347 {
0348 if (!IsBoxSide (theSide))
0349 {
0350 throw Standard_ProgramError ("AIS_ViewCube::SetBoxSideLabel(), invalid enumeration value");
0351 }
0352 myBoxSideLabels.Bind (theSide, theLabel);
0353 SetToUpdate();
0354 }
0355
0356
0357 const Quantity_Color& TextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
0358
0359
0360
0361 void SetTextColor (const Quantity_Color& theColor)
0362 {
0363 myDrawer->TextAspect()->SetColor (theColor);
0364 SynchronizeAspects();
0365 }
0366
0367
0368
0369 const TCollection_AsciiString& Font() const { return myDrawer->TextAspect()->Aspect()->Font(); }
0370
0371
0372
0373 void SetFont (const TCollection_AsciiString& theFont)
0374 {
0375 myDrawer->TextAspect()->Aspect()->SetFont (theFont);
0376 SynchronizeAspects();
0377 }
0378
0379
0380 Standard_Real FontHeight() const { return myDrawer->TextAspect()->Height(); }
0381
0382
0383
0384 void SetFontHeight (Standard_Real theValue)
0385 {
0386 if (Abs (myDrawer->TextAspect()->Height() - theValue) > Precision::Confusion())
0387 {
0388 myDrawer->TextAspect()->SetHeight (theValue);
0389 SetToUpdate();
0390 }
0391 }
0392
0393
0394
0395 TCollection_AsciiString AxisLabel (Prs3d_DatumParts theAxis) const
0396 {
0397 const TCollection_AsciiString* aLabel = myAxesLabels.Seek (theAxis);
0398 return aLabel != NULL ? *aLabel : TCollection_AsciiString();
0399 }
0400
0401
0402 void SetAxesLabels (const TCollection_AsciiString& theX,
0403 const TCollection_AsciiString& theY,
0404 const TCollection_AsciiString& theZ)
0405 {
0406 myAxesLabels.Bind (Prs3d_DatumParts_XAxis, theX);
0407 myAxesLabels.Bind (Prs3d_DatumParts_YAxis, theY);
0408 myAxesLabels.Bind (Prs3d_DatumParts_ZAxis, theZ);
0409 SetToUpdate();
0410 }
0411
0412 public:
0413
0414
0415
0416 virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE
0417 {
0418 SetBoxColor (theColor);
0419 }
0420
0421
0422 virtual void UnsetColor() Standard_OVERRIDE
0423 {
0424 myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
0425 myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
0426 myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
0427 SynchronizeAspects();
0428 }
0429
0430
0431
0432 virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE
0433 {
0434 SetBoxTransparency (theValue);
0435 }
0436
0437
0438 virtual void UnsetTransparency() Standard_OVERRIDE
0439 {
0440 SetBoxTransparency (0.0f);
0441 }
0442
0443
0444 virtual void SetMaterial (const Graphic3d_MaterialAspect& theMat) Standard_OVERRIDE
0445 {
0446 myDrawer->ShadingAspect()->SetMaterial (theMat);
0447 myBoxEdgeAspect ->SetMaterial (theMat);
0448 myBoxCornerAspect->SetMaterial (theMat);
0449 SynchronizeAspects();
0450 }
0451
0452
0453 virtual void UnsetMaterial() Standard_OVERRIDE
0454 {
0455 Graphic3d_MaterialAspect aMat (Graphic3d_NameOfMaterial_UserDefined);
0456 aMat.SetColor (Quantity_NOC_WHITE);
0457 aMat.SetAmbientColor (Quantity_NOC_GRAY60);
0458 myDrawer->ShadingAspect()->SetMaterial (aMat);
0459 myBoxEdgeAspect ->SetMaterial (aMat);
0460 myBoxEdgeAspect ->SetColor (Quantity_NOC_GRAY30);
0461 myBoxCornerAspect->SetMaterial (aMat);
0462 myBoxCornerAspect->SetColor (Quantity_NOC_GRAY30);
0463 SynchronizeAspects();
0464 }
0465
0466 public:
0467
0468
0469 Standard_EXPORT Standard_Real Duration() const;
0470
0471
0472
0473 Standard_EXPORT void SetDuration (Standard_Real theValue);
0474
0475
0476
0477
0478 Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; }
0479
0480
0481 void SetResetCamera (Standard_Boolean theToReset) { myToResetCameraUp = theToReset; }
0482
0483
0484 Standard_Boolean ToFitSelected() const { return myToFitSelected; }
0485
0486
0487 void SetFitSelected (Standard_Boolean theToFitSelected) { myToFitSelected = theToFitSelected; }
0488
0489
0490 Standard_EXPORT Standard_Boolean HasAnimation() const;
0491
0492
0493
0494 Standard_EXPORT virtual void StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner);
0495
0496
0497
0498
0499 Standard_EXPORT virtual Standard_Boolean UpdateAnimation (const Standard_Boolean theToUpdate);
0500
0501
0502 Standard_EXPORT virtual void HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner);
0503
0504 protected:
0505
0506
0507
0508 Standard_EXPORT Standard_Boolean updateAnimation();
0509
0510
0511
0512
0513 Standard_EXPORT virtual void viewFitAll (const Handle(V3d_View)& theView,
0514 const Handle(Graphic3d_Camera)& theCamera);
0515
0516 protected:
0517
0518
0519 virtual void onAfterAnimation() {}
0520
0521
0522 virtual void onAnimationFinished() {}
0523
0524 public:
0525
0526
0527 virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
0528
0529
0530 virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return Handle(SelectMgr_EntityOwner)(); }
0531
0532
0533
0534
0535
0536
0537 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
0538 const Handle(Prs3d_Presentation)& thePrs,
0539 const Standard_Integer theMode = 0) Standard_OVERRIDE;
0540
0541
0542
0543
0544
0545 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
0546 const Standard_Integer theMode) Standard_OVERRIDE;
0547
0548
0549 virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
0550
0551
0552
0553 virtual void ClearSelected() Standard_OVERRIDE {}
0554
0555
0556
0557
0558
0559 Standard_EXPORT virtual void HilightOwnerWithColor (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) Standard_OVERRIDE;
0566
0567
0568
0569 virtual void UnsetAttributes() Standard_OVERRIDE
0570 {
0571 setDefaultAttributes();
0572 SetToUpdate();
0573 }
0574
0575
0576 virtual void UnsetHilightAttributes() Standard_OVERRIDE
0577 {
0578 myHilightDrawer.Nullify();
0579 setDefaultHighlightAttributes();
0580 SetToUpdate();
0581 }
0582
0583 protected:
0584
0585
0586
0587
0588
0589
0590 Standard_EXPORT virtual void createBoxPartTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0591 Standard_Integer& theNbNodes,
0592 Standard_Integer& theNbTris,
0593 V3d_TypeOfOrientation theDir) const;
0594
0595
0596
0597
0598
0599
0600 Standard_EXPORT virtual void createBoxSideTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0601 Standard_Integer& theNbNodes,
0602 Standard_Integer& theNbTris,
0603 V3d_TypeOfOrientation theDir) const;
0604
0605
0606
0607
0608
0609
0610 Standard_EXPORT virtual void createBoxEdgeTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0611 Standard_Integer& theNbNodes,
0612 Standard_Integer& theNbTris,
0613 V3d_TypeOfOrientation theDir) const;
0614
0615
0616
0617
0618
0619
0620 Standard_EXPORT virtual void createBoxCornerTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0621 Standard_Integer& theNbNodes,
0622 Standard_Integer& theNbTris,
0623 V3d_TypeOfOrientation theDir) const;
0624
0625 protected:
0626
0627
0628
0629
0630
0631
0632
0633
0634 Standard_EXPORT static void createRoundRectangleTriangles (const Handle(Graphic3d_ArrayOfTriangles)& theTris,
0635 Standard_Integer& theNbNodes,
0636 Standard_Integer& theNbTris,
0637 const gp_XY& theSize,
0638 Standard_Real theRadius,
0639 const gp_Trsf& theTrsf);
0640
0641 protected:
0642
0643 NCollection_DataMap<V3d_TypeOfOrientation, TCollection_AsciiString>
0644 myBoxSideLabels;
0645 NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString>
0646 myAxesLabels;
0647 Handle(Prs3d_ShadingAspect) myBoxEdgeAspect;
0648 Handle(Prs3d_ShadingAspect) myBoxCornerAspect;
0649
0650 Standard_Real mySize;
0651 Standard_Real myBoxEdgeMinSize;
0652 Standard_Real myBoxEdgeGap;
0653 Standard_Real myBoxFacetExtension;
0654 Standard_Real myAxesPadding;
0655 Standard_Real myAxesRadius;
0656 Standard_Real myAxesConeRadius;
0657 Standard_Real myAxesSphereRadius;
0658 Standard_Real myCornerMinSize;
0659 Standard_Real myRoundRadius;
0660 Standard_Boolean myToDisplayAxes;
0661 Standard_Boolean myToDisplayEdges;
0662 Standard_Boolean myToDisplayVertices;
0663 Standard_Boolean myIsYup;
0664
0665 protected:
0666
0667 Handle(AIS_AnimationCamera) myViewAnimation;
0668 Handle(Graphic3d_Camera) myStartState;
0669 Handle(Graphic3d_Camera) myEndState;
0670 Standard_Boolean myToAutoStartAnim;
0671 Standard_Boolean myIsFixedAnimation;
0672 Standard_Boolean myToFitSelected;
0673 Standard_Boolean myToResetCameraUp;
0674
0675 };
0676
0677
0678
0679 class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
0680 {
0681 DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
0682 public:
0683
0684
0685 AIS_ViewCubeOwner (const Handle(AIS_ViewCube)& theObject,
0686 V3d_TypeOfOrientation theOrient,
0687 Standard_Integer thePriority = 5)
0688 : SelectMgr_EntityOwner ((const Handle(SelectMgr_SelectableObject)& )theObject, thePriority),
0689 myMainOrient (theOrient)
0690 {
0691 myFromDecomposition = true;
0692 }
0693
0694
0695
0696 virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE { return Standard_True; }
0697
0698
0699 V3d_TypeOfOrientation MainOrientation() const { return myMainOrient; }
0700
0701
0702 virtual Standard_Boolean HandleMouseClick (const Graphic3d_Vec2i& thePoint,
0703 Aspect_VKeyMouse theButton,
0704 Aspect_VKeyFlags theModifiers,
0705 bool theIsDoubleClick) Standard_OVERRIDE
0706 {
0707 (void )thePoint; (void )theButton; (void )theModifiers; (void )theIsDoubleClick;
0708 AIS_ViewCube* aCubePrs = dynamic_cast<AIS_ViewCube* >(mySelectable);
0709 aCubePrs->HandleClick (this);
0710 return Standard_True;
0711 }
0712
0713 protected:
0714
0715 V3d_TypeOfOrientation myMainOrient;
0716
0717 };
0718
0719
0720 class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray
0721 {
0722 DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray)
0723 public:
0724
0725
0726 Standard_EXPORT AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner)& theOwner,
0727 const Handle(Graphic3d_ArrayOfTriangles)& theTris);
0728
0729
0730 Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
0731 SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
0732
0733 protected:
0734
0735
0736 Standard_EXPORT bool isValidRay (const SelectBasics_SelectingVolumeManager& theMgr) const;
0737
0738 };
0739
0740 #endif