#include <Geom_Line.hxx>
#include <Geom_Plane.hxx>
#include <Geom_Transformation.hxx>
+#include <Prs3d_Arrow.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_ShadingAspect.hxx>
+#include <Prs3d_ToolDisk.hxx>
+#include <Prs3d_ToolSphere.hxx>
#include <Select3D_SensitiveCircle.hxx>
#include <Select3D_SensitivePoint.hxx>
#include <Select3D_SensitiveSegment.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
+#include <Select3D_SensitivePrimitiveArray.hxx>
#include <SelectMgr_SequenceOfOwner.hxx>
-#include <StdPrs_ToolDisk.hxx>
-#include <StdPrs_ToolCylinder.hxx>
-#include <StdPrs_ToolSphere.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <V3d_View.hxx>
aTrsf.SetTransformation (gp_Ax2 (gp::Origin(), aVDir, aXDir), gp::XOY());
}
- AIS_InteractiveObject::SetLocalTransformation (aTrsf);
-
- Handle(Geom_Transformation) aGeomTrsf = new Geom_Transformation (this->Transformation());
-
+ Handle(Geom_Transformation) aGeomTrsf = new Geom_Transformation (aTrsf);
+ // we explicitly call here setLocalTransformation() of the base class
+ // since AIS_Manipulator::setLocalTransformation() implementation throws exception
+ // as protection from external calls
+ AIS_InteractiveObject::setLocalTransformation (aGeomTrsf);
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
myAxes[anIt].Transform (aGeomTrsf);
if (myIsZoomPersistentMode)
{
- if (!(GetTransformPersistenceMode () == Graphic3d_TMF_ZoomPers
- && GetTransformPersistencePoint().IsEqual (myPosition.Location(), 0.)))
+ if (TransformPersistence().IsNull()
+ || TransformPersistence()->Mode() != Graphic3d_TMF_ZoomPers
+ || !TransformPersistence()->AnchorPoint().IsEqual (myPosition.Location(), 0.0))
{
- setTransformPersistence (Graphic3d_TMF_ZoomPers, myPosition.Location());
+ setTransformPersistence (new Graphic3d_TransformPers (Graphic3d_TMF_ZoomPers, myPosition.Location()));
}
}
}
if (!theToEnable)
{
- setTransformPersistence (Graphic3d_TMF_None, gp::Origin());
+ setTransformPersistence (Handle(Graphic3d_TransformPers)());
}
updateTransformation();
//=======================================================================
//function : SetTransformPersistence
-//purpose :
+//purpose :
//=======================================================================
-void AIS_Manipulator::SetTransformPersistence (const Graphic3d_TransModeFlags& theFlag, const gp_Pnt& thePoint)
+void AIS_Manipulator::SetTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
Standard_ASSERT_RETURN (!myIsZoomPersistentMode,
"AIS_Manipulator::SetTransformPersistence: "
- "Custom settings are not supported by this class in ZoomPersistence mode",);
+ "Custom settings are not allowed by this class in ZoomPersistence mode",);
- setTransformPersistence (theFlag, thePoint);
+ setTransformPersistence (theTrsfPers);
}
//=======================================================================
//function : setTransformPersistence
//purpose :
//=======================================================================
-void AIS_Manipulator::setTransformPersistence (const Graphic3d_TransModeFlags& theFlag, const gp_Pnt& thePoint)
+void AIS_Manipulator::setTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers)
{
- AIS_InteractiveObject::SetTransformPersistence (theFlag, thePoint);
+ AIS_InteractiveObject::SetTransformPersistence (theTrsfPers);
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
{
- myAxes[anIt].SetTransformPersistence (theFlag, thePoint);
+ myAxes[anIt].SetTransformPersistence (theTrsfPers);
}
}
//=======================================================================
-//function : SetLocalTransformation
-//purpose :
+//function : setLocalTransformation
+//purpose :
//=======================================================================
-void AIS_Manipulator::SetLocalTransformation (const gp_Trsf& /*theTransformation*/)
+void AIS_Manipulator::setLocalTransformation (const Handle(Geom_Transformation)& /*theTrsf*/)
{
- Standard_ASSERT_INVOKE (
- "AIS_Manipulator::SetLocalTransformation: "
- "Custom transformation is not supported by this class");
+ Standard_ASSERT_INVOKE ("AIS_Manipulator::setLocalTransformation: "
+ "Custom transformation is not supported by this class");
}
//=======================================================================
anAspectAx->SetColor (myAxes[anIt].Color());
aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect());
myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx);
- myAxes[anIt].SetTransformPersistence (GetTransformPersistenceMode(),
- GetTransformPersistencePoint());
+ myAxes[anIt].SetTransformPersistence (TransformPersistence());
}
updateTransformation();
if (!theSeq (1)->IsKind (STANDARD_TYPE (AIS_ManipulatorOwner)))
{
- thePM->Color (this, GetContext()->HilightColor(), 0);
+ thePM->Color (this, GetContext()->HighlightStyle(), 0);
return;
}
Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theSeq (1));
- myHighlightAspect->Aspect()->SetInteriorColor (GetContext()->HilightColor());
+ myHighlightAspect->Aspect()->SetInteriorColor (GetContext()->HighlightStyle()->Color());
Handle(Graphic3d_Group) aGroup = getGroup (anOwner->Index(), anOwner->Mode());
if (aGroup.IsNull())
{
//function : HilightOwnerWithColor
//purpose :
//=======================================================================
-void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM, const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner)
+void AIS_Manipulator::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)& thePM,
+ const Handle(Graphic3d_HighlightStyle)& theStyle,
+ const Handle(SelectMgr_EntityOwner)& theOwner)
{
Handle(AIS_ManipulatorOwner) anOwner = Handle(AIS_ManipulatorOwner)::DownCast (theOwner);
Handle(Prs3d_Presentation) aPresentation = getHighlightPresentation (anOwner);
{
return;
}
- aPresentation->Highlight (Aspect_TOHM_COLOR, theColor);
+ aPresentation->Highlight (theStyle);
for (Graphic3d_SequenceOfGroup::Iterator aGroupIter (aPresentation->Groups());
aGroupIter.More(); aGroupIter.Next())
{
{
anOwner = new SelectMgr_EntityOwner (this, 5);
}
- Handle(Select3D_SensitiveTriangulation) aTri;
+
if (aMode == AIS_MM_Translation || aMode == AIS_MM_None)
{
for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment (anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
aLine->SetSensitivityFactor (15);
theSelection->Add (aLine);
+
// enlarge sensitivity by triangulation
- aTri = new Select3D_SensitiveTriangulation (anOwner, anAxis.TranslatorCylinder().Triangulation(), TopLoc_Location(), Standard_True);
- theSelection->Add (aTri);
- aTri = new Select3D_SensitiveTriangulation (anOwner, anAxis.TranslatorArrow().Triangulation(), TopLoc_Location(), Standard_True);
- theSelection->Add (aTri);
- aTri = new Select3D_SensitiveTriangulation (anOwner, anAxis.TranslatorArrowBottom().Triangulation(), TopLoc_Location(), Standard_True);
+ Handle(Select3D_SensitivePrimitiveArray) aTri = new Select3D_SensitivePrimitiveArray (anOwner);
+ aTri->InitTriangulation (anAxis.TriangleArray()->Attributes(), anAxis.TriangleArray()->Indices(), TopLoc_Location());
theSelection->Add (aTri);
}
}
aCircle->SetSensitivityFactor (15);
theSelection->Add (aCircle);
// enlarge sensitivity by triangulation
- aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].RotatorDisk().Triangulation(), TopLoc_Location(), Standard_True);
+ Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].RotatorDisk().Triangulation(), TopLoc_Location(), Standard_True);
theSelection->Add (aTri);
}
}
aPnt->SetSensitivityFactor (15);
theSelection->Add (aPnt);
// enlarge sensitivity by triangulation
- aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
+ Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
theSelection->Add (aTri);
}
}
}
-//=======================================================================
-//class : Cylinder
-//function : Init
-//purpose :
-//=======================================================================
-void AIS_Manipulator::Cylinder::Init (const Standard_ShortReal theBotRad, const Standard_ShortReal theTopRad,
- const Standard_ShortReal theHeight,
- const Standard_Integer theSlicesNb, const Standard_Integer theStacksNb,
- const gp_Ax1& thePosition)
-{
- myPosition = thePosition;
- myBottomRad = theBotRad;
- myTopRad = theTopRad;
- myHeight = theHeight;
-
- StdPrs_ToolCylinder aTool (myBottomRad, myTopRad, myHeight, theSlicesNb, theStacksNb);
- gp_Ax3 aSystem (myPosition.Location(), myPosition.Direction());
- gp_Trsf aTrsf;
- aTrsf.SetTransformation (aSystem, gp_Ax3());
-
- aTool.FillArray (myArray, myTriangulation, aTrsf);
-}
-
//=======================================================================
//class : Disk
//function : Init
myInnerRad = theInnerRadius;
myOuterRad = theOuterRadius;
- StdPrs_ToolDisk aTool (theInnerRadius, theOuterRadius, theSlicesNb, theStacksNb);
+ Prs3d_ToolDisk aTool (theInnerRadius, theOuterRadius, theSlicesNb, theStacksNb);
gp_Ax3 aSystem (myPosition.Location(), myPosition.Direction());
gp_Trsf aTrsf;
aTrsf.SetTransformation (aSystem, gp_Ax3());
myPosition = thePosition;
myRadius = theRadius;
- StdPrs_ToolSphere aTool (theRadius, theSlicesNb, theStacksNb);
+ Prs3d_ToolSphere aTool (theRadius, theSlicesNb, theStacksNb);
gp_Trsf aTrsf;
aTrsf.SetTranslation (gp_Vec(gp::Origin(), thePosition));
aTool.FillArray (myArray, myTriangulation, aTrsf);
//=======================================================================
//class : Axis
//function : Compute
-//purpose :
+//purpose :
//=======================================================================
-void AIS_Manipulator::Axis::Compute (const Handle_PrsMgr_PresentationManager3d& thePrsMgr,
+
+void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
const Handle(Prs3d_ShadingAspect)& theAspect)
{
- Handle(Graphic3d_Group) aGroup;
-
if (myHasTranslation)
{
- const Standard_ShortReal anArrowLength = 0.25f * myLength;
- const Standard_ShortReal aCylinderLength = myLength - anArrowLength;
-
- myCylinder.Init (myAxisRadius, myAxisRadius, aCylinderLength, myFacettesNumber, 2, gp_Ax1 (gp::Origin(), myReferenceAxis.Direction()));
-
- gp_Pnt anArrowBottom (0.0, 0.0, 0.0);
- anArrowBottom.Translate (myReferenceAxis.Direction().XYZ() * aCylinderLength);
-
- myArrow.Init (myAxisRadius * 1.5f, 0.0f, anArrowLength, myFacettesNumber, 2, gp_Ax1 (anArrowBottom, myReferenceAxis.Direction()));
- myArrowBottom.Init (myAxisRadius, myAxisRadius * 1.5f, gp_Ax1 (anArrowBottom, myReferenceAxis.Direction()), myFacettesNumber);
- myArrowTipPos = anArrowBottom;
-
+ const Standard_Real anArrowLength = 0.25 * myLength;
+ const Standard_Real aCylinderLength = myLength - anArrowLength;
+ myArrowTipPos = gp_Pnt (0.0, 0.0, 0.0).Translated (myReferenceAxis.Direction().XYZ() * aCylinderLength);
+
+ myTriangleArray = Prs3d_Arrow::DrawShaded (gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
+ myAxisRadius,
+ myLength,
+ myAxisRadius * 1.5,
+ anArrowLength,
+ myFacettesNumber);
myTranslatorGroup = Prs3d_Root::NewGroup (thePrs);
myTranslatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
- myTranslatorGroup->AddPrimitiveArray (myCylinder.Array());
- myTranslatorGroup->AddPrimitiveArray (myArrow.Array());
- myTranslatorGroup->AddPrimitiveArray (myArrowBottom.Array());
+ myTranslatorGroup->AddPrimitiveArray (myTriangleArray);
if (myHighlightTranslator.IsNull())
{
myHighlightTranslator = new Prs3d_Presentation (thePrsMgr->StructureManager());
}
-
- myHighlightTranslator->Clear();
- aGroup = Prs3d_Root::CurrentGroup (myHighlightTranslator);
- aGroup->AddPrimitiveArray (myCylinder.Array());
- aGroup->AddPrimitiveArray (myArrow.Array());
- aGroup->AddPrimitiveArray (myArrowBottom.Array());
+ else
+ {
+ myHighlightTranslator->Clear();
+ }
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightTranslator);
+ aGroup->AddPrimitiveArray (myTriangleArray);
}
if (myHasScaling)
{
myHighlightScaler = new Prs3d_Presentation (thePrsMgr->StructureManager());
}
-
- myHighlightScaler->Clear();
- aGroup = Prs3d_Root::CurrentGroup (myHighlightScaler);
+ else
+ {
+ myHighlightScaler->Clear();
+ }
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightScaler);
aGroup->AddPrimitiveArray (myCube.Array());
}
{
myHighlightRotator = new Prs3d_Presentation (thePrsMgr->StructureManager());
}
-
- myHighlightRotator->Clear();
- aGroup = Prs3d_Root::CurrentGroup (myHighlightRotator);
+ else
+ {
+ myHighlightRotator->Clear();
+ }
+ Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup (myHighlightRotator);
Prs3d_Root::CurrentGroup (myHighlightRotator)->AddPrimitiveArray (myCircle.Array());
}
}