1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_Mirror.cpp
4 // Created: 6 April 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "SketcherPrs_Mirror.h"
8 #include "SketcherPrs_Tools.h"
9 #include "SketcherPrs_PositionMgr.h"
11 #include <SketchPlugin_Constraint.h>
13 #include <Graphic3d_AspectLine3d.hxx>
14 #include <Prs3d_Root.hxx>
18 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Mirror, SketcherPrs_SymbolPrs);
19 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Mirror, SketcherPrs_SymbolPrs);
21 static Handle(Image_AlienPixMap) MyPixMap;
23 SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint,
24 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
25 : SketcherPrs_SymbolPrs(theConstraint, thePlane)
30 bool SketcherPrs_Mirror::updatePoints(double theStep) const
32 ObjectPtr aAxisObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
33 if (SketcherPrs_Tools::getShape(aAxisObj).get() == NULL)
36 std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
37 std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
38 if (anAttrB.get() == NULL)
40 std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
41 if (anAttrC.get() == NULL)
44 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
45 int aNb = anAttrB->size();
46 if (aNb != anAttrC->size())
49 myPntArray = new Graphic3d_ArrayOfPoints(2 * aNb);
53 for (i = 0; i < aNb; i++) {
54 aObj = anAttrB->object(i);
55 aP1 = aMgr->getPosition(aObj, this, theStep);
56 myPntArray->SetVertice(i + 1, aP1);
58 for (i = 0; i < aNb; i++) {
59 aObj = anAttrC->object(i);
60 aP1 = aMgr->getPosition(aObj, this, theStep);
61 myPntArray->SetVertice(aNb + i + 1, aP1);
67 void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
69 std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
70 std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
71 if (anAttrB.get() == NULL)
73 std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
74 if (anAttrC.get() == NULL)
77 int aNb = anAttrB->size();
78 if (aNb != anAttrC->size())
81 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
83 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
84 aGroup->SetPrimitivesAspect(aLineAspect);
87 addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
89 // Draw source objects
90 drawListOfShapes(anAttrB, thePrs);
92 // draw mirrored objects
93 drawListOfShapes(anAttrC, thePrs);