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 <SketchPlugin_MultiRotation.h>
13 #include <SketchPlugin_MultiTranslation.h>
14 #include <ModelAPI_AttributeInteger.h>
15 #include <ModelAPI_AttributeRefList.h>
17 #include <Graphic3d_AspectLine3d.hxx>
18 #include <Prs3d_Root.hxx>
22 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
23 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Transformation, SketcherPrs_SymbolPrs);
25 static Handle(Image_AlienPixMap) MyPixMap;
27 SketcherPrs_Transformation::SketcherPrs_Transformation(ModelAPI_Feature* theConstraint,
28 const std::shared_ptr<GeomAPI_Ax3>& thePlane,
30 : SketcherPrs_SymbolPrs(theConstraint, thePlane), myIsTranslation(isTranslation)
33 if (theConstraint->getKind() == SketchPlugin_MultiTranslation::ID()) {
34 aPointsNb = theConstraint->integer(SketchPlugin_MultiTranslation::NUMBER_OF_COPIES_ID())->value();
35 } else if (theConstraint->getKind() == SketchPlugin_MultiRotation::ID()) {
36 aPointsNb = theConstraint->integer(SketchPlugin_MultiRotation::NUMBER_OF_COPIES_ID())->value();
38 aPointsNb == 0 ? aPointsNb = 2 : aPointsNb++; // by default we have 2 points for symbols
39 myPntArray = new Graphic3d_ArrayOfPoints(aPointsNb);
42 bool SketcherPrs_Transformation::updatePoints(double theStep) const
44 std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
45 std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
46 if (anAttrB.get() == NULL)
49 int aNbB = anAttrB->size();
53 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
58 for (i = 0; i < aNbB; i++) {
59 aObj = anAttrB->object(i);
60 if (!aObj.get()) // TODO:empty_result
61 // this check should be removed here after the result flush is corrected
62 // the problem is, that feature::execute() flushes redisplay by each result creation
63 // but it is possible(e.g. in the sketch circle, that there should be more than one result.
64 // Here, crash happens, because the second result is not created yet
66 aP1 = aMgr->getPosition(aObj, this, theStep);
67 myPntArray->SetVertice(i + 1, aP1);
73 void SketcherPrs_Transformation::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
75 std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
76 std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
77 if (anAttrB.get() == NULL)
80 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
82 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
83 aGroup->SetPrimitivesAspect(aLineAspect);
85 drawListOfShapes(anAttrB, thePrs);