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 <GeomAPI_Pnt.h>
13 #include <SketchPlugin_Constraint.h>
15 #include <AIS_Drawer.hxx>
16 #include <gp_Pnt2d.hxx>
18 #include <Prs3d_PointAspect.hxx>
19 #include <Prs3d_Root.hxx>
20 #include <Prs3d_LineAspect.hxx>
22 #include <Graphic3d_MarkerImage.hxx>
23 #include <Graphic3d_AspectMarker3d.hxx>
24 #include <Graphic3d_AspectLine3d.hxx>
25 #include <Graphic3d_ArrayOfSegments.hxx>
28 // Function which is defined in SketchPlugin_ConstraintDistance.cpp
29 extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
30 const std::string& theAttribute);
34 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
35 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
37 static Handle(Image_AlienPixMap) MyPixMap;
39 SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint,
40 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
41 : SketcherPrs_SymbolPrs(theConstraint, thePlane)
43 myPntArray = new Graphic3d_ArrayOfPoints(2);
44 myPntArray->AddVertex(0., 0., 0.);
45 myPntArray->AddVertex(0. ,0., 0.);
48 void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
49 const Handle(Prs3d_Presentation)& thePresentation,
50 const Standard_Integer theMode)
54 std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_A());
55 if (aLine1.get() == NULL)
58 std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getLine(myConstraint, SketchPlugin_Constraint::ENTITY_B());
59 if (aLine2.get() == NULL)
62 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
63 gp_Pnt aP1 = aMgr->getPosition(aLine1, this);
64 gp_Pnt aP2 = aMgr->getPosition(aLine2, this);
66 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
67 aGroup->SetPrimitivesAspect(myAspect);
68 myPntArray->SetVertice(1, aP1);
69 myPntArray->SetVertice(2, aP2);
70 aGroup->AddPrimitiveArray(myPntArray);
73 void SketcherPrs_Perpendicular::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
75 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
77 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
78 aGroup->SetPrimitivesAspect(aLineAspect);
80 addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
81 addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());