1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_Rigid.cpp
4 // Created: 16 February 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "SketcherPrs_Rigid.h"
8 #include "SketcherPrs_Tools.h"
9 #include "SketcherPrs_PositionMgr.h"
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Edge.h>
13 #include <GeomAPI_Curve.h>
14 #include <GeomAPI_Vertex.h>
16 #include <SketchPlugin_Constraint.h>
18 #include <AIS_Drawer.hxx>
19 #include <gp_Pnt2d.hxx>
21 #include <Graphic3d_AspectLine3d.hxx>
22 #include <Prs3d_Root.hxx>
24 #include <GeomAdaptor_Curve.hxx>
25 #include <BRep_Tool.hxx>
26 #include <StdPrs_DeflectionCurve.hxx>
27 #include <StdPrs_Point.hxx>
28 #include <Geom_CartesianPoint.hxx>
32 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
33 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
35 static Handle(Image_AlienPixMap) MyPixMap;
39 SketcherPrs_Rigid::SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint,
40 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
41 : SketcherPrs_SymbolPrs(theConstraint, thePlane)
43 myPntArray = new Graphic3d_ArrayOfPoints(1);
44 myPntArray->AddVertex(0., 0., 0.);
48 bool SketcherPrs_Rigid::updatePoints(double theStep) const
50 ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
51 if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
54 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
55 gp_Pnt aP1 = aMgr->getPosition(aObj, this, theStep);
56 myPntArray->SetVertice(1, aP1);
61 void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
63 ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
64 std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
65 if (aShape.get() == NULL)
68 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
69 if (aShape->isEdge()) {
70 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
71 aGroup->SetPrimitivesAspect(aLineAspect);
72 std::shared_ptr<GeomAPI_Curve> aCurve = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
73 if (aCurve->isLine()) {
74 addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
76 GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
77 StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
81 Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
82 myDrawer->SetPointAspect(aPntAspect);
84 std::shared_ptr<GeomAPI_Vertex> aVertex = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(aShape));
85 std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
86 Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
87 StdPrs_Point::Add(thePrs, aPoint, myDrawer);