Salome HOME
Fix for the issue #593: do not remove naming attribute, but use TNaming_Builder for...
[modules/shaper.git] / src / SketcherPrs / SketcherPrs_SymbolPrs.cpp
index b4e646709886c7f327bb81be9f1a16afe0d7c578..224a4b1dc36bbfac20152273288ea4042be96ce0 100644 (file)
@@ -12,6 +12,8 @@
 #include <GeomAPI_Vertex.h>
 #include <GeomAPI_Curve.h>
 
+#include <Events_Error.h>
+
 #include <Graphic3d_ArrayOfSegments.hxx>
 #include <Graphic3d_BndBox4f.hxx>
 
@@ -247,14 +249,23 @@ Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon()
   if (myIconsMap.count(iconName()) == 1) {
     return myIconsMap[iconName()];
   }
-  TCollection_AsciiString aFile(getenv("NewGeomResources"));
-  aFile += FSEP;
-  aFile += iconName();
-  Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
-  if (aPixMap->Load(aFile)) {
-    myIconsMap[iconName()] = aPixMap;
-    return aPixMap;
+  char* aEnv = getenv("NEWGEOM_ROOT_DIR");
+  if (aEnv != NULL) {
+    TCollection_AsciiString aFile(aEnv);
+    aFile+=FSEP;
+    aFile+="resources";
+    aFile += FSEP;
+    aFile += iconName();
+    Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
+    if (aPixMap->Load(aFile)) {
+      myIconsMap[iconName()] = aPixMap;
+      return aPixMap;
+    }
   }
+  static const char aMsg[] = "Error! constraint images are not found";
+  cout<<aMsg<<endl;
+  Events_Error::send(aMsg);
+  myIconsMap[iconName()] = Handle(Image_AlienPixMap)();
   return Handle(Image_AlienPixMap)();
 }
 
@@ -269,7 +280,11 @@ void SketcherPrs_SymbolPrs::ClearSelected()
 void SketcherPrs_SymbolPrs::prepareAspect()
 {
   if (myAspect.IsNull()) {
-    myAspect = new Graphic3d_AspectMarker3d(icon());
+    Handle(Image_AlienPixMap) aIcon = icon();
+    if (aIcon.IsNull()) 
+      myAspect = new Graphic3d_AspectMarker3d();
+    else
+      myAspect = new Graphic3d_AspectMarker3d(aIcon);
   }
 }
 
@@ -335,10 +350,12 @@ void SketcherPrs_SymbolPrs::Compute(const Handle(PrsMgr_PresentationManager3d)&
   int aNbVertex = myPntArray->VertexNumber();
   if (myOwner.IsNull()) {
     myOwner = new SelectMgr_EntityOwner(this);
-    for (int i = 1; i <= aNbVertex; i++) {
-      Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i);
-      mySPoints.Append(aSP);
-    }
+  }
+
+  mySPoints.Clear();
+  for (int i = 1; i <= aNbVertex; i++) {
+    Handle(SketcherPrs_SensitivePoint) aSP = new SketcherPrs_SensitivePoint(myOwner, myPntArray, i);
+    mySPoints.Append(aSP);
   }
 
   Handle(Graphic3d_Group) aGroup = Prs3d_Root::NewGroup(thePresentation);
@@ -465,3 +482,20 @@ void SketcherPrs_SymbolPrs::drawShape(const std::shared_ptr<GeomAPI_Shape>& theS
     StdPrs_Point::Add(thePrs, aPoint, myDrawer);
   }
 }
+
+void SketcherPrs_SymbolPrs::drawListOfShapes(const std::shared_ptr<ModelAPI_AttributeRefList>& theListAttr, 
+                                             const Handle(Prs3d_Presentation)& thePrs) const
+{
+  int aNb = theListAttr->size();
+  if (aNb == 0)
+    return;
+  int i;
+  ObjectPtr aObj;
+  for (i = 0; i < aNb; i++) {
+    aObj = theListAttr->object(i);
+    std::shared_ptr<GeomAPI_Shape> aShape = SketcherPrs_Tools::getShape(aObj);
+    if (aShape.get() != NULL)
+      drawShape(aShape, thePrs);
+  }
+}
+