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 <ModelAPI_AttributeRefList.h>
15 #include <Graphic3d_AspectLine3d.hxx>
16 #include <Prs3d_Root.hxx>
20 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Mirror, SketcherPrs_SymbolPrs);
21 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Mirror, SketcherPrs_SymbolPrs);
23 static Handle(Image_AlienPixMap) MyPixMap;
25 SketcherPrs_Mirror::SketcherPrs_Mirror(ModelAPI_Feature* theConstraint,
26 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
27 : SketcherPrs_SymbolPrs(theConstraint, thePlane)
32 bool SketcherPrs_Mirror::updatePoints(double theStep) const
34 ObjectPtr aAxisObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
35 if (SketcherPrs_Tools::getShape(aAxisObj).get() == NULL)
38 std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
39 std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
40 if (anAttrB.get() == NULL)
42 std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
43 if (anAttrC.get() == NULL)
46 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
47 int aNb = anAttrB->size();
48 if (aNb != anAttrC->size())
51 myPntArray = new Graphic3d_ArrayOfPoints(2 * aNb);
55 for (i = 0; i < aNb; i++) {
56 aObj = anAttrB->object(i);
57 aP1 = aMgr->getPosition(aObj, this, theStep);
58 myPntArray->SetVertice(i + 1, aP1);
60 for (i = 0; i < aNb; i++) {
61 aObj = anAttrC->object(i);
62 aP1 = aMgr->getPosition(aObj, this, theStep);
63 myPntArray->SetVertice(aNb + i + 1, aP1);
69 void SketcherPrs_Mirror::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
71 std::shared_ptr<ModelAPI_Data> aData = myConstraint->data();
72 std::shared_ptr<ModelAPI_AttributeRefList> anAttrB = aData->reflist(SketchPlugin_Constraint::ENTITY_B());
73 if (anAttrB.get() == NULL)
75 std::shared_ptr<ModelAPI_AttributeRefList> anAttrC = aData->reflist(SketchPlugin_Constraint::ENTITY_C());
76 if (anAttrC.get() == NULL)
79 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
80 int aNb = anAttrB->size();
81 if (aNb != anAttrC->size())
84 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
86 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
87 aGroup->SetPrimitivesAspect(aLineAspect);
90 addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
92 // Draw source objects
95 for (i = 0; i < aNb; i++) {
96 aObj = anAttrB->object(i);
97 std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
98 if (aShape.get() != NULL)
99 drawShape(aShape, thePrs);
101 // draw mirrored objects
102 for (i = 0; i < aNb; i++) {
103 aObj = anAttrC->object(i);
104 std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
105 if (aShape.get() != NULL)
106 drawShape(aShape, thePrs);