]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Make working possible when constraint images are not accessible
authorvsv <vitaly.smetannikov@opencascade.com>
Thu, 21 May 2015 09:40:18 +0000 (12:40 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Thu, 21 May 2015 09:40:18 +0000 (12:40 +0300)
src/SketcherPrs/CMakeLists.txt
src/SketcherPrs/SketcherPrs_SymbolPrs.cpp

index 833d9b62b5fd4fc967dc3ecf91cbe987968041bb..fb508fed714d25e78555e2b5c2dc50e2a7cb611c 100644 (file)
@@ -43,6 +43,7 @@ SET(PROJECT_LIBRARIES
     Config
     ModelAPI
     GeomAPI
+       Events
     ${CAS_KERNEL} 
     ${CAS_MODELER} 
     ${CAS_VIEWER}
@@ -76,6 +77,7 @@ ADD_LIBRARY(SketcherPrs SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
 
 INCLUDE_DIRECTORIES(
   ${PROJECT_SOURCE_DIR}/src/Config
+  ${PROJECT_SOURCE_DIR}/src/Events
   ${PROJECT_SOURCE_DIR}/src/ModelAPI
   ${PROJECT_SOURCE_DIR}/src/GeomAPI
   ${PROJECT_SOURCE_DIR}/src/GeomDataAPI
index 9a7e9a43178df9d3460a6f9708133ede2718f951..d5119b1b15b8245a8a1281bee8510306cb589e7c 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,13 +249,21 @@ 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("NewGeomResources");
+  if (aEnv != NULL) {
+    TCollection_AsciiString aFile(aEnv);
+    aFile += FSEP;
+    aFile += iconName();
+    Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap();
+    if (aPixMap->Load(aFile)) {
+      myIconsMap[iconName()] = aPixMap;
+      return aPixMap;
+    }
+  } else {
+    static const char aMsg[] = "Error! NewGeomResources environment variable is not defined: constraint images are not found";
+    cout<<aMsg<<endl;
+    Events_Error::send(aMsg);
+    myIconsMap[iconName()] = Handle(Image_AlienPixMap)();
   }
   return Handle(Image_AlienPixMap)();
 }
@@ -269,7 +279,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);
   }
 }