1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_Perpendicular.cpp
4 // Created: 12 March 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "SketcherPrs_Perpendicular.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_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
20 static Handle(Image_AlienPixMap) MyPixMap;
22 SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(ModelAPI_Feature* theConstraint,
23 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
24 : SketcherPrs_SymbolPrs(theConstraint, thePlane)
28 bool SketcherPrs_Perpendicular::IsReadyToDisplay(ModelAPI_Feature* theConstraint,
29 const std::shared_ptr<GeomAPI_Ax3>&/* thePlane*/)
31 bool aReadyToDisplay = false;
34 SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_A());
36 SketcherPrs_Tools::getResult(theConstraint, SketchPlugin_Constraint::ENTITY_B());
38 aReadyToDisplay = SketcherPrs_Tools::getShape(aObj1).get() != NULL &&
39 SketcherPrs_Tools::getShape(aObj2).get() != NULL;
40 return aReadyToDisplay;
43 bool SketcherPrs_Perpendicular::updateIfReadyToDisplay(double theStep, bool withColor) const
45 if (!IsReadyToDisplay(myConstraint, myPlane))
49 SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
51 SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
53 // Compute position of symbols
54 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
55 gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep);
56 gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep);
57 myPntArray = new Graphic3d_ArrayOfPoints(2, withColor);
58 myPntArray->AddVertex(aP1);
59 myPntArray->AddVertex(aP2);
64 void SketcherPrs_Perpendicular::drawLines(const Handle(Prs3d_Presentation)& thePrs,
65 Quantity_Color theColor) const
67 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
69 Handle(Graphic3d_AspectLine3d) aLineAspect =
70 new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
71 aGroup->SetPrimitivesAspect(aLineAspect);
73 // Draw constrained lines
74 addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
75 addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());