Salome HOME
Symbols for translation/rotation are created
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_Transformation.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        SketcherPrs_Transformation.cpp
4 // Created:     16 February 2015
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "SketcherPrs_Transformation.h"
8 #include "SketcherPrs_Tools.h"
9 #include "SketcherPrs_PositionMgr.h"
10
11 #include <SketchPlugin_Constraint.h>
12 #include <ModelAPI_AttributeRefList.h>
13
14 #include <Graphic3d_AspectLine3d.hxx>
15 #include <Prs3d_Root.hxx>
16
17
18
19 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
20 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
21
22 static Handle(Image_AlienPixMap) MyPixMap;
23
24 SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theConstraint, 
25                                            const std::shared_ptr<GeomAPI_Ax3>& thePlane,
26                                            bool isTranslation) 
27  : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation)
28 {
29 }  
30
31 bool SketcherPrs_Transformation::updatePoints(double theStep) const 
32 {
33   std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
34   std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
35   if (anAttrB.get() == NULL)
36     return false;
37
38   int aNbB = anAttrB->size();
39   if (aNbB == 0)
40     return false;
41
42   SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
43   myPntArray = new Graphic3d_ArrayOfPoints(aNbB);
44
45   int i;
46   ObjectPtr aObj;
47   gp_Pnt aP1;
48   for (i = 0; i < aNbB; i++) {
49     aObj = anAttrB->object(i);
50     aP1 = aMgr->getPosition(aObj, this, theStep);
51     myPntArray->SetVertice(i + 1, aP1);
52   }  
53
54   return true;
55 }
56
57 void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
58 {
59   std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
60   std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
61   if (anAttrB.get() == NULL)
62     return;
63
64   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
65
66   Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
67   aGroup->SetPrimitivesAspect(aLineAspect);
68
69   drawListOfShapes(anAttrB, thePrs);
70 }
71