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);
35 Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
37 if (myIconsMap.count(iconName()) == 1) {
38 return myIconsMap[iconName()];
40 TCollection_AsciiString aFile(getenv("NewGeomResources"));
43 Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
44 if (aPixMap->Load(aFile)) {
45 myIconsMap[iconName()] = aPixMap;
48 return Handle(Image_AlienPixMap)();
51 void SketcherPrs_SymbolPrs::ClearSelected()
53 Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( NULL );
54 if( !aSelectionPrs.IsNull() ) {
55 aSelectionPrs->Clear();
59 void SketcherPrs_SymbolPrs::prepareAspect()
61 if (myAspect.IsNull()) {
62 myAspect = new Graphic3d_AspectMarker3d(icon());
66 void SketcherPrs_SymbolPrs::addLine(const Handle(Graphic3d_Group)& theGroup, std::string theAttrName) const
68 std::shared_ptr<GeomAPI_Edge> aLine = SketcherPrs_Tools::getLine(myConstraint, theAttrName);
69 if (aLine.get() == NULL)
72 std::shared_ptr<GeomAPI_Pnt> aPnt1 = aLine->firstPoint();
73 std::shared_ptr<GeomAPI_Pnt> aPnt2 = aLine->lastPoint();
75 Handle(Graphic3d_ArrayOfSegments) aLines = new Graphic3d_ArrayOfSegments(2, 1);
76 aLines->AddVertex(aPnt1->impl<gp_Pnt>());
77 aLines->AddVertex(aPnt2->impl<gp_Pnt>());
78 theGroup->AddPrimitiveArray(aLines);