#include <Select3D_SensitiveSegment.hxx>
#include <SelectMgr_EntityOwner.hxx>
#include <SelectMgr_Selection.hxx>
+#include <Standard_NumericError.hxx>
#include <StdPrs_Curve.hxx>
#include <TColgp_Array1OfPnt.hxx>
#include <TopoDS.hxx>
gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location();
-//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ();
myIsXYZAxis(Standard_True)
{
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
-//POP Standard_Real aLength = UnitsAPI::CurrentToLS (100. ,"LENGTH");
Standard_Real aLength;
try {
aLength = UnitsAPI::AnyToLS(100. ,"mm");
gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location();
-//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ();
}
+//=======================================================================
+//function : AIS_Axis
+//purpose :
+//=======================================================================
+AIS_Axis::AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength)
+: myComponent (new Geom_Line (theAxis)),
+ myTypeOfAxis (AIS_TOAX_ZAxis),
+ myIsXYZAxis (Standard_True)
+{
+ myDir = theAxis.Direction();
+ myPfirst = theAxis.Location();
+ if (theLength <= 0 && theLength != -1)
+ {
+ throw Standard_NumericError ("AIS_Axis::AIS_Axis : invalid value for theLength parameter");
+ }
+ myVal = (theLength == -1) ? UnitsAPI::AnyToLS (250000., "mm") : theLength;
+ myPlast = myPfirst.XYZ() + myVal * myDir.XYZ();
+ SetInfiniteState();
+ Handle(Prs3d_DatumAspect) aDatumAspect = new Prs3d_DatumAspect();
+ aDatumAspect->SetDrawLabels (Standard_False);
+ myDrawer->SetDatumAspect (aDatumAspect);
+ Handle(Prs3d_LineAspect) aDefaultLineAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
+ myDrawer->SetLineAspect (aDefaultLineAspect);
+ myLineAspect = myDrawer->LineAspect();
+}
//=======================================================================
//function : SetComponent
gp_Dir thedir = myComponent->Position().Direction();
gp_Pnt loc = myComponent->Position().Location();
-//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
myPlast = loc.XYZ() - aLength*thedir.XYZ();
const Standard_Integer )
{
thePrs->SetInfiniteState (myInfiniteState);
- thePrs->SetDisplayPriority(5);
+ thePrs->SetDisplayPriority (5);
if (!myIsXYZAxis)
{
GeomAdaptor_Curve curv (myComponent);
SynchronizeAspects();
}
+//=======================================================================
+//function : SetDisplayAspect
+//purpose :
+//=======================================================================
+void AIS_Axis::SetDisplayAspect (const Handle(Prs3d_LineAspect)& theNewLineAspect)
+{
+ myDrawer->SetLineAspect (theNewLineAspect);
+ myLineAspect = myDrawer->LineAspect();
+ SetColor (theNewLineAspect->Aspect()->Color());
+}
+
//=======================================================================
//function : ComputeFields
//purpose :
//! Initializes the axis1 position anAxis.
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis);
+ //! Initializes the ray as axis with start point and direction
+ //! @param[in] theAxis Start point and direction of the ray
+ //! @param[in] theLength Optional length of the ray (ray is infinite by default).
+ Standard_EXPORT AIS_Axis (const gp_Ax1& theAxis, const Standard_Real theLength = -1);
+
//! Returns the axis entity aComponent and identifies it
//! as a component of a shape.
const Handle(Geom_Line)& Component() const { return myComponent; }
virtual AIS_KindOfInteractive Type() const Standard_OVERRIDE { return AIS_KindOfInteractive_Datum; }
Standard_EXPORT void SetColor (const Quantity_Color& aColor) Standard_OVERRIDE;
-
+
Standard_EXPORT void SetWidth (const Standard_Real aValue) Standard_OVERRIDE;
-
+
+ //! Set required visualization parameters.
+ Standard_EXPORT void SetDisplayAspect (const Handle(Prs3d_LineAspect)& theNewDatumAspect);
+
Standard_EXPORT void UnsetColor() Standard_OVERRIDE;
-
+
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
private:
Quantity_Color anAxisColor = Quantity_NOC_GREEN;
Handle(Geom_Axis2Placement) anAx2Axis =
new Geom_Axis2Placement (gp_Ax2(anAxisLocation, anAxisDirection));
- Handle(AIS_Axis) anAISAxis = new AIS_Axis (anAx2Axis, AIS_TOAX_ZAxis);
- const Handle(Prs3d_Drawer)& anAxisDrawer = anAISAxis->Attributes();
- anAxisDrawer->SetOwnDatumAspects();
- Standard_Real aLength = UnitsAPI::AnyToLS (250000., "mm");
- anAxisDrawer->DatumAspect()->SetAxisLength (aLength, aLength, aLength);
- anAxisDrawer->DatumAspect()->SetDrawLabels (false);
- anAxisDrawer->DatumAspect()->SetDrawArrows (true);
- anAISAxis->SetColor (Quantity_NOC_GREEN);
- anAISAxis->SetAxis2Placement (anAx2Axis, AIS_TOAX_ZAxis); // This is workaround to update axis length
- ViewerTest::Display (TCollection_AsciiString(aName) + "_axis", anAISAxis, false);
+ Handle(AIS_Axis) anAISAxis = new AIS_Axis (gp_Ax1 (anAxisLocation, anAxisDirection));
+ anAISAxis->SetColor (anAxisColor);
+ ViewerTest::Display (TCollection_AsciiString (aName) + "_axis", anAISAxis, false);
// Display axis start point
Handle(AIS_Point) anAISStartPnt = new AIS_Point (new Geom_CartesianPoint (anAxisLocation));
Standard_Real aNormalLength = aNormalLengths.Value (anIndex + 1);
if (aNormal.SquareModulus() > ShortRealEpsilon())
{
- Handle(Geom_Axis2Placement) anAx2Normal =
- new Geom_Axis2Placement(gp_Ax2(aPoint, gp_Dir((Standard_Real )aNormal.x(), (Standard_Real )aNormal.y(), (Standard_Real )aNormal.z())));
- Handle(AIS_Axis) anAISNormal = new AIS_Axis (anAx2Normal, AIS_TOAX_ZAxis);
- const Handle(Prs3d_Drawer)& aNormalDrawer = anAISNormal->Attributes();
- aNormalDrawer->SetOwnDatumAspects();
- aNormalDrawer->DatumAspect()->SetAxisLength (aNormalLength, aNormalLength, aNormalLength);
- aNormalDrawer->DatumAspect()->SetDrawLabels (false);
- aNormalDrawer->DatumAspect()->SetDrawArrows (true);
+ gp_Dir aNormalDir ((Standard_Real)aNormal.x(), (Standard_Real)aNormal.y(), (Standard_Real)aNormal.z());
+ Handle(AIS_Axis) anAISNormal = new AIS_Axis (gp_Ax1 (aPoint, aNormalDir), aNormalLength);
anAISNormal->SetColor (Quantity_NOC_BLUE);
- anAISNormal->SetAxis2Placement (anAx2Normal, AIS_TOAX_ZAxis); // This is workaround to update axis length
anAISNormal->SetInfiniteState (false);
ViewerTest::Display (TCollection_AsciiString(aName) + "_normal_" + anIndex, anAISNormal, false);
}