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(SelectMgr_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(SelectMgr_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 const Handle(AIS_InteractiveObject)& anObj = anObjIter.ChangeValue();
706 const gp_Trsf& anOldTrsf = aTrsfIter.Value();
707 const Handle(Geom_Transformation)& aParentTrsf = anObj->CombinedParentTransformation();
708 if (!aParentTrsf.IsNull()
709 && aParentTrsf->Form() != gp_Identity)
711 // recompute local transformation relative to parent transformation
712 const gp_Trsf aNewLocalTrsf = aParentTrsf->Trsf().Inverted() * theTrsf * aParentTrsf->Trsf() * anOldTrsf;
713 anObj->SetLocalTransformation (aNewLocalTrsf);
717 anObj->SetLocalTransformation (theTrsf * anOldTrsf);
722 if ((myCurrentMode == AIS_MM_Translation && myBehaviorOnTransform.FollowTranslation)
723 || (myCurrentMode == AIS_MM_Rotation && myBehaviorOnTransform.FollowRotation)
724 || (myCurrentMode == AIS_MM_TranslationPlane && myBehaviorOnTransform.FollowDragging))
726 gp_Pnt aPos = myStartPosition.Location().Transformed (theTrsf);
727 gp_Dir aVDir = myStartPosition.Direction().Transformed (theTrsf);
728 gp_Dir aXDir = myStartPosition.XDirection().Transformed (theTrsf);
729 SetPosition (gp_Ax2 (aPos, aVDir, aXDir));
733 //=======================================================================
734 //function : Transform
736 //=======================================================================
737 gp_Trsf AIS_Manipulator::Transform (const Standard_Integer thePX, const Standard_Integer thePY,
738 const Handle(V3d_View)& theView)
741 if (ObjectTransformation (thePX, thePY, theView, aTrsf))
749 //=======================================================================
750 //function : SetPosition
752 //=======================================================================
753 void AIS_Manipulator::SetPosition (const gp_Ax2& thePosition)
755 if (!myPosition.Location().IsEqual (thePosition.Location(), Precision::Confusion())
756 || !myPosition.Direction().IsEqual (thePosition.Direction(), Precision::Angular())
757 || !myPosition.XDirection().IsEqual (thePosition.XDirection(), Precision::Angular()))
759 myPosition = thePosition;
760 myAxes[0].SetPosition (getAx1FromAx2Dir (thePosition, 0));
761 myAxes[1].SetPosition (getAx1FromAx2Dir (thePosition, 1));
762 myAxes[2].SetPosition (getAx1FromAx2Dir (thePosition, 2));
763 updateTransformation();
767 //=======================================================================
768 //function : updateTransformation
769 //purpose : set local transformation to avoid graphics recomputation
770 //=======================================================================
771 void AIS_Manipulator::updateTransformation()
775 if (!myIsZoomPersistentMode)
777 aTrsf.SetTransformation (myPosition, gp::XOY());
781 const gp_Dir& aVDir = myPosition.Direction();
782 const gp_Dir& aXDir = myPosition.XDirection();
783 aTrsf.SetTransformation (gp_Ax2 (gp::Origin(), aVDir, aXDir), gp::XOY());
786 Handle(Geom_Transformation) aGeomTrsf = new Geom_Transformation (aTrsf);
787 // we explicitly call here setLocalTransformation() of the base class
788 // since AIS_Manipulator::setLocalTransformation() implementation throws exception
789 // as protection from external calls
790 AIS_InteractiveObject::setLocalTransformation (aGeomTrsf);
791 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
793 myAxes[anIt].Transform (aGeomTrsf);
796 if (myIsZoomPersistentMode)
798 if (TransformPersistence().IsNull()
799 || TransformPersistence()->Mode() != Graphic3d_TMF_ZoomPers
800 || !TransformPersistence()->AnchorPoint().IsEqual (myPosition.Location(), 0.0))
802 setTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, myPosition.Location()));
807 //=======================================================================
810 //=======================================================================
811 void AIS_Manipulator::SetSize (const Standard_ShortReal theSideLength)
813 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
815 myAxes[anIt].SetSize (theSideLength);
821 //=======================================================================
824 //=======================================================================
825 void AIS_Manipulator::SetGap (const Standard_ShortReal theValue)
827 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
829 myAxes[anIt].SetIndent (theValue);
835 //=======================================================================
836 //function : DeactivateCurrentMode
838 //=======================================================================
839 void AIS_Manipulator::DeactivateCurrentMode()
841 if (!myIsActivationOnDetection)
843 Handle(Graphic3d_Group) aGroup = getGroup (myCurrentIndex, myCurrentMode);
849 Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect();
850 anAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
851 anAspect->SetMaterial (myDrawer->ShadingAspect()->Material());
852 if (myCurrentMode == AIS_MM_TranslationPlane)
853 anAspect->SetTransparency(1.0);
856 anAspect->SetTransparency(myDrawer->ShadingAspect()->Transparency());
857 anAspect->SetColor(myAxes[myCurrentIndex].Color());
860 aGroup->SetGroupPrimitivesAspect (anAspect->Aspect());
864 myCurrentMode = AIS_MM_None;
866 if (myHasStartedTransformation)
868 myHasStartedTransformation = Standard_False;
872 //=======================================================================
873 //function : SetZoomPersistence
875 //=======================================================================
876 void AIS_Manipulator::SetZoomPersistence (const Standard_Boolean theToEnable)
878 if (myIsZoomPersistentMode != theToEnable)
883 myIsZoomPersistentMode = theToEnable;
887 setTransformPersistence (Handle(Graphic3d_TransformPers)());
890 updateTransformation();
893 //=======================================================================
894 //function : SetTransformPersistence
896 //=======================================================================
897 void AIS_Manipulator::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
899 Standard_ASSERT_RETURN (!myIsZoomPersistentMode,
900 "AIS_Manipulator::SetTransformPersistence: "
901 "Custom settings are not allowed by this class in ZoomPersistence mode",);
903 setTransformPersistence (theTrsfPers);
906 //=======================================================================
907 //function : setTransformPersistence
909 //=======================================================================
910 void AIS_Manipulator::setTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
912 AIS_InteractiveObject::SetTransformPersistence (theTrsfPers);
914 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
916 myAxes[anIt].SetTransformPersistence (theTrsfPers);
920 //=======================================================================
921 //function : setLocalTransformation
923 //=======================================================================
924 void AIS_Manipulator::setLocalTransformation (const Handle(Geom_Transformation)& /*theTrsf*/)
926 Standard_ASSERT_INVOKE ("AIS_Manipulator::setLocalTransformation: "
927 "Custom transformation is not supported by this class");
930 //=======================================================================
933 //=======================================================================
934 void AIS_Manipulator::Compute (const Handle(PrsMgr_PresentationManager3d)& thePrsMgr,
935 const Handle(Prs3d_Presentation)& thePrs,
936 const Standard_Integer theMode)
938 if (theMode != AIS_Shaded)
943 thePrs->SetInfiniteState (Standard_True);
944 thePrs->SetMutable (Standard_True);
945 Handle(Graphic3d_Group) aGroup;
946 Handle(Prs3d_ShadingAspect) anAspect = new Prs3d_ShadingAspect();
947 anAspect->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
948 anAspect->SetMaterial (myDrawer->ShadingAspect()->Material());
949 anAspect->SetTransparency (myDrawer->ShadingAspect()->Transparency());
952 myCenter.Init (myAxes[0].AxisRadius() * 2.0f, gp::Origin());
953 aGroup = thePrs->NewGroup ();
954 aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
955 aGroup->AddPrimitiveArray (myCenter.Array());
957 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
960 aGroup = thePrs->NewGroup ();
962 Handle(Prs3d_ShadingAspect) anAspectAx = new Prs3d_ShadingAspect (new Graphic3d_AspectFillArea3d(*anAspect->Aspect()));
963 anAspectAx->SetColor (myAxes[anIt].Color());
964 aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect());
965 myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx);
966 myAxes[anIt].SetTransformPersistence (TransformPersistence());
969 updateTransformation();
972 //=======================================================================
973 //function : HilightSelected
975 //=======================================================================
976 void AIS_Manipulator::HilightSelected (const Handle(PrsMgr_PresentationManager3d)& thePM,
977 const SelectMgr_SequenceOfOwner& theSeq)
979 if (theSeq.IsEmpty())
984 if (myIsActivationOnDetection)
989 if (!theSeq (1)->IsKind (STANDARD_TYPE (AIS_ManipulatorOwner)))
991 thePM->Color (this, GetContext()->HighlightStyle(), 0);
995 Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theSeq (1));
996 myHighlightAspect->Aspect()->SetInteriorColor (GetContext()->HighlightStyle()->Color());
997 Handle(Graphic3d_Group) aGroup = getGroup (anOwner->Index(), anOwner->Mode());
1003 if (anOwner->Mode() == AIS_MM_TranslationPlane)
1005 myDraggerHighlight->SetColor(myAxes[anOwner->Index()].Color());
1006 aGroup->SetGroupPrimitivesAspect(myDraggerHighlight->Aspect());
1009 aGroup->SetGroupPrimitivesAspect(myHighlightAspect->Aspect());
1011 myCurrentIndex = anOwner->Index();
1012 myCurrentMode = anOwner->Mode();
1015 //=======================================================================
1016 //function : ClearSelected
1018 //=======================================================================
1019 void AIS_Manipulator::ClearSelected()
1021 DeactivateCurrentMode();
1024 //=======================================================================
1025 //function : HilightOwnerWithColor
1027 //=======================================================================
1028 void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
1029 const Handle(Prs3d_Drawer)& theStyle,
1030 const Handle(SelectMgr_EntityOwner)& theOwner)
1032 Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theOwner);
1033 Handle(Prs3d_Presentation) aPresentation = getHighlightPresentation (anOwner);
1034 if (aPresentation.IsNull())
1039 aPresentation->CStructure()->ViewAffinity = thePM->StructureManager()->ObjectAffinity (Handle(Standard_Transient) (this));
1041 if (anOwner->Mode() == AIS_MM_TranslationPlane)
1043 Handle(Prs3d_Drawer) aStyle = new Prs3d_Drawer();
1044 aStyle->SetColor (myAxes[anOwner->Index()].Color());
1045 aStyle->SetTransparency (0.5);
1046 aPresentation->Highlight (aStyle);
1050 aPresentation->Highlight (theStyle);
1053 for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
1054 aGroupIter.More(); aGroupIter.Next())
1056 Handle(Graphic3d_Group)& aGrp = aGroupIter.ChangeValue();
1059 aGrp->SetGroupPrimitivesAspect (myHighlightAspect->Aspect());
1062 aPresentation->SetZLayer (Graphic3d_ZLayerId_Topmost);
1063 thePM->AddToImmediateList (aPresentation);
1065 if (myIsActivationOnDetection)
1067 if (HasActiveMode())
1069 DeactivateCurrentMode();
1072 myCurrentIndex = anOwner->Index();
1073 myCurrentMode = anOwner->Mode();
1077 //=======================================================================
1078 //function : ComputeSelection
1080 //=======================================================================
1081 void AIS_Manipulator::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection,
1082 const Standard_Integer theMode)
1085 AIS_ManipulatorMode aMode = (AIS_ManipulatorMode) theMode;
1086 if (aMode == AIS_MM_None)
1090 Handle(SelectMgr_EntityOwner) anOwner;
1091 if (aMode == AIS_MM_None)
1093 anOwner = new SelectMgr_EntityOwner (this, 5);
1096 if (aMode == AIS_MM_Translation || aMode == AIS_MM_None)
1098 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
1100 if (!myAxes[anIt].HasTranslation())
1104 const Axis& anAxis = myAxes[anIt];
1105 if (aMode != AIS_MM_None)
1107 anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Translation, 9);
1109 // define sensitivity by line
1110 Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment (anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
1111 aLine->SetSensitivityFactor (15);
1112 theSelection->Add (aLine);
1114 // enlarge sensitivity by triangulation
1115 Handle(Select3D_SensitivePrimitiveArray) aTri = new Select3D_SensitivePrimitiveArray (anOwner);
1116 aTri->InitTriangulation (anAxis.TriangleArray()->Attributes(), anAxis.TriangleArray()->Indices(), TopLoc_Location());
1117 theSelection->Add (aTri);
1121 if (aMode == AIS_MM_Rotation || aMode == AIS_MM_None)
1123 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
1125 if (!myAxes[anIt].HasRotation())
1129 const Axis& anAxis = myAxes[anIt];
1130 if (aMode != AIS_MM_None)
1132 anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Rotation, 9);
1134 // define sensitivity by circle
1135 Handle(Geom_Circle) aGeomCircle = new Geom_Circle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
1136 Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle, anAxis.FacettesNumber());
1137 aCircle->SetSensitivityFactor (15);
1138 theSelection->Add (aCircle);
1139 // enlarge sensitivity by triangulation
1140 Handle(Select3D_SensitiveTriangulation) aTri = new ManipSensTriangulation (anOwner, myAxes[anIt].RotatorDisk().Triangulation(), anAxis.ReferenceAxis().Direction());
1141 theSelection->Add (aTri);
1145 if (aMode == AIS_MM_Scaling || aMode == AIS_MM_None)
1147 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
1149 if (!myAxes[anIt].HasScaling())
1153 if (aMode != AIS_MM_None)
1155 anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Scaling, 9);
1157 // define sensitivity by point
1158 Handle(Select3D_SensitivePoint) aPnt = new Select3D_SensitivePoint (anOwner, myAxes[anIt].ScalerCubePosition());
1159 aPnt->SetSensitivityFactor (15);
1160 theSelection->Add (aPnt);
1161 // enlarge sensitivity by triangulation
1162 Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
1163 theSelection->Add (aTri);
1167 if (aMode == AIS_MM_TranslationPlane || aMode == AIS_MM_None)
1169 for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
1171 if (!myAxes[anIt].HasDragging())
1175 if (aMode != AIS_MM_None)
1177 anOwner = new AIS_ManipulatorOwner(this, anIt, AIS_MM_TranslationPlane, 9);
1180 // define sensitivity by two crossed lines
1182 aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition();
1183 aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition();
1184 gp_XYZ aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
1186 Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
1187 aLine1->SetSensitivityFactor(10);
1188 theSelection->Add(aLine1);
1189 Handle(Select3D_SensitiveSegment) aLine2 = new Select3D_SensitiveSegment(anOwner, gp::Origin(), aMidP);
1190 aLine2->SetSensitivityFactor(10);
1191 theSelection->Add(aLine2);
1193 // enlarge sensitivity by triangulation
1194 Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].DraggerSector().Triangulation(), TopLoc_Location(), Standard_True);
1195 theSelection->Add(aTri);
1200 //=======================================================================
1204 //=======================================================================
1205 void AIS_Manipulator::Disk::Init (const Standard_ShortReal theInnerRadius,
1206 const Standard_ShortReal theOuterRadius,
1207 const gp_Ax1& thePosition,
1208 const Standard_Integer theSlicesNb,
1209 const Standard_Integer theStacksNb)
1211 myPosition = thePosition;
1212 myInnerRad = theInnerRadius;
1213 myOuterRad = theOuterRadius;
1215 Prs3d_ToolDisk aTool (theInnerRadius, theOuterRadius, theSlicesNb, theStacksNb);
1216 gp_Ax3 aSystem (myPosition.Location(), myPosition.Direction());
1218 aTrsf.SetTransformation (aSystem, gp_Ax3());
1219 aTool.FillArray (myArray, myTriangulation, aTrsf);
1222 //=======================================================================
1226 //=======================================================================
1227 void AIS_Manipulator::Sphere::Init (const Standard_ShortReal theRadius,
1228 const gp_Pnt& thePosition,
1229 const Standard_Integer theSlicesNb,
1230 const Standard_Integer theStacksNb)
1232 myPosition = thePosition;
1233 myRadius = theRadius;
1235 Prs3d_ToolSphere aTool (theRadius, theSlicesNb, theStacksNb);
1237 aTrsf.SetTranslation (gp_Vec(gp::Origin(), thePosition));
1238 aTool.FillArray (myArray, myTriangulation, aTrsf);
1241 //=======================================================================
1245 //=======================================================================
1246 void AIS_Manipulator::Cube::Init (const gp_Ax1& thePosition, const Standard_ShortReal theSize)
1248 myArray = new Graphic3d_ArrayOfTriangles (12 * 3, 0, Standard_True);
1250 Poly_Array1OfTriangle aPolyTriangles (1, 12);
1251 TColgp_Array1OfPnt aPoints (1, 36);
1252 NCollection_Array1<gp_Dir> aNormals (1, 12);
1253 myTriangulation = new Poly_Triangulation (aPoints, aPolyTriangles);
1255 gp_Ax2 aPln (thePosition.Location(), thePosition.Direction());
1256 gp_Pnt aBottomLeft = thePosition.Location().XYZ() - aPln.XDirection().XYZ() * theSize * 0.5 - aPln.YDirection().XYZ() * theSize * 0.5;
1257 gp_Pnt aV2 = aBottomLeft.XYZ() + aPln.YDirection().XYZ() * theSize;
1258 gp_Pnt aV3 = aBottomLeft.XYZ() + aPln.YDirection().XYZ() * theSize + aPln.XDirection().XYZ() * theSize;
1259 gp_Pnt aV4 = aBottomLeft.XYZ() + aPln.XDirection().XYZ() * theSize;
1260 gp_Pnt aTopRight = thePosition.Location().XYZ() + thePosition.Direction().XYZ() * theSize
1261 + aPln.XDirection().XYZ() * theSize * 0.5 + aPln.YDirection().XYZ() * theSize * 0.5;
1262 gp_Pnt aV5 = aTopRight.XYZ() - aPln.YDirection().XYZ() * theSize;
1263 gp_Pnt aV6 = aTopRight.XYZ() - aPln.YDirection().XYZ() * theSize - aPln.XDirection().XYZ() * theSize;
1264 gp_Pnt aV7 = aTopRight.XYZ() - aPln.XDirection().XYZ() * theSize;
1266 gp_Dir aRight ((gp_Vec(aTopRight, aV7) ^ gp_Vec(aTopRight, aV2)).XYZ());
1267 gp_Dir aFront ((gp_Vec(aV3, aV4) ^ gp_Vec(aV3, aV5)).XYZ());
1270 addTriangle (0, aBottomLeft, aV2, aV3, -thePosition.Direction());
1271 addTriangle (1, aBottomLeft, aV3, aV4, -thePosition.Direction());
1274 addTriangle (2, aV3, aV4, aV5, aFront);
1275 addTriangle (3, aV3, aV5, aTopRight, aFront);
1278 addTriangle (4, aBottomLeft, aV2, aV7, -aFront);
1279 addTriangle (5, aBottomLeft, aV7, aV6, -aFront);
1282 addTriangle (6, aV7, aV6, aV5, thePosition.Direction());
1283 addTriangle (7, aTopRight, aV7, aV5, thePosition.Direction());
1286 addTriangle (8, aV6, aV5, aV4, -aRight);
1287 addTriangle (9, aBottomLeft, aV6, aV4, -aRight);
1290 addTriangle (10, aV3, aTopRight, aV7, aRight);
1291 addTriangle (11, aV3, aV7, aV2, aRight);
1294 //=======================================================================
1296 //function : addTriangle
1298 //=======================================================================
1299 void AIS_Manipulator::Cube::addTriangle (const Standard_Integer theIndex,
1300 const gp_Pnt& theP1, const gp_Pnt& theP2, const gp_Pnt& theP3,
1301 const gp_Dir& theNormal)
1303 myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 1, theP1);
1304 myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 2, theP2);
1305 myTriangulation->ChangeNodes().SetValue (theIndex * 3 + 3, theP3);
1307 myTriangulation->ChangeTriangles().SetValue (theIndex + 1, Poly_Triangle (theIndex * 3 + 1, theIndex * 3 + 2, theIndex * 3 + 3));
1308 myArray->AddVertex (theP1, theNormal);
1309 myArray->AddVertex (theP2, theNormal);
1310 myArray->AddVertex (theP3, theNormal);
1313 //=======================================================================
1317 //=======================================================================
1318 void AIS_Manipulator::Sector::Init (const Standard_ShortReal theRadius,
1319 const gp_Ax1& thePosition,
1320 const gp_Dir& theXDirection,
1321 const Standard_Integer theSlicesNb,
1322 const Standard_Integer theStacksNb)
1324 Prs3d_ToolSector aTool(theRadius, theSlicesNb, theStacksNb);
1325 gp_Ax3 aSystem(thePosition.Location(), thePosition.Direction(), theXDirection);
1327 aTrsf.SetTransformation(aSystem, gp_Ax3());
1328 aTool.FillArray(myArray, myTriangulation, aTrsf);
1331 //=======================================================================
1333 //function : Constructor
1335 //=======================================================================
1336 AIS_Manipulator::Axis::Axis (const gp_Ax1& theAxis,
1337 const Quantity_Color& theColor,
1338 const Standard_ShortReal theLength)
1339 : myReferenceAxis (theAxis),
1340 myPosition (theAxis),
1342 myHasTranslation (Standard_True),
1343 myLength (theLength),
1344 myAxisRadius (0.5f),
1345 myHasScaling (Standard_True),
1347 myHasRotation (Standard_True),
1348 myInnerRadius (myLength + myBoxSize),
1349 myDiskThickness (myBoxSize * 0.5f),
1351 myHasDragging(Standard_True),
1352 myFacettesNumber (20),
1353 myCircleRadius (myLength + myBoxSize + myBoxSize * 0.5f * 0.5f)
1358 //=======================================================================
1360 //function : Compute
1362 //=======================================================================
1364 void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
1365 const Handle(Prs3d_Presentation)& thePrs,
1366 const Handle(Prs3d_ShadingAspect)& theAspect)
1368 if (myHasTranslation)
1370 const Standard_Real anArrowLength = 0.25 * myLength;
1371 const Standard_Real aCylinderLength = myLength - anArrowLength;
1372 myArrowTipPos = gp_Pnt (0.0, 0.0, 0.0).Translated (myReferenceAxis.Direction().XYZ() * aCylinderLength);
1374 myTriangleArray = Prs3d_Arrow::DrawShaded (gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
1380 myTranslatorGroup = thePrs->NewGroup ();
1381 myTranslatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1382 myTranslatorGroup->AddPrimitiveArray (myTriangleArray);
1384 if (myHighlightTranslator.IsNull())
1386 myHighlightTranslator = new Prs3d_Presentation (thePrsMgr->StructureManager());
1390 myHighlightTranslator->Clear();
1393 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightTranslator);
1394 aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1395 aGroup->AddPrimitiveArray (myTriangleArray);
1401 myCubePos = myReferenceAxis.Direction().XYZ() * (myLength + myIndent);
1402 myCube.Init (gp_Ax1 (myCubePos, myReferenceAxis.Direction()), myBoxSize);
1404 myScalerGroup = thePrs->NewGroup ();
1405 myScalerGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1406 myScalerGroup->AddPrimitiveArray (myCube.Array());
1408 if (myHighlightScaler.IsNull())
1410 myHighlightScaler = new Prs3d_Presentation (thePrsMgr->StructureManager());
1414 myHighlightScaler->Clear();
1417 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightScaler);
1418 aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1419 aGroup->AddPrimitiveArray (myCube.Array());
1425 myCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f;
1426 myCircle.Init (myInnerRadius + myIndent * 2, myInnerRadius + myDiskThickness + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), myFacettesNumber * 2);
1427 myRotatorGroup = thePrs->NewGroup ();
1428 myRotatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1429 myRotatorGroup->AddPrimitiveArray (myCircle.Array());
1431 if (myHighlightRotator.IsNull())
1433 myHighlightRotator = new Prs3d_Presentation (thePrsMgr->StructureManager());
1437 myHighlightRotator->Clear();
1440 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightRotator);
1441 aGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
1442 aGroup->AddPrimitiveArray (myCircle.Array());
1449 if (myReferenceAxis.Direction().X() > 0)
1450 aXDirection = gp::DY();
1451 else if (myReferenceAxis.Direction().Y() > 0)
1452 aXDirection = gp::DZ();
1454 aXDirection = gp::DX();
1456 mySector.Init(myInnerRadius + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), aXDirection, myFacettesNumber * 2);
1457 myDraggerGroup = thePrs->NewGroup();
1459 Handle(Graphic3d_AspectFillArea3d) aFillArea = new Graphic3d_AspectFillArea3d();
1460 myDraggerGroup->SetGroupPrimitivesAspect(aFillArea);
1461 myDraggerGroup->AddPrimitiveArray(mySector.Array());
1463 if (myHighlightDragger.IsNull())
1465 myHighlightDragger = new Prs3d_Presentation(thePrsMgr->StructureManager());
1469 myHighlightDragger->Clear();
1472 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(myHighlightDragger);
1473 aGroup->SetGroupPrimitivesAspect(aFillArea);
1474 aGroup->AddPrimitiveArray(mySector.Array());