diff --git a/samples/mfc/standard/01_Geometry/src/GeomSources.cpp b/samples/mfc/standard/01_Geometry/src/GeomSources.cpp index a3f333b042..d19cf07ec3 100755 --- a/samples/mfc/standard/01_Geometry/src/GeomSources.cpp +++ b/samples/mfc/standard/01_Geometry/src/GeomSources.cpp @@ -1304,15 +1304,20 @@ gp_Dir A2YDirection = A2.YDirection() ; \n\ 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); @@ -1321,9 +1326,11 @@ gp_Dir A2YDirection = A2.YDirection() ; \n\ 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 = "; diff --git a/samples/mfc/standard/01_Geometry/src/ISession2D/ISession_Direction.cpp b/samples/mfc/standard/01_Geometry/src/ISession2D/ISession_Direction.cpp index b01a86f1c8..fe4c5403b3 100755 --- a/samples/mfc/standard/01_Geometry/src/ISession2D/ISession_Direction.cpp +++ b/samples/mfc/standard/01_Geometry/src/ISession2D/ISession_Direction.cpp @@ -25,27 +25,43 @@ ISession_Direction::ISession_Direction() } -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(); } @@ -54,44 +70,63 @@ ISession_Direction::~ISession_Direction() } -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); + // Set style for arrow + Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect(); + anArrowAspect->SetLength (myArrowLength); - gp_Pnt LastPoint = myPnt ; - LastPoint.Translate (myLength*gp_Vec(myDir)) ; + gp_Pnt aLastPoint = myPnt; + aLastPoint.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); - } + // 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::ComputeSelection(const Handle(SelectMgr_Selection)& /*aSelection*/, - const Standard_Integer /*aMode*/) -{ -} - -void ISession_Direction::SetText(TCollection_ExtendedString & aText) +void ISession_Direction::Compute (const Handle(Prs3d_Projector)& /*aProjector*/, + const Handle(Prs3d_Presentation)& /*aPresentation*/) { - myText = aText; } -void ISession_Direction::SetText(Standard_CString aText) +void ISession_Direction::ComputeSelection (const Handle(SelectMgr_Selection)& /*aSelection*/, + const Standard_Integer /*aMode*/) { - myText = aText; +} + +void ISession_Direction::SetText (TCollection_ExtendedString & theText) +{ + myText = theText; +} + +void ISession_Direction::SetText (Standard_CString theText) +{ + myText = theText; +} + +void ISession_Direction::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect) +{ + myDrawer->SetLineAspect (theAspect); } diff --git a/samples/mfc/standard/01_Geometry/src/ISession2D/ISession_Direction.h b/samples/mfc/standard/01_Geometry/src/ISession2D/ISession_Direction.h index 20c391b4fe..04a010fbd9 100755 --- a/samples/mfc/standard/01_Geometry/src/ISession2D/ISession_Direction.h +++ b/samples/mfc/standard/01_Geometry/src/ISession2D/ISession_Direction.h @@ -15,14 +15,15 @@ class ISession_Direction : public AIS_InteractiveObject { 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) diff --git a/samples/mfc/standard/01_Geometry/src/StdAfx.h b/samples/mfc/standard/01_Geometry/src/StdAfx.h index 2461566432..971d2d4267 100755 --- a/samples/mfc/standard/01_Geometry/src/StdAfx.h +++ b/samples/mfc/standard/01_Geometry/src/StdAfx.h @@ -191,6 +191,7 @@ #include #include #include +#include #include #include #include @@ -214,6 +215,7 @@ #include #include +#include #include #include #include diff --git a/samples/mfc/standard/02_Modeling/src/ISession_Direction.cpp b/samples/mfc/standard/02_Modeling/src/ISession_Direction.cpp index 1dc7faacc5..ab99968773 100755 --- a/samples/mfc/standard/02_Modeling/src/ISession_Direction.cpp +++ b/samples/mfc/standard/02_Modeling/src/ISession_Direction.cpp @@ -36,13 +36,19 @@ void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& /*a const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer /*aMode*/) { - Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect(); - anArrowAspect->SetLength(myStartPnt.Distance(myEndPnt)); - myDrawer->SetArrowAspect(anArrowAspect); + // Set style for arrow + Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect(); - DsgPrs_LengthPresentation::Add(aPresentation,myDrawer, - myStartPnt,myEndPnt, - DsgPrs_AS_LASTAR); + // 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()); } - - diff --git a/samples/mfc/standard/02_Modeling/src/ISession_Direction.h b/samples/mfc/standard/02_Modeling/src/ISession_Direction.h index cfec6d22e2..bd34207f2e 100755 --- a/samples/mfc/standard/02_Modeling/src/ISession_Direction.h +++ b/samples/mfc/standard/02_Modeling/src/ISession_Direction.h @@ -17,23 +17,27 @@ #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_) diff --git a/samples/mfc/standard/02_Modeling/src/StdAfx.h b/samples/mfc/standard/02_Modeling/src/StdAfx.h index d560b6540f..66f33e323b 100755 --- a/samples/mfc/standard/02_Modeling/src/StdAfx.h +++ b/samples/mfc/standard/02_Modeling/src/StdAfx.h @@ -57,6 +57,8 @@ #include #include #include +#include +#include #include #include #include @@ -125,6 +127,9 @@ #include #include #include +#include +#include +#include #include #include #include