Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-23 09:16:38

0001 // Created on: 2015-12-23
0002 // Created by: Anastasia BORISOVA
0003 // Copyright (c) 2015 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_Manipulator_HeaderFile
0017 #define _AIS_Manipulator_HeaderFile
0018 
0019 #include <AIS_InteractiveObject.hxx>
0020 #include <AIS_ManipulatorMode.hxx>
0021 #include <gp_Ax1.hxx>
0022 #include <gp_Dir.hxx>
0023 #include <gp_Pnt.hxx>
0024 #include <Graphic3d_ArrayOfTriangles.hxx>
0025 #include <Graphic3d_Group.hxx>
0026 #include <NCollection_HSequence.hxx>
0027 #include <Poly_Triangulation.hxx>
0028 #include <V3d_View.hxx>
0029 #include <Standard_DefineHandle.hxx>
0030 
0031 //! Interactive object class to manipulate local transformation of another interactive
0032 //! object or a group of objects via mouse.
0033 //! It manages three types of manipulations in 3D space:
0034 //! - translation through axis
0035 //! - scaling within axis
0036 //! - rotation around axis
0037 //! To enable one of this modes, selection mode (from 1 to 3) is to be activated.
0038 //! There are three orthogonal transformation axes defined by position property of
0039 //! the manipulator. Particular transformation mode can be disabled for each
0040 //! of the axes or all of them. Furthermore each of the axes can be hidden or
0041 //! made visible.
0042 //! The following steps demonstrate how to attach, configure and use manipulator
0043 //! for an interactive object:
0044 //! Step 1. Create manipulator object and adjust it appearance:
0045 //! @code
0046 //! occ::handle<AIS_Manipulator> aManipulator = new AIS_Manipulator();
0047 //! aManipulator->SetPart (0, AIS_Manipulator::Scaling, false);
0048 //! aManipulator->SetPart (1, AIS_Manipulator::Rotation, false);
0049 //! // Attach manipulator to already displayed object and manage manipulation modes
0050 //! aManipulator->AttachToObject (anAISObject);
0051 //! aManipulator->EnableMode (AIS_Manipulator::Translation);
0052 //! aManipulator->EnableMode (AIS_Manipulator::Rotation);
0053 //! aManipulator->EnableMode (AIS_Manipulator::Scaling);
0054 //! @endcode
0055 //! Note that you can enable only one manipulation mode but have all visual parts displayed.
0056 //! This code allows you to view manipulator and select its manipulation parts.
0057 //! Note that manipulator activates mode on part selection.
0058 //! If this mode is activated, no selection will be performed for manipulator.
0059 //! It can be activated with highlighting. To enable this:
0060 //! @code
0061 //! aManipulator->SetModeActivationOnDetection (true);
0062 //! @endcode
0063 //! Step 2. To perform transformation of object use next code in your event processing chain:
0064 //! @code
0065 //! // catch mouse button down event
0066 //! if (aManipulator->HasActiveMode())
0067 //! {
0068 //!   aManipulator->StartTransform (anXPix, anYPix, aV3dView);
0069 //! }
0070 //! ...
0071 //! // or track mouse move event
0072 //! if (aManipulator->HasActiveMode())
0073 //! {
0074 //!   aManipulator->Transform (anXPix, anYPix, aV3dView);
0075 //!   aV3dView->Redraw();
0076 //! }
0077 //! ...
0078 //! // or catch mouse button up event (apply) or escape event (cancel)
0079 //! aManipulator->StopTransform(/*bool toApply*/);
0080 //! @endcode
0081 //! Step 3. To deactivate current manipulation mode use:
0082 //! @code aManipulator->DeactivateCurrentMode();
0083 //! @endcode
0084 //! Step 4. To detach manipulator from object use:
0085 //! @code
0086 //! aManipulator->Detach();
0087 //! @endcode
0088 //! The last method erases manipulator object.
0089 class AIS_Manipulator : public AIS_InteractiveObject
0090 {
0091 public:
0092   //! Constructs a manipulator object with default placement and all parts to be displayed.
0093   Standard_EXPORT AIS_Manipulator();
0094 
0095   //! Constructs a manipulator object with input location and positions of axes and all parts to be
0096   //! displayed.
0097   Standard_EXPORT AIS_Manipulator(const gp_Ax2& thePosition);
0098 
0099   //! Disable or enable visual parts for translation, rotation or scaling for some axis.
0100   //! By default all parts are enabled (will be displayed).
0101   //! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation
0102   //! (selection) mode.
0103   //! @warning Raises program error if axis index is < 0 or > 2.
0104   Standard_EXPORT void SetPart(const int                 theAxisIndex,
0105                                const AIS_ManipulatorMode theMode,
0106                                const bool                theIsEnabled);
0107 
0108   //! Disable or enable visual parts for translation, rotation or scaling for ALL axes.
0109   //! By default all parts are enabled (will be displayed).
0110   //! @warning Enabling or disabling of visual parts of manipulator does not manage the manipulation
0111   //! (selection) mode.
0112   //! @warning Raises program error if axis index is < 0 or > 2.
0113   Standard_EXPORT void SetPart(const AIS_ManipulatorMode theMode, const bool theIsEnabled);
0114 
0115   //! Behavior settings to be applied when performing transformation:
0116   //! - FollowTranslation - whether the manipulator will be moved together with an object.
0117   //! - FollowRotation - whether the manipulator will be rotated together with an object.
0118   struct OptionsForAttach
0119   {
0120 
0121     OptionsForAttach()
0122         : AdjustPosition(true),
0123           AdjustSize(false),
0124           EnableModes(true)
0125     {
0126     }
0127 
0128     OptionsForAttach& SetAdjustPosition(const bool theApply)
0129     {
0130       AdjustPosition = theApply;
0131       return *this;
0132     }
0133 
0134     OptionsForAttach& SetAdjustSize(const bool theApply)
0135     {
0136       AdjustSize = theApply;
0137       return *this;
0138     }
0139 
0140     OptionsForAttach& SetEnableModes(const bool theApply)
0141     {
0142       EnableModes = theApply;
0143       return *this;
0144     }
0145 
0146     bool AdjustPosition;
0147     bool AdjustSize;
0148     bool EnableModes;
0149   };
0150 
0151   //! Attaches himself to the input interactive object and become displayed in the same context.
0152   //! It is placed in the center of object bounding box, and its size is adjusted to the object
0153   //! bounding box.
0154   Standard_EXPORT void Attach(const occ::handle<AIS_InteractiveObject>& theObject,
0155                               const OptionsForAttach& theOptions = OptionsForAttach());
0156 
0157   //! Attaches himself to the input interactive object group and become displayed in the same
0158   //! context. It become attached to the first object, baut manage manipulation of the whole group.
0159   //! It is placed in the center of object bounding box, and its size is adjusted to the object
0160   //! bounding box.
0161   Standard_EXPORT void Attach(
0162     const occ::handle<NCollection_HSequence<occ::handle<AIS_InteractiveObject>>>& theObject,
0163     const OptionsForAttach& theOptions = OptionsForAttach());
0164 
0165   //! Enable manipualtion mode.
0166   //! @warning It activates selection mode in the current context.
0167   //! If manipulator is not displayed, no mode will be activated.
0168   Standard_EXPORT void EnableMode(const AIS_ManipulatorMode theMode);
0169 
0170   //! Enables mode activation on detection (highlighting).
0171   //! By default, mode is activated on selection of manipulator part.
0172   //! @warning If this mode is enabled, selection of parts does nothing.
0173   void SetModeActivationOnDetection(const bool theToEnable)
0174   {
0175     myIsActivationOnDetection = theToEnable;
0176   }
0177 
0178   //! @return true if manual mode activation is enabled.
0179   bool IsModeActivationOnDetection() const { return myIsActivationOnDetection; }
0180 
0181 public:
0182   //! Drag object in the viewer.
0183   //! @param[in] theCtx       interactive context
0184   //! @param[in] theView      active View
0185   //! @param[in] theOwner     the owner of detected entity
0186   //! @param[in] theDragFrom  drag start point
0187   //! @param[in] theDragTo    drag end point
0188   //! @param[in] theAction    drag action
0189   //! @return FALSE if object rejects dragging action (e.g. AIS_DragAction_Start)
0190   Standard_EXPORT bool ProcessDragging(const occ::handle<AIS_InteractiveContext>& theCtx,
0191                                        const occ::handle<V3d_View>&               theView,
0192                                        const occ::handle<SelectMgr_EntityOwner>&  theOwner,
0193                                        const NCollection_Vec2<int>&               theDragFrom,
0194                                        const NCollection_Vec2<int>&               theDragTo,
0195                                        const AIS_DragAction theAction) override;
0196 
0197   //! Init start (reference) transformation.
0198   //! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
0199   //! and is used only for custom transform set. If Transform(const int, const
0200   //! int) is used, initial data is set automatically, and it is reset on
0201   //! DeactivateCurrentMode call if it is not reset yet.
0202   Standard_EXPORT void StartTransform(const int                    theX,
0203                                       const int                    theY,
0204                                       const occ::handle<V3d_View>& theView);
0205 
0206   //! Apply to the owning objects the input transformation.
0207   //! @remark The transformation is set using SetLocalTransformation for owning objects.
0208   //! The location of the manipulator is stored also in Local Transformation,
0209   //! so that there's no need to redisplay objects.
0210   //! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
0211   //! and is used only for custom transform set.
0212   //! @warning It will does nothing if transformation is not initiated (with StartTransform() call).
0213   Standard_EXPORT void Transform(const gp_Trsf& aTrsf);
0214 
0215   //! Apply camera transformation to flat skin manipulator
0216   Standard_EXPORT void RecomputeTransformation(
0217     const occ::handle<Graphic3d_Camera>& theCamera) override;
0218 
0219   //! Recomputes sensitive primitives for the given selection mode.
0220   //! @param theMode selection mode to recompute sensitive primitives
0221   Standard_EXPORT void RecomputeSelection(const AIS_ManipulatorMode theMode);
0222 
0223   //! Reset start (reference) transformation.
0224   //! @param[in] theToApply  option to apply or to cancel the started transformation.
0225   //! @warning It is used in chain with StartTransform-Transform(gp_Trsf)-StopTransform
0226   //! and is used only for custom transform set.
0227   Standard_EXPORT void StopTransform(const bool theToApply = true);
0228 
0229   //! Apply transformation made from mouse moving from start position
0230   //! (save on the first Transform() call and reset on DeactivateCurrentMode() call.)
0231   //! to the in/out mouse position (theX, theY)
0232   Standard_EXPORT gp_Trsf Transform(const int                    theX,
0233                                     const int                    theY,
0234                                     const occ::handle<V3d_View>& theView);
0235 
0236   //! Computes transformation of parent object according to the active mode and input motion vector.
0237   //! You can use this method to get object transformation according to current mode or use own
0238   //! algorithm to implement any other transformation for modes.
0239   //! @return transformation of parent object.
0240   Standard_EXPORT bool ObjectTransformation(const int                    theX,
0241                                             const int                    theY,
0242                                             const occ::handle<V3d_View>& theView,
0243                                             gp_Trsf&                     theTrsf);
0244 
0245   //! Make inactive the current selected manipulator part and reset current axis index and current
0246   //! mode. After its call HasActiveMode() returns false.
0247   //! @sa HasActiveMode()
0248   Standard_EXPORT void DeactivateCurrentMode();
0249 
0250   //! Detaches himself from the owner object, and removes itself from context.
0251   Standard_EXPORT void Detach();
0252 
0253   //! @return all owning objects.
0254   Standard_EXPORT occ::handle<NCollection_HSequence<occ::handle<AIS_InteractiveObject>>> Objects()
0255     const;
0256 
0257   //! @return the first (leading) object of the owning objects.
0258   Standard_EXPORT occ::handle<AIS_InteractiveObject> Object() const;
0259 
0260   //! @return one of the owning objects.
0261   //! @warning raises program error if theIndex is more than owning objects count or less than 1.
0262   Standard_EXPORT occ::handle<AIS_InteractiveObject> Object(const int theIndex) const;
0263 
0264   //! @return true if manipulator is attached to some interactive object (has owning object).
0265   bool IsAttached() const { return HasOwner(); }
0266 
0267   //! @return true if some part of manipulator is selected (transformation mode is active, and
0268   //! owning object can be transformed).
0269   bool HasActiveMode() const { return IsAttached() && myCurrentMode != AIS_MM_None; }
0270 
0271   bool HasActiveTransformation() { return myHasStartedTransformation; }
0272 
0273   gp_Trsf StartTransformation() const
0274   {
0275     return !myStartTrsfs.IsEmpty() ? myStartTrsfs.First() : gp_Trsf();
0276   }
0277 
0278   gp_Trsf StartTransformation(int theIndex) const
0279   {
0280     Standard_ProgramError_Raise_if(
0281       theIndex < 1 || theIndex > Objects()->Upper(),
0282       "AIS_Manipulator::StartTransformation(): theIndex is out of bounds");
0283     return !myStartTrsfs.IsEmpty() ? myStartTrsfs(theIndex) : gp_Trsf();
0284   }
0285 
0286 public: //! @name Configuration of graphical transformations
0287   //! Enable or disable zoom persistence mode for the manipulator. With
0288   //! this mode turned on the presentation will keep fixed screen size.
0289   //! @warning when turned on this option overrides transform persistence
0290   //! properties and local transformation to achieve necessary visual effect.
0291   //! @warning revise use of AdjustSize argument of of \sa AttachToObjects method
0292   //! when enabling zoom persistence.
0293   Standard_EXPORT void SetZoomPersistence(const bool theToEnable);
0294 
0295   //! Returns state of zoom persistence mode, whether it turned on or off.
0296   bool ZoomPersistence() const { return myIsZoomPersistentMode; }
0297 
0298   //! Redefines transform persistence management to setup transformation for sub-presentation of
0299   //! axes.
0300   //! @warning this interactive object does not support custom transformation persistence when
0301   //! using \sa ZoomPersistence mode. In this mode the transformation persistence flags for
0302   //! presentations are overridden by this class.
0303   //! @warning Invokes debug assertion to catch incompatible usage of the method with \sa
0304   //! ZoomPersistence mode, silently does nothing in release mode.
0305   //! @warning revise use of AdjustSize argument of of \sa AttachToObjects method
0306   //! when enabling zoom persistence.
0307   Standard_EXPORT void SetTransformPersistence(
0308     const occ::handle<Graphic3d_TransformPers>& theTrsfPers) override;
0309 
0310 public: //! @name Setters for parameters
0311   enum ManipulatorSkin
0312   {
0313     ManipulatorSkin_Shaded,
0314     ManipulatorSkin_Flat
0315   };
0316 
0317   //! @return current manipulator skin mode.
0318   ManipulatorSkin SkinMode() const { return mySkinMode; }
0319 
0320   //! Sets skin mode for the manipulator.
0321   Standard_EXPORT void SetSkinMode(const ManipulatorSkin theSkinMode);
0322 
0323   AIS_ManipulatorMode ActiveMode() const { return myCurrentMode; }
0324 
0325   int ActiveAxisIndex() const { return myCurrentIndex; }
0326 
0327   //! @return poition of manipulator interactive object.
0328   const gp_Ax2& Position() const { return myPosition; }
0329 
0330   //! Sets position of the manipulator object.
0331   Standard_EXPORT void SetPosition(const gp_Ax2& thePosition);
0332 
0333   float Size() const { return myAxes[0].Size(); }
0334 
0335   //! Sets size (length of side of the manipulator cubic bounding box.
0336   Standard_EXPORT void SetSize(const float theSideLength);
0337 
0338   //! Sets gaps between translator, scaler and rotator sub-presentations.
0339   Standard_EXPORT void SetGap(const float theValue);
0340 
0341 public:
0342   //! Behavior settings to be applied when performing transformation:
0343   //! - FollowTranslation - whether the manipulator will be moved together with an object.
0344   //! - FollowRotation - whether the manipulator will be rotated together with an object.
0345   struct BehaviorOnTransform
0346   {
0347 
0348     BehaviorOnTransform()
0349         : FollowTranslation(true),
0350           FollowRotation(true),
0351           FollowDragging(true)
0352     {
0353     }
0354 
0355     BehaviorOnTransform& SetFollowTranslation(const bool theApply)
0356     {
0357       FollowTranslation = theApply;
0358       return *this;
0359     }
0360 
0361     BehaviorOnTransform& SetFollowRotation(const bool theApply)
0362     {
0363       FollowRotation = theApply;
0364       return *this;
0365     }
0366 
0367     BehaviorOnTransform& SetFollowDragging(const bool theApply)
0368     {
0369       FollowDragging = theApply;
0370       return *this;
0371     }
0372 
0373     bool FollowTranslation;
0374     bool FollowRotation;
0375     bool FollowDragging;
0376   };
0377 
0378   //! Sets behavior settings for transformation action carried on the manipulator,
0379   //! whether it translates, rotates together with the transformed object or not.
0380   void SetTransformBehavior(const BehaviorOnTransform& theSettings)
0381   {
0382     myBehaviorOnTransform = theSettings;
0383   }
0384 
0385   //! @return behavior settings for transformation action of the manipulator.
0386   BehaviorOnTransform& ChangeTransformBehavior() { return myBehaviorOnTransform; }
0387 
0388   //! @return behavior settings for transformation action of the manipulator.
0389   const BehaviorOnTransform& TransformBehavior() const { return myBehaviorOnTransform; }
0390 
0391 public: //! @name Presentation computation
0392   //! Fills presentation.
0393   //! @note Manipulator presentation does not use display mode and for all modes has the same
0394   //! presentation.
0395   Standard_EXPORT void Compute(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0396                                const occ::handle<Prs3d_Presentation>&         thePrs,
0397                                const int                                      theMode = 0) override;
0398 
0399   //! Computes selection sensitive zones (triangulation) for manipulator.
0400   //! @param[in] theNode  Selection mode that is treated as transformation mode.
0401   Standard_EXPORT void ComputeSelection(const occ::handle<SelectMgr_Selection>& theSelection,
0402                                         const int                               theMode) override;
0403 
0404   //! Disables auto highlighting to use HilightSelected() and HilightOwnerWithColor() overridden
0405   //! methods.
0406   bool IsAutoHilight() const override { return false; }
0407 
0408   //! Method which clear all selected owners belonging
0409   //! to this selectable object (for fast presentation draw).
0410   Standard_EXPORT void ClearSelected() override;
0411 
0412   //! Method which draws selected owners (for fast presentation draw).
0413   Standard_EXPORT void HilightSelected(
0414     const occ::handle<PrsMgr_PresentationManager>&                  thePM,
0415     const NCollection_Sequence<occ::handle<SelectMgr_EntityOwner>>& theSeq) override;
0416 
0417   //! Method which hilight an owner belonging to
0418   //! this selectable object (for fast presentation draw).
0419   Standard_EXPORT void HilightOwnerWithColor(
0420     const occ::handle<PrsMgr_PresentationManager>& thePM,
0421     const occ::handle<Prs3d_Drawer>&               theStyle,
0422     const occ::handle<SelectMgr_EntityOwner>&      theOwner) override;
0423 
0424 protected:
0425   Standard_EXPORT void init();
0426 
0427   Standard_EXPORT void updateTransformation();
0428 
0429   Standard_EXPORT occ::handle<Prs3d_Presentation> getHighlightPresentation(
0430     const occ::handle<SelectMgr_EntityOwner>& theOwner) const;
0431 
0432   Standard_EXPORT occ::handle<Graphic3d_Group> getGroup(const int                 theIndex,
0433                                                         const AIS_ManipulatorMode theMode) const;
0434 
0435   Standard_EXPORT void attachToPoint(const gp_Pnt& thePoint);
0436 
0437   Standard_EXPORT void attachToBox(const Bnd_Box& theBox);
0438 
0439   Standard_EXPORT void adjustSize(const Bnd_Box& theBox);
0440 
0441   Standard_EXPORT void setTransformPersistence(
0442     const occ::handle<Graphic3d_TransformPers>& theTrsfPers);
0443 
0444   //! Redefines local transformation management method to inform user of improper use.
0445   //! @warning this interactive object does not support setting custom local transformation,
0446   //! this class solely uses this property to implement visual positioning of the manipulator
0447   //! without need for recomputing presentation.
0448   //! @warning Invokes debug assertion in debug to catch incompatible usage of the
0449   //! method, silently does nothing in release mode.
0450   Standard_EXPORT void setLocalTransformation(const occ::handle<TopLoc_Datum3D>& theTrsf) override;
0451   using AIS_InteractiveObject::SetLocalTransformation; // hide visibility
0452 
0453 protected: //! @name Auxiliary classes to fill presentation with proper primitives
0454   class Quadric
0455   {
0456   public:
0457     virtual ~Quadric()
0458     {
0459       myTriangulation.Nullify();
0460       myArray.Nullify();
0461     }
0462 
0463     const occ::handle<Poly_Triangulation>& Triangulation() const { return myTriangulation; }
0464 
0465     const occ::handle<Graphic3d_ArrayOfTriangles>& Array() const { return myArray; }
0466 
0467   protected:
0468     occ::handle<Poly_Triangulation>         myTriangulation;
0469     occ::handle<Graphic3d_ArrayOfTriangles> myArray;
0470   };
0471 
0472   class Disk : public Quadric
0473   {
0474   public:
0475     Disk()
0476         : Quadric(),
0477           myInnerRad(0.0f),
0478           myOuterRad(1.0f)
0479     {
0480     }
0481 
0482     ~Disk() override = default;
0483 
0484     void Init(const float   theInnerRadius,
0485               const float   theOuterRadius,
0486               const gp_Ax1& thePosition,
0487               const double  theAngle,
0488               const int     theSlicesNb = 20,
0489               const int     theStacksNb = 20);
0490 
0491   protected:
0492     gp_Ax1 myPosition;
0493     float  myInnerRad;
0494     float  myOuterRad;
0495   };
0496 
0497   class Sphere : public Quadric
0498   {
0499   public:
0500     Sphere()
0501         : Quadric(),
0502           myRadius(1.0f)
0503     {
0504     }
0505 
0506     void Init(const float           theRadius,
0507               const gp_Pnt&         thePosition,
0508               const ManipulatorSkin theSkinMode,
0509               const int             theSlicesNb = 20,
0510               const int             theStacksNb = 20);
0511 
0512   protected:
0513     gp_Pnt myPosition;
0514     float  myRadius;
0515   };
0516 
0517   class Cube
0518   {
0519   public:
0520     Cube() = default;
0521 
0522     ~Cube() = default;
0523 
0524     void Init(const gp_Ax1& thePosition, const float myBoxSize, const ManipulatorSkin theSkinMode);
0525 
0526     const occ::handle<Poly_Triangulation>& Triangulation() const { return myTriangulation; }
0527 
0528     const occ::handle<Graphic3d_ArrayOfTriangles>& Array() const { return myArray; }
0529 
0530   private:
0531     void addTriangle(const int     theIndex,
0532                      const gp_Pnt& theP1,
0533                      const gp_Pnt& theP2,
0534                      const gp_Pnt& theP3,
0535                      const gp_Dir& theNormal);
0536 
0537   protected:
0538     occ::handle<Poly_Triangulation>         myTriangulation;
0539     occ::handle<Graphic3d_ArrayOfTriangles> myArray;
0540   };
0541 
0542   class Sector : public Quadric
0543   {
0544   public:
0545     Sector()
0546         : Quadric(),
0547           myRadius(0.0f)
0548     {
0549     }
0550 
0551     ~Sector() override = default;
0552 
0553     void Init(const float           theRadius,
0554               const gp_Ax1&         thePosition,
0555               const gp_Dir&         theXDirection,
0556               const ManipulatorSkin theSkinMode,
0557               const int             theSlicesNb = 5,
0558               const int             theStacksNb = 5);
0559 
0560   protected:
0561     gp_Ax1 myPosition;
0562     float  myRadius;
0563   };
0564 
0565   //! The class describes on axis sub-object.
0566   //! It includes sub-objects itself:
0567   //! -rotator
0568   //! -translator
0569   //! -scaler
0570   class Axis
0571   {
0572   public:
0573     Axis(const gp_Ax1&         theAxis   = gp_Ax1(),
0574          const Quantity_Color& theColor  = Quantity_Color(),
0575          const float           theLength = 10.0f);
0576 
0577     void Compute(const occ::handle<PrsMgr_PresentationManager>& thePrsMgr,
0578                  const occ::handle<Prs3d_Presentation>&         thePrs,
0579                  const occ::handle<Prs3d_ShadingAspect>&        theAspect,
0580                  const ManipulatorSkin                          theSkinMode);
0581 
0582     const gp_Ax1& ReferenceAxis() const { return myReferenceAxis; }
0583 
0584     void SetPosition(const gp_Ax1& thePosition) { myPosition = thePosition; }
0585 
0586     const gp_Ax1& Position() const { return myPosition; }
0587 
0588     void SetTransformPersistence(const occ::handle<Graphic3d_TransformPers>& theTrsfPers)
0589     {
0590       if (!myHighlightTranslator.IsNull())
0591       {
0592         myHighlightTranslator->SetTransformPersistence(theTrsfPers);
0593       }
0594 
0595       if (!myHighlightScaler.IsNull())
0596       {
0597         myHighlightScaler->SetTransformPersistence(theTrsfPers);
0598       }
0599 
0600       if (!myHighlightRotator.IsNull())
0601       {
0602         myHighlightRotator->SetTransformPersistence(theTrsfPers);
0603       }
0604 
0605       if (!myHighlightDragger.IsNull())
0606       {
0607         myHighlightDragger->SetTransformPersistence(theTrsfPers);
0608       }
0609     }
0610 
0611     void Transform(const occ::handle<TopLoc_Datum3D>& theTransformation)
0612     {
0613       if (!myHighlightTranslator.IsNull())
0614       {
0615         myHighlightTranslator->SetTransformation(theTransformation);
0616       }
0617 
0618       if (!myHighlightScaler.IsNull())
0619       {
0620         myHighlightScaler->SetTransformation(theTransformation);
0621       }
0622 
0623       if (!myHighlightRotator.IsNull())
0624       {
0625         myHighlightRotator->SetTransformation(theTransformation);
0626       }
0627 
0628       if (!myHighlightDragger.IsNull())
0629       {
0630         myHighlightDragger->SetTransformation(theTransformation);
0631       }
0632     }
0633 
0634     bool HasTranslation() const { return myHasTranslation; }
0635 
0636     bool HasRotation() const { return myHasRotation; }
0637 
0638     bool HasScaling() const { return myHasScaling; }
0639 
0640     bool HasDragging() const { return myHasDragging; }
0641 
0642     void SetTranslation(const bool theIsEnabled) { myHasTranslation = theIsEnabled; }
0643 
0644     void SetRotation(const bool theIsEnabled) { myHasRotation = theIsEnabled; }
0645 
0646     void SetScaling(const bool theIsEnabled) { myHasScaling = theIsEnabled; }
0647 
0648     void SetDragging(const bool theIsEnabled) { myHasDragging = theIsEnabled; }
0649 
0650     Quantity_Color Color() const { return myColor; }
0651 
0652     float AxisLength() const { return myLength; }
0653 
0654     float BoxSize() const { return myBoxSize; }
0655 
0656     float AxisRadius() const { return myAxisRadius; }
0657 
0658     float Indent() const { return myIndent; }
0659 
0660     void SetAxisRadius(const float theValue) { myAxisRadius = theValue; }
0661 
0662     const occ::handle<Prs3d_Presentation>& TranslatorHighlightPrs() const
0663     {
0664       return myHighlightTranslator;
0665     }
0666 
0667     const occ::handle<Prs3d_Presentation>& RotatorHighlightPrs() const
0668     {
0669       return myHighlightRotator;
0670     }
0671 
0672     const occ::handle<Prs3d_Presentation>& ScalerHighlightPrs() const { return myHighlightScaler; }
0673 
0674     const occ::handle<Prs3d_Presentation>& DraggerHighlightPrs() const
0675     {
0676       return myHighlightDragger;
0677     }
0678 
0679     const occ::handle<Graphic3d_Group>& TranslatorGroup() const { return myTranslatorGroup; }
0680 
0681     const occ::handle<Graphic3d_Group>& RotatorGroup() const { return myRotatorGroup; }
0682 
0683     const occ::handle<Graphic3d_Group>& ScalerGroup() const { return myScalerGroup; }
0684 
0685     const occ::handle<Graphic3d_Group>& DraggerGroup() const { return myDraggerGroup; }
0686 
0687     const occ::handle<Graphic3d_ArrayOfTriangles>& TriangleArray() const { return myTriangleArray; }
0688 
0689     void SetIndent(const float theValue) { myIndent = theValue; }
0690 
0691     float Size() const { return myInnerRadius + myDiskThickness + myIndent * 2; }
0692 
0693     float InnerRadius() const { return myInnerRadius + myIndent * 2.0f; }
0694 
0695     gp_Pnt ScalerCenter(const gp_Pnt& theLocation) const
0696     {
0697       return theLocation.XYZ()
0698              + myPosition.Direction().XYZ() * (myLength + myIndent + myBoxSize * 0.5f);
0699     }
0700 
0701     void SetSize(const float theValue)
0702     {
0703       if (myIndent > theValue * 0.1f)
0704       {
0705         myLength        = theValue * 0.7f;
0706         myBoxSize       = theValue * 0.15f;
0707         myDiskThickness = theValue * 0.05f;
0708         myIndent        = theValue * 0.05f;
0709       }
0710       else // use pre-set value of predent
0711       {
0712         float aLength   = theValue - 2 * myIndent;
0713         myLength        = aLength * 0.8f;
0714         myBoxSize       = aLength * 0.15f;
0715         myDiskThickness = aLength * 0.05f;
0716       }
0717       myInnerRadius = myIndent * 2 + myBoxSize + myLength;
0718       myAxisRadius  = myBoxSize / 4.0f;
0719     }
0720 
0721     int FacettesNumber() const { return myFacettesNumber; }
0722 
0723   public:
0724     const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; }
0725 
0726     const Sector& DraggerSector() const { return mySector; }
0727 
0728     const Disk& RotatorDisk() const { return myCircle; }
0729 
0730     float RotatorDiskRadius() const { return myCircleRadius; }
0731 
0732     const Cube& ScalerCube() const { return myCube; }
0733 
0734     const gp_Pnt& ScalerCubePosition() const { return myCubePos; }
0735 
0736   protected:
0737     gp_Ax1         myReferenceAxis; //!< Returns reference axis assignment.
0738     gp_Ax1         myPosition;      //!< Position of the axis including local transformation.
0739     Quantity_Color myColor;
0740 
0741     bool  myHasTranslation;
0742     float myLength; //!< Length of translation axis.
0743     float myAxisRadius;
0744 
0745     bool  myHasScaling;
0746     float myBoxSize; //!< Size of scaling cube.
0747 
0748     bool  myHasRotation;
0749     float myInnerRadius; //!< Radius of rotation circle.
0750     float myDiskThickness;
0751     float myIndent; //!< Gap between visual part of the manipulator.
0752 
0753     bool myHasDragging;
0754 
0755   protected:
0756     int myFacettesNumber;
0757 
0758     gp_Pnt myArrowTipPos;
0759     Sector mySector;
0760     Disk   myCircle;
0761     float  myCircleRadius;
0762     Cube   myCube;
0763     gp_Pnt myCubePos;
0764 
0765     occ::handle<Graphic3d_Group> myTranslatorGroup;
0766     occ::handle<Graphic3d_Group> myScalerGroup;
0767     occ::handle<Graphic3d_Group> myRotatorGroup;
0768     occ::handle<Graphic3d_Group> myDraggerGroup;
0769 
0770     occ::handle<Prs3d_Presentation> myHighlightTranslator;
0771     occ::handle<Prs3d_Presentation> myHighlightScaler;
0772     occ::handle<Prs3d_Presentation> myHighlightRotator;
0773     occ::handle<Prs3d_Presentation> myHighlightDragger;
0774 
0775     occ::handle<Graphic3d_ArrayOfTriangles> myTriangleArray;
0776   };
0777 
0778 protected:
0779   Axis   myAxes[3];               //!< Tree axes of the manipulator.
0780   Sphere myCenter;                //!< Visual part displaying the center sphere of the manipulator.
0781                                   // clang-format off
0782   gp_Ax2 myPosition; //!< Position of the manipulator object. it displays its location and position of its axes.
0783 
0784   Disk                    myCircle; //!< Outer circle
0785   occ::handle<Graphic3d_Group> myCircleGroup;
0786 
0787   Disk                    mySector; //!< Sector indicating the rotation angle
0788   occ::handle<Graphic3d_Group> mySectorGroup;
0789 
0790   int myCurrentIndex; //!< Index of active axis.
0791   AIS_ManipulatorMode myCurrentMode; //!< Name of active manipulation mode.
0792   ManipulatorSkin mySkinMode; //!< Name of active skin mode.
0793 
0794   bool myIsActivationOnDetection; //!< Manual activation of modes (not on parts selection).
0795   bool myIsZoomPersistentMode; //!< Zoom persistence mode activation.
0796   BehaviorOnTransform myBehaviorOnTransform; //!< Behavior settings applied on manipulator when transforming an object.
0797 
0798 protected: //! @name Fields for interactive transformation. Fields only for internal needs. They do not have public interface.
0799 
0800   NCollection_Sequence<gp_Trsf> myStartTrsfs; //!< Owning object transformation for start. It is used internally.
0801   bool myHasStartedTransformation; //!< Shows if transformation is processed (sequential calls of Transform()).
0802                                   // clang-format on
0803   gp_Ax2 myStartPosition;         //! Start position of manipulator.
0804   gp_Pnt myStartPick;             //! 3d point corresponding to start mouse pick.
0805   double myPrevState;             //! Previous value of angle during rotation.
0806 
0807   //! Aspect used to color current detected part and current selected part.
0808   occ::handle<Prs3d_ShadingAspect> myHighlightAspect;
0809 
0810   //! Aspect used to color sector part when it's selected.
0811   occ::handle<Prs3d_ShadingAspect> myDraggerHighlight;
0812 
0813 public:
0814   DEFINE_STANDARD_RTTIEXT(AIS_Manipulator, AIS_InteractiveObject)
0815 };
0816 #endif // _AIS_Manipulator_HeaderFile