Back to home page

EIC code displayed by LXR

 
 

    


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

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