mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-09-03 14:10:33 +03:00
0031990: Coding, Draw Harness - Replace C-like pointers to function in Draw_SaveAndRestore class to virtual function
Save/Restore interface has been moved to Draw_Drawable3D base class. Create a singleton Draw_Params class for DRAW parameters
This commit is contained in:
@@ -12,54 +12,48 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
#include <DrawTrSurf_BSplineCurve2d.hxx>
|
||||
|
||||
#include <Draw_Color.hxx>
|
||||
#include <Draw_Display.hxx>
|
||||
#include <Draw_Drawable3D.hxx>
|
||||
#include <Draw_MarkerShape.hxx>
|
||||
#include <DrawTrSurf_BSplineCurve2d.hxx>
|
||||
#include <DrawTrSurf.hxx>
|
||||
#include <DrawTrSurf_Params.hxx>
|
||||
#include <Geom2d_BSplineCurve.hxx>
|
||||
#include <GeomTools_Curve2dSet.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <TColgp_Array1OfPnt2d.hxx>
|
||||
#include <TColStd_Array1OfReal.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve2d,DrawTrSurf_Curve2d)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(DrawTrSurf_BSplineCurve2d, DrawTrSurf_Curve2d)
|
||||
|
||||
DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (
|
||||
const Handle(Geom2d_BSplineCurve)& C)
|
||||
: DrawTrSurf_Curve2d (C, Draw_vert, 100) {
|
||||
|
||||
drawKnots = Standard_True;
|
||||
knotsForm = Draw_Losange;
|
||||
knotsLook = Draw_violet;
|
||||
knotsDim = 5;
|
||||
drawPoles = Standard_True;
|
||||
polesLook = Draw_rouge;
|
||||
}
|
||||
|
||||
|
||||
|
||||
DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (
|
||||
const Handle(Geom2d_BSplineCurve)& C, const Draw_Color& CurvColor,
|
||||
const Draw_Color& PolesColor, const Draw_Color& KnotsColor,
|
||||
const Draw_MarkerShape KnotsShape, const Standard_Integer KnotsSize,
|
||||
const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots, const Standard_Integer Discret)
|
||||
: DrawTrSurf_Curve2d (C, CurvColor, Discret) {
|
||||
|
||||
drawKnots = ShowKnots;
|
||||
knotsForm = KnotsShape;
|
||||
knotsLook = KnotsColor;
|
||||
knotsDim = KnotsSize;
|
||||
drawPoles = ShowPoles;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::DrawOn (Draw_Display& dis) const
|
||||
DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (const Handle(Geom2d_BSplineCurve)& C)
|
||||
: DrawTrSurf_Curve2d (C, Draw_vert, 100)
|
||||
{
|
||||
drawKnots = Standard_True;
|
||||
knotsForm = Draw_Losange;
|
||||
knotsLook = Draw_violet;
|
||||
knotsDim = 5;
|
||||
drawPoles = Standard_True;
|
||||
polesLook = Draw_rouge;
|
||||
}
|
||||
|
||||
DrawTrSurf_BSplineCurve2d::DrawTrSurf_BSplineCurve2d (const Handle(Geom2d_BSplineCurve)& C, const Draw_Color& CurvColor,
|
||||
const Draw_Color& PolesColor, const Draw_Color& KnotsColor,
|
||||
const Draw_MarkerShape KnotsShape, const Standard_Integer KnotsSize,
|
||||
const Standard_Boolean ShowPoles, const Standard_Boolean ShowKnots, const Standard_Integer Discret)
|
||||
: DrawTrSurf_Curve2d (C, CurvColor, Discret)
|
||||
{
|
||||
drawKnots = ShowKnots;
|
||||
knotsForm = KnotsShape;
|
||||
knotsLook = KnotsColor;
|
||||
knotsDim = KnotsSize;
|
||||
drawPoles = ShowPoles;
|
||||
polesLook = PolesColor;
|
||||
}
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::DrawOn (Draw_Display& dis) const
|
||||
{
|
||||
Handle(Geom2d_BSplineCurve) C = Handle(Geom2d_BSplineCurve)::DownCast(curv);
|
||||
|
||||
if (drawPoles) {
|
||||
@@ -89,74 +83,78 @@ void DrawTrSurf_BSplineCurve2d::DrawOn (Draw_Display& dis) const
|
||||
}
|
||||
}
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::FindPole (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real XPrec,
|
||||
Standard_Integer& Index) const
|
||||
{
|
||||
Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
|
||||
Standard_Real Prec = XPrec / D.Zoom();
|
||||
gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
|
||||
Index++;
|
||||
Standard_Integer NbPoles = bc->NbPoles();
|
||||
gp_Pnt P;
|
||||
gp_Pnt2d P2d;
|
||||
while (Index <= NbPoles)
|
||||
{
|
||||
P2d = bc->Pole(Index);
|
||||
P.SetCoord (P2d.X(), P2d.Y(), 0.0);
|
||||
if (D.Project(P).Distance(p1) <= Prec)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::ShowPoles () { drawPoles = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::ShowKnots () { drawKnots = Standard_True; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::ClearPoles () { drawPoles = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::ClearKnots () { drawKnots = Standard_False; }
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::FindPole (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real XPrec,
|
||||
Standard_Integer& Index) const {
|
||||
|
||||
Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
|
||||
Standard_Real Prec = XPrec / D.Zoom();
|
||||
gp_Pnt2d p1(X/D.Zoom(),Y/D.Zoom());
|
||||
Index++;
|
||||
Standard_Integer NbPoles = bc->NbPoles();
|
||||
gp_Pnt P;
|
||||
gp_Pnt2d P2d;
|
||||
while (Index <= NbPoles) {
|
||||
P2d = bc->Pole(Index);
|
||||
P.SetCoord (P2d.X(), P2d.Y(), 0.0);
|
||||
if (D.Project(P).Distance(p1) <= Prec)
|
||||
return;
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
|
||||
void DrawTrSurf_BSplineCurve2d::FindKnot (
|
||||
const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec,
|
||||
Standard_Integer& Index) const {
|
||||
|
||||
Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
|
||||
gp_Pnt2d P2d;
|
||||
gp_Pnt P;
|
||||
gp_Pnt2d p1(X,Y);
|
||||
Index++;
|
||||
Standard_Integer NbKnots = bc->NbKnots();
|
||||
while (Index <= NbKnots) {
|
||||
P2d = bc->Value(bc->Knot(Index));
|
||||
P.SetCoord (P2d.X(), P2d.Y(), 0.0);
|
||||
if (D.Project(P).Distance(p1) <= Prec)
|
||||
return;
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
void DrawTrSurf_BSplineCurve2d::FindKnot (const Standard_Real X, const Standard_Real Y, const Draw_Display& D, const Standard_Real Prec,
|
||||
Standard_Integer& Index) const
|
||||
{
|
||||
Handle(Geom2d_BSplineCurve) bc = Handle(Geom2d_BSplineCurve)::DownCast(curv);
|
||||
gp_Pnt2d P2d;
|
||||
gp_Pnt P;
|
||||
gp_Pnt2d p1(X,Y);
|
||||
Index++;
|
||||
Standard_Integer NbKnots = bc->NbKnots();
|
||||
while (Index <= NbKnots)
|
||||
{
|
||||
P2d = bc->Value(bc->Knot(Index));
|
||||
P.SetCoord (P2d.X(), P2d.Y(), 0.0);
|
||||
if (D.Project(P).Distance(p1) <= Prec)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Index++;
|
||||
}
|
||||
Index = 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Copy
|
||||
//purpose :
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve2d::Copy()const
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve2d::Copy() const
|
||||
{
|
||||
Handle(DrawTrSurf_BSplineCurve2d) DC = new DrawTrSurf_BSplineCurve2d
|
||||
(Handle(Geom2d_BSplineCurve)::DownCast(curv->Copy()),
|
||||
look,polesLook,knotsLook,knotsForm,knotsDim,
|
||||
drawPoles,drawKnots,
|
||||
GetDiscretisation());
|
||||
|
||||
|
||||
return DC;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(Draw_Drawable3D) DrawTrSurf_BSplineCurve2d::Restore (Standard_IStream& theStream)
|
||||
{
|
||||
const DrawTrSurf_Params& aParams = DrawTrSurf::Parameters();
|
||||
Handle(Geom2d_BSplineCurve) aGeomCurve = Handle(Geom2d_BSplineCurve)::DownCast (GeomTools_Curve2dSet::ReadCurve2d (theStream));
|
||||
Handle(DrawTrSurf_BSplineCurve2d) aDrawCurve = new DrawTrSurf_BSplineCurve2d (aGeomCurve,
|
||||
aParams.CurvColor, aParams.PolesColor, aParams.KnotsColor,
|
||||
aParams.KnotsMarker, aParams.KnotsSize,
|
||||
aParams.IsShowPoles, aParams.IsShowKnots,
|
||||
aParams.Discret);
|
||||
return aDrawCurve;
|
||||
}
|
||||
|
Reference in New Issue
Block a user