1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_Transformation.cpp
4 // Created: 16 February 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "SketcherPrs_Transformation.h"
8 #include "SketcherPrs_Tools.h"
9 #include "SketcherPrs_PositionMgr.h"
11 #include <SketchPlugin_Constraint.h>
12 #include <ModelAPI_AttributeRefList.h>
14 #include <Graphic3d_AspectLine3d.hxx>
15 #include <Prs3d_Root.hxx>
19 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
20 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
22 static Handle(Image_AlienPixMap) MyPixMap;
24 SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theConstraint,
25 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
27 : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation)
31 bool SketcherPrs_Transformation::updatePoints(double theStep) const
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)
38 int aNbB = anAttrB->size();
42 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
43 myPntArray = new Graphic3d_ArrayOfPoints(aNbB);
48 for (i = 0; i < aNbB; i++) {
49 aObj = anAttrB->object(i);
50 if (!aObj.get()) // TODO:empty_result
51 // this check should be removed here after the result flush is corrected
52 // the problem is, that feature::execute() flushes redisplay by each result creation
53 // but it is possible(e.g. in the sketch circle, that there should be more than one result.
54 // Here, crash happens, because the second result is not created yet
56 aP1 = aMgr->getPosition(aObj, this, theStep);
57 myPntArray->SetVertice(i + 1, aP1);
63 void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
65 std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
66 std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
67 if (anAttrB.get() == NULL)
70 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
72 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
73 aGroup->SetPrimitivesAspect(aLineAspect);
75 drawListOfShapes(anAttrB, thePrs);