Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:02:56

0001 // Created on: 2017-07-25
0002 // Created by: Anastasia BOBYLEVA
0003 // Copyright (c) 2017-2019 OPEN CASCADE SAS
0004 //
0005 // This file is part of Open CASCADE Technology software library.
0006 //
0007 // This library is free software; you can redistribute it and/or modify it under
0008 // the terms of the GNU Lesser General Public License version 2.1 as published
0009 // by the Free Software Foundation, with special exception defined in the file
0010 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0011 // distribution for complete text of the license and disclaimer of any warranty.
0012 //
0013 // Alternatively, this file may be used under the terms of Open CASCADE
0014 // commercial license or contractual agreement.
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 //! Interactive object for displaying the view manipulation cube.
0035 //!
0036 //! View cube consists of several parts that are responsible for different camera manipulations:
0037 //! @li Cube sides represent main views: top, bottom, left, right, front and back.
0038 //! @li Edges represent rotation of one of main views on 45 degrees.
0039 //! @li Vertices represent rotation of one of man views in two directions.
0040 //!
0041 //! The object is expected to behave like a trihedron in the view corner,
0042 //! therefore its position should be defined using transformation persistence flags:
0043 //! @code SetTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_TriedronPers, Aspect_TOTP_LEFT_LOWER, Graphic3d_Vec2i (100, 100)); @endcode
0044 //!
0045 //! View Cube parts are sensitive to detection, or dynamic highlighting (but not selection),
0046 //! and every its owner AIS_ViewCubeOwner corresponds to camera transformation.
0047 //! @code
0048 //!   for (aViewCube->StartAnimation (aDetectedOwner); aViewCube->HasAnimation(); )
0049 //!   {
0050 //!     aViewCube->UpdateAnimation();
0051 //!     ... // updating of application window
0052 //!   }
0053 //! @endcode
0054 //! or
0055 //! @code aViewCube->HandleClick (aDetectedOwner); @endcode
0056 //! that includes transformation loop.
0057 //! This loop allows external actions like application updating. For this purpose AIS_ViewCube has virtual interface onAfterAnimation(),
0058 //! that is to be redefined on application level.
0059 class AIS_ViewCube : public AIS_InteractiveObject
0060 {
0061   DEFINE_STANDARD_RTTIEXT(AIS_ViewCube, AIS_InteractiveObject)
0062 public:
0063 
0064   //! Return TRUE if specified orientation belongs to box side.
0065   Standard_EXPORT static bool IsBoxSide (V3d_TypeOfOrientation theOrient);
0066 
0067   //! Return TRUE if specified orientation belongs to box edge.
0068   Standard_EXPORT static bool IsBoxEdge (V3d_TypeOfOrientation theOrient);
0069 
0070   //! Return TRUE if specified orientation belongs to box corner (vertex).
0071   Standard_EXPORT static bool IsBoxCorner (V3d_TypeOfOrientation theOrient);
0072 
0073 public:
0074 
0075   //! Empty constructor.
0076   Standard_EXPORT AIS_ViewCube();
0077 
0078   //! Return view animation.
0079   const Handle(AIS_AnimationCamera)& ViewAnimation() const { return myViewAnimation; }
0080 
0081   //! Set view animation.
0082   void SetViewAnimation (const Handle(AIS_AnimationCamera)& theAnimation) { myViewAnimation = theAnimation; }
0083 
0084   //! Return TRUE if automatic camera transformation on selection (highlighting) is enabled; TRUE by default.
0085   Standard_Boolean ToAutoStartAnimation() const { return myToAutoStartAnim; }
0086 
0087   //! Enable/disable automatic camera transformation on selection (highlighting).
0088   //! The automatic logic can be disabled if application wants performing action manually
0089   //! basing on picking results (AIS_ViewCubeOwner).
0090   void SetAutoStartAnimation (bool theToEnable) { myToAutoStartAnim = theToEnable; }
0091 
0092   //! Return TRUE if camera animation should be done in uninterruptible loop; TRUE by default.
0093   Standard_Boolean IsFixedAnimationLoop() const { return myIsFixedAnimation; }
0094 
0095   //! Set if camera animation should be done in uninterruptible loop.
0096   void SetFixedAnimationLoop (bool theToEnable) { myIsFixedAnimation = theToEnable; }
0097 
0098   //! Reset all size and style parameters to default.
0099   //! @warning It doesn't reset position of View Cube
0100   Standard_EXPORT void ResetStyles();
0101 
0102 protected:
0103 
0104   //! Set default visual attributes
0105   Standard_EXPORT void setDefaultAttributes();
0106 
0107   //! Set default dynamic highlight properties
0108   Standard_EXPORT void setDefaultHighlightAttributes();
0109 
0110 public: //! @name Geometry management API
0111 
0112   //! @return size (width and height) of View cube sides; 100 by default.
0113   Standard_Real Size() const { return mySize; }
0114 
0115   //! Sets size (width and height) of View cube sides.
0116   //! @param theToAdaptAnother if TRUE, then other parameters will be adapted to specified size
0117   Standard_EXPORT void SetSize (Standard_Real theValue,
0118                                 Standard_Boolean theToAdaptAnother = true);
0119 
0120   //! Return box facet extension to edge/corner facet split; 10 by default.
0121   Standard_Real BoxFacetExtension() const { return myBoxFacetExtension; }
0122 
0123   //! Set new value of box facet extension.
0124   void SetBoxFacetExtension (Standard_Real theValue)
0125   {
0126     if (Abs (myBoxFacetExtension - theValue) > Precision::Confusion())
0127     {
0128       myBoxFacetExtension = theValue;
0129       SetToUpdate();
0130     }
0131   }
0132 
0133   //! Return padding between axes and 3D part (box); 10 by default.
0134   Standard_Real AxesPadding() const { return myAxesPadding; }
0135 
0136   //! Set new value of padding between axes and 3D part (box).
0137   void SetAxesPadding (Standard_Real theValue)
0138   {
0139     if (Abs (myAxesPadding - theValue) > Precision::Confusion())
0140     {
0141       myAxesPadding = theValue;
0142       SetToUpdate();
0143     }
0144   }
0145 
0146   //! Return gap between box edges and box sides; 0 by default.
0147   Standard_Real BoxEdgeGap() const { return myBoxEdgeGap; }
0148 
0149   //! Set new value of box edges gap.
0150   void SetBoxEdgeGap (Standard_Real theValue)
0151   {
0152     if (Abs (myBoxEdgeGap - theValue) > Precision::Confusion())
0153     {
0154       myBoxEdgeGap = theValue;
0155       SetToUpdate();
0156     }
0157   }
0158 
0159   //! Return minimal size of box edge; 2 by default.
0160   Standard_Real BoxEdgeMinSize() const { return myBoxEdgeMinSize; }
0161 
0162   //! Set new value of box edge minimal size.
0163   void SetBoxEdgeMinSize (Standard_Real theValue)
0164   {
0165     if (Abs (myBoxEdgeMinSize - theValue) > Precision::Confusion())
0166     {
0167       myBoxEdgeMinSize = theValue;
0168       SetToUpdate();
0169     }
0170   }
0171 
0172   //! Return minimal size of box corner; 2 by default.
0173   Standard_Real BoxCornerMinSize() const { return myCornerMinSize; }
0174 
0175   //! Set new value of box corner minimal size.
0176   void SetBoxCornerMinSize (Standard_Real theValue)
0177   {
0178     if (Abs (myCornerMinSize - theValue) > Precision::Confusion())
0179     {
0180       myCornerMinSize = theValue;
0181       SetToUpdate();
0182     }
0183   }
0184 
0185   //! Return relative radius of side corners (round rectangle); 0.0 by default.
0186   //! The value in within [0, 0.5] range meaning absolute radius = RoundRadius() / Size().
0187   Standard_Real RoundRadius() const { return myRoundRadius; }
0188 
0189   //! Set relative radius of View Cube sides corners (round rectangle).
0190   //! The value should be within [0, 0.5] range.
0191   Standard_EXPORT void SetRoundRadius (const Standard_Real theValue);
0192 
0193   //! Returns radius of axes of the trihedron; 1.0 by default.
0194   Standard_Real AxesRadius() const { return myAxesRadius; }
0195 
0196   //! Sets radius of axes of the trihedron.
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   //! Returns radius of cone of axes of the trihedron; 3.0 by default.
0207   Standard_Real AxesConeRadius() const { return myAxesConeRadius; }
0208 
0209   //! Sets radius of cone of axes of the trihedron.
0210   void SetAxesConeRadius (Standard_Real theRadius)
0211   {
0212     if (Abs (myAxesConeRadius - theRadius) > Precision::Confusion())
0213     {
0214       myAxesConeRadius = theRadius;
0215       SetToUpdate();
0216     }
0217   }
0218 
0219   //! Returns radius of sphere (central point) of the trihedron; 4.0 by default.
0220   Standard_Real AxesSphereRadius() const { return myAxesSphereRadius; }
0221 
0222   //! Sets radius of sphere (central point) of the trihedron.
0223   void SetAxesSphereRadius (Standard_Real theRadius)
0224   {
0225     if (Abs (myAxesSphereRadius - theRadius) > Precision::Confusion())
0226     {
0227       myAxesSphereRadius = theRadius;
0228       SetToUpdate();
0229     }
0230   }
0231 
0232   //! @return TRUE if trihedron is drawn; TRUE by default.
0233   Standard_Boolean ToDrawAxes() const { return myToDisplayAxes; }
0234 
0235   //! Enable/disable drawing of trihedron.
0236   void SetDrawAxes (Standard_Boolean theValue)
0237   {
0238     if (myToDisplayAxes != theValue)
0239     {
0240       myToDisplayAxes = theValue;
0241       SetToUpdate();
0242     }
0243   }
0244 
0245   //! @return TRUE if edges of View Cube is drawn; TRUE by default.
0246   Standard_Boolean ToDrawEdges() const { return myToDisplayEdges; }
0247 
0248   //! Enable/disable drawing of edges of View Cube.
0249   void SetDrawEdges (Standard_Boolean theValue)
0250   {
0251     if (myToDisplayEdges != theValue)
0252     {
0253       myToDisplayEdges = theValue;
0254       SetToUpdate();
0255     }
0256   }
0257 
0258   //! Return TRUE if vertices (vertex) of View Cube is drawn; TRUE by default.
0259   Standard_Boolean ToDrawVertices() const { return myToDisplayVertices; }
0260 
0261   //! Enable/disable drawing of vertices (corners) of View Cube.
0262   void SetDrawVertices (Standard_Boolean theValue)
0263   {
0264     if (myToDisplayVertices != theValue)
0265     {
0266       myToDisplayVertices = theValue;
0267       SetToUpdate();
0268     }
0269   }
0270 
0271   //! Return TRUE if application expects Y-up viewer orientation instead of Z-up; FALSE by default.
0272   Standard_Boolean IsYup() const { return myIsYup; }
0273 
0274   //! Set if application expects Y-up viewer orientation instead of Z-up.
0275   Standard_EXPORT void SetYup (Standard_Boolean theIsYup,
0276                                Standard_Boolean theToUpdateLabels = Standard_True);
0277 
0278 public: //! @name Style management API
0279 
0280   //! Return shading style of box sides.
0281   const Handle(Prs3d_ShadingAspect)& BoxSideStyle() const { return myDrawer->ShadingAspect(); }
0282 
0283   //! Return shading style of box edges.
0284   const Handle(Prs3d_ShadingAspect)& BoxEdgeStyle() const { return myBoxEdgeAspect; }
0285 
0286   //! Return shading style of box corners.
0287   const Handle(Prs3d_ShadingAspect)& BoxCornerStyle() const { return myBoxCornerAspect; }
0288 
0289   //! Return value of front color for the 3D part of object.
0290   const Quantity_Color& BoxColor() const { return myDrawer->ShadingAspect()->Color(); }
0291 
0292   //! Set new value of front color for the 3D part of object.
0293   //! @param theColor [in] input color value.
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   //! Return transparency for 3D part of object.
0308   Standard_Real BoxTransparency() const { return myDrawer->ShadingAspect()->Transparency(); }
0309 
0310   //! Set new value of transparency for 3D part of object.
0311   //! @param theValue [in] input transparency value
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   //! Return color of sides back material.
0326   const Quantity_Color& InnerColor() const { return myDrawer->ShadingAspect()->Color (Aspect_TOFM_BACK_SIDE); }
0327 
0328   //! Set color of sides back material. Alias for:
0329   //! @code Attributes()->ShadingAspect()->Aspect()->ChangeBackMaterial().SetColor() @endcode
0330   void SetInnerColor (const Quantity_Color& theColor)
0331   {
0332     myDrawer->ShadingAspect()->SetColor (theColor, Aspect_TOFM_BACK_SIDE);
0333     SynchronizeAspects();
0334   }
0335 
0336   //! Return box side label or empty string if undefined.
0337   //! Default labels: FRONT, BACK, LEFT, RIGHT, TOP, BOTTOM.
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   //! Set box side label.
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   //! Return text color of labels of box sides; BLACK by default.
0357   const Quantity_Color& TextColor() const { return myDrawer->TextAspect()->Aspect()->Color(); }
0358 
0359   //! Set color of text labels on box sides. Alias for:
0360   //! @code Attributes()->TextAspect()->SetColor() @endcode
0361   void SetTextColor (const Quantity_Color& theColor)
0362   {
0363     myDrawer->TextAspect()->SetColor (theColor);
0364     SynchronizeAspects();
0365   }
0366 
0367   //! Return font name that is used for displaying of sides and axes text. Alias for:
0368   //! @code Attributes()->TextAspect()->Aspect()->SetFont() @endcode
0369   const TCollection_AsciiString& Font() const { return myDrawer->TextAspect()->Aspect()->Font(); }
0370 
0371   //! Set font name that is used for displaying of sides and axes text. Alias for:
0372   //! @code Attributes()->TextAspect()->SetFont() @endcode
0373   void SetFont (const TCollection_AsciiString& theFont)
0374   {
0375     myDrawer->TextAspect()->Aspect()->SetFont (theFont);
0376     SynchronizeAspects();
0377   }
0378 
0379   //! Return height of font
0380   Standard_Real FontHeight() const { return myDrawer->TextAspect()->Height(); }
0381 
0382   //! Change font height. Alias for:
0383   //! @code Attributes()->TextAspect()->SetHeight() @endcode
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   //! Return axes labels or empty string if undefined.
0394   //! Default labels: X, Y, Z.
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   //! Set axes labels.
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   //! Set new value of color for the whole object.
0415   //! @param theColor [in] input color value.
0416   virtual void SetColor (const Quantity_Color& theColor) Standard_OVERRIDE
0417   {
0418     SetBoxColor (theColor);
0419   }
0420 
0421   //! Reset color for the whole object.
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   //! Set new value of transparency for the whole object.
0431   //! @param theValue [in] input transparency value.
0432   virtual void SetTransparency (const Standard_Real theValue) Standard_OVERRIDE
0433   {
0434     SetBoxTransparency (theValue);
0435   }
0436 
0437   //! Reset transparency for the whole object.
0438   virtual void UnsetTransparency() Standard_OVERRIDE
0439   {
0440     SetBoxTransparency (0.0f);
0441   }
0442 
0443   //! Sets the material for the interactive object.
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   //! Sets the material for the interactive object.
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: //! @name animation methods
0467 
0468   //! Return duration of animation in seconds; 0.5 sec by default
0469   Standard_EXPORT Standard_Real Duration() const;
0470 
0471   //! Set duration of animation.
0472   //! @param theValue [in] input value of duration in seconds
0473   Standard_EXPORT void SetDuration (Standard_Real theValue);
0474 
0475   //! Return TRUE if new camera Up direction should be always set to default value for a new camera Direction; FALSE by default.
0476   //! When this flag is FALSE, the new camera Up will be set as current Up orthogonalized to the new camera Direction,
0477   //! and will set to default Up on second click.
0478   Standard_Boolean ToResetCameraUp() const { return myToResetCameraUp; }
0479 
0480   //! Set if new camera Up direction should be always set to default value for a new camera Direction.
0481   void SetResetCamera (Standard_Boolean theToReset) { myToResetCameraUp = theToReset; }
0482 
0483   //! Return TRUE if animation should fit selected objects and FALSE to fit entire scene; TRUE by default.
0484   Standard_Boolean ToFitSelected() const { return myToFitSelected; }
0485 
0486   //! Set if animation should fit selected objects or to fit entire scene.
0487   void SetFitSelected (Standard_Boolean theToFitSelected) { myToFitSelected = theToFitSelected; }
0488 
0489   //! @return TRUE if View Cube has unfinished animation of view camera.
0490   Standard_EXPORT Standard_Boolean HasAnimation() const;
0491 
0492   //! Start camera transformation corresponding to the input detected owner.
0493   //! @param theOwner [in] detected owner.
0494   Standard_EXPORT virtual void StartAnimation (const Handle(AIS_ViewCubeOwner)& theOwner);
0495 
0496   //! Perform one step of current camera transformation.
0497   //! theToUpdate [in] enable/disable update of view.
0498   //! @return TRUE if animation is not stopped.
0499   Standard_EXPORT virtual Standard_Boolean UpdateAnimation (const Standard_Boolean theToUpdate);
0500 
0501   //! Perform camera transformation corresponding to the input detected owner.
0502   Standard_EXPORT virtual void HandleClick (const Handle(AIS_ViewCubeOwner)& theOwner);
0503 
0504 protected:
0505 
0506   //! Perform internal single step of animation.
0507   //! @return FALSE if animation has been finished
0508   Standard_EXPORT Standard_Boolean updateAnimation();
0509 
0510   //! Fit selected/all into view.
0511   //! @param theView [in] view definition to retrieve scene bounding box
0512   //! @param theCamera [in,out] camera definition
0513   Standard_EXPORT virtual void viewFitAll (const Handle(V3d_View)& theView,
0514                                            const Handle(Graphic3d_Camera)& theCamera);
0515 
0516 protected: //! @name protected virtual API
0517 
0518   //! Method that is called after one step of transformation.
0519   virtual void onAfterAnimation() {}
0520 
0521   //! Method that is called after transformation finish.
0522   virtual void onAnimationFinished() {}
0523 
0524 public: //! @name Presentation computation
0525 
0526   //! Return TRUE for supported display mode.
0527   virtual Standard_Boolean AcceptDisplayMode (const Standard_Integer theMode) const Standard_OVERRIDE { return theMode == 0; }
0528 
0529   //! Global selection has no meaning for this class.
0530   virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return Handle(SelectMgr_EntityOwner)(); }
0531 
0532   //! Compute 3D part of View Cube.
0533   //! @param thePrsMgr [in] presentation manager.
0534   //! @param thePrs [in] input presentation that is to be filled with flat presentation primitives.
0535   //! @param theMode [in] display mode.
0536   //! @warning this object accept only 0 display mode.
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   //! Redefine computing of sensitive entities for View Cube.
0542   //! @param theSelection [in] input selection object that is to be filled with sensitive entities.
0543   //! @param theMode [in] selection mode.
0544   //! @warning object accepts only 0 selection mode.
0545   Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
0546                                                  const Standard_Integer theMode) Standard_OVERRIDE;
0547 
0548   //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden methods.
0549   virtual Standard_Boolean IsAutoHilight() const Standard_OVERRIDE { return Standard_False; }
0550 
0551   //! Method which clear all selected owners belonging to this selectable object.
0552   //! @warning this object does not support selection.
0553   virtual void ClearSelected() Standard_OVERRIDE {}
0554 
0555   //! Method which highlights input owner belonging to this selectable object.
0556   //! @param thePM [in] presentation manager
0557   //! @param theStyle [in] style for dynamic highlighting.
0558   //! @param theOwner [in] input entity owner.
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   //! Method which draws selected owners.
0564   Standard_EXPORT virtual void HilightSelected (const Handle(PrsMgr_PresentationManager)& thePM,
0565                                                 const SelectMgr_SequenceOfOwner& theSeq) Standard_OVERRIDE;
0566 
0567   //! Set default parameters for visual attributes
0568   //! @sa Attributes()
0569   virtual void UnsetAttributes() Standard_OVERRIDE
0570   {
0571     setDefaultAttributes();
0572     SetToUpdate();
0573   }
0574 
0575   //! Set default parameters for dynamic highlighting attributes, reset highlight attributes
0576   virtual void UnsetHilightAttributes() Standard_OVERRIDE
0577   {
0578     myHilightDrawer.Nullify();
0579     setDefaultHighlightAttributes();
0580     SetToUpdate();
0581   }
0582 
0583 protected: //! @name Auxiliary classes to fill presentation with proper primitives
0584 
0585   //! Create triangulation for a box part - for presentation and selection purposes.
0586   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0587   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
0588   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this triangulation
0589   //! @param theDir     [in] part to define
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   //! Create triangulation for a box side.
0596   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0597   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
0598   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this triangulation
0599   //! @param theDir     [in] part to define
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   //! Create triangulation for a box edge.
0606   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0607   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
0608   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this triangulation
0609   //! @param theDir     [in] part to define
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   //! Create triangulation for a box corner (vertex).
0616   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0617   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
0618   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this triangulation
0619   //! @param theDir     [in] part to define
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   //! Create triangulation for a rectangle with round corners.
0628   //! @param theTris    [in,out] triangulation to fill, or NULL to return size
0629   //! @param theNbNodes [in,out] should be incremented by a number of nodes defining this triangulation
0630   //! @param theNbTris  [in,out] should be incremented by a number of triangles defining this triangulation
0631   //! @param theSize    [in] rectangle dimensions
0632   //! @param theRadius  [in] radius at corners
0633   //! @param theTrsf    [in] transformation
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;     //!< map with box side labels
0645   NCollection_DataMap<Prs3d_DatumParts, TCollection_AsciiString>
0646                                 myAxesLabels;        //!< map with axes labels
0647   Handle(Prs3d_ShadingAspect)   myBoxEdgeAspect;     //!< style for box edges
0648   Handle(Prs3d_ShadingAspect)   myBoxCornerAspect;   //!< style for box corner
0649 
0650   Standard_Real                 mySize;              //!< size of box side, length of one axis
0651   Standard_Real                 myBoxEdgeMinSize;    //!< minimal size of box edge
0652   Standard_Real                 myBoxEdgeGap;        //!< gap between box side and box edge
0653   Standard_Real                 myBoxFacetExtension; //!< box facet extension
0654   Standard_Real                 myAxesPadding;       //!< Padding between box and axes
0655   Standard_Real                 myAxesRadius;        //!< radius of axes of the trihedron; 1.0 by default
0656   Standard_Real                 myAxesConeRadius;    //!< radius of cone of axes of the trihedron; 3.0 by default
0657   Standard_Real                 myAxesSphereRadius;  //!< radius of sphere (central point) of the trihedron; 4.0 by default
0658   Standard_Real                 myCornerMinSize;     //!< minimal size of box corner
0659   Standard_Real                 myRoundRadius;       //!< relative round radius within [0; 0.5] range
0660   Standard_Boolean              myToDisplayAxes;     //!< trihedron visibility
0661   Standard_Boolean              myToDisplayEdges;    //!< box edges visibility
0662   Standard_Boolean              myToDisplayVertices; //!< box corners (vertices) visibility
0663   Standard_Boolean              myIsYup;             //!< flag indicating that application expects Y-up viewer orientation instead of Z-up
0664 
0665 protected: //! @name Animation options
0666 
0667   Handle(AIS_AnimationCamera)   myViewAnimation;     //!< Camera animation object
0668   Handle(Graphic3d_Camera)      myStartState;        //!< Start state of view camera
0669   Handle(Graphic3d_Camera)      myEndState;          //!< End state of view camera
0670   Standard_Boolean              myToAutoStartAnim;   //!< start animation automatically on click
0671   Standard_Boolean              myIsFixedAnimation;  //!< fixed-loop animation
0672   Standard_Boolean              myToFitSelected;     //!< fit selected or fit entire scene
0673   Standard_Boolean              myToResetCameraUp;   //!< always reset camera up direction to default
0674 
0675 };
0676 
0677 //! Redefined entity owner that is highlighted when owner is detected,
0678 //! even if Interactive Context highlighted on last detection procedure.
0679 class AIS_ViewCubeOwner : public SelectMgr_EntityOwner
0680 {
0681   DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeOwner, SelectMgr_EntityOwner)
0682 public:
0683 
0684   //! Main constructor.
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   //! @return TRUE. This owner will always call method
0695   //! Hilight for its Selectable Object when the owner is detected.
0696   virtual Standard_Boolean IsForcedHilight() const Standard_OVERRIDE { return Standard_True; }
0697 
0698   //! Return new orientation to set.
0699   V3d_TypeOfOrientation MainOrientation() const { return myMainOrient; }
0700 
0701   //! Handle mouse button click event.
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; //!< new orientation to set
0716 
0717 };
0718 
0719 //! Simple sensitive element for picking by point only.
0720 class AIS_ViewCubeSensitive : public Select3D_SensitivePrimitiveArray
0721 {
0722   DEFINE_STANDARD_RTTIEXT(AIS_ViewCubeSensitive, Select3D_SensitivePrimitiveArray)
0723 public:
0724 
0725   //! Constructor.
0726   Standard_EXPORT AIS_ViewCubeSensitive (const Handle(SelectMgr_EntityOwner)& theOwner,
0727                                          const Handle(Graphic3d_ArrayOfTriangles)& theTris);
0728 
0729   //! Checks whether element overlaps current selecting volume.
0730   Standard_EXPORT virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
0731                                                     SelectBasics_PickResult& thePickResult) Standard_OVERRIDE;
0732 
0733 protected:
0734 
0735   //! Checks if picking ray can be used for detection.
0736   Standard_EXPORT bool isValidRay (const SelectBasics_SelectingVolumeManager& theMgr) const;
0737 
0738 };
0739 
0740 #endif // _AIS_ViewCube_HeaderFile