1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0024339: Vectors not displayed correctly in MFC samples [6.7.0 Beta]: ISession_Direction classes were rewritten without using of DsgPrs_LengthPresentation class.

Corrections to support old results in geometry samples: added ISession_Direction::SetLineAspect(); ISession_Direction class in Modeling sample was corrected.
This commit is contained in:
aba 2013-11-21 15:03:55 +04:00 committed by bugmaster
parent 659b232a7c
commit e5b32824c4
7 changed files with 125 additions and 65 deletions

View File

@ -1304,15 +1304,20 @@ gp_Dir A2YDirection = A2.YDirection() ; \n\
AddSeparator(aDoc,Message); 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); DisplayPoint(aDoc,P1,"P1",false,0.1);
Handle(ISession_Direction) aDirection = new ISession_Direction(P1,D,2); Handle(ISession_Direction) aDirection = new ISession_Direction(P1,D,2);
aDoc->GetAISContext()->Display(aDirection, Standard_False); aDoc->GetAISContext()->Display(aDirection, Standard_False);
Handle(ISession_Direction) aDirection2 = new ISession_Direction(P1,AXDirection,2); Handle(ISession_Direction) aDirection2 = new ISession_Direction(P1,AXDirection,2);
aDirection2->SetText("A.XDirection"); aDirection2->SetText("A.XDirection");
aDirection2->SetLineAspect (anAxesAspect);
aDoc->GetAISContext()->Display(aDirection2, Standard_False); aDoc->GetAISContext()->Display(aDirection2, Standard_False);
Handle(ISession_Direction) aDirection3 = new ISession_Direction(P1,AYDirection,2); Handle(ISession_Direction) aDirection3 = new ISession_Direction(P1,AYDirection,2);
aDirection3->SetText("A.YDirection"); aDirection3->SetText("A.YDirection");
aDirection3->SetLineAspect (anAxesAspect);
aDoc->GetAISContext()->Display(aDirection3, Standard_False); aDoc->GetAISContext()->Display(aDirection3, Standard_False);
DisplayPoint(aDoc,P2,"P2",false,0.1); 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); Handle(ISession_Direction) aDirection5 = new ISession_Direction(P2,A2XDirection,2);
aDirection5->SetText("A2 XDirection"); aDirection5->SetText("A2 XDirection");
aDirection5->SetLineAspect (anAxesAspect);
aDoc->GetAISContext()->Display(aDirection5, Standard_False); aDoc->GetAISContext()->Display(aDirection5, Standard_False);
Handle(ISession_Direction) aDirection6 = new ISession_Direction(P2,A2YDirection,2); Handle(ISession_Direction) aDirection6 = new ISession_Direction(P2,A2YDirection,2);
aDirection6->SetText("A2 YDirection"); aDirection6->SetText("A2 YDirection");
aDirection6->SetLineAspect (anAxesAspect);
aDoc->GetAISContext()->Display(aDirection6, Standard_False); aDoc->GetAISContext()->Display(aDirection6, Standard_False);
Message += "IsDirectA = "; Message += "IsDirectA = ";

View File

@ -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) ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
:myPnt(aPnt),myDir(aDir),myLength(aLength),myArrowLength(anArrowLength) 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) ISession_Direction::ISession_Direction (const gp_Pnt& aPnt,
:myPnt(aPnt),myDir(aVec),myArrowLength(anArrowLength) const gp_Vec& aVec,
Standard_Real anArrowLength)
: myPnt (aPnt),
myDir (aVec),
myArrowLength (anArrowLength)
{ {
myLength = aVec.Magnitude(); myLength = aVec.Magnitude();
} }
ISession_Direction::ISession_Direction(const gp_Pnt2d& aPnt2d, ISession_Direction::ISession_Direction (const gp_Pnt2d& aPnt2d,
const gp_Dir2d& aDir2d, const gp_Dir2d& aDir2d,
Standard_Real aLength) Standard_Real aLength)
:myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aDir2d.X(),aDir2d.Y(),0)),myLength(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, ISession_Direction::ISession_Direction (const gp_Pnt2d& aPnt2d,
const gp_Vec2d& aVec2d) const gp_Vec2d& aVec2d)
:myPnt(gp_Pnt(aPnt2d.X(),aPnt2d.Y(),0)),myDir(gp_Dir(aVec2d.X(),aVec2d.Y(),0)) : myPnt (gp_Pnt (aPnt2d.X(), aPnt2d.Y(), 0.0)),
myDir (gp_Dir(aVec2d.X(), aVec2d.Y(), 0.0))
{ {
myLength = aVec2d.Magnitude(); myLength = aVec2d.Magnitude();
myArrowLength = myDrawer->ArrowAspect()->Length();
} }
@ -54,44 +70,63 @@ ISession_Direction::~ISession_Direction()
} }
void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, void ISession_Direction::Compute (const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/) const Standard_Integer /*aMode*/)
{ {
Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect(); // Set style for arrow
anArrowAspect->SetLength(myArrowLength); Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
myDrawer->SetArrowAspect(anArrowAspect); anArrowAspect->SetLength (myArrowLength);
gp_Pnt LastPoint = myPnt ; gp_Pnt aLastPoint = myPnt;
LastPoint.Translate (myLength*gp_Vec(myDir)) ; aLastPoint.Translate (myLength*gp_Vec(myDir));
if (myText.Length() == 0) // Draw Line
DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myPnt,LastPoint,DsgPrs_AS_LASTAR); Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (2);
else aPrims->AddVertex (myPnt);
{ aPrims->AddVertex (aLastPoint);
gp_Pnt OffsetPoint = myPnt; Prs3d_Root::CurrentGroup (aPresentation)->SetPrimitivesAspect (myDrawer->LineAspect()->Aspect());
OffsetPoint.Translate ( (myLength) *gp_Vec(myDir)) ; Prs3d_Root::CurrentGroup (aPresentation)->AddPrimitiveArray (aPrims);
DsgPrs_LengthPresentation::Add(aPresentation,myDrawer,myText,myPnt,LastPoint, -myDir, OffsetPoint, DsgPrs_AS_LASTAR); // 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*/, void ISession_Direction::Compute (const Handle(Prs3d_Projector)& /*aProjector*/,
const Handle(Prs3d_Presentation)& /*aPresentation*/) 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)
{ {
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);
} }

View File

@ -15,14 +15,15 @@ class ISession_Direction : public AIS_InteractiveObject
{ {
public: public:
TCollection_ExtendedString myText; TCollection_ExtendedString myText;
void SetText(TCollection_ExtendedString& aText); void SetText (TCollection_ExtendedString& aText);
void SetText(Standard_CString aText); void SetText (Standard_CString aText);
void SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect);
ISession_Direction(); 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_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_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_Dir2d& aDir2d,Standard_Real aLength=1);
ISession_Direction(const gp_Pnt2d& aPnt2d,const gp_Vec2d& aVec2d); ISession_Direction (const gp_Pnt2d& aPnt2d,const gp_Vec2d& aVec2d);
virtual ~ISession_Direction(); virtual ~ISession_Direction();
DEFINE_STANDARD_RTTI(ISession_Direction) DEFINE_STANDARD_RTTI(ISession_Direction)

View File

@ -191,6 +191,7 @@
#include <Graphic3d_Group.hxx> #include <Graphic3d_Group.hxx>
#include <Graphic3d_Array1OfVertex.hxx> #include <Graphic3d_Array1OfVertex.hxx>
#include <Graphic3d_ArrayOfPolylines.hxx> #include <Graphic3d_ArrayOfPolylines.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <GProp_PEquation.hxx> #include <GProp_PEquation.hxx>
#include <gp.hxx> #include <gp.hxx>
#include <gp_Ax2d.hxx> #include <gp_Ax2d.hxx>
@ -214,6 +215,7 @@
#include <Poly_Triangulation.hxx> #include <Poly_Triangulation.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_Root.hxx> #include <Prs3d_Root.hxx>
#include <Prs3d_Text.hxx> #include <Prs3d_Text.hxx>
#include <Prs3d_ArrowAspect.hxx> #include <Prs3d_ArrowAspect.hxx>

View File

@ -36,13 +36,19 @@ void ISession_Direction::Compute(const Handle(PrsMgr_PresentationManager3d)& /*a
const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer /*aMode*/) const Standard_Integer /*aMode*/)
{ {
Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect(); // Set style for arrow
anArrowAspect->SetLength(myStartPnt.Distance(myEndPnt)); Handle(Prs3d_ArrowAspect) anArrowAspect = myDrawer->ArrowAspect();
myDrawer->SetArrowAspect(anArrowAspect);
DsgPrs_LengthPresentation::Add(aPresentation,myDrawer, // Draw Line
myStartPnt,myEndPnt, Handle(Graphic3d_ArrayOfSegments) aPrims = new Graphic3d_ArrayOfSegments (2);
DsgPrs_AS_LASTAR); 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());
} }

View File

@ -17,23 +17,27 @@
#include "AIS_InteractiveObject.hxx" #include "AIS_InteractiveObject.hxx"
DEFINE_STANDARD_HANDLE(ISession_Direction,AIS_InteractiveObject) DEFINE_STANDARD_HANDLE(ISession_Direction,AIS_InteractiveObject)
class ISession_Direction : public AIS_InteractiveObject class ISession_Direction : public AIS_InteractiveObject
{ {
public: public:
ISession_Direction(); ISession_Direction();
ISession_Direction(const gp_Pnt& aPnt,const gp_Pnt& aPnt2); ISession_Direction(const gp_Pnt& aPnt,const gp_Pnt& aPnt2);
ISession_Direction(const gp_Pnt& aPnt,const gp_Vec& aVec); ISession_Direction(const gp_Pnt& aPnt,const gp_Vec& aVec);
DEFINE_STANDARD_RTTI(ISession_Direction) DEFINE_STANDARD_RTTI(ISession_Direction)
private: private:
void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager,
const Handle(Prs3d_Presentation)& aPresentation, const Handle(Prs3d_Presentation)& aPresentation,
const Standard_Integer aMode); const Standard_Integer aMode);
void ComputeSelection(const class Handle_SelectMgr_Selection &,const int){};
gp_Pnt myStartPnt; void ComputeSelection (const class Handle_SelectMgr_Selection &,const int){};
gp_Pnt myEndPnt;
private:
gp_Pnt myStartPnt;
gp_Pnt myEndPnt;
}; };
#endif // !defined(AFX_ISession_Direction_H__767C0DB3_A3B0_11D1_8DA3_0800369C8A03__INCLUDED_) #endif // !defined(AFX_ISession_Direction_H__767C0DB3_A3B0_11D1_8DA3_0800369C8A03__INCLUDED_)

View File

@ -57,6 +57,8 @@
#include <Geom_Circle.hxx> #include <Geom_Circle.hxx>
#include <Geom_Transformation.hxx> #include <Geom_Transformation.hxx>
#include <Geom_CylindricalSurface.hxx> #include <Geom_CylindricalSurface.hxx>
#include <Graphic3d_ArrayOfSegments.hxx>
#include <Graphic3d_Group.hxx>
#include <BRepBuilderAPI_GTransform.hxx> #include <BRepBuilderAPI_GTransform.hxx>
#include <BRepPrimAPI_MakeBox.hxx> #include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeCone.hxx> #include <BRepPrimAPI_MakeCone.hxx>
@ -125,6 +127,9 @@
#include <Plate_PinpointConstraint.hxx> #include <Plate_PinpointConstraint.hxx>
#include <Plate_D1.hxx> #include <Plate_D1.hxx>
#include <Plate_GtoCConstraint.hxx> #include <Plate_GtoCConstraint.hxx>
#include <Prs3d_Arrow.hxx>
#include <Prs3d_LineAspect.hxx>
#include <Prs3d_Root.hxx>
#include <GeomPlate_Surface.hxx> #include <GeomPlate_Surface.hxx>
#include <GeomProjLib.hxx> #include <GeomProjLib.hxx>
#include <GCE2d_MakeSegment.hxx> #include <GCE2d_MakeSegment.hxx>