Salome HOME
e171bf80cf4edc98205f9feec8c7252ecd725250
[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
13 #include <SketchPlugin_Constraint.h>
14
15 #include <AIS_Drawer.hxx>
16 #include <gp_Pnt2d.hxx>
17
18 #include <Prs3d_PointAspect.hxx>
19 #include <Prs3d_Root.hxx>
20 #include <Prs3d_LineAspect.hxx>
21
22 #include <Graphic3d_MarkerImage.hxx>
23 #include <Graphic3d_AspectMarker3d.hxx>
24 #include <Graphic3d_AspectLine3d.hxx>
25 #include <Graphic3d_ArrayOfSegments.hxx>
26
27 #include <Select3D_SensitivePoint.hxx>
28 #include <Select3D_SensitiveSegment.hxx>
29
30 #include <SelectMgr_SequenceOfOwner.hxx>
31 #include <SelectMgr_Selection.hxx>
32 #include <SelectMgr_EntityOwner.hxx>
33
34
35 extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
36                                                       const std::string& theAttribute);
37
38
39 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
40 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
41
42 static Handle(Image_AlienPixMap) MyPixMap;
43
44 SketcherPrs_Rigid::SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint, 
45                                            const std::shared_ptr<GeomAPI_Ax3>& thePlane) 
46  : SketcherPrs_SymbolPrs(theConstraint, thePlane)
47 {
48   myPntArray = new Graphic3d_ArrayOfPoints(1);
49   myPntArray->AddVertex(0., 0., 0.);
50 }  
51
52 void SketcherPrs_Rigid::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
53                                    const Handle(Prs3d_Presentation)& thePresentation, 
54                                    const Standard_Integer theMode)
55 {
56   prepareAspect();
57
58   std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
59   if (aLine1.get() == NULL)
60     return;
61
62   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
63   gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
64
65   Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
66   aGroup->SetPrimitivesAspect(myAspect);
67   myPntArray->SetVertice(1, aP1);
68   aGroup->AddPrimitiveArray(myPntArray);
69 }
70
71 void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
72 {
73   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
74
75   Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
76   aGroup->SetPrimitivesAspect(aLineAspect);
77
78   addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
79 }
80