Salome HOME
It is a filters implementation to be set in the XML file.
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index 0bf4c4bcb84ca93108fe097c9e5935261cad7ed9..b04468f7d18ea5f53ac411207c6a77a9787e0365 100644 (file)
 #include <ModuleBase_WidgetFactory.h>
 #include <ModuleBase_Tools.h>
 #include <ModuleBase_IViewer.h>
+#include<ModuleBase_FilterFactory.h>
 
 #include <Config_Common.h>
 #include <Config_FeatureMessage.h>
 #include <Config_PointerMessage.h>
 #include <Config_ModuleReader.h>
 #include <Config_PropManager.h>
+#include <Config_SelectionFilterMessage.h>
 
 #include <QApplication>
 #include <QFileDialog>
 
 QMap<QString, QString> XGUI_Workshop::myIcons;
 
-std::string XGUI_Workshop::featureIconStr(const FeaturePtr& theFeature)
-{
-  std::string aKind = theFeature->getKind();
-  QString aId(aKind.c_str());
-  if (!myIcons.contains(aId))
-    return std::string();
-
-  return myIcons[aId].toStdString();
-}
 
 QIcon XGUI_Workshop::featureIcon(const FeaturePtr& theFeature)
 {
   QIcon anIcon;
 
-  QString anIconString = featureIconStr(theFeature).c_str();
+  std::string aKind = theFeature->getKind();
+  QString aId(aKind.c_str());
+  if (!myIcons.contains(aId))
+    return anIcon;
+
+  QString anIconString = myIcons[aId];
 
   ModelAPI_ExecState aState = theFeature->data()->execState();
   switch(aState) {
@@ -102,13 +100,12 @@ QIcon XGUI_Workshop::featureIcon(const FeaturePtr& theFeature)
     }
     break;
     case ModelAPI_StateExecFailed: {
-      anIcon = ModuleBase_Tools::composite(":pictures/exec_state_failed.png",
-                                           12, 12, anIconString);
+      anIcon = ModuleBase_Tools::composite(":pictures/exec_state_failed.png", anIconString);
     }
     break;
     case ModelAPI_StateInvalidArgument: {
       anIcon = ModuleBase_Tools::composite(":pictures/exec_state_invalid_parameters.png",
-                                           12, 12, anIconString);
+                                           anIconString);
     }
     break;
     default: break;  
@@ -188,8 +185,10 @@ void XGUI_Workshop::startApplication()
   aLoop->registerListener(this, Events_Loop::eventByName("CurrentDocumentChanged"));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOSHOW));
   aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
+  aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
 
   registerValidators();
+
   // Calling of  loadCustomProps before activating module is required
   // by Config_PropManger to restore user-defined path to plugins
   XGUI_Preferences::loadCustomProps();
@@ -420,7 +419,21 @@ void XGUI_Workshop::processEvent(const std::shared_ptr<Events_Message>& theMessa
     // If not found then activate global document
     activatePart(ResultPartPtr()); 
 
-  } else {
+  }
+  else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_SELFILTER_LOADED)) {
+    std::shared_ptr<Config_SelectionFilterMessage> aMsg = 
+      std::dynamic_pointer_cast<Config_SelectionFilterMessage>(theMessage);
+    if (aMsg) {
+      if (aMsg->attributeId().empty()) {  // feature validator
+        moduleConnector()->selectionFilters()->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId());
+      } else {  // attribute validator
+        moduleConnector()->selectionFilters()->assignFilter(aMsg->selectionFilterId(), aMsg->featureId(), aMsg->attributeId());
+      }
+    }
+  }
+
+  
+  else {
     //Show error dialog if error message received.
     std::shared_ptr<Events_Error> anAppError = std::dynamic_pointer_cast<Events_Error>(theMessage);
     if (anAppError) {