1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_Rigid.cpp
4 // Created: 16 February 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "SketcherPrs_Rigid.h"
8 #include "SketcherPrs_Tools.h"
9 #include "SketcherPrs_PositionMgr.h"
11 #include <GeomAPI_Pnt.h>
12 #include <GeomAPI_Edge.h>
13 #include <GeomAPI_Curve.h>
14 #include <GeomAPI_Vertex.h>
16 #include <SketchPlugin_Constraint.h>
18 #include <AIS_Drawer.hxx>
19 #include <gp_Pnt2d.hxx>
21 #include <Prs3d_PointAspect.hxx>
22 #include <Prs3d_Root.hxx>
23 #include <Prs3d_LineAspect.hxx>
25 #include <Graphic3d_MarkerImage.hxx>
26 #include <Graphic3d_AspectMarker3d.hxx>
27 #include <Graphic3d_AspectLine3d.hxx>
28 #include <Graphic3d_ArrayOfSegments.hxx>
30 #include <Select3D_SensitivePoint.hxx>
31 #include <Select3D_SensitiveSegment.hxx>
33 #include <SelectMgr_SequenceOfOwner.hxx>
34 #include <SelectMgr_Selection.hxx>
35 #include <SelectMgr_EntityOwner.hxx>
37 #include <GeomAdaptor_Curve.hxx>
38 #include <BRep_Tool.hxx>
39 #include <StdPrs_DeflectionCurve.hxx>
40 #include <StdPrs_Point.hxx>
41 #include <Geom_CartesianPoint.hxx>
44 extern std::shared_ptr<GeomAPI_Pnt2d> getFeaturePoint(DataPtr theData,
45 const std::string& theAttribute);
48 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
49 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Rigid, SketcherPrs_SymbolPrs);
51 static Handle(Image_AlienPixMap) MyPixMap;
53 SketcherPrs_Rigid::SketcherPrs_Rigid(SketchPlugin_Constraint* theConstraint,
54 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
55 : SketcherPrs_SymbolPrs(theConstraint, thePlane)
57 myPntArray = new Graphic3d_ArrayOfPoints(1);
58 myPntArray->AddVertex(0., 0., 0.);
61 void SketcherPrs_Rigid::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
62 const Handle(Prs3d_Presentation)& thePresentation,
63 const Standard_Integer theMode)
67 ObjectPtr aObj1 = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
68 std::shared_ptr<GeomAPI_Shape> aLine1 = SketcherPrs_Tools::getShape(aObj1);
69 if (aLine1.get() == NULL)
72 SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get();
73 gp_Pnt aP1 = aMgr->getPosition(aObj1, this);
75 Handle(Graphic3d_Group) aGroup = Prs3d_Root::CurrentGroup(thePresentation);
76 aGroup->SetPrimitivesAspect(myAspect);
77 myPntArray->SetVertice(1, aP1);
78 aGroup->AddPrimitiveArray(myPntArray);
81 void SketcherPrs_Rigid::drawLines(const Handle(Prs3d_Presentation)& thePrs, Quantity_Color theColor) const
83 ObjectPtr aObj = SketcherPrs_Tools::getResult(myConstraint, SketchPlugin_Constraint::ENTITY_A());
84 std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
85 if (aShape.get() == NULL)
88 Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePrs);
89 if (aShape->isEdge()) {
90 Handle(Graphic3d_AspectLine3d) aLineAspect = new Graphic3d_AspectLine3d(theColor, Aspect_TOL_SOLID, 2);
91 aGroup->SetPrimitivesAspect(aLineAspect);
92 std::shared_ptr<GeomAPI_Curve> aCurve = std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
93 if (aCurve->isLine()) {
94 addLine(aGroup, SketchPlugin_Constraint::ENTITY_A());
96 GeomAdaptor_Curve aAdaptor(aCurve->impl<Handle(Geom_Curve)>(), aCurve->startParam(), aCurve->endParam());
97 StdPrs_DeflectionCurve::Add(thePrs,aAdaptor,myDrawer);
101 Handle(Prs3d_PointAspect) aPntAspect = new Prs3d_PointAspect(Aspect_TOM_PLUS, theColor, 1);
102 myDrawer->SetPointAspect(aPntAspect);
104 std::shared_ptr<GeomAPI_Vertex> aVertex = std::shared_ptr<GeomAPI_Vertex>(new GeomAPI_Vertex(aShape));
105 std::shared_ptr<GeomAPI_Pnt> aPnt = aVertex->point();
106 Handle(Geom_CartesianPoint) aPoint = new Geom_CartesianPoint(aPnt->impl<gp_Pnt>());
107 StdPrs_Point::Add(thePrs, aPoint, myDrawer);