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;
37 SketcherPrs_Rigid::SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint,
38 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
39 : SketcherPrs_SymbolPrs(theConstraint, thePlane)
41 myPntArray = new Graphic3d_ArrayOfPoints(1);
42 myPntArray->AddVertex(0., 0., 0.);
45 void SketcherPrs_Rigid::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
46 const Handle(Prs3d_Presentation)& thePresentation,
47 const Standard_Integer theMode)
51 ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
52 std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getShape(aObj1);
53 if (aLine1.get() == NULL)
56 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
57 gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
59 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
60 aGroup->SetPrimitivesAspect(myAspect);
61 myPntArray->SetVertice(1, aP1);
62 aGroup->AddPrimitiveArray(myPntArray);
65 void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
67 ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
68 std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
69 if (aShape.get() == NULL)
72 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
73 if (aShape->isEdge()) {
74 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
75 aGroup->SetPrimitivesAspect(aLineAspect);
76 std::shared_ptr<GeomAPI_Curve> aCurve = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
77 if (aCurve->isLine()) {
78 addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
80 GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
81 StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
85 Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
86 myDrawer->SetPointAspect(aPntAspect);
88 std::shared_ptr<GeomAPI_Vertex> aVertex = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(aShape));
89 std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
90 Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
91 StdPrs_Point::Add(thePrs, aPoint, myDrawer);