Salome HOME
73963b7fed11d3dce7c4356effe22da7981756d3
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Rigid.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_Rigid.cpp
4 // Created:     16 February 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "SketcherPrs_Rigid.h"
8 #include "SketcherPrs_Tools.h"
9 #include "SketcherPrs_PositionMgr.h"
10
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Edge.h>
13 #include <GeomAPI_Curve.h>
14 #include <GeomAPI_Vertex.h>
15
16 #include <SketchPlugin_Constraint.h>
17
18 #include <AIS_Drawer.hxx>
19 #include <gp_Pnt2d.hxx>
20
21 #include <Graphic3d_AspectLine3d.hxx>
22 #include <Prs3d_Root.hxx>
23
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>
29
30
31
32 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
33 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
34
35 static Handle(Image_AlienPixMap) MyPixMap; 
36
37
38
39 SketcherPrs_Rigid::SketcherPrs_Rigid(ModelAPI_Feature* theConstraint, 
40                                            const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
41  : SketcherPrs_SymbolPrs(theConstraint, thePlane)
42 {
43   myPntArray = new Graphic3d_ArrayOfPoints(1);
44   myPntArray->AddVertex(0., 0., 0.);
45 }  
46
47
48 bool SketcherPrs_Rigid::updatePoints(double theStep) const 
49 {
50   ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
51   if (SketcherPrs_Tools::getShape(aObj).get() == NULL)
52     return false;
53
54   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
55   gp_Pnt aP1 = aMgr->getPosition(aObj, this, theStep);
56   myPntArray->SetVertice(1, aP1);
57   return true;
58 }
59
60
61 void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
62 {
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)
66     return;
67
68   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
69   Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
70   aGroup->SetPrimitivesAspect(aLineAspect);
71
72   Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
73   myDrawer->SetPointAspect(aPntAspect);
74   drawShape(aShape, thePrs);
75 }
76