//! Main constructor.
ManipSensCircle (const Handle(SelectMgr_EntityOwner)& theOwnerId,
const gp_Circ& theCircle,
+ const Standard_Real theU1,
+ const Standard_Real theU2,
const Standard_Integer theNbPnts)
- : Select3D_SensitiveCircle (theOwnerId, theCircle, Standard_False, theNbPnts),
+ : Select3D_SensitiveCircle (theOwnerId, theCircle, theU1, theU2, Standard_False, theNbPnts),
ManipSensRotation (theCircle.Position().Direction()) {}
//! Checks whether the circle overlaps current selecting volume
aDraggerMaterial.SetAmbientColor (Quantity_NOC_BLACK);
aDraggerMaterial.SetDiffuseColor (Quantity_NOC_BLACK);
aDraggerMaterial.SetSpecularColor(Quantity_NOC_BLACK);
- aDraggerMaterial.SetMaterialType(Graphic3d_MATERIAL_ASPECT);
+ aDraggerMaterial.SetMaterialType (Graphic3d_MATERIAL_ASPECT);
myDraggerHighlight = new Prs3d_ShadingAspect();
- myDraggerHighlight->Aspect()->SetInteriorStyle(Aspect_IS_SOLID);
- myDraggerHighlight->SetMaterial(aDraggerMaterial);
+ myDraggerHighlight->Aspect()->SetInteriorStyle (Aspect_IS_SOLID);
+ myDraggerHighlight->SetMaterial (aDraggerMaterial);
- myDraggerHighlight->SetTransparency(0.5);
+ myDraggerHighlight->SetTransparency (0.5);
- SetSize (100);
+ myTranslatorSensitivity = 15;
+ myRotatorSensitivity = 15;
+ myScalerSensitivity = 15;
+ myDraggerSensitivity = 10;
+
+ setSize (100.0f);
SetZLayer (Graphic3d_ZLayerId_Topmost);
}
myHasStartedTransformation (Standard_False),
myStartPosition (gp::XOY()),
myStartPick (0.0, 0.0, 0.0),
- myPrevState (0.0)
+ myPrevState (0.0),
+ myIndent (0.2f)
{
SetInfiniteState();
SetMutable (Standard_True);
myHasStartedTransformation (Standard_False),
myStartPosition (gp::XOY()),
myStartPick (0.0, 0.0, 0.0),
- myPrevState (0.0)
+ myPrevState (0.0),
+ myIndent (0.2f)
{
SetInfiniteState();
SetMutable (Standard_True);
}
}
+//=======================================================================
+//function : SetArcAngle
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetArcAngle (const Standard_ShortReal theStartAngle,
+ const Standard_ShortReal theFinishAngle)
+{
+ myAxes[0].SetArcAngle (-theFinishAngle, -theStartAngle);
+ myAxes[1].SetArcAngle (theStartAngle, theFinishAngle);
+ myAxes[2].SetArcAngle (theStartAngle, theFinishAngle);
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetAxisRadius
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetAxisRadius (const Standard_ShortReal theValue)
+{
+ myAxisRadius = theValue;
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetDiskThickness
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetDiskThickness (const Standard_ShortReal theDiskThickness)
+{
+ myDiskThickness = theDiskThickness;
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetInnerRadius
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetInnerRadius (const Standard_ShortReal theInnerRadius)
+{
+ myInnerRadius = theInnerRadius;
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetArrowLengthFactor
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetArrowLengthFactor (const Standard_ShortReal theArrowLengthFactor)
+{
+ myLength = theArrowLengthFactor;
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetArrowHeadLength
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetArrowHeadLength (const Standard_ShortReal theArrowHeadLength)
+{
+ myArrowHeadLength = theArrowHeadLength;
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetDragPlaneSize
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetDragPlaneSize(const Standard_ShortReal theDragPlaneSize)
+{
+ myDragPlaneSize = theDragPlaneSize;
+ SetToUpdate();
+}
+
+//=======================================================================
+//function : SetBoxSize
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetBoxSize (const Standard_ShortReal theBoxSize)
+{
+ myBoxSize = theBoxSize;
+ SetToUpdate();
+}
+
//=======================================================================
//function : EnableMode
//purpose :
Standard_Real aYSize = aYmax - aYmin;
Standard_Real aZSize = aZmax - aZmin;
- SetSize ((Standard_ShortReal) (Max (aXSize, Max (aYSize, aZSize)) * 0.5));
+ setSize ((Standard_ShortReal) (Max (aXSize, Max (aYSize, aZSize)) * 0.5));
}
//=======================================================================
return Standard_False;
}
+//=======================================================================
+//function : SetMouse
+//purpose :
+//=======================================================================
+void AIS_Manipulator::SetMouse (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView)
+{
+ if (!IsAttached())
+ {
+ return;
+ }
+
+ Graphic3d_Vec3d anInputPoint, aProj;
+ theView->ConvertWithProj (theX, theY, anInputPoint.x(), anInputPoint.y(), anInputPoint.z(), aProj.x(), aProj.y(), aProj.z());
+ const gp_Lin anInputLine(gp_Pnt(anInputPoint.x(), anInputPoint.y(), anInputPoint.z()), gp_Dir(aProj.x(), aProj.y(), aProj.z()));
+
+ gp_Pnt aStartPnt(anInputPoint.x(), anInputPoint.y(), anInputPoint.z());
+ Standard_Real aD1 = anInputLine.Distance (myPosition.Location());
+ Standard_Real aD2 = myPosition.Location().Distance (aStartPnt);
+
+ Standard_Real aDist = Sqrt (aD2 * aD2 - aD1* aD1);
+ gp_Pnt aResPnt = aStartPnt.XYZ() + anInputLine.Direction().XYZ() * aDist;
+
+ gp_Trsf aTrsf;
+ aTrsf.SetTranslation (myPosition.Location(), aResPnt);
+
+ myStartTrsfs.Clear();
+ Handle(AIS_ManipulatorObjectSequence) anObjects = Objects();
+ for (AIS_ManipulatorObjectSequence::Iterator anObjIter(*anObjects); anObjIter.More(); anObjIter.Next())
+ {
+ myStartTrsfs.Append (anObjIter.Value()->LocalTransformation());
+ }
+ myStartPosition = myPosition;
+
+ myHasStartedTransformation = true;
+
+ Transform (aTrsf);
+
+ gp_Pnt aPos = myStartPosition.Location().Transformed (aTrsf);
+ gp_Dir aVDir = myStartPosition.Direction().Transformed (aTrsf);
+ gp_Dir aXDir = myStartPosition.XDirection().Transformed (aTrsf);
+ SetPosition (gp_Ax2(aPos, aVDir, aXDir));
+
+ StopTransform();
+}
+
//=======================================================================
//function : ProcessDragging
//purpose :
}
//=======================================================================
-//function : SetSize
+//function : setSize
//purpose :
//=======================================================================
-void AIS_Manipulator::SetSize (const Standard_ShortReal theSideLength)
+void AIS_Manipulator::setSize (const Standard_ShortReal theSideLength)
{
- for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
+ if (myIndent > theSideLength * 0.1f)
+ {
+ myLength = theSideLength * 0.7f;
+ myBoxSize = theSideLength * 0.15f;
+ myDiskThickness = theSideLength * 0.05f;
+ myIndent = theSideLength * 0.05f;
+ }
+ else // use pre-set value of predent
{
- myAxes[anIt].SetSize (theSideLength);
+ Standard_ShortReal aLength = theSideLength - 2 * myIndent;
+ myLength = aLength * 0.8f;
+ myBoxSize = aLength * 0.15f;
+ myDiskThickness = aLength * 0.05f;
}
+ myInnerRadius = myIndent * 2 + myBoxSize + myLength;
+ myDragPlaneSize = myInnerRadius * 0.5f;
+ myAxisRadius = myBoxSize / 4.0f;
+ myArrowHeadLength = myLength * 0.25f;
SetToUpdate();
}
//=======================================================================
void AIS_Manipulator::SetGap (const Standard_ShortReal theValue)
{
- for (Standard_Integer anIt = 0; anIt < 3; ++anIt)
- {
- myAxes[anIt].SetIndent (theValue);
- }
-
+ myIndent = theValue;
SetToUpdate();
}
anAspect->SetTransparency (myDrawer->ShadingAspect()->Transparency());
// Display center
- myCenter.Init (myAxes[0].AxisRadius() * 2.0f, gp::Origin());
+ myCenter.Init (myAxisRadius * 1.5f, gp::Origin());
aGroup = thePrs->NewGroup ();
aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
aGroup->AddPrimitiveArray (myCenter.Array());
Handle(Prs3d_ShadingAspect) anAspectAx = new Prs3d_ShadingAspect (new Graphic3d_AspectFillArea3d(*anAspect->Aspect()));
anAspectAx->SetColor (myAxes[anIt].Color());
aGroup->SetGroupPrimitivesAspect (anAspectAx->Aspect());
- myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx);
+ myAxes[anIt].Compute (thePrsMgr, thePrs, anAspectAx, this);
myAxes[anIt].SetTransformPersistence (TransformPersistence());
}
}
// define sensitivity by line
Handle(Select3D_SensitiveSegment) aLine = new Select3D_SensitiveSegment (anOwner, gp::Origin(), anAxis.TranslatorTipPosition());
- aLine->SetSensitivityFactor (15);
+ aLine->SetSensitivityFactor (myTranslatorSensitivity);
theSelection->Add (aLine);
// enlarge sensitivity by triangulation
anOwner = new AIS_ManipulatorOwner (this, anIt, AIS_MM_Rotation, 9);
}
// define sensitivity by circle
- const gp_Circ aGeomCircle (gp_Ax2 (gp::Origin(), anAxis.ReferenceAxis().Direction()), anAxis.RotatorDiskRadius());
- Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle, anAxis.FacettesNumber());
- aCircle->SetSensitivityFactor (15);
+ const Standard_ShortReal aSensCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f;
+ const gp_Circ aGeomCircle (gp_Ax2(gp::Origin(), anAxis.ReferenceAxis().Direction()), aSensCircleRadius);
+ Handle(Select3D_SensitiveCircle) aCircle = new ManipSensCircle (anOwner, aGeomCircle, myAxes[anIt].StartAngle(), myAxes[anIt].EndAngle(), anAxis.FacettesNumber());
+ aCircle->SetSensitivityFactor (myRotatorSensitivity);
theSelection->Add (aCircle);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new ManipSensTriangulation (anOwner, myAxes[anIt].RotatorDisk().Triangulation(), anAxis.ReferenceAxis().Direction());
}
// define sensitivity by point
Handle(Select3D_SensitivePoint) aPnt = new Select3D_SensitivePoint (anOwner, myAxes[anIt].ScalerCubePosition());
- aPnt->SetSensitivityFactor (15);
+ aPnt->SetSensitivityFactor (myScalerSensitivity);
theSelection->Add (aPnt);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation (anOwner, myAxes[anIt].ScalerCube().Triangulation(), TopLoc_Location(), Standard_True);
}
// define sensitivity by two crossed lines
- gp_Pnt aP1, aP2;
- aP1 = myAxes[((anIt + 1) % 3)].TranslatorTipPosition();
- aP2 = myAxes[((anIt + 2) % 3)].TranslatorTipPosition();
- gp_XYZ aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
+ gp_Pnt aP1 = myAxes[((anIt + 1) % 3)].Position().Direction().XYZ() * myDragPlaneSize;
+ gp_Pnt aP2 = myAxes[((anIt + 2) % 3)].Position().Direction().XYZ() * myDragPlaneSize;
+ const gp_Pnt aMidP = (aP1.XYZ() + aP2.XYZ()) / 2.0;
Handle(Select3D_SensitiveSegment) aLine1 = new Select3D_SensitiveSegment(anOwner, aP1, aP2);
- aLine1->SetSensitivityFactor(10);
- theSelection->Add(aLine1);
+ aLine1->SetSensitivityFactor (myDraggerSensitivity);
+ theSelection->Add (aLine1);
Handle(Select3D_SensitiveSegment) aLine2 = new Select3D_SensitiveSegment(anOwner, gp::Origin(), aMidP);
- aLine2->SetSensitivityFactor(10);
- theSelection->Add(aLine2);
+ aLine2->SetSensitivityFactor (myDraggerSensitivity);
+ theSelection->Add (aLine2);
// enlarge sensitivity by triangulation
Handle(Select3D_SensitiveTriangulation) aTri = new Select3D_SensitiveTriangulation(anOwner, myAxes[anIt].DraggerSector().Triangulation(), TopLoc_Location(), Standard_True);
- theSelection->Add(aTri);
+ theSelection->Add (aTri);
}
}
}
void AIS_Manipulator::Disk::Init (const Standard_ShortReal theInnerRadius,
const Standard_ShortReal theOuterRadius,
const gp_Ax1& thePosition,
+ const Standard_ShortReal theStartAngle,
+ const Standard_ShortReal theEndAngle,
const Standard_Integer theSlicesNb,
const Standard_Integer theStacksNb)
{
- myPosition = thePosition;
- myInnerRad = theInnerRadius;
- myOuterRad = theOuterRadius;
-
Prs3d_ToolDisk aTool (theInnerRadius, theOuterRadius, theSlicesNb, theStacksNb);
- gp_Ax3 aSystem (myPosition.Location(), myPosition.Direction());
+ aTool.SetAngleRange (theStartAngle, theEndAngle);
+ gp_Ax3 aSystem (thePosition.Location(), thePosition.Direction());
gp_Trsf aTrsf;
aTrsf.SetTransformation (aSystem, gp_Ax3());
myArray = aTool.CreateTriangulation (aTrsf);
//function : Init
//purpose :
//=======================================================================
-void AIS_Manipulator::Sector::Init (const Standard_ShortReal theRadius,
+void AIS_Manipulator::Sector::Init (const Standard_ShortReal theSize,
const gp_Ax1& thePosition,
- const gp_Dir& theXDirection,
- const Standard_Integer theSlicesNb,
- const Standard_Integer theStacksNb)
+ const gp_Dir& theXDirection)
{
- Prs3d_ToolSector aTool(theRadius, theSlicesNb, theStacksNb);
- gp_Ax3 aSystem(thePosition.Location(), thePosition.Direction(), theXDirection);
+ gp_Ax3 aSystem (thePosition.Location(), thePosition.Direction(), theXDirection);
gp_Trsf aTrsf;
- aTrsf.SetTransformation(aSystem, gp_Ax3());
- myArray = aTool.CreateTriangulation (aTrsf);
- myTriangulation = aTool.CreatePolyTriangulation (aTrsf);
+ aTrsf.SetTransformation (aSystem, gp_Ax3());
+
+ myArray = new Graphic3d_ArrayOfTriangles(4, 6, Graphic3d_ArrayFlags_VertexNormal);
+ myTriangulation = new Poly_Triangulation(4, 2, Standard_False);
+ TColgp_Array1OfPnt& aNodes = myTriangulation->ChangeNodes();
+ Poly_Array1OfTriangle& aTriangles = myTriangulation->ChangeTriangles();
+
+ gp_Dir aNormal = gp_Dir(0.0, 0.0, -1.0).Transformed(aTrsf);
+
+ gp_Pnt aV1 = gp_Pnt (0.0, 0.0, 0.0).Transformed (aTrsf);
+ gp_Pnt aV2 = gp_Pnt (0.0, theSize, 0.0).Transformed (aTrsf);
+ gp_Pnt aV3 = gp_Pnt (theSize, theSize, 0.0).Transformed (aTrsf);
+ gp_Pnt aV4 = gp_Pnt (theSize, 0.0, 0.0).Transformed (aTrsf);
+
+ myArray->AddVertex (aV1, aNormal);
+ myArray->AddVertex (aV2, aNormal);
+ myArray->AddVertex (aV3, aNormal);
+ myArray->AddVertex (aV4, aNormal);
+ myArray->AddTriangleEdges (3, 1, 2);
+ myArray->AddTriangleEdges (1, 3, 4);
+
+ aNodes.SetValue (1, aV1);
+ aNodes.SetValue (2, aV2);
+ aNodes.SetValue (3, aV3);
+ aNodes.SetValue (4, aV4);
+ aTriangles.SetValue (1, Poly_Triangle(3, 1, 2));
+ aTriangles.SetValue (2, Poly_Triangle(1, 3, 4));
}
//=======================================================================
myPosition (theAxis),
myColor (theColor),
myHasTranslation (Standard_True),
- myLength (theLength),
- myAxisRadius (0.5f),
myHasScaling (Standard_True),
- myBoxSize (2.0f),
myHasRotation (Standard_True),
- myInnerRadius (myLength + myBoxSize),
- myDiskThickness (myBoxSize * 0.5f),
- myIndent (0.2f),
- myHasDragging(Standard_True),
- myFacettesNumber (20),
- myCircleRadius (myLength + myBoxSize + myBoxSize * 0.5f * 0.5f)
+ myStartAngle (0.0f),
+ myEndAngle (2.0f * Standard_ShortReal(M_PI)),
+ myHasDragging (Standard_True),
+ myFacettesNumber (20)
{
//
}
//function : Compute
//purpose :
//=======================================================================
-
void AIS_Manipulator::Axis::Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
- const Handle(Prs3d_ShadingAspect)& theAspect)
+ const Handle(Prs3d_ShadingAspect)& theAspect,
+ const Handle(AIS_Manipulator)& theManipulator)
{
+ const Standard_ShortReal aLenght = theManipulator->ArrowLengthFactor();
+ const Standard_ShortReal anIndent = theManipulator->Gap();
+
if (myHasTranslation)
{
- const Standard_Real anArrowLength = 0.25 * myLength;
- const Standard_Real aCylinderLength = myLength - anArrowLength;
+ const Standard_ShortReal anArrowHeadLength = theManipulator->ArrowHeadLength();
+ const Standard_ShortReal anAxisRadius = theManipulator->AxisRadius();
+ const Standard_Real aCylinderLength = aLenght - anArrowHeadLength + anAxisRadius;
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,
+ anAxisRadius,
+ aLenght,
+ anAxisRadius * 1.5,
+ anArrowHeadLength,
myFacettesNumber);
myTranslatorGroup = thePrs->NewGroup();
myTranslatorGroup->SetClosed (true);
if (myHasScaling)
{
- myCubePos = myReferenceAxis.Direction().XYZ() * (myLength + myIndent);
- myCube.Init (gp_Ax1 (myCubePos, myReferenceAxis.Direction()), myBoxSize);
+ myCubePos = myReferenceAxis.Direction().XYZ() * (aLenght + anIndent);
+ myCube.Init (gp_Ax1 (myCubePos, myReferenceAxis.Direction()), theManipulator->BoxSize());
myScalerGroup = thePrs->NewGroup();
myScalerGroup->SetClosed (true);
if (myHasRotation)
{
- myCircleRadius = myInnerRadius + myIndent * 2 + myDiskThickness * 0.5f;
- myCircle.Init (myInnerRadius + myIndent * 2, myInnerRadius + myDiskThickness + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), myFacettesNumber * 2);
+ const Standard_ShortReal anInnerRadius = theManipulator->InnerRadius();
+ myCircle.Init (anInnerRadius + anIndent * 2,
+ anInnerRadius + theManipulator->DiskThickness() + anIndent * 2,
+ gp_Ax1(gp::Origin(), myReferenceAxis.Direction()),
+ myStartAngle, myEndAngle,
+ myFacettesNumber * 2);
myRotatorGroup = thePrs->NewGroup ();
myRotatorGroup->SetGroupPrimitivesAspect (theAspect->Aspect());
myRotatorGroup->AddPrimitiveArray (myCircle.Array());
else
aXDirection = gp::DX();
- mySector.Init(myInnerRadius + myIndent * 2, gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), aXDirection, myFacettesNumber * 2);
+ mySector.Init (theManipulator->DragPlaneSize(), gp_Ax1(gp::Origin(), myReferenceAxis.Direction()), aXDirection);
myDraggerGroup = thePrs->NewGroup();
Handle(Graphic3d_AspectFillArea3d) aFillArea = new Graphic3d_AspectFillArea3d();
Standard_EXPORT Standard_Boolean ObjectTransformation (const Standard_Integer theX, const Standard_Integer theY,
const Handle(V3d_View)& theView, gp_Trsf& theTrsf);
+ //! Moves the manipulator and objests to the location of the mouse.
+ Standard_EXPORT void SetMouse (const Standard_Integer theX, const Standard_Integer theY, const Handle(V3d_View)& theView);
+
//! Make inactive the current selected manipulator part and reset current axis index and current mode.
//! After its call HasActiveMode() returns false.
//! @sa HasActiveMode()
//! Sets position of the manipulator object.
Standard_EXPORT void SetPosition (const gp_Ax2& thePosition);
- Standard_ShortReal Size() const { return myAxes[0].Size(); }
-
- //! Sets size (length of side of the manipulator cubic bounding box.
- Standard_EXPORT void SetSize (const Standard_ShortReal theSideLength);
+ //! Gets gaps between translator, scaler and rotator sub-presentations.
+ Standard_ShortReal Gap() const { return myIndent; }
//! Sets gaps between translator, scaler and rotator sub-presentations.
Standard_EXPORT void SetGap (const Standard_ShortReal theValue);
+ //! Sets the angular size of the rotation disk.
+ Standard_EXPORT void SetArcAngle (const Standard_ShortReal theStartAngle, const Standard_ShortReal theFinishAngle);
+
+ //! Gets the thickness of the translation axis.
+ Standard_ShortReal AxisRadius() const { return myAxisRadius; }
+
+ //! Sets the thickness of the translation axis.
+ Standard_EXPORT void SetAxisRadius (const Standard_ShortReal theValue);
+
+ //! Gets thickness of the rotation disk.
+ Standard_ShortReal DiskThickness() const { return myDiskThickness; }
+
+ //! Sets thickness of the rotation disk.
+ Standard_EXPORT void SetDiskThickness (const Standard_ShortReal theDiskThickness);
+
+ //! Gets inner radius of the rotation disk.
+ Standard_ShortReal InnerRadius() const { return myInnerRadius; }
+
+ //! Sets inner radius of the rotation disk.
+ Standard_EXPORT void SetInnerRadius (const Standard_ShortReal theInnerRadius);
+
+ //! Gets length of the translation axis.
+ Standard_ShortReal ArrowLengthFactor() const { return myLength; }
+
+ //! Sets length of the translation axis.
+ Standard_EXPORT void SetArrowLengthFactor (const Standard_ShortReal theArrowLengthFactor);
+
+ //! Gets length of the arrow tip of the translation axis.
+ Standard_ShortReal ArrowHeadLength() const { return myArrowHeadLength; }
+
+ //! Sets length of the arrow tip of the translation axis.
+ Standard_EXPORT void SetArrowHeadLength (const Standard_ShortReal theArrowHeadLength);
+
+ //! Gets size of drag plane.
+ Standard_ShortReal DragPlaneSize() const { return myDragPlaneSize; }
+
+ //! Sets size of drag plane.
+ Standard_EXPORT void SetDragPlaneSize (const Standard_ShortReal theDragPlaneSize);
+
+ //! Gets size of the scaling box.
+ Standard_ShortReal BoxSize() const { return myBoxSize; }
+
+ //! Sets size of the scaling box.
+ Standard_EXPORT void SetBoxSize (const Standard_ShortReal theBoxSize);
+
+ //! Sets the sensitivity of the translation part.
+ void SetTranslatorSensitivity (const Standard_Integer theSensitivity) { myTranslatorSensitivity = theSensitivity; }
+
+ //! Sets the sensitivity of the rotation part.
+ void SetRotatorSensitivity (const Standard_Integer theSensitivity) { myRotatorSensitivity = theSensitivity; }
+
+ //! Sets the sensitivity of the scale part.
+ void SetScalerSensitivity (const Standard_Integer theSensitivity) { myScalerSensitivity = theSensitivity; }
+
+ //! Sets the sensitivity of the dragging part.
+ void SetDraggerSensitivity (const Standard_Integer theSensitivity) { myDraggerSensitivity = theSensitivity; }
+
public:
//! Behavior settings to be applied when performing transformation:
Standard_EXPORT void adjustSize (const Bnd_Box& theBox);
+ Standard_EXPORT void setSize (const Standard_ShortReal theSideLength);
+
Standard_EXPORT void setTransformPersistence (const Handle(Graphic3d_TransformPers)& theTrsfPers);
//! Redefines local transformation management method to inform user of inproper use.
public:
Disk()
- : Quadric(),
- myInnerRad(0.0f),
- myOuterRad(1.0f)
+ : Quadric()
{ }
~Disk() { }
void Init (const Standard_ShortReal theInnerRadius,
const Standard_ShortReal theOuterRadius,
- const gp_Ax1& thePosition,
- const Standard_Integer theSlicesNb = 20,
- const Standard_Integer theStacksNb = 20);
-
- protected:
-
- gp_Ax1 myPosition;
- Standard_ShortReal myInnerRad;
- Standard_ShortReal myOuterRad;
+ const gp_Ax1& thePosition,
+ const Standard_ShortReal theStartAngle,
+ const Standard_ShortReal theEndAngle,
+ const Standard_Integer theSlicesNb = 20,
+ const Standard_Integer theStacksNb = 20);
};
class Sphere : public Quadric
~Sector() { }
- void Init(const Standard_ShortReal theRadius,
- const gp_Ax1& thePosition,
- const gp_Dir& theXDirection,
- const Standard_Integer theSlicesNb = 5,
- const Standard_Integer theStacksNb = 5);
+ void Init (const Standard_ShortReal theSize,
+ const gp_Ax1& thePosition,
+ const gp_Dir& theXDirection);
protected:
void Compute (const Handle(PrsMgr_PresentationManager)& thePrsMgr,
const Handle(Prs3d_Presentation)& thePrs,
- const Handle(Prs3d_ShadingAspect)& theAspect);
+ const Handle(Prs3d_ShadingAspect)& theAspect,
+ const Handle(AIS_Manipulator)& theManipulator);
const gp_Ax1& ReferenceAxis() const { return myReferenceAxis; }
void SetScaling (const Standard_Boolean theIsEnabled) { myHasScaling = theIsEnabled; }
- void SetDragging(const Standard_Boolean theIsEnabled) { myHasDragging = theIsEnabled; }
+ void SetDragging (const Standard_Boolean theIsEnabled) { myHasDragging = theIsEnabled; }
- Quantity_Color Color() const { return myColor; }
+ void SetArcAngle (const Standard_ShortReal theStartAngle, const Standard_ShortReal theEndAngle)
+ {
+ myStartAngle = theStartAngle;
+ myEndAngle = theEndAngle;
+ }
- Standard_ShortReal AxisLength() const { return myLength; }
+ Standard_ShortReal StartAngle() const { return myStartAngle; }
- Standard_ShortReal AxisRadius() const { return myAxisRadius; }
+ Standard_ShortReal EndAngle() const { return myEndAngle; }
- void SetAxisRadius (const Standard_ShortReal theValue) { myAxisRadius = theValue; }
+ Quantity_Color Color() const { return myColor; }
const Handle(Prs3d_Presentation)& TranslatorHighlightPrs() const { return myHighlightTranslator; }
const Handle(Graphic3d_ArrayOfTriangles)& TriangleArray() const { return myTriangleArray; }
- void SetIndent (const Standard_ShortReal theValue) { myIndent = theValue; }
-
- Standard_ShortReal Size() const { return myLength + myBoxSize + myDiskThickness + myIndent * 2.0f; }
-
- gp_Pnt ScalerCenter (const gp_Pnt& theLocation) const { return theLocation.XYZ() + myPosition.Direction().XYZ() * (myLength + myIndent + myBoxSize * 0.5f); }
-
- void SetSize (const Standard_ShortReal theValue)
- {
- if (myIndent > theValue * 0.1f)
- {
- myLength = theValue * 0.7f;
- myBoxSize = theValue * 0.15f;
- myDiskThickness = theValue * 0.05f;
- myIndent = theValue * 0.05f;
- }
- else // use pre-set value of predent
- {
- Standard_ShortReal aLength = theValue - 2 * myIndent;
- myLength = aLength * 0.8f;
- myBoxSize = aLength * 0.15f;
- myDiskThickness = aLength * 0.05f;
- }
- myInnerRadius = myIndent * 2 + myBoxSize + myLength;
- myAxisRadius = myBoxSize / 4.0f;
- }
-
Standard_Integer FacettesNumber() const { return myFacettesNumber; }
public:
const gp_Pnt& TranslatorTipPosition() const { return myArrowTipPos; }
const Sector& DraggerSector() const { return mySector; }
const Disk& RotatorDisk() const { return myCircle; }
- float RotatorDiskRadius() const { return myCircleRadius; }
const Cube& ScalerCube() const { return myCube; }
const gp_Pnt& ScalerCubePosition() const { return myCubePos; }
protected:
gp_Ax1 myReferenceAxis; //!< Returns reference axis assignment.
- gp_Ax1 myPosition; //!< Position of the axis including local transformation.
+ gp_Ax1 myPosition; //!< Position of the axis including local transformation.
Quantity_Color myColor;
Standard_Boolean myHasTranslation;
- Standard_ShortReal myLength; //!< Length of translation axis.
- Standard_ShortReal myAxisRadius;
-
Standard_Boolean myHasScaling;
- Standard_ShortReal myBoxSize; //!< Size of scaling cube.
-
Standard_Boolean myHasRotation;
- Standard_ShortReal myInnerRadius; //!< Radius of rotation circle.
- Standard_ShortReal myDiskThickness;
- Standard_ShortReal myIndent; //!< Gap between visual part of the manipulator.
-
Standard_Boolean myHasDragging;
+ Standard_ShortReal myStartAngle; //!< Start angle of the arc.
+ Standard_ShortReal myEndAngle; //!< End angle of the arc.
+
protected:
Standard_Integer myFacettesNumber;
gp_Pnt myArrowTipPos;
Sector mySector;
Disk myCircle;
- float myCircleRadius;
Cube myCube;
gp_Pnt myCubePos;
Sphere myCenter; //!< Visual part displaying the center sphere of the manipulator.
gp_Ax2 myPosition; //!< Position of the manipulator object. it displays its location and position of its axes.
+ Standard_ShortReal myLength; //!< Length of translation axis.
+ Standard_ShortReal myArrowHeadLength; //!< Length of the arrow tip.
+ Standard_ShortReal myAxisRadius; //!< Radius of axis.
+
+ Standard_ShortReal myBoxSize; //!< Size of scaling cube.
+
+ Standard_ShortReal myInnerRadius; //!< Radius of rotation circle.
+ Standard_ShortReal myDiskThickness; //!< Thickness of the rotating disc.
+ Standard_ShortReal myIndent; //!< Gap between visual part of the manipulator.
+
+ Standard_ShortReal myDragPlaneSize; //!< Size of the plane to drag.
+
+ Standard_Integer myTranslatorSensitivity;
+ Standard_Integer myRotatorSensitivity;
+ Standard_Integer myScalerSensitivity;
+ Standard_Integer myDraggerSensitivity;
+
Standard_Integer myCurrentIndex; //!< Index of active axis.
AIS_ManipulatorMode myCurrentMode; //!< Name of active manipulation mode.
aCmd.AddOption ("followDragging", "... {0|1} - set following dragging transform");
aCmd.AddOption ("gap", "... value - set gap between sub-parts");
aCmd.AddOption ("part", "... axis mode {0|1} - set visual part");
- aCmd.AddOption ("parts", "... all axes mode {0|1} - set visual part");
+ aCmd.AddOption ("parts", "... all mode {0|1} - set visual part");
+ aCmd.AddOption ("angle", "... startAngle endAngle - set arc angle");
+ aCmd.AddOption ("axisrad", "... radius - set axis radius");
+ aCmd.AddOption ("diskthickness", "... value - set disk thickness");
+ aCmd.AddOption ("innerrad", "... radius - set axis radius");
+ aCmd.AddOption ("arrlen", "... len - set axis lenght");
+ aCmd.AddOption ("arrheadlen", "... len - set length of the arrow tip");
+ aCmd.AddOption ("dragplanesize", "... size - set size of the drag plane");
+ aCmd.AddOption ("boxsize", "... size - set size os scaling box");
aCmd.AddOption ("pos", "... x y z [nx ny nz [xx xy xz]] - set position of manipulator");
- aCmd.AddOption ("size", "... size - set size of manipulator");
aCmd.AddOption ("zoomable", "... {0|1} - set zoom persistence");
aCmd.Parse (theArgsNb, theArgVec);
return 1;
}
- aManipulator->SetPart(static_cast<AIS_ManipulatorMode>(aMode), aOnOff);
+ aManipulator->SetPart (static_cast<AIS_ManipulatorMode>(aMode), aOnOff);
+ }
+ if (aCmd.HasOption ("angle", 2, Standard_True))
+ {
+ Standard_Integer aStartAngle = aCmd.ArgInt ("angle", 0);
+ Standard_Integer anEndAngle = aCmd.ArgInt ("angle", 1);
+ aManipulator->SetArcAngle (Standard_ShortReal (aStartAngle * M_PI / 180.0f),
+ Standard_ShortReal (anEndAngle * M_PI / 180.0f));
+ }
+ if (aCmd.HasOption ("axisrad", 1, Standard_True))
+ {
+ Standard_ShortReal aRadius = aCmd.ArgFloat ("axisrad", 0);
+ if (aRadius <= 0 )
+ {
+ Message::SendFail ("Syntax error: radius value should be positive");
+ return 1;
+ }
+ aManipulator->SetAxisRadius (aRadius);
+ }
+ if (aCmd.HasOption("diskthickness", 1, Standard_True))
+ {
+ Standard_ShortReal aDiskThickness = aCmd.ArgFloat ("diskthickness", 0);
+ if (aDiskThickness <= 0)
+ {
+ Message::SendFail ("Syntax error: disk thickness value should be positive");
+ return 1;
+ }
+ aManipulator->SetDiskThickness (aDiskThickness);
+ }
+ if (aCmd.HasOption("innerrad", 1, Standard_True))
+ {
+ Standard_ShortReal anInnerRadius = aCmd.ArgFloat ("innerrad", 0);
+ if (anInnerRadius <= 0)
+ {
+ Message::SendFail ("Syntax error: disk thickness value should be positive");
+ return 1;
+ }
+ aManipulator->SetInnerRadius (anInnerRadius);
+ }
+ if (aCmd.HasOption ("arrlen", 1, Standard_True))
+ {
+ Standard_ShortReal anArrowLength = aCmd.ArgFloat ("arrlen", 0);
+ if (anArrowLength <= 0)
+ {
+ Message::SendFail ("Syntax error: arrow lenght value should be positive");
+ return 1;
+ }
+ aManipulator->SetArrowLengthFactor (anArrowLength);
+ }
+ if (aCmd.HasOption ("arrheadlen", 1, Standard_True))
+ {
+ Standard_ShortReal anArrowHeadLength = aCmd.ArgFloat ("arrheadlen", 0);
+ if (anArrowHeadLength <= 0)
+ {
+ Message::SendFail ("Syntax error: arrow head lenght value should be positive");
+ return 1;
+ }
+ aManipulator->SetArrowHeadLength (anArrowHeadLength);
+ }
+ if (aCmd.HasOption ("dragplanesize", 1, Standard_True))
+ {
+ Standard_ShortReal aDragPlaneSize = aCmd.ArgFloat ("dragplanesize", 0);
+ if (aDragPlaneSize <= 0)
+ {
+ Message::SendFail ("Syntax error: drag plane size should be positive");
+ return 1;
+ }
+ aManipulator->SetDragPlaneSize (aDragPlaneSize);
+ }
+ if (aCmd.HasOption ("boxsize", 1, Standard_True))
+ {
+ Standard_ShortReal aBoxSize = aCmd.ArgFloat ("boxsize", 0);
+ if (aBoxSize <= 0)
+ {
+ Message::SendFail ("Syntax error: box size should be positive");
+ return 1;
+ }
+ aManipulator->SetBoxSize (aBoxSize);
}
if (aCmd.HasOption ("pos", 3, Standard_True))
{
aManipulator->SetPosition (gp_Ax2 (aLocation, aVDir, aXDir));
}
- if (aCmd.HasOption ("size", 1, Standard_True))
- {
- aManipulator->SetSize (aCmd.ArgFloat ("size"));
- }
if (aCmd.HasOption ("zoomable", 1, Standard_True))
{
aManipulator->SetZoomPersistence (!aCmd.ArgBool ("zoomable"));
if (ViewerTest::GetAISContext()->IsDisplayed (aManipulator))
{
- ViewerTest::GetAISContext()->Remove (aManipulator, Standard_False);
- ViewerTest::GetAISContext()->Display (aManipulator, Standard_False);
+ ViewerTest::GetAISContext()->Redisplay (aManipulator, Standard_False);
}
}
"\n '-followDragging {0|1}' - set following dragging transform"
"\n '-gap value' - set gap between sub-parts"
"\n '-part axis mode {0|1}' - set visual part"
- "\n '-parts axis mode {0|1}' - set visual part"
+ "\n '-parts mode {0|1}' - set visual part"
+ "\n '-angle startAngle endAngle - set arc angle"
+ "\n '-axisrad radius - set axis radius"
+ "\n '-diskthickness value - set disk thickness"
+ "\n '-innerrad radius - set axis radius"
+ "\n '-arrlen len - set axis lenght"
+ "\n '-arrheadlen len - set length of the arrow tip"
+ "\n '-dragplanesize size - set size of the drag plane"
+ "\n '-boxsize size - set size os scaling box"
"\n '-pos x y z [nx ny nz [xx xy xz]' - set position of manipulator"
- "\n '-size value' - set size of manipulator"
+ //"\n '-size value' - set size of manipulator"
"\n '-zoomable {0|1}' - set zoom persistence",
__FILE__, VManipulator, group);