1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: SketcherPrs_SymbolPrs.cpp
4 // Created: 12 March 2015
5 // Author: Vitaly SMETANNIKOV
7 #include "SketcherPrs_SymbolPrs.h"
8 #include "SketcherPrs_Tools.h"
10 #include <GeomAPI_Edge.h>
12 #include <Graphic3d_ArrayOfSegments.hxx>
21 IMPLEMENT_STANDARD_HANDLE(SketcherPrs_SymbolPrs, AIS_InteractiveObject);
22 IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_SymbolPrs, AIS_InteractiveObject);
25 std::map<const char*, Handle(Image_AlienPixMap)> SketcherPrs_SymbolPrs::myIconsMap;
28 SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(SketchPlugin_Constraint* theConstraint,
29 const std::shared_ptr<GeomAPI_Ax3>& thePlane)
30 : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
32 SetAutoHilight(Standard_False);
36 Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
38 if (myIconsMap.count(iconName()) == 1) {
39 return myIconsMap[iconName()];
41 TCollection_AsciiString aFile(getenv("NewGeomResources"));
44 Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
45 if (aPixMap->Load(aFile)) {
46 myIconsMap[iconName()] = aPixMap;
49 return Handle(Image_AlienPixMap)();
52 void SketcherPrs_SymbolPrs::ClearSelected()
54 Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( NULL );
55 if( !aSelectionPrs.IsNull() ) {
56 aSelectionPrs->Clear();
60 void SketcherPrs_SymbolPrs::prepareAspect()
62 if (myAspect.IsNull()) {
63 myAspect = new Graphic3d_AspectMarker3d(icon());
67 void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const
69 std::shared_ptr<GeomAPI_Shape> aLine = SketcherPrs_Tools::getLine(myConstraint, theAttrName);
70 if (aLine.get() == NULL)
72 std::shared_ptr<GeomAPI_Edge> aEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLine));
74 std::shared_ptr<GeomAPI_Pnt> aPnt1 = aEdge->firstPoint();
75 std::shared_ptr<GeomAPI_Pnt> aPnt2 = aEdge->lastPoint();
77 Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
78 aLines->AddVertex(aPnt1->impl<gp_Pnt>());
79 aLines->AddVertex(aPnt2->impl<gp_Pnt>());
80 theGroup->AddPrimitiveArray(aLines);