]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/ModelHighAPI/ModelHighAPI_Interface.cpp
Salome HOME
Copyright update 2022
[modules/shaper.git] / src / ModelHighAPI / ModelHighAPI_Interface.cpp
index ad53e125b0c8581ce5663969c92844bee96a670b..82917af4e89c5e8236cf16a904ae243d70ad8fa0 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2014-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2014-2022  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -82,16 +82,20 @@ void ModelHighAPI_Interface::execute(bool isForce)
   Events_Loop* aLoop = Events_Loop::loop();
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
   aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED));
-  //aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
   //aLoop->flush(Events_Loop::eventByName(EVENT_OBJECT_DELETED));
 }
 
-void ModelHighAPI_Interface::setName(const std::string& theName)
+void ModelHighAPI_Interface::setName(const std::wstring& theName)
 {
-  feature()->data()->setName(theName);
+  if (feature().get() && feature()->data()->isValid())
+    feature()->data()->setName(theName);
+  else {
+    std::cout<<"Error: set name "<<theName.c_str()<<" for an invalid feature"<<std::endl;
+  }
 }
 
-std::string ModelHighAPI_Interface::name() const
+std::wstring ModelHighAPI_Interface::name() const
 {
   return feature()->data()->name();
 }
@@ -110,10 +114,12 @@ std::list<ModelHighAPI_Selection> ModelHighAPI_Interface::results() const
 
   std::list<ModelHighAPI_Selection> aSelectionList;
 
-  std::list<std::shared_ptr<ModelAPI_Result> > aResults = feature()->results();
-  for (auto it = aResults.begin(), end = aResults.end(); it != end; ++it) {
-    if (!(*it)->isDisabled())
-      aSelectionList.push_back(ModelHighAPI_Selection(*it));
+  if (feature().get())  {
+    std::list<std::shared_ptr<ModelAPI_Result> > aResults = feature()->results();
+    for (auto it = aResults.begin(), end = aResults.end(); it != end; ++it) {
+      if (!(*it)->isDisabled())
+        aSelectionList.push_back(ModelHighAPI_Selection(*it));
+    }
   }
 
   return aSelectionList;