mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0032389: Visualization, AIS_Axis - simple ray creation and displaying
- Added constructor to create axis by gp_Ax1 - Added possibility to display axis as ray - Added function SetDisplayAspect to set required visualization parameters
This commit is contained in:
parent
9749af25ae
commit
1f3c5058f2
@ -34,6 +34,7 @@
|
|||||||
#include <Select3D_SensitiveSegment.hxx>
|
#include <Select3D_SensitiveSegment.hxx>
|
||||||
#include <SelectMgr_EntityOwner.hxx>
|
#include <SelectMgr_EntityOwner.hxx>
|
||||||
#include <SelectMgr_Selection.hxx>
|
#include <SelectMgr_Selection.hxx>
|
||||||
|
#include <Standard_NumericError.hxx>
|
||||||
#include <StdPrs_Curve.hxx>
|
#include <StdPrs_Curve.hxx>
|
||||||
#include <TColgp_Array1OfPnt.hxx>
|
#include <TColgp_Array1OfPnt.hxx>
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
@ -56,7 +57,6 @@ myIsXYZAxis(Standard_False)
|
|||||||
|
|
||||||
gp_Dir thedir = myComponent->Position().Direction();
|
gp_Dir thedir = myComponent->Position().Direction();
|
||||||
gp_Pnt loc = myComponent->Position().Location();
|
gp_Pnt loc = myComponent->Position().Location();
|
||||||
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
|
|
||||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
|
Standard_Real aLength = UnitsAPI::AnyToLS(250000., "mm");
|
||||||
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
||||||
myPlast = loc.XYZ() - aLength*thedir.XYZ();
|
myPlast = loc.XYZ() - aLength*thedir.XYZ();
|
||||||
@ -73,7 +73,6 @@ myTypeOfAxis(anAxisType),
|
|||||||
myIsXYZAxis(Standard_True)
|
myIsXYZAxis(Standard_True)
|
||||||
{
|
{
|
||||||
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
|
Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
|
||||||
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (100. ,"LENGTH");
|
|
||||||
Standard_Real aLength;
|
Standard_Real aLength;
|
||||||
try {
|
try {
|
||||||
aLength = UnitsAPI::AnyToLS(100. ,"mm");
|
aLength = UnitsAPI::AnyToLS(100. ,"mm");
|
||||||
@ -104,12 +103,36 @@ AIS_Axis::AIS_Axis(const Handle(Geom_Axis1Placement)& anAxis)
|
|||||||
|
|
||||||
gp_Dir thedir = myComponent->Position().Direction();
|
gp_Dir thedir = myComponent->Position().Direction();
|
||||||
gp_Pnt loc = myComponent->Position().Location();
|
gp_Pnt loc = myComponent->Position().Location();
|
||||||
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
|
|
||||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
|
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
|
||||||
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
||||||
myPlast = 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
|
//function : SetComponent
|
||||||
@ -125,7 +148,6 @@ void AIS_Axis::SetComponent(const Handle(Geom_Line)& aComponent)
|
|||||||
|
|
||||||
gp_Dir thedir = myComponent->Position().Direction();
|
gp_Dir thedir = myComponent->Position().Direction();
|
||||||
gp_Pnt loc = myComponent->Position().Location();
|
gp_Pnt loc = myComponent->Position().Location();
|
||||||
//POP Standard_Real aLength = UnitsAPI::CurrentToLS (250000. ,"LENGTH");
|
|
||||||
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
|
Standard_Real aLength = UnitsAPI::AnyToLS(250000. ,"mm");
|
||||||
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
myPfirst = loc.XYZ() + aLength*thedir.XYZ();
|
||||||
myPlast = loc.XYZ() - aLength*thedir.XYZ();
|
myPlast = loc.XYZ() - aLength*thedir.XYZ();
|
||||||
@ -166,7 +188,7 @@ void AIS_Axis::Compute (const Handle(PrsMgr_PresentationManager)& ,
|
|||||||
const Standard_Integer )
|
const Standard_Integer )
|
||||||
{
|
{
|
||||||
thePrs->SetInfiniteState (myInfiniteState);
|
thePrs->SetInfiniteState (myInfiniteState);
|
||||||
thePrs->SetDisplayPriority(5);
|
thePrs->SetDisplayPriority (5);
|
||||||
if (!myIsXYZAxis)
|
if (!myIsXYZAxis)
|
||||||
{
|
{
|
||||||
GeomAdaptor_Curve curv (myComponent);
|
GeomAdaptor_Curve curv (myComponent);
|
||||||
@ -230,6 +252,17 @@ void AIS_Axis::SetWidth(const Standard_Real aValue)
|
|||||||
SynchronizeAspects();
|
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
|
//function : ComputeFields
|
||||||
//purpose :
|
//purpose :
|
||||||
|
@ -49,6 +49,11 @@ public:
|
|||||||
//! Initializes the axis1 position anAxis.
|
//! Initializes the axis1 position anAxis.
|
||||||
Standard_EXPORT AIS_Axis(const Handle(Geom_Axis1Placement)& 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
|
//! Returns the axis entity aComponent and identifies it
|
||||||
//! as a component of a shape.
|
//! as a component of a shape.
|
||||||
const Handle(Geom_Line)& Component() const { return myComponent; }
|
const Handle(Geom_Line)& Component() const { return myComponent; }
|
||||||
@ -92,6 +97,9 @@ public:
|
|||||||
|
|
||||||
Standard_EXPORT void SetWidth (const Standard_Real aValue) 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 UnsetColor() Standard_OVERRIDE;
|
||||||
|
|
||||||
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
|
Standard_EXPORT void UnsetWidth() Standard_OVERRIDE;
|
||||||
|
@ -7224,16 +7224,9 @@ static Standard_Integer VSelectByAxis (Draw_Interpretor& theDI,
|
|||||||
Quantity_Color anAxisColor = Quantity_NOC_GREEN;
|
Quantity_Color anAxisColor = Quantity_NOC_GREEN;
|
||||||
Handle(Geom_Axis2Placement) anAx2Axis =
|
Handle(Geom_Axis2Placement) anAx2Axis =
|
||||||
new Geom_Axis2Placement (gp_Ax2(anAxisLocation, anAxisDirection));
|
new Geom_Axis2Placement (gp_Ax2(anAxisLocation, anAxisDirection));
|
||||||
Handle(AIS_Axis) anAISAxis = new AIS_Axis (anAx2Axis, AIS_TOAX_ZAxis);
|
Handle(AIS_Axis) anAISAxis = new AIS_Axis (gp_Ax1 (anAxisLocation, anAxisDirection));
|
||||||
const Handle(Prs3d_Drawer)& anAxisDrawer = anAISAxis->Attributes();
|
anAISAxis->SetColor (anAxisColor);
|
||||||
anAxisDrawer->SetOwnDatumAspects();
|
ViewerTest::Display (TCollection_AsciiString (aName) + "_axis", anAISAxis, false);
|
||||||
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);
|
|
||||||
|
|
||||||
// Display axis start point
|
// Display axis start point
|
||||||
Handle(AIS_Point) anAISStartPnt = new AIS_Point (new Geom_CartesianPoint (anAxisLocation));
|
Handle(AIS_Point) anAISStartPnt = new AIS_Point (new Geom_CartesianPoint (anAxisLocation));
|
||||||
@ -7253,16 +7246,9 @@ static Standard_Integer VSelectByAxis (Draw_Interpretor& theDI,
|
|||||||
Standard_Real aNormalLength = aNormalLengths.Value (anIndex + 1);
|
Standard_Real aNormalLength = aNormalLengths.Value (anIndex + 1);
|
||||||
if (aNormal.SquareModulus() > ShortRealEpsilon())
|
if (aNormal.SquareModulus() > ShortRealEpsilon())
|
||||||
{
|
{
|
||||||
Handle(Geom_Axis2Placement) anAx2Normal =
|
gp_Dir aNormalDir ((Standard_Real)aNormal.x(), (Standard_Real)aNormal.y(), (Standard_Real)aNormal.z());
|
||||||
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 (gp_Ax1 (aPoint, aNormalDir), aNormalLength);
|
||||||
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);
|
|
||||||
anAISNormal->SetColor (Quantity_NOC_BLUE);
|
anAISNormal->SetColor (Quantity_NOC_BLUE);
|
||||||
anAISNormal->SetAxis2Placement (anAx2Normal, AIS_TOAX_ZAxis); // This is workaround to update axis length
|
|
||||||
anAISNormal->SetInfiniteState (false);
|
anAISNormal->SetInfiniteState (false);
|
||||||
ViewerTest::Display (TCollection_AsciiString(aName) + "_normal_" + anIndex, anAISNormal, false);
|
ViewerTest::Display (TCollection_AsciiString(aName) + "_normal_" + anIndex, anAISNormal, false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user