1 // Created on: 2015-12-23
2 // Created by: Anastasia BORISOVA
3 // Copyright (c) 2015 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <AIS_Manipulator.hxx>
18 #include <AIS_InteractiveContext.hxx>
19 #include <AIS_ManipulatorOwner.hxx>
20 #include <Extrema_ExtElC.hxx>
21 #include <gce_MakeDir.hxx>
22 #include <Geom_Circle.hxx>
23 #include <Geom_Transformation.hxx>
24 #include <IntAna_IntConicQuad.hxx>
25 #include <Prs3d_Arrow.hxx>
26 #include <Prs3d_Root.hxx>
27 #include <Prs3d_ShadingAspect.hxx>
28 #include <Prs3d_ToolDisk.hxx>
29 #include <Prs3d_ToolSector.hxx>
30 #include <Prs3d_ToolSphere.hxx>
31 #include <Select3D_SensitiveCircle.hxx>
32 #include <Select3D_SensitivePoint.hxx>
33 #include <Select3D_SensitiveSegment.hxx>
34 #include <Select3D_SensitiveTriangulation.hxx>
35 #include <Select3D_SensitivePrimitiveArray.hxx>
36 #include <SelectMgr_SequenceOfOwner.hxx>
37 #include <TColgp_Array1OfPnt.hxx>
38 #include <V3d_View.hxx>
40 IMPLEMENT_STANDARD_HANDLE (AIS_Manipulator, AIS_InteractiveObject)
41 IMPLEMENT_STANDARD_RTTIEXT(AIS_Manipulator, AIS_InteractiveObject)
43 IMPLEMENT_HSEQUENCE(AIS_ManipulatorObjectSequence)
47 //! Return Ax1 for specified direction of Ax2.
48 static gp_Ax1 getAx1FromAx2Dir (const gp_Ax2& theAx2,
53 case 0: return gp_Ax1 (theAx2.Location(), theAx2.XDirection());
54 case 1: return gp_Ax1 (theAx2.Location(), theAx2.YDirection());
55 case 2: return theAx2.Axis();
57 throw Standard_ProgramError ("AIS_Manipulator - Invalid axis index");
60 //! Auxiliary tool for filtering picking ray.
61 class ManipSensRotation
65 ManipSensRotation (const gp_Dir& thePlaneNormal) : myPlaneNormal (thePlaneNormal), myAngleTol (10.0 * M_PI / 180.0) {}
67 //! Checks if picking ray can be used for detection.
68 Standard_Boolean isValidRay (const SelectBasics_SelectingVolumeManager& theMgr) const
70 if (theMgr.GetActiveSelectionType() != SelectBasics_SelectingVolumeManager::Point)
72 return Standard_False;
75 const gp_Vec aRay (theMgr.GetNearPickedPnt(), theMgr.GetFarPickedPnt());
76 return !aRay.IsNormal (myPlaneNormal, myAngleTol);
80 Standard_Real myAngleTol;
83 //! Sensitive circle with filtering picking ray.
84 class ManipSensCircle : public Select3D_SensitiveCircle, public ManipSensRotation
88 ManipSensCircle (const Handle(SelectBasics_EntityOwner)& theOwnerId,
89 const Handle(Geom_Circle)& theCircle,
90 const Standard_Integer theNbPnts)
91 : Select3D_SensitiveCircle (theOwnerId, theCircle, Standard_False, theNbPnts),
92 ManipSensRotation (theCircle->Position().Direction()) {}
94 //! Checks whether the circle overlaps current selecting volume
95 virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
96 SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
98 return isValidRay (theMgr)
99 && Select3D_SensitiveCircle::Matches (theMgr, thePickResult);
103 //! Sensitive triangulation with filtering picking ray.
104 class ManipSensTriangulation : public Select3D_SensitiveTriangulation, public ManipSensRotation
107 ManipSensTriangulation (const Handle(SelectBasics_EntityOwner)& theOwnerId,
108 const Handle(Poly_Triangulation)& theTrg,
109 const gp_Dir& thePlaneNormal)
110 : Select3D_SensitiveTriangulation (theOwnerId, theTrg, TopLoc_Location(), Standard_True),
111 ManipSensRotation (thePlaneNormal) {}
113 //! Checks whether the circle overlaps current selecting volume
114 virtual Standard_Boolean Matches (SelectBasics_SelectingVolumeManager& theMgr,
115 SelectBasics_PickResult& thePickResult) Standard_OVERRIDE
117 return isValidRay (theMgr)
118 && Select3D_SensitiveTriangulation::Matches (theMgr, thePickResult);
123 //=======================================================================
126 //=======================================================================
127 void AIS_Manipulator::init()
129 // Create axis in the default coordinate system. The custom position is applied in local transformation.
130 myAxes[0] = Axis (gp::OX(), Quantity_NOC_RED);
131 myAxes[1] = Axis (gp::OY(), Quantity_NOC_GREEN);
132 myAxes[2] = Axis (gp::OZ(), Quantity_NOC_BLUE1);
134 Graphic3d_MaterialAspect aShadingMaterial;
135 aShadingMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
136 aShadingMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
138 myDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
139 myDrawer->ShadingAspect()->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
140 myDrawer->ShadingAspect()->SetColor (Quantity_NOC_WHITE);
141 myDrawer->ShadingAspect()->SetMaterial (aShadingMaterial);
143 Graphic3d_MaterialAspect aHilightMaterial;
144 aHilightMaterial.SetColor (Quantity_NOC_AZURE);
145 aHilightMaterial.SetReflectionModeOff (Graphic3d_TOR_AMBIENT);
146 aHilightMaterial.SetReflectionModeOff (Graphic3d_TOR_DIFFUSE);
147 aHilightMaterial.SetReflectionModeOff (Graphic3d_TOR_SPECULAR);
148 aHilightMaterial.SetReflectionModeOff (Graphic3d_TOR_EMISSION);
149 aHilightMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
151 myHighlightAspect = new Prs3d_ShadingAspect();
152 myHighlightAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
153 myHighlightAspect->SetMaterial (aHilightMaterial);
155 Graphic3d_MaterialAspect aDraggerMaterial;
156 aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_DIFFUSE);
157 aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_SPECULAR);
158 aDraggerMaterial.SetReflectionModeOff(Graphic3d_TOR_EMISSION);
159 aDraggerMaterial.SetMaterialType(Graphic3d_MATERIAL_ASPECT);
160 aDraggerMaterial.SetAmbient(1.0);
162 myDraggerHighlight = new Prs3d_ShadingAspect();
163 myDraggerHighlight->Aspect()->SetInteriorStyle(Aspect_IS_SOLID);
164 myDraggerHighlight->SetMaterial(aDraggerMaterial);
166 myDraggerHighlight->SetTransparency(0.5);
169 SetZLayer (Graphic3d_ZLayerId_Topmost);
172 //=======================================================================
173 //function : getHighlightPresentation
175 //=======================================================================
176 Handle(Prs3d_Presentation) AIS_Manipulator::getHighlightPresentation (const Handle(SelectMgr_EntityOwner)& theOwner) const
178 Handle(Prs3d_Presentation) aDummyPrs;
179 Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theOwner);
180 if (anOwner.IsNull())
185 switch (anOwner->Mode())
187 case AIS_MM_Translation : return myAxes[anOwner->Index()].TranslatorHighlightPrs();
188 case AIS_MM_Rotation : return myAxes[anOwner->Index()].RotatorHighlightPrs();
189 case AIS_MM_Scaling : return myAxes[anOwner->Index()].ScalerHighlightPrs();
190 case AIS_MM_TranslationPlane: return myAxes[anOwner->Index()].DraggerHighlightPrs();
191 case AIS_MM_None : break;
197 //=======================================================================
198 //function : getGroup
200 //=======================================================================
201 Handle(Graphic3d_Group) AIS_Manipulator::getGroup (const Standard_Integer theIndex, const AIS_ManipulatorMode theMode) const
203 Handle(Graphic3d_Group) aDummyGroup;
205 if (theIndex < 0 || theIndex > 2)
212 case AIS_MM_Translation : return myAxes[theIndex].TranslatorGroup();
213 case AIS_MM_Rotation : return myAxes[theIndex].RotatorGroup();
214 case AIS_MM_Scaling : return myAxes[theIndex].ScalerGroup();
215 case AIS_MM_TranslationPlane: return myAxes[theIndex].DraggerGroup();
216 case AIS_MM_None : break;
222 //=======================================================================
223 //function : Constructor
225 //=======================================================================
226 AIS_Manipulator::AIS_Manipulator()
227 : myPosition (gp::XOY()),
229 myCurrentMode (AIS_MM_None),
230 myIsActivationOnDetection (Standard_False),
231 myIsZoomPersistentMode (Standard_True),
232 myHasStartedTransformation (Standard_False),
233 myStartPosition (gp::XOY()),
234 myStartPick (0.0, 0.0, 0.0),
238 SetMutable (Standard_True);
239 SetDisplayMode (AIS_Shaded);
243 //=======================================================================
244 //function : Constructor
246 //=======================================================================
247 AIS_Manipulator::AIS_Manipulator (const gp_Ax2& thePosition)
248 : myPosition (thePosition),
250 myCurrentMode (AIS_MM_None),
251 myIsActivationOnDetection (Standard_False),
252 myIsZoomPersistentMode (Standard_True),
253 myHasStartedTransformation (Standard_False),
254 myStartPosition (gp::XOY()),
255 myStartPick (0.0, 0.0, 0.0),
259 SetMutable (Standard_True);
260 SetDisplayMode (AIS_Shaded);
264 //=======================================================================
267 //=======================================================================
268 void AIS_Manipulator::SetPart (const Standard_Integer theAxisIndex, const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled)
270 Standard_ProgramError_Raise_if (theAxisIndex < 0 || theAxisIndex > 2, "AIS_Manipulator::SetMode(): axis index should be between 0 and 2");
273 case AIS_MM_Translation:
274 myAxes[theAxisIndex].SetTranslation (theIsEnabled);
277 case AIS_MM_Rotation:
278 myAxes[theAxisIndex].SetRotation (theIsEnabled);
282 myAxes[theAxisIndex].SetScaling (theIsEnabled);
285 case AIS_MM_TranslationPlane:
286 myAxes[theAxisIndex].SetDragging(theIsEnabled);
294 //=======================================================================
297 //=======================================================================
298 void AIS_Manipulator::SetPart (const AIS_ManipulatorMode theMode, const Standard_Boolean theIsEnabled)
300 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
302 SetPart (anIt, theMode, theIsEnabled);
306 //=======================================================================
307 //function : EnableMode
309 //=======================================================================
310 void AIS_Manipulator::EnableMode (const AIS_ManipulatorMode theMode)
317 const Handle(AIS_InteractiveContext)& aContext = GetContext();
318 if (aContext.IsNull())
323 aContext->Activate (this, theMode);
326 //=======================================================================
327 //function : attachToBox
329 //=======================================================================
330 void AIS_Manipulator::attachToBox (const Bnd_Box& theBox)
337 Standard_Real anXmin = 0.0, anYmin = 0.0, aZmin = 0.0, anXmax = 0.0, anYmax = 0.0, aZmax = 0.0;
338 theBox.Get (anXmin, anYmin, aZmin, anXmax, anYmax, aZmax);
340 gp_Ax2 aPosition = gp::XOY();
341 aPosition.SetLocation (gp_Pnt ((anXmin + anXmax) * 0.5, (anYmin + anYmax) * 0.5, (aZmin + aZmax) * 0.5));
342 SetPosition (aPosition);
345 //=======================================================================
346 //function : adjustSize
348 //=======================================================================
349 void AIS_Manipulator::adjustSize (const Bnd_Box& theBox)
351 Standard_Real aXmin = 0., aYmin = 0., aZmin = 0., aXmax = 0., aYmax = 0., aZmax = 0.0;
352 theBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax);
353 Standard_Real aXSize = aXmax - aXmin;
354 Standard_Real aYSize = aYmax - aYmin;
355 Standard_Real aZSize = aZmax - aZmin;
357 SetSize ((Standard_ShortReal) (Max (aXSize, Max (aYSize, aZSize)) * 0.5));
360 //=======================================================================
363 //=======================================================================
364 void AIS_Manipulator::Attach (const Handle(AIS_InteractiveObject)& theObject, const OptionsForAttach& theOptions)
366 if (theObject->IsKind (STANDARD_TYPE(AIS_Manipulator)))
371 Handle(AIS_ManipulatorObjectSequence) aSeq = new AIS_ManipulatorObjectSequence();
372 aSeq->Append (theObject);
373 Attach (aSeq, theOptions);
376 //=======================================================================
379 //=======================================================================
380 void AIS_Manipulator::Attach (const Handle(AIS_ManipulatorObjectSequence)& theObjects, const OptionsForAttach& theOptions)
382 if (theObjects->Size() < 1)
387 SetOwner (theObjects);
389 const Handle(AIS_InteractiveObject)& aCurObject = theObjects->Value (theObjects->Lower());
390 aCurObject->BoundingBox (aBox);
392 if (theOptions.AdjustPosition)
397 if (theOptions.AdjustSize)
402 const Handle(AIS_InteractiveContext)& aContext = Object()->GetContext();
403 if (!aContext.IsNull())
405 if (!aContext->IsDisplayed (this))
407 aContext->Display (this, Standard_False);
411 aContext->Update (this, Standard_False);
412 aContext->RecomputeSelectionOnly (this);
415 aContext->Load (this);
418 if (theOptions.EnableModes)
420 EnableMode (AIS_MM_Rotation);
421 EnableMode (AIS_MM_Translation);
422 EnableMode (AIS_MM_Scaling);
423 EnableMode (AIS_MM_TranslationPlane);
427 //=======================================================================
430 //=======================================================================
431 void AIS_Manipulator::Detach()
433 DeactivateCurrentMode();
440 Handle(AIS_InteractiveObject) anObject = Object();
441 const Handle(AIS_InteractiveContext)& aContext = anObject->GetContext();
442 if (!aContext.IsNull())
444 aContext->Remove (this, Standard_False);
450 //=======================================================================
453 //=======================================================================
454 Handle(AIS_ManipulatorObjectSequence) AIS_Manipulator::Objects() const
456 return Handle(AIS_ManipulatorObjectSequence)::DownCast (GetOwner());
459 //=======================================================================
462 //=======================================================================
463 Handle(AIS_InteractiveObject) AIS_Manipulator::Object (const Standard_Integer theIndex) const
465 Handle(AIS_ManipulatorObjectSequence) anOwner = Handle(AIS_ManipulatorObjectSequence)::DownCast (GetOwner());
467 Standard_ProgramError_Raise_if (theIndex < anOwner->Lower() || theIndex > anOwner->Upper(), "AIS_Manipulator::Object(): wrong index value");
469 if (anOwner.IsNull() || anOwner->IsEmpty())
474 return anOwner->Value (theIndex);
477 //=======================================================================
480 //=======================================================================
481 Handle(AIS_InteractiveObject) AIS_Manipulator::Object() const
486 //=======================================================================
487 //function : ObjectTransformation
489 //=======================================================================
490 Standard_Boolean AIS_Manipulator::ObjectTransformation (const Standard_Integer theMaxX, const Standard_Integer theMaxY,
491 const Handle(V3d_View)& theView, gp_Trsf& theTrsf)
493 // Initialize start reference data
494 if (!myHasStartedTransformation)
496 myStartTrsfs.Clear();
497 Handle(AIS_ManipulatorObjectSequence) anObjects = Objects();
498 for (AIS_ManipulatorObjectSequence::Iterator anObjIter (*anObjects); anObjIter.More(); anObjIter.Next())
500 myStartTrsfs.Append (anObjIter.Value()->LocalTransformation());
502 myStartPosition = myPosition;
505 // Get 3d point with projection vector
506 Graphic3d_Vec3d anInputPoint, aProj;
507 theView->ConvertWithProj (theMaxX, theMaxY, anInputPoint.x(), anInputPoint.y(), anInputPoint.z(), aProj.x(), aProj.y(), aProj.z());
508 const gp_Lin anInputLine (gp_Pnt (anInputPoint.x(), anInputPoint.y(), anInputPoint.z()), gp_Dir (aProj.x(), aProj.y(), aProj.z()));
509 switch (myCurrentMode)
511 case AIS_MM_Translation:
514 const gp_Lin aLine (myStartPosition.Location(), myAxes[myCurrentIndex].Position().Direction());
515 Extrema_ExtElC anExtrema (anInputLine, aLine, Precision::Angular());
516 if (!anExtrema.IsDone()
517 || anExtrema.IsParallel()
518 || anExtrema.NbExt() != 1)
520 // translation cannot be done co-directed with camera
521 return Standard_False;
524 Extrema_POnCurv anExPnts[2];
525 anExtrema.Points (1, anExPnts[0], anExPnts[1]);
526 const gp_Pnt aNewPosition = anExPnts[1].Value();
527 if (!myHasStartedTransformation)
529 myStartPick = aNewPosition;
530 myHasStartedTransformation = Standard_True;
531 return Standard_True;
533 else if (aNewPosition.Distance (myStartPick) < Precision::Confusion())
535 return Standard_False;
539 if (myCurrentMode == AIS_MM_Translation)
541 aNewTrsf.SetTranslation (gp_Vec(myStartPick, aNewPosition));
544 else if (myCurrentMode == AIS_MM_Scaling)
546 if (aNewPosition.Distance (myStartPosition.Location()) < Precision::Confusion())
548 return Standard_False;
551 Standard_Real aCoeff = myStartPosition.Location().Distance (aNewPosition)
552 / myStartPosition.Location().Distance (myStartPick);
553 aNewTrsf.SetScale (myPosition.Location(), aCoeff);
556 return Standard_True;
558 case AIS_MM_Rotation:
560 const gp_Pnt aPosLoc = myStartPosition.Location();
561 const gp_Ax1 aCurrAxis = getAx1FromAx2Dir (myStartPosition, myCurrentIndex);
562 IntAna_IntConicQuad aIntersector (anInputLine, gp_Pln (aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
563 if (!aIntersector.IsDone()
564 || aIntersector.IsParallel()
565 || aIntersector.NbPoints() < 1)
567 return Standard_False;
570 const gp_Pnt aNewPosition = aIntersector.Point (1);
571 if (!myHasStartedTransformation)
573 myStartPick = aNewPosition;
574 myHasStartedTransformation = Standard_True;
575 gp_Dir aStartAxis = gce_MakeDir (aPosLoc, myStartPick);
576 myPrevState = aStartAxis.AngleWithRef (gce_MakeDir(aPosLoc, aNewPosition), aCurrAxis.Direction());
577 return Standard_True;
580 if (aNewPosition.Distance (myStartPick) < Precision::Confusion())
582 return Standard_False;
585 gp_Dir aStartAxis = aPosLoc.IsEqual (myStartPick, Precision::Confusion())
586 ? getAx1FromAx2Dir (myStartPosition, (myCurrentIndex + 1) % 3).Direction()
587 : gce_MakeDir (aPosLoc, myStartPick);
589 gp_Dir aCurrentAxis = gce_MakeDir (aPosLoc, aNewPosition);
590 Standard_Real anAngle = aStartAxis.AngleWithRef (aCurrentAxis, aCurrAxis.Direction());
592 // Change value of an angle if it should have different sign.
593 if (anAngle * myPrevState < 0 && Abs (anAngle) < M_PI_2)
595 Standard_Real aSign = myPrevState > 0 ? -1.0 : 1.0;
596 anAngle = aSign * (M_PI * 2 - anAngle);
599 if (Abs (anAngle) < Precision::Confusion())
601 return Standard_False;
605 aNewTrsf.SetRotation (aCurrAxis, anAngle);
607 myPrevState = anAngle;
608 return Standard_True;
610 case AIS_MM_TranslationPlane:
612 const gp_Pnt aPosLoc = myStartPosition.Location();
613 const gp_Ax1 aCurrAxis = getAx1FromAx2Dir(myStartPosition, myCurrentIndex);
614 IntAna_IntConicQuad aIntersector(anInputLine, gp_Pln(aPosLoc, aCurrAxis.Direction()), Precision::Angular(), Precision::Intersection());
615 if (!aIntersector.IsDone() || aIntersector.NbPoints() < 1)
617 return Standard_False;
620 const gp_Pnt aNewPosition = aIntersector.Point(1);
621 if (!myHasStartedTransformation)
623 myStartPick = aNewPosition;
624 myHasStartedTransformation = Standard_True;
625 return Standard_True;
628 if (aNewPosition.Distance(myStartPick) < Precision::Confusion())
630 return Standard_False;
634 aNewTrsf.SetTranslation(gp_Vec(myStartPick, aNewPosition));
636 return Standard_True;
640 return Standard_False;
643 return Standard_False;
646 //=======================================================================
647 //function : StartTransform
649 //=======================================================================
650 void AIS_Manipulator::StartTransform (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView)
652 if (myHasStartedTransformation)
658 ObjectTransformation (theX, theY, theView, aTrsf);
661 //=======================================================================
662 //function : StopTransform
664 //=======================================================================
665 void AIS_Manipulator::StopTransform (const Standard_Boolean theToApply)
667 if (!IsAttached() || !myHasStartedTransformation)
672 myHasStartedTransformation = Standard_False;
678 Handle(AIS_ManipulatorObjectSequence) anObjects = Objects();
679 AIS_ManipulatorObjectSequence::Iterator anObjIter (*anObjects);
680 NCollection_Sequence<gp_Trsf>::Iterator aTrsfIter (myStartTrsfs);
681 for (; anObjIter.More(); anObjIter.Next(), aTrsfIter.Next())
683 anObjIter.ChangeValue()->SetLocalTransformation (aTrsfIter.Value());
685 SetPosition (myStartPosition);
688 //=======================================================================
689 //function : Transform
691 //=======================================================================
692 void AIS_Manipulator::Transform (const gp_Trsf& theTrsf)
694 if (!IsAttached() || !myHasStartedTransformation)
700 Handle(AIS_ManipulatorObjectSequence) anObjects = Objects();
701 AIS_ManipulatorObjectSequence::Iterator anObjIter (*anObjects);
702 NCollection_Sequence<gp_Trsf>::Iterator aTrsfIter (myStartTrsfs);
703 for (; anObjIter.More(); anObjIter.Next(), aTrsfIter.Next())
705 anObjIter.ChangeValue()->SetLocalTransformation (theTrsf * aTrsfIter.Value());
709 if ((myCurrentMode == AIS_MM_Translation && myBehaviorOnTransform.FollowTranslation)
710 || (myCurrentMode == AIS_MM_Rotation && myBehaviorOnTransform.FollowRotation)
711 || (myCurrentMode == AIS_MM_TranslationPlane && myBehaviorOnTransform.FollowDragging))
713 gp_Pnt aPos = myStartPosition.Location().Transformed (theTrsf);
714 gp_Dir aVDir = myStartPosition.Direction().Transformed (theTrsf);
715 gp_Dir aXDir = myStartPosition.XDirection().Transformed (theTrsf);
716 SetPosition (gp_Ax2 (aPos, aVDir, aXDir));
720 //=======================================================================
721 //function : Transform
723 //=======================================================================
724 gp_Trsf AIS_Manipulator::Transform (const Standard_Integer thePX, const Standard_Integer thePY,
725 const Handle(V3d_View)& theView)
728 if (ObjectTransformation (thePX, thePY, theView, aTrsf))
736 //=======================================================================
737 //function : SetPosition
739 //=======================================================================
740 void AIS_Manipulator::SetPosition (const gp_Ax2& thePosition)
742 if (!myPosition.Location().IsEqual (thePosition.Location(), Precision::Confusion())
743 || !myPosition.Direction().IsEqual (thePosition.Direction(), Precision::Angular())
744 || !myPosition.XDirection().IsEqual (thePosition.XDirection(), Precision::Angular()))
746 myPosition = thePosition;
747 myAxes[0].SetPosition (getAx1FromAx2Dir (thePosition, 0));
748 myAxes[1].SetPosition (getAx1FromAx2Dir (thePosition, 1));
749 myAxes[2].SetPosition (getAx1FromAx2Dir (thePosition, 2));
750 updateTransformation();
754 //=======================================================================
755 //function : updateTransformation
756 //purpose : set local transformation to avoid graphics recomputation
757 //=======================================================================
758 void AIS_Manipulator::updateTransformation()
762 if (!myIsZoomPersistentMode)
764 aTrsf.SetTransformation (myPosition, gp::XOY());
768 const gp_Dir& aVDir = myPosition.Direction();
769 const gp_Dir& aXDir = myPosition.XDirection();
770 aTrsf.SetTransformation (gp_Ax2 (gp::Origin(), aVDir, aXDir), gp::XOY());
773 Handle(Geom_Transformation) aGeomTrsf = new Geom_Transformation (aTrsf);
774 // we explicitly call here setLocalTransformation() of the base class
775 // since AIS_Manipulator::setLocalTransformation() implementation throws exception
776 // as protection from external calls
777 AIS_InteractiveObject::setLocalTransformation (aGeomTrsf);
778 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
780 myAxes[anIt].Transform (aGeomTrsf);
783 if (myIsZoomPersistentMode)
785 if (TransformPersistence().IsNull()
786 || TransformPersistence()->Mode() != Graphic3d_TMF_ZoomPers
787 || !TransformPersistence()->AnchorPoint().IsEqual (myPosition.Location(), 0.0))
789 setTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, myPosition.Location()));
794 //=======================================================================
797 //=======================================================================
798 void AIS_Manipulator::SetSize (const Standard_ShortReal theSideLength)
800 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
802 myAxes[anIt].SetSize (theSideLength);
808 //=======================================================================
811 //=======================================================================
812 void AIS_Manipulator::SetGap (const Standard_ShortReal theValue)
814 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
816 myAxes[anIt].SetIndent (theValue);
822 //=======================================================================
823 //function : DeactivateCurrentMode
825 //=======================================================================
826 void AIS_Manipulator::DeactivateCurrentMode()
828 if (!myIsActivationOnDetection)
830 Handle(Graphic3d_Group) aGroup = getGroup (myCurrentIndex, myCurrentMode);
836 Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect();
837 anAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
838 anAspect->SetMaterial (myDrawer->ShadingAspect()->Material());
839 if (myCurrentMode == AIS_MM_TranslationPlane)
840 anAspect->SetTransparency(1.0);
843 anAspect->SetTransparency(myDrawer->ShadingAspect()->Transparency());
844 anAspect->SetColor(myAxes[myCurrentIndex].Color());
847 aGroup->SetGroupPrimitivesAspect (anAspect->Aspect());
851 myCurrentMode = AIS_MM_None;
853 if (myHasStartedTransformation)
855 myHasStartedTransformation = Standard_False;
859 //=======================================================================
860 //function : SetZoomPersistence
862 //=======================================================================
863 void AIS_Manipulator::SetZoomPersistence (const Standard_Boolean theToEnable)
865 if (myIsZoomPersistentMode != theToEnable)
870 myIsZoomPersistentMode = theToEnable;
874 setTransformPersistence (Handle(Graphic3d_TransformPers)());
877 updateTransformation();
880 //=======================================================================
881 //function : SetTransformPersistence
883 //=======================================================================
884 void AIS_Manipulator::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
886 Standard_ASSERT_RETURN (!myIsZoomPersistentMode,
887 "AIS_Manipulator::SetTransformPersistence: "
888 "Custom settings are not allowed by this class in ZoomPersistence mode",);
890 setTransformPersistence (theTrsfPers);
893 //=======================================================================
894 //function : setTransformPersistence
896 //=======================================================================
897 void AIS_Manipulator::setTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
899 AIS_InteractiveObject::SetTransformPersistence (theTrsfPers);
901 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
903 myAxes[anIt].SetTransformPersistence (theTrsfPers);
907 //=======================================================================
908 //function : setLocalTransformation
910 //=======================================================================
911 void AIS_Manipulator::setLocalTransformation (const Handle(Geom_Transformation)& /*theTrsf*/)
913 Standard_ASSERT_INVOKE ("AIS_Manipulator::setLocalTransformation: "
914 "Custom transformation is not supported by this class");
917 //=======================================================================
920 //=======================================================================
921 void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
922 const Handle(Prs3d_Presentation)& thePrs,
923 const Standard_Integer theMode)
925 if (theMode != AIS_Shaded)
930 thePrs->SetInfiniteState (Standard_True);
931 thePrs->SetMutable (Standard_True);
932 Handle(Graphic3d_Group) aGroup;
933 Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect();
934 anAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
935 anAspect->SetMaterial (myDrawer->ShadingAspect()->Material());
936 anAspect->SetTransparency (myDrawer->ShadingAspect()->Transparency());
939 myCenter.Init (myAxes[0].AxisRadius() * 2.0f, gp::Origin());
940 aGroup = thePrs->NewGroup ();
941 aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
942 aGroup->AddPrimitiveArray (myCenter.Array());
944 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
947 aGroup = thePrs->NewGroup ();
949 Handle(Prs3d_ShadingAspect) anAspectAx = new Prs3d_ShadingAspect (new Graphic3d_AspectFillArea3d(*anAspect->Aspect()));
950 anAspectAx->SetColor (myAxes[anIt].Color());
951 aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect());
952 myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx);
953 myAxes[anIt].SetTransformPersistence (TransformPersistence());
956 updateTransformation();
959 //=======================================================================
960 //function : HilightSelected
962 //=======================================================================
963 void AIS_Manipulator::HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
964 const SelectMgr_SequenceOfOwner& theSeq)
966 if (theSeq.IsEmpty())
971 if (myIsActivationOnDetection)
976 if (!theSeq (1)->IsKind (STANDARD_TYPE (AIS_ManipulatorOwner)))
978 thePM->Color (this, GetContext()->HighlightStyle(), 0);
982 Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theSeq (1));
983 myHighlightAspect->Aspect()->SetInteriorColor (GetContext()->HighlightStyle()->Color());
984 Handle(Graphic3d_Group) aGroup = getGroup (anOwner->Index(), anOwner->Mode());
990 if (anOwner->Mode() == AIS_MM_TranslationPlane)
992 myDraggerHighlight->SetColor(myAxes[anOwner->Index()].Color());
993 aGroup->SetGroupPrimitivesAspect(myDraggerHighlight->Aspect());
996 aGroup->SetGroupPrimitivesAspect(myHighlightAspect->Aspect());
998 myCurrentIndex = anOwner->Index();
999 myCurrentMode = anOwner->Mode();
1002 //=======================================================================
1003 //function : ClearSelected
1005 //=======================================================================
1006 void AIS_Manipulator::ClearSelected()
1008 DeactivateCurrentMode();
1011 //=======================================================================
1012 //function : HilightOwnerWithColor
1014 //=======================================================================
1015 void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
1016 const Handle(Prs3d_Drawer)& theStyle,
1017 const Handle(SelectMgr_EntityOwner)& theOwner)
1019 Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theOwner);
1020 Handle(Prs3d_Presentation) aPresentation = getHighlightPresentation (anOwner);
1021 if (aPresentation.IsNull())
1025 if (anOwner->Mode() == AIS_MM_TranslationPlane)
1027 Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer();
1028 aStyle->SetColor(myAxes[anOwner->Index()].Color());
1029 aStyle->SetTransparency(0.5);
1030 aPresentation->Highlight(aStyle);
1033 aPresentation->Highlight(theStyle);
1034 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
1035 aGroupIter.More(); aGroupIter.Next())
1037 Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
1040 aGrp->SetGroupPrimitivesAspect (myHighlightAspect->Aspect());
1043 aPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost);
1044 thePM->AddToImmediateList (aPresentation);
1046 if (myIsActivationOnDetection)
1048 if (HasActiveMode())
1050 DeactivateCurrentMode();
1053 myCurrentIndex = anOwner->Index();
1054 myCurrentMode = anOwner->Mode();
1058 //=======================================================================
1059 //function : ComputeSelection
1061 //=======================================================================
1062 void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
1063 const Standard_Integer theMode)
1066 AIS_ManipulatorMode aMode = (AIS_ManipulatorMode) theMode;
1067 if (aMode == AIS_MM_None)
1071 Handle(SelectMgr_EntityOwner) anOwner;
1072 if (aMode == AIS_MM_None)
1074 anOwner = new SelectMgr_EntityOwner (this, 5);
1077 if (aMode == AIS_MM_Translation || aMode == AIS_MM_None)
1079 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
1081 if (!myAxes[anIt].HasTranslation())
1085 const Axis& anAxis = myAxes[anIt];
1086 if (aMode != AIS_MM_None)
1088 anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Translation, 9);
1090 // define sensitivity by line
1091 Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment (anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
1092 aLine->SetSensitivityFactor (15);
1093 theSelection->Add (aLine);
1095 // enlarge sensitivity by triangulation
1096 Handle(Select3D_SensitivePrimitiveArray) aTri = new Select3D_SensitivePrimitiveArray (anOwner);
1097 aTri->InitTriangulation (anAxis.TriangleArray()->Attributes(), anAxis.TriangleArray()->Indices(), TopLoc_Location());
1098 theSelection->Add (aTri);
1102 if (aMode == AIS_MM_Rotation || aMode == AIS_MM_None)
1104 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
1106 if (!myAxes[anIt].HasRotation())
1110 const Axis& anAxis = myAxes[anIt];
1111 if (aMode != AIS_MM_None)
1113 anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Rotation, 9);
1115 // define sensitivity by circle
1116 Handle(Geom_Circle) aGeomCircle = new Geom_Circle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
1117 Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle, anAxis.FacettesNumber());
1118 aCircle->SetSensitivityFactor (15);
1119 theSelection->Add (aCircle);
1120 // enlarge sensitivity by triangulation
1121 Handle(Select3D_SensitiveTriangulation) aTri = new ManipSensTriangulation (anOwner, myAxes[anIt].RotatorDisk().Triangulation(), anAxis.ReferenceAxis().Direction());
1122 theSelection->Add (aTri);
1126 if (aMode == AIS_MM_Scaling || aMode == AIS_MM_None)
1128 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
1130 if (!myAxes[anIt].HasScaling())
1134 if (aMode != AIS_MM_None)
1136 anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Scaling, 9);
1138 // define sensitivity by point
1139 Handle(Select3D_SensitivePoint) aPnt = new Select3D_SensitivePoint (anOwner, myAxes[anIt].ScalerCubePosition());
1140 aPnt->SetSensitivityFactor (15);
1141 theSelection->Add (aPnt);
1142 // enlarge sensitivity by triangulation
1143 Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
1144 theSelection->Add (aTri);
1148 if (aMode == AIS_MM_TranslationPlane || aMode == AIS_MM_None)
1150 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
1152 if (!myAxes[anIt].HasDragging())
1156 if (aMode != AIS_MM_None)
1158 anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_TranslationPlane, 9);
1161 // define sensitivity by two crossed lines
1163 aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition();
1164 aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition();
1165 gp_XYZ aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
1167 Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
1168 aLine1->SetSensitivityFactor(10);
1169 theSelection->Add(aLine1);
1170 Handle(Select3D_SensitiveSegment) aLine2 = new Select3D_SensitiveSegment(anOwner, gp::Origin(), aMidP);
1171 aLine2->SetSensitivityFactor(10);
1172 theSelection->Add(aLine2);
1174 // enlarge sensitivity by triangulation
1175 Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].DraggerSector().Triangulation(), TopLoc_Location(), Standard_True);
1176 theSelection->Add(aTri);
1181 //=======================================================================
1185 //=======================================================================
1186 void AIS_Manipulator::Disk::Init (const Standard_ShortReal theInnerRadius,
1187 const Standard_ShortReal theOuterRadius,
1188 const gp_Ax1& thePosition,
1189 const Standard_Integer theSlicesNb,
1190 const Standard_Integer theStacksNb)
1192 myPosition = thePosition;
1193 myInnerRad = theInnerRadius;
1194 myOuterRad = theOuterRadius;
1196 Prs3d_ToolDisk aTool (theInnerRadius, theOuterRadius, theSlicesNb, theStacksNb);
1197 gp_Ax3 aSystem (myPosition.Location(), myPosition.Direction());
1199 aTrsf.SetTransformation (aSystem, gp_Ax3());
1200 aTool.FillArray (myArray, myTriangulation, aTrsf);
1203 //=======================================================================
1207 //=======================================================================
1208 void AIS_Manipulator::Sphere::Init (const Standard_ShortReal theRadius,
1209 const gp_Pnt& thePosition,
1210 const Standard_Integer theSlicesNb,
1211 const Standard_Integer theStacksNb)
1213 myPosition = thePosition;
1214 myRadius = theRadius;
1216 Prs3d_ToolSphere aTool (theRadius, theSlicesNb, theStacksNb);
1218 aTrsf.SetTranslation (gp_Vec(gp::Origin(), thePosition));
1219 aTool.FillArray (myArray, myTriangulation, aTrsf);
1222 //=======================================================================
1226 //=======================================================================
1227 void AIS_Manipulator::Cube::Init (const gp_Ax1& thePosition, const Standard_ShortReal theSize)
1229 myArray = new Graphic3d_ArrayOfTriangles (12 * 3, 0, Standard_True);
1231 Poly_Array1OfTriangle aPolyTriangles (1, 12);
1232 TColgp_Array1OfPnt aPoints (1, 36);
1233 NCollection_Array1<gp_Dir> aNormals (1, 12);
1234 myTriangulation = new Poly_Triangulation (aPoints, aPolyTriangles);
1236 gp_Ax2 aPln (thePosition.Location(), thePosition.Direction());
1237 gp_Pnt aBottomLeft = thePosition.Location().XYZ() - aPln.XDirection().XYZ() * theSize * 0.5 - aPln.YDirection().XYZ() * theSize * 0.5;
1238 gp_Pnt aV2 = aBottomLeft.XYZ() + aPln.YDirection().XYZ() * theSize;
1239 gp_Pnt aV3 = aBottomLeft.XYZ() + aPln.YDirection().XYZ() * theSize + aPln.XDirection().XYZ() * theSize;
1240 gp_Pnt aV4 = aBottomLeft.XYZ() + aPln.XDirection().XYZ() * theSize;
1241 gp_Pnt aTopRight = thePosition.Location().XYZ() + thePosition.Direction().XYZ() * theSize
1242 + aPln.XDirection().XYZ() * theSize * 0.5 + aPln.YDirection().XYZ() * theSize * 0.5;
1243 gp_Pnt aV5 = aTopRight.XYZ() - aPln.YDirection().XYZ() * theSize;
1244 gp_Pnt aV6 = aTopRight.XYZ() - aPln.YDirection().XYZ() * theSize - aPln.XDirection().XYZ() * theSize;
1245 gp_Pnt aV7 = aTopRight.XYZ() - aPln.XDirection().XYZ() * theSize;
1247 gp_Dir aRight ((gp_Vec(aTopRight, aV7) ^ gp_Vec(aTopRight, aV2)).XYZ());
1248 gp_Dir aFront ((gp_Vec(aV3, aV4) ^ gp_Vec(aV3, aV5)).XYZ());
1251 addTriangle (0, aBottomLeft, aV2, aV3, -thePosition.Direction());
1252 addTriangle (1, aBottomLeft, aV3, aV4, -thePosition.Direction());
1255 addTriangle (2, aV3, aV4, aV5, aFront);
1256 addTriangle (3, aV3, aV5, aTopRight, aFront);
1259 addTriangle (4, aBottomLeft, aV2, aV7, -aFront);
1260 addTriangle (5, aBottomLeft, aV7, aV6, -aFront);
1263 addTriangle (6, aV7, aV6, aV5, thePosition.Direction());
1264 addTriangle (7, aTopRight, aV7, aV5, thePosition.Direction());
1267 addTriangle (8, aV6, aV5, aV4, -aRight);
1268 addTriangle (9, aBottomLeft, aV6, aV4, -aRight);
1271 addTriangle (10, aV3, aTopRight, aV7, aRight);
1272 addTriangle (11, aV3, aV7, aV2, aRight);
1275 //=======================================================================
1277 //function : addTriangle
1279 //=======================================================================
1280 void AIS_Manipulator::Cube::addTriangle (const Standard_Integer theIndex,
1281 const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3,
1282 const gp_Dir& theNormal)
1284 myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 1, theP1);
1285 myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 2, theP2);
1286 myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 3, theP3);
1288 myTriangulation->ChangeTriangles().SetValue (theIndex + 1, Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3));
1289 myArray->AddVertex (theP1, theNormal);
1290 myArray->AddVertex (theP2, theNormal);
1291 myArray->AddVertex (theP3, theNormal);
1294 //=======================================================================
1298 //=======================================================================
1299 void AIS_Manipulator::Sector::Init (const Standard_ShortReal theRadius,
1300 const gp_Ax1& thePosition,
1301 const gp_Dir& theXDirection,
1302 const Standard_Integer theSlicesNb,
1303 const Standard_Integer theStacksNb)
1305 Prs3d_ToolSector aTool(theRadius, theSlicesNb, theStacksNb);
1306 gp_Ax3 aSystem(thePosition.Location(), thePosition.Direction(), theXDirection);
1308 aTrsf.SetTransformation(aSystem, gp_Ax3());
1309 aTool.FillArray(myArray, myTriangulation, aTrsf);
1312 //=======================================================================
1314 //function : Constructor
1316 //=======================================================================
1317 AIS_Manipulator::Axis::Axis (const gp_Ax1& theAxis,
1318 const Quantity_Color& theColor,
1319 const Standard_ShortReal theLength)
1320 : myReferenceAxis (theAxis),
1321 myPosition (theAxis),
1323 myHasTranslation (Standard_True),
1324 myLength (theLength),
1325 myAxisRadius (0.5f),
1326 myHasScaling (Standard_True),
1328 myHasRotation (Standard_True),
1329 myInnerRadius (myLength + myBoxSize),
1330 myDiskThickness (myBoxSize * 0.5f),
1332 myHasDragging(Standard_True),
1333 myFacettesNumber (20),
1334 myCircleRadius (myLength + myBoxSize + myBoxSize * 0.5f * 0.5f)
1339 //=======================================================================
1341 //function : Compute
1343 //=======================================================================
1345 void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
1346 const Handle(Prs3d_Presentation)& thePrs,
1347 const Handle(Prs3d_ShadingAspect)& theAspect)
1349 if (myHasTranslation)
1351 const Standard_Real anArrowLength = 0.25 * myLength;
1352 const Standard_Real aCylinderLength = myLength - anArrowLength;
1353 myArrowTipPos = gp_Pnt (0.0, 0.0, 0.0).Translated (myReferenceAxis.Direction().XYZ() * aCylinderLength);
1355 myTriangleArray = Prs3d_Arrow::DrawShaded (gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
1361 myTranslatorGroup = thePrs->NewGroup ();
1362 myTranslatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1363 myTranslatorGroup->AddPrimitiveArray (myTriangleArray);
1365 if (myHighlightTranslator.IsNull())
1367 myHighlightTranslator = new Prs3d_Presentation (thePrsMgr->StructureManager());
1371 myHighlightTranslator->Clear();
1374 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightTranslator);
1375 aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1376 aGroup->AddPrimitiveArray (myTriangleArray);
1382 myCubePos = myReferenceAxis.Direction().XYZ() * (myLength + myIndent);
1383 myCube.Init (gp_Ax1 (myCubePos, myReferenceAxis.Direction()), myBoxSize);
1385 myScalerGroup = thePrs->NewGroup ();
1386 myScalerGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1387 myScalerGroup->AddPrimitiveArray (myCube.Array());
1389 if (myHighlightScaler.IsNull())
1391 myHighlightScaler = new Prs3d_Presentation (thePrsMgr->StructureManager());
1395 myHighlightScaler->Clear();
1398 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightScaler);
1399 aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1400 aGroup->AddPrimitiveArray (myCube.Array());
1406 myCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f;
1407 myCircle.Init (myInnerRadius + myIndent * 2, myInnerRadius + myDiskThickness + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), myFacettesNumber * 2);
1408 myRotatorGroup = thePrs->NewGroup ();
1409 myRotatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1410 myRotatorGroup->AddPrimitiveArray (myCircle.Array());
1412 if (myHighlightRotator.IsNull())
1414 myHighlightRotator = new Prs3d_Presentation (thePrsMgr->StructureManager());
1418 myHighlightRotator->Clear();
1421 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightRotator);
1422 aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1423 aGroup->AddPrimitiveArray (myCircle.Array());
1430 if (myReferenceAxis.Direction().X() > 0)
1431 aXDirection = gp::DY();
1432 else if (myReferenceAxis.Direction().Y() > 0)
1433 aXDirection = gp::DZ();
1435 aXDirection = gp::DX();
1437 mySector.Init(myInnerRadius + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), aXDirection, myFacettesNumber * 2);
1438 myDraggerGroup = thePrs->NewGroup();
1440 Handle(Graphic3d_AspectFillArea3d) aFillArea = new Graphic3d_AspectFillArea3d();
1441 myDraggerGroup->SetGroupPrimitivesAspect(aFillArea);
1442 myDraggerGroup->AddPrimitiveArray(mySector.Array());
1444 if (myHighlightDragger.IsNull())
1446 myHighlightDragger = new Prs3d_Presentation(thePrsMgr->StructureManager());
1450 myHighlightDragger->Clear();
1453 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(myHighlightDragger);
1454 aGroup->SetGroupPrimitivesAspect(aFillArea);
1455 aGroup->AddPrimitiveArray(mySector.Array());