Corrections to support old results in geometry samples: added ISession_Direction::SetLineAspect(); ISession_Direction class in Modeling sample was corrected.
AddSeparator(aDoc,Message);
//--------------------------------------------------------------
+ // Set style for vector lines
+ Handle(Prs3d_LineAspect) anAxesAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
+
DisplayPoint(aDoc,P1,"P1",false,0.1);
Handle(ISession_Direction) aDirection = new ISession_Direction(P1,D,2);
aDoc->GetAISContext()->Display(aDirection, Standard_False);
Handle(ISession_Direction) aDirection2 = new ISession_Direction(P1,AXDirection,2);
aDirection2->SetText("A.XDirection");
+ aDirection2->SetLineAspect (anAxesAspect);
aDoc->GetAISContext()->Display(aDirection2, Standard_False);
Handle(ISession_Direction) aDirection3 = new ISession_Direction(P1,AYDirection,2);
aDirection3->SetText("A.YDirection");
+ aDirection3->SetLineAspect (anAxesAspect);
aDoc->GetAISContext()->Display(aDirection3, Standard_False);
DisplayPoint(aDoc,P2,"P2",false,0.1);
Handle(ISession_Direction) aDirection5 = new ISession_Direction(P2,A2XDirection,2);
aDirection5->SetText("A2 XDirection");
+ aDirection5->SetLineAspect (anAxesAspect);
aDoc->GetAISContext()->Display(aDirection5, Standard_False);
Handle(ISession_Direction) aDirection6 = new ISession_Direction(P2,A2YDirection,2);
aDirection6->SetText("A2 YDirection");
+ aDirection6->SetLineAspect (anAxesAspect);
aDoc->GetAISContext()->Display(aDirection6, Standard_False);
Message += "IsDirectA = ";
}
-ISession_Direction::ISession_Direction(const gp_Pnt& aPnt,const gp_Dir& aDir,Standard_Real aLength,Standard_Real anArrowLength)
-:myPnt(aPnt),myDir(aDir),myLength(aLength),myArrowLength(anArrowLength)
+ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
+ const gp_Dir& aDir,
+ Standard_Real aLength,
+ Standard_Real anArrowLength)
+: myPnt (aPnt),
+ myDir (aDir),
+ myLength (aLength),
+ myArrowLength (anArrowLength)
{}
-ISession_Direction::ISession_Direction(const gp_Pnt& aPnt,const gp_Vec& aVec,Standard_Real anArrowLength)
-:myPnt(aPnt),myDir(aVec),myArrowLength(anArrowLength)
+ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
+ const gp_Vec& aVec,
+ Standard_Real anArrowLength)
+: myPnt (aPnt),
+ myDir (aVec),
+ myArrowLength (anArrowLength)
{
myLength = aVec.Magnitude();
}
-ISession_Direction::ISession_Direction(const gp_Pnt2d& aPnt2d,
- const gp_Dir2d& aDir2d,
- Standard_Real aLength)
-:myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aDir2d.X(),aDir2d.Y(),0)),myLength(aLength)
-{}
+ISession_Direction::ISession_Direction (const gp_Pnt2d& aPnt2d,
+ const gp_Dir2d& aDir2d,
+ Standard_Real aLength)
+: myPnt (gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0.0)),
+ myDir (gp_Dir(aDir2d.X(),aDir2d.Y(),0.0)),
+ myLength (aLength)
+{
+ myArrowLength = myDrawer->ArrowAspect()->Length();
+}
-ISession_Direction::ISession_Direction(const gp_Pnt2d& aPnt2d,
- const gp_Vec2d& aVec2d)
-:myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aVec2d.X(),aVec2d.Y(),0))
+ISession_Direction::ISession_Direction (const gp_Pnt2d& aPnt2d,
+ const gp_Vec2d& aVec2d)
+: myPnt (gp_Pnt (aPnt2d.X(), aPnt2d.Y(), 0.0)),
+ myDir (gp_Dir(aVec2d.X(), aVec2d.Y(), 0.0))
{
myLength = aVec2d.Magnitude();
+ myArrowLength = myDrawer->ArrowAspect()->Length();
}
}
-void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer /*aMode*/)
+void ISession_Direction::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer /*aMode*/)
{
- Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
- anArrowAspect->SetLength(myArrowLength);
- myDrawer->SetArrowAspect(anArrowAspect);
-
- gp_Pnt LastPoint = myPnt ;
- LastPoint.Translate (myLength*gp_Vec(myDir)) ;
-
- if (myText.Length() == 0)
- DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myPnt,LastPoint,DsgPrs_AS_LASTAR);
- else
- {
- gp_Pnt OffsetPoint = myPnt;
- OffsetPoint.Translate ( (myLength) *gp_Vec(myDir)) ;
- DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myText,myPnt,LastPoint, -myDir, OffsetPoint, DsgPrs_AS_LASTAR);
- }
+ // Set style for arrow
+ Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
+ anArrowAspect->SetLength (myArrowLength);
+
+ gp_Pnt aLastPoint = myPnt;
+ aLastPoint.Translate (myLength*gp_Vec(myDir));
+
+ // Draw Line
+ Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (2);
+ aPrims->AddVertex (myPnt);
+ aPrims->AddVertex (aLastPoint);
+ Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect());
+ Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (aPrims);
+ // Draw arrow
+ Prs3d_Arrow::Draw (aPresentation,
+ aLastPoint,
+ myDir,
+ anArrowAspect->Angle(),
+ anArrowAspect->Length());
+
+ // Draw text
+ if (myText.Length() != 0)
+ {
+ gp_Pnt aTextPosition = aLastPoint;
+ Prs3d_Text::Draw (aPresentation,
+ myDrawer->TextAspect(),
+ myText,
+ aTextPosition);
+ }
}
-void ISession_Direction::Compute(const Handle(Prs3d_Projector)& /*aProjector*/,
- const Handle(Prs3d_Presentation)& /*aPresentation*/)
- {
- }
+void ISession_Direction::Compute (const Handle(Prs3d_Projector)& /*aProjector*/,
+ const Handle(Prs3d_Presentation)& /*aPresentation*/)
+{
+}
-void ISession_Direction::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/,
- const Standard_Integer /*aMode*/)
-{
+void ISession_Direction::ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/,
+ const Standard_Integer /*aMode*/)
+{
+}
+
+void ISession_Direction::SetText (TCollection_ExtendedString & theText)
+{
+ myText = theText;
}
-void ISession_Direction::SetText(TCollection_ExtendedString & aText)
+void ISession_Direction::SetText (Standard_CString theText)
{
- myText = aText;
+ myText = theText;
}
-void ISession_Direction::SetText(Standard_CString aText)
+void ISession_Direction::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
{
- myText = aText;
+ myDrawer->SetLineAspect (theAspect);
}
{
public:
TCollection_ExtendedString myText;
- void SetText(TCollection_ExtendedString& aText);
- void SetText(Standard_CString aText);
+ void SetText (TCollection_ExtendedString& aText);
+ void SetText (Standard_CString aText);
+ void SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
ISession_Direction();
- ISession_Direction(const gp_Pnt& aPnt,const gp_Dir& aDir,Standard_Real aLength=1,Standard_Real anArrowLength=1);
- ISession_Direction(const gp_Pnt& aPnt,const gp_Vec& aVec,Standard_Real anArrowLength=1);
+ ISession_Direction (const gp_Pnt& aPnt,const gp_Dir& aDir,Standard_Real aLength=1,Standard_Real anArrowLength=1);
+ ISession_Direction (const gp_Pnt& aPnt,const gp_Vec& aVec,Standard_Real anArrowLength=1);
- ISession_Direction(const gp_Pnt2d& aPnt2d,const gp_Dir2d& aDir2d,Standard_Real aLength=1);
- ISession_Direction(const gp_Pnt2d& aPnt2d,const gp_Vec2d& aVec2d);
+ ISession_Direction (const gp_Pnt2d& aPnt2d,const gp_Dir2d& aDir2d,Standard_Real aLength=1);
+ ISession_Direction (const gp_Pnt2d& aPnt2d,const gp_Vec2d& aVec2d);
virtual ~ISession_Direction();
DEFINE_STANDARD_RTTI(ISession_Direction)
#include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
#include <GProp_PEquation.hxx>
#include <gp.hxx>
#include <gp_Ax2d.hxx>
#include <Poly_Triangulation.hxx>
#include <Precision.hxx>
+#include <Prs3d_Arrow.hxx>
#include <Prs3d_Root.hxx>
#include <Prs3d_Text.hxx>
#include <Prs3d_ArrowAspect.hxx>
const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/)
{
- Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
- anArrowAspect->SetLength(myStartPnt.Distance(myEndPnt));
- myDrawer->SetArrowAspect(anArrowAspect);
-
- DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,
- myStartPnt,myEndPnt,
- DsgPrs_AS_LASTAR);
+ // Set style for arrow
+ Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
+
+ // Draw Line
+ Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (2);
+ aPrims->AddVertex (myStartPnt);
+ aPrims->AddVertex (myEndPnt);
+ Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect());
+ Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (aPrims);
+ // Draw arrow
+ Prs3d_Arrow::Draw (aPresentation,
+ myEndPnt,
+ gp_Dir (gp_Vec(myStartPnt, myEndPnt)),
+ anArrowAspect->Angle(),
+ anArrowAspect->Length());
}
-
-
#include "AIS_InteractiveObject.hxx"
DEFINE_STANDARD_HANDLE(ISession_Direction,AIS_InteractiveObject)
-class ISession_Direction : public AIS_InteractiveObject
+class ISession_Direction : public AIS_InteractiveObject
{
public:
- ISession_Direction();
+ ISession_Direction();
ISession_Direction(const gp_Pnt& aPnt,const gp_Pnt& aPnt2);
ISession_Direction(const gp_Pnt& aPnt,const gp_Vec& aVec);
- DEFINE_STANDARD_RTTI(ISession_Direction)
+ DEFINE_STANDARD_RTTI(ISession_Direction)
private:
- void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
- const Handle(Prs3d_Presentation)& aPresentation,
- const Standard_Integer aMode);
- void ComputeSelection(const class Handle_SelectMgr_Selection &,const int){};
- gp_Pnt myStartPnt;
- gp_Pnt myEndPnt;
+ void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
+ const Handle(Prs3d_Presentation)& aPresentation,
+ const Standard_Integer aMode);
+
+ void ComputeSelection (const class Handle_SelectMgr_Selection &,const int){};
+
+private:
+
+ gp_Pnt myStartPnt;
+ gp_Pnt myEndPnt;
};
#endif // !defined(AFX_ISession_Direction_H__767C0DB3_A3B0_11D1_8DA3_0800369C8A03__INCLUDED_)
#include <Geom_Circle.hxx>
#include <Geom_Transformation.hxx>
#include <Geom_CylindricalSurface.hxx>
+#include <Graphic3d_ArrayOfSegments.hxx>
+#include <Graphic3d_Group.hxx>
#include <BRepBuilderAPI_GTransform.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCone.hxx>
#include <Plate_PinpointConstraint.hxx>
#include <Plate_D1.hxx>
#include <Plate_GtoCConstraint.hxx>
+#include <Prs3d_Arrow.hxx>
+#include <Prs3d_LineAspect.hxx>
+#include <Prs3d_Root.hxx>
#include <GeomPlate_Surface.hxx>
#include <GeomProjLib.hxx>
#include <GCE2d_MakeSegment.hxx>