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>
29 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
30 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Perpendicular, SketcherPrs_SymbolPrs);
32 static Handle(Image_AlienPixMap) MyPixMap;
34 SketcherPrs_Perpendicular::SketcherPrs_Perpendicular(SketchPlugin_Constraint* theConstraint,
35 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
36 : SketcherPrs_SymbolPrs(theConstraint, thePlane)
38 myPntArray = new Graphic3d_ArrayOfPoints(2);
39 myPntArray->AddVertex(0., 0., 0.);
40 myPntArray->AddVertex(0., 0., 0.);
43 void SketcherPrs_Perpendicular::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
44 const Handle(Prs3d_Presentation)& thePresentation,
45 const Standard_Integer theMode)
49 ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
50 ObjectPtr aObj2 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_B());
52 std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getShape(aObj1);
53 if (aLine1.get() == NULL)
56 std::shared_ptr<GeomAPI_Shape> aLine2 = SketcherPrs_Tools::getShape(aObj2);
57 if (aLine2.get() == NULL)
60 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
61 gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
62 gp_Pnt aP2 = aMgr->getPosition(aObj2, this);
64 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
65 aGroup->SetPrimitivesAspect(myAspect);
66 myPntArray->SetVertice(1, aP1);
67 myPntArray->SetVertice(2, aP2);
68 aGroup->AddPrimitiveArray(myPntArray);
71 void SketcherPrs_Perpendicular::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
73 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
75 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
76 aGroup->SetPrimitivesAspect(aLineAspect);
78 addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
79 addLine(aGroup, SketchPlugin_Constraint::ENTITY_B());