]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Ability for plugins to manage state (on/off) of their features added
authorsbh <sergey.belash@opencascade.com>
Fri, 12 Dec 2014 15:35:00 +0000 (18:35 +0300)
committersbh <sergey.belash@opencascade.com>
Fri, 12 Dec 2014 15:48:55 +0000 (18:48 +0300)
27 files changed:
src/Model/Model_Session.cpp
src/Model/Model_Validator.cpp
src/Model/Model_Validator.h
src/ModelAPI/ModelAPI_Events.cpp
src/ModelAPI/ModelAPI_Events.h
src/ModelAPI/ModelAPI_Plugin.h
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_SelectionValidator.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationSketch.cpp [deleted file]
src/PartSet/PartSet_OperationSketch.h [deleted file]
src/PartSet/PartSet_Validators.cpp
src/PartSet/PartSet_Validators.h
src/PartSetPlugin/CMakeLists.txt
src/PartSetPlugin/PartSetPlugin_Plugin.cpp
src/PartSetPlugin/PartSetPlugin_Plugin.h
src/SketchPlugin/CMakeLists.txt
src/SketchPlugin/SketchPlugin_Plugin.cpp
src/SketchPlugin/SketchPlugin_Plugin.h
src/SketchPlugin/plugin-Sketch.xml
src/XGUI/XGUI_ActionsMgr.cpp
src/XGUI/XGUI_ActionsMgr.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 9e87c0560c993e7d08b5084c07523f346786c9b8..94f6cf2a87ca245ac8dce804f76e0ae36381f841 100644 (file)
@@ -291,6 +291,14 @@ void Model_Session::registerPlugin(ModelAPI_Plugin* thePlugin)
   static Events_ID EVENT_LOAD = Events_Loop::loop()->eventByName(EVENT_PLUGIN_LOADED);
   ModelAPI_EventCreator::get()->sendUpdated(ObjectPtr(), EVENT_LOAD);
   Events_Loop::loop()->flush(EVENT_LOAD);
+  // If the plugin has an ability to process GUI events, register it
+  Events_Listener* aListener = dynamic_cast<Events_Listener*>(thePlugin);
+  if (aListener) {
+    Events_Loop* aLoop = Events_Loop::loop();
+    static Events_ID aStateRequestEventId =
+        Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_REQUEST);
+    aLoop->registerListener(aListener, aStateRequestEventId);
+  }
 }
 
 ModelAPI_ValidatorsFactory* Model_Session::validators()
index dee9841c3c2c4de887ca1a7fa5536f417a1dba15..c2c994da9cd65dc1b194115c8250aa524760ae1c 100644 (file)
@@ -90,7 +90,7 @@ void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
       }
     }
   }
-  addDefaultValidators(theResult);
+  addDefaultValidators(theResult, theArguments);
 }
 
 void Model_ValidatorsFactory::validators(const std::string& theFeatureID,
@@ -134,13 +134,15 @@ const ModelAPI_Validator* Model_ValidatorsFactory::validator(const std::string&
   return NULL;
 }
 
-void Model_ValidatorsFactory::addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const
+void Model_ValidatorsFactory::addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators,
+  std::list<std::list<std::string> >& theArguments) const
 {
   const static std::string kDefaultId = "Model_FeatureValidator";
   std::map<std::string, ModelAPI_Validator*>::const_iterator it = myIDs.find(kDefaultId);
   if(it == myIDs.end())
     return;
   theValidators.push_back(it->second);
+  theArguments.push_back(std::list<std::string>());
 }
 
 bool Model_ValidatorsFactory::validate(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
index 35e2d18c0c7ee05e286b93b28b37071e8990d262..e2f67b617dde97fb7a9024be9d37217d8a2fd95b 100644 (file)
@@ -89,7 +89,8 @@ class Model_ValidatorsFactory : public ModelAPI_ValidatorsFactory
   virtual bool isConcealed(std::string theFeature, std::string theAttribute);
 
 protected:
-  void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators) const;
+  void addDefaultValidators(std::list<ModelAPI_Validator*>& theValidators,
+                            std::list<std::list<std::string> >& theArguments) const;
   /// Get instance from Session
   Model_ValidatorsFactory();
 
index b219a9adf0db4dec6ecff2954996e96876f63616..447019a2af949ecef3a45409556b9af53d4bf6c9 100644 (file)
@@ -34,3 +34,53 @@ ModelAPI_ObjectDeletedMessage::~ModelAPI_ObjectDeletedMessage()
 
 }
 
+ModelAPI_FeatureStateMessage::ModelAPI_FeatureStateMessage(const Events_ID theID,
+                                                           const void* theSender)
+ : Events_Message(theID, theSender)
+{
+  myCurrentFeature = std::shared_ptr<ModelAPI_Feature>();
+}
+
+ModelAPI_FeatureStateMessage::~ModelAPI_FeatureStateMessage()
+{
+
+}
+
+std::shared_ptr<ModelAPI_Feature> ModelAPI_FeatureStateMessage::feature() const
+{
+  return myCurrentFeature;
+}
+
+void ModelAPI_FeatureStateMessage::setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature)
+{
+  myCurrentFeature = theFeature;
+}
+
+bool ModelAPI_FeatureStateMessage::hasState(const std::string& theKey) const
+{
+  return myFeatureState.find(theKey) != myFeatureState.end();
+}
+
+bool ModelAPI_FeatureStateMessage::state(const  std::string& theFeatureId, bool theDefault) const
+{
+  if(hasState(theFeatureId)) {
+    return myFeatureState.at(theFeatureId);
+  }
+  return theDefault;
+}
+
+void ModelAPI_FeatureStateMessage::setState(const std::string& theFeatureId, bool theValue)
+{
+  myFeatureState[theFeatureId] = theValue;
+}
+
+std::list<std::string> ModelAPI_FeatureStateMessage::features() const
+{
+  std::list<std::string> result;
+  std::map<std::string, bool>::const_iterator it = myFeatureState.begin();
+  for( ; it != myFeatureState.end(); ++it) {
+    result.push_back(it->first);
+  }
+  return result;
+}
+
index 5e6816271e291a4e1b9e781e735ade3501c8002e..26441f25336f9115398f9ea8bc68a88f1475e75c 100644 (file)
@@ -9,11 +9,13 @@
 
 #include <ModelAPI.h>
 #include <ModelAPI_Object.h>
+#include <ModelAPI_Feature.h>
 #include <Events_MessageGroup.h>
 
 #include <memory>
 #include <string>
 #include <set>
+#include <map>
 
 
 class ModelAPI_Document;
@@ -37,6 +39,9 @@ static const char * EVENT_OBJECT_TOSHOW = "ObjectShow";
 /// Event ID that data of feature has to be shown (comes with ModelAPI_ObjectUpdatedMessage)
 static const char * EVENT_OBJECT_TOHIDE = "ObjectHide";
 
+static const char * EVENT_FEATURE_STATE_REQUEST = "FeatureStateRequest";
+static const char * EVENT_FEATURE_STATE_RESPONSE = "FeatureStateResponse";
+
 /// Message that feature was changed (used for Object Browser update): moved, updated and deleted
 class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup
 {
@@ -94,4 +99,27 @@ class MODELAPI_EXPORT ModelAPI_EventCreator
   static void set(const ModelAPI_EventCreator* theCreator);
 };
 
+// TODO(sbh): Move this message into a separate package, like "GuiAPI"
+class ModelAPI_FeatureStateMessage : public Events_Message
+{
+ public:
+  MODELAPI_EXPORT ModelAPI_FeatureStateMessage(const Events_ID theID, const void* theSender = 0);
+  MODELAPI_EXPORT virtual ~ModelAPI_FeatureStateMessage();
+
+  // For request
+  MODELAPI_EXPORT std::shared_ptr<ModelAPI_Feature> feature() const;
+  MODELAPI_EXPORT void setFeature(std::shared_ptr<ModelAPI_Feature>& theFeature);
+  // For response
+  MODELAPI_EXPORT bool hasState(const std::string& theFeatureId) const;
+  MODELAPI_EXPORT bool state(const  std::string& theFeatureId, bool theDefault = false) const;
+  MODELAPI_EXPORT void setState(const std::string& theFeatureId, bool theValue);
+  MODELAPI_EXPORT std::list<std::string> features() const;
+
+ private:
+  // For Request
+  std::shared_ptr<ModelAPI_Feature> myCurrentFeature;
+  // For response
+  std::map<std::string, bool> myFeatureState;
+};
+
 #endif
index 829cb750f32e4849b68b0a196cc0e35993d9dc9c..c3fc113f758a603f097f1ef904944072121fe700 100644 (file)
@@ -34,7 +34,6 @@ class MODELAPI_EXPORT ModelAPI_Plugin
   ModelAPI_Plugin()
   {
   }
-  ;
 };
 
 #endif
index 301fbcca5f8da76c26bc5b829f0f55d7f810870c..00e90732e4cf4efeeaab495ead46ba72c097aa1f 100644 (file)
@@ -72,11 +72,6 @@ bool ModuleBase_Operation::isValid() const
   return aFactory->validate(myFeature);
 }
 
-bool ModuleBase_Operation::isNestedOperationsEnabled() const
-{
-  return true;
-}
-
 //void ModuleBase_Operation::storeCustomValue()
 //{
 //  if (!myFeature) {
@@ -364,4 +359,4 @@ void ModuleBase_Operation::setPropertyPanel(ModuleBase_IPropertyPanel* theProp)
 bool ModuleBase_Operation::isGranted(QString theId) const
 {
   return myNestedFeatures.contains(theId);
-}
\ No newline at end of file
+}
index 4e76077f249ac3872ca617d237320f1987d07547..a9333a7e8cf6796062e689e01f6cc068be5ebfcd 100644 (file)
@@ -100,11 +100,6 @@ Q_OBJECT
   */
   virtual bool isValid() const;
 
-  /// Returns whether the nested operations are enabled.
-  /// The state can depend on the operation current state.
-  /// \return enabled state
-  virtual bool isNestedOperationsEnabled() const;
-
   /// Sets the operation feature
   void setFeature(FeaturePtr theFeature);
 
index 78a29cdfa22bfb0d9e5aab1eaec4ae1febc38e76..180d59936a37308129a606c3f15429a1d883ec5e 100644 (file)
 
 #include <ModelAPI_Validator.h>
 
+#include <list>
+#include <string>
+
 class ModuleBase_SelectionValidator : public ModelAPI_Validator
 {
  public:
   virtual bool isValid(const ModuleBase_ISelection* theSelection) const = 0;
+  virtual bool isValid(const ModuleBase_ISelection* theSelection,
+                       const std::list<std::string>& theArguments) const
+  {
+    return isValid(theSelection);
+  }
 };
 
 #endif
index a3aba0edeff020d9fa505edb99b27580c4e2f0e5..fc2f4b0b82d2502af48722a81be8346f5f73ce25 100644 (file)
@@ -15,7 +15,6 @@ SET(PROJECT_HEADERS
        PartSet_WidgetPoint2d.h
        PartSet_WidgetPoint2dDistance.h
        PartSet_WidgetShapeSelector.h
-       PartSet_OperationSketch.h
        PartSet_Filters.h
 )
 
@@ -28,7 +27,6 @@ SET(PROJECT_SOURCES
        PartSet_WidgetPoint2d.cpp
        PartSet_WidgetPoint2dDistance.cpp
        PartSet_WidgetShapeSelector.cpp
-       PartSet_OperationSketch.cpp
        PartSet_Filters.cpp
 )
 
index b13d3542e464f744187d146f00de632e315adec1..c154d43d4804b95a66db049279c76be00e05d770 100644 (file)
@@ -1,7 +1,6 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
 
 #include "PartSet_Module.h"
-#include <PartSet_OperationSketch.h>
 #include <PartSet_WidgetSketchLabel.h>
 #include <PartSet_Validators.h>
 #include <PartSet_Tools.h>
@@ -139,6 +138,7 @@ void PartSet_Module::registerValidators()
   aFactory->registerValidator("PartSet_PerpendicularValidator", new PartSet_PerpendicularValidator);
   aFactory->registerValidator("PartSet_ParallelValidator", new PartSet_ParallelValidator);
   aFactory->registerValidator("PartSet_RadiusValidator", new PartSet_RadiusValidator);
+  aFactory->registerValidator("PartSet_RigidValidator", new PartSet_RigidValidator);
   aFactory->registerValidator("PartSet_DifferentObjects", new PartSet_DifferentObjectsValidator);
 }
 
@@ -464,16 +464,6 @@ void PartSet_Module::launchEditing()
   }
 }
 
-/// Returns new instance of operation object (used in createOperation for customization)
-ModuleBase_Operation* PartSet_Module::getNewOperation(const std::string& theFeatureId)
-{
-  if (theFeatureId == PartSet_OperationSketch::Type()) {
-    return new PartSet_OperationSketch(theFeatureId.c_str(), this);
-  }
-  return ModuleBase_IModule::getNewOperation(theFeatureId);
-}
-
-
 void PartSet_Module::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
 {
   myWorkshop->viewer()->enableSelection(true);
index 70e4141cae1229f6eb5ad70b90f442b9d633b904..e04148a1db65620069090f9feeca5d8017c9c656 100644 (file)
@@ -117,9 +117,6 @@ protected slots:
   void launchEditing();
 
  protected:
-  /// Returns new instance of operation object (used in createOperation for customization)
-  virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
-
   /// Register validators for this module
   virtual void registerValidators();
 
diff --git a/src/PartSet/PartSet_OperationSketch.cpp b/src/PartSet/PartSet_OperationSketch.cpp
deleted file mode 100644 (file)
index b2677b5..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_OperationSketch.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_OperationSketch.h>
-#include <PartSet_Tools.h>
-
-#include <SketchPlugin_Sketch.h>
-#include <SketchPlugin_ConstraintLength.h>
-
-#include <ModelAPI_Data.h>
-#include <ModelAPI_AttributeDouble.h>
-#include <ModelAPI_AttributeRefList.h>
-#include <ModelAPI_Events.h>
-
-#include <GeomAlgoAPI_FaceBuilder.h>
-#include <GeomDataAPI_Point.h>
-#include <GeomDataAPI_Dir.h>
-#include <GeomAPI_XYZ.h>
-
-#include <ModuleBase_ViewerPrs.h>
-#include <ModuleBase_ISelection.h>
-#include <ModuleBase_IViewer.h>
-#include <Events_Loop.h>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-#include <QMouseEvent>
-
-using namespace std;
-
-PartSet_OperationSketch::PartSet_OperationSketch(const QString& theId, QObject* theParent)
-    : ModuleBase_Operation(theId, theParent)
-{
-}
-
-PartSet_OperationSketch::~PartSet_OperationSketch()
-{
-}
-
-bool PartSet_OperationSketch::isNestedOperationsEnabled() const
-{
-  bool aHasSketchPlane = false;
-  if (feature()) {
-    std::shared_ptr<ModelAPI_Data> aData = feature()->data();
-    AttributeDoublePtr anAttr;
-    std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
-        aData->attribute(SketchPlugin_Sketch::NORM_ID()));
-    aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
-  }
-  return aHasSketchPlane;
-}
diff --git a/src/PartSet/PartSet_OperationSketch.h b/src/PartSet/PartSet_OperationSketch.h
deleted file mode 100644 (file)
index d7120dc..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        PartSet_OperationSketch.h
-// Created:     20 Apr 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_OperationSketch_H
-#define PartSet_OperationSketch_H
-
-#include "PartSet.h"
-
-#include <ModuleBase_Operation.h>
-#include <SketchPlugin_Sketch.h>
-
-/*!
- \class PartSet_OperationSketch
- * \brief The operation for the sketch feature creation
- */
-class PARTSET_EXPORT PartSet_OperationSketch : public ModuleBase_Operation
-{
-Q_OBJECT
-
- public:
-  /// Returns the operation type key
-  static std::string Type()
-  {
-    return SketchPlugin_Sketch::ID();
-  }
-
-  /// Constructor
-  /// \param theId the feature identifier
-  /// \param theParent the operation parent
-  PartSet_OperationSketch(const QString& theId, QObject* theParent);
-  /// Destructor
-  virtual ~PartSet_OperationSketch();
-
-  /// Returns whether the nested operations are enabled.
-  /// The state can depend on the operation current state.
-  /// It returns true after the sketch plane is choosen.
-  /// \return enabled state
-  virtual bool isNestedOperationsEnabled() const;
-
-};
-
-#endif
index 8f026d712489af75f531e6150b3b844ec18a6627..fa7ac518f60a1696c8a4b04f5b88cc7392107735 100644 (file)
@@ -18,6 +18,9 @@
 #include <ModelAPI_AttributeReference.h>
 
 #include <list>
+#ifdef _DEBUG
+#include <iostream>
+#endif
 
 int shapesNbPoints(const ModuleBase_ISelection* theSelection)
 {
@@ -55,7 +58,7 @@ int shapesNbLines(const ModuleBase_ISelection* theSelection)
 
 bool PartSet_DistanceValidator::isValid(const ModuleBase_ISelection* theSelection) const
 {
-  int aCount = shapesNbPoints(theSelection);
+  int aCount = shapesNbPoints(theSelection) + shapesNbLines(theSelection);
   return (aCount > 0) && (aCount < 3);
 }
 
@@ -98,7 +101,11 @@ bool PartSet_RadiusValidator::isValid(const ModuleBase_ISelection* theSelection)
   return (aCount > 0) && (aCount < 2);
 }
 
-
+bool PartSet_RigidValidator::isValid(const ModuleBase_ISelection* theSelection) const
+{
+  int aCount = shapesNbLines(theSelection);
+  return (aCount > 0) && (aCount < 2);
+}
 
 bool PartSet_DifferentObjectsValidator::isValid(const FeaturePtr& theFeature, 
                                                 const std::list<std::string>& theArguments,
@@ -163,4 +170,4 @@ bool PartSet_DifferentObjectsValidator::isValid(const AttributePtr& theAttribute
 {
   // not implemented
   return true;
-}
\ No newline at end of file
+}
index 373cd8e13597692dae680e60f7be4903cf9c4819..d0829b58692fe405a404b8df7874b119a9c12060 100644 (file)
@@ -52,6 +52,13 @@ class PartSet_RadiusValidator : public ModuleBase_SelectionValidator
   PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
 };
 
+//! A class to validate a selection for Perpendicular constraint operation
+class PartSet_RigidValidator : public ModuleBase_SelectionValidator
+{
+ public:
+  PARTSET_EXPORT virtual bool isValid(const ModuleBase_ISelection* theSelection) const;
+};
+
 class PartSet_DifferentObjectsValidator : public ModelAPI_RefAttrValidator
 {
  public:
index 1b10b60c7b5dba6d381d38513be31a6901d102bc..cd3dcad9478402b5244761c09e2cf7d8ccd4ab26 100644 (file)
@@ -26,6 +26,7 @@ ADD_LIBRARY(PartSetPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RES
 TARGET_LINK_LIBRARIES(PartSetPlugin ${PROJECT_LIBRARIES} ModelAPI)
 
 INCLUDE_DIRECTORIES(
+  ../Events
   ../ModelAPI
   ../GeomAPI
 )
index 2869895bf1938ba928613836b26f67992d44251c..c4d50434636509f50168f7a0aef153dd3e96e73b 100644 (file)
@@ -4,9 +4,16 @@
 #include "PartSetPlugin_Part.h"
 #include "PartSetPlugin_Duplicate.h"
 #include "PartSetPlugin_Remove.h"
+
+#include <Events_Loop.h>
+
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
 
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
 using namespace std;
 
 // the only created instance of this plugin
@@ -32,3 +39,31 @@ FeaturePtr PartSetPlugin_Plugin::createFeature(string theFeatureID)
   // feature of such kind is not found
   return FeaturePtr();
 }
+
+void PartSetPlugin_Plugin::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+  const Events_ID kRequestEvent =
+      Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_REQUEST);
+  if (theMessage->eventID() == kRequestEvent) {
+    Events_Loop::loop()->send(getFeaturesState(), false);
+  } else if (theMessage.get()) {
+    #ifdef _DEBUG
+    std::cout << "PartSetPlugin_Plugin::processEvent: unhandled message caught: " << std::endl
+              << theMessage->eventID().eventText() << std::endl;
+    #endif
+  }
+}
+
+std::shared_ptr<ModelAPI_FeatureStateMessage> PartSetPlugin_Plugin::getFeaturesState()
+{
+  const Events_ID kResponseEvent =
+        Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE);
+  std::shared_ptr<ModelAPI_FeatureStateMessage> aMsg =
+      std::make_shared<ModelAPI_FeatureStateMessage>(kResponseEvent, this);
+  std::string aStdDocKind = ModelAPI_Session::get()->activeDocument()->kind();
+  bool aDocIsPart = (aStdDocKind == PartSetPlugin_Part::ID());
+  aMsg->setState(PartSetPlugin_Part::ID(), true);
+  aMsg->setState(PartSetPlugin_Duplicate::ID(), aDocIsPart);
+  aMsg->setState(PartSetPlugin_Remove::ID(), aDocIsPart);
+  return aMsg;
+}
index 9969cb403b4dc407299a26cff2e1999e575ac7ea..364ebb48dfbf4f12e2fbd571930136890e3c3b0b 100644 (file)
@@ -7,19 +7,28 @@
 #ifndef PartSetPlugin_Plugin_H_
 #define PartSetPlugin_Plugin_H_
 
-#include "PartSetPlugin.h"
-#include "ModelAPI_Plugin.h"
-#include "ModelAPI_Feature.h"
+#include <PartSetPlugin.h>
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Events.h>
 
-class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin : public ModelAPI_Plugin
+#include <Events_Listener.h>
+
+#include <memory>
+
+class PARTSETPLUGIN_EXPORT PartSetPlugin_Plugin : public ModelAPI_Plugin,
+                                                  public Events_Listener
 {
  public:
   /// Creates the feature object of this plugin by the feature string ID
   virtual FeaturePtr createFeature(std::string theFeatureID);
 
- public:
   /// Is needed for python wrapping by swig
   PartSetPlugin_Plugin();
+
+  //! Redefinition of Events_Listener method
+  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+  std::shared_ptr<ModelAPI_FeatureStateMessage> getFeaturesState();
 };
 
 #endif
index 16cbcccde16ec681804ff67ecbb44bd78d80168a..d801aabacb294e48c188df5d896674172be61454 100644 (file)
@@ -64,6 +64,7 @@ TARGET_LINK_LIBRARIES(SketchPlugin ${PROJECT_LIBRARIES})
 
 INCLUDE_DIRECTORIES(
   ../Config
+  ../Events
   ../ModelAPI
   ../GeomAPI
   ../GeomAlgoAPI
index 7035cff11d3a5098070b1ae52bce6ff4dd0d7ac0..6680aef33008ad4a073d0ed3e3e6b7eebdc207f5 100644 (file)
@@ -1,26 +1,37 @@
 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
 
-#include "SketchPlugin_Plugin.h"
-#include "SketchPlugin_Sketch.h"
-#include "SketchPlugin_Line.h"
-#include "SketchPlugin_Point.h"
-#include "SketchPlugin_Circle.h"
-#include "SketchPlugin_Arc.h"
-#include "SketchPlugin_ConstraintCoincidence.h"
-#include "SketchPlugin_ConstraintDistance.h"
-#include "SketchPlugin_ConstraintLength.h"
-#include "SketchPlugin_ConstraintParallel.h"
-#include "SketchPlugin_ConstraintPerpendicular.h"
-#include "SketchPlugin_ConstraintRadius.h"
-#include "SketchPlugin_ConstraintRigid.h"
-#include "SketchPlugin_Validators.h"
-#include "SketchPlugin_ResultValidators.h"
+#include <SketchPlugin_Plugin.h>
+#include <SketchPlugin_Sketch.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
+#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintParallel.h>
+#include <SketchPlugin_ConstraintPerpendicular.h>
+#include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_ConstraintRigid.h>
+#include <SketchPlugin_Validators.h>
+#include <SketchPlugin_ResultValidators.h>
+
+#include <Events_Loop.h>
+#include <GeomDataAPI_Dir.h>
+
 #include <ModelAPI_Session.h>
 #include <ModelAPI_Document.h>
 #include <ModelAPI_Validator.h>
+#include <ModelAPI_Data.h>
 
 #include <Config_PropManager.h>
 
+#include <memory>
+
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
 using namespace std;
 
 // the only created instance of this plugin
@@ -94,3 +105,45 @@ FeaturePtr SketchPlugin_Plugin::createFeature(string theFeatureID)
   // feature of such kind is not found
   return FeaturePtr();
 }
+
+void SketchPlugin_Plugin::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+  const Events_ID kRequestEvent =
+      Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_REQUEST);
+  if (theMessage->eventID() == kRequestEvent) {
+    std::shared_ptr<ModelAPI_FeatureStateMessage> aStateMessage =
+        std::dynamic_pointer_cast<ModelAPI_FeatureStateMessage>(theMessage);
+    Events_Loop::loop()->send(getFeaturesState(aStateMessage->feature()), false);
+  }
+}
+
+std::shared_ptr<ModelAPI_FeatureStateMessage> SketchPlugin_Plugin
+::getFeaturesState(const std::shared_ptr<ModelAPI_Feature>& theFeature) const
+{
+  const Events_ID kResponseEvent = Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE);
+  std::shared_ptr<ModelAPI_FeatureStateMessage> aMsg =
+      std::make_shared<ModelAPI_FeatureStateMessage>(kResponseEvent, this);
+
+  bool aHasSketchPlane = false;
+  std::shared_ptr<SketchPlugin_Sketch> aSketchFeature =
+      std::dynamic_pointer_cast<SketchPlugin_Sketch>(theFeature);
+  if (aSketchFeature.get()) {
+    std::shared_ptr<ModelAPI_Data> aData = aSketchFeature->data();
+    std::shared_ptr<GeomDataAPI_Dir> aNormal =
+      std::dynamic_pointer_cast<GeomDataAPI_Dir>(aData->attribute(SketchPlugin_Sketch::NORM_ID()));
+    aHasSketchPlane = aNormal && !(aNormal->x() == 0 && aNormal->y() == 0 && aNormal->z() == 0);
+
+    aMsg->setState(SketchPlugin_Point::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_Line::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_Circle::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_Arc::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintCoincidence::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintDistance::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintLength::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintParallel::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintPerpendicular::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintRadius::ID(), aHasSketchPlane);
+    aMsg->setState(SketchPlugin_ConstraintRigid::ID(), aHasSketchPlane);
+  }
+  return aMsg;
+}
index dab7e9b1c19f5bf718604066f9c55e3691404c0b..fad6fa739df89b3b55d9a66ede701a2dd67bc863 100644 (file)
@@ -4,14 +4,16 @@
 // Created:     31 Mar 2014
 // Author:      Mikhail PONIKAROV
 
-#ifndef SketchPlugin_Plugin_H_
-#define SketchPlugin_Plugin_H_
+#ifndef SKETCHPLUGIN_PLUGIN_H_
+#define SKETCHPLUGIN_PLUGIN_H_
 
-#include "SketchPlugin.h"
-#include "ModelAPI_Plugin.h"
-#include "ModelAPI_Feature.h"
+#include <SketchPlugin.h>
+#include <Events_Listener.h>
+#include <ModelAPI_Plugin.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Events.h>
 
-class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin : public ModelAPI_Plugin
+class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin : public ModelAPI_Plugin, public Events_Listener
 {
  public:
   /// Creates the feature object of this plugin by the feature string ID
@@ -20,6 +22,11 @@ class SKETCHPLUGIN_EXPORT SketchPlugin_Plugin : public ModelAPI_Plugin
  public:
   /// Is needed for python wrapping by swig
   SketchPlugin_Plugin();
+  //! Redefinition of Events_Listener method
+  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+ protected:
+  std::shared_ptr<ModelAPI_FeatureStateMessage> getFeaturesState(
+      const std::shared_ptr<ModelAPI_Feature>& theFeature) const;
 };
 
 #endif
index 14b18da747379e7f3351a41feedf092fb375ff54..571c97d778faad15a39edfb0648d8e29969f332b 100644 (file)
       </feature>
        <!--  SketchConstraintRigid  -->
       <feature id="SketchConstraintRigid" title="Fixed" tooltip="Create constraint defining fixed object" icon=":icons/fixed.png">
-           <shape_selector id="ConstraintEntityA" label="Object" tooltip="Select any object in the viewer" 
+        <shape_selector id="ConstraintEntityA" label="Object" tooltip="Select any object in the viewer" 
                        shape_types="edge vertex">
                    <validator id="SketchPlugin_ResultPoint"/>
                        <validator id="SketchPlugin_ResultLine"/>
                        <validator id="SketchPlugin_ResultArc"/>
                </shape_selector>
+           <validator id="PartSet_RigidValidator"/>
       </feature>
     </group>
   </workbench>
index 36179f2a4f5a99490f600ecbe880ab96599dd556..851e3fef0adff9e5feb81c9e2eb35d4f5c9b7f49 100644 (file)
@@ -4,18 +4,25 @@
  * XGUI_ActionsMgr.cpp
  */
 
-#include "XGUI_ActionsMgr.h"
-#include "XGUI_Workshop.h"
-#include "XGUI_OperationMgr.h"
-#include "XGUI_SalomeConnector.h"
-
 #include <AppElements_Command.h>
 
-#include <ModelAPI_Session.h>
+#include <XGUI_ActionsMgr.h>
+#include <XGUI_Workshop.h>
+#include <XGUI_OperationMgr.h>
+#include <XGUI_SalomeConnector.h>
+#include <XGUI_Selection.h>
+#include <XGUI_SelectionMgr.h>
 
-#include <ModuleBase_Operation.h>
+#include <Events_Loop.h>
 #include <Events_Error.h>
 
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Events.h>
+#include <ModelAPI_Validator.h>
+#include <ModuleBase_Operation.h>
+#include <ModuleBase_SelectionValidator.h>
+
+
 #include <QAction>
 
 #ifdef _DEBUG
@@ -34,6 +41,12 @@ XGUI_ActionsMgr::XGUI_ActionsMgr(XGUI_Workshop* theParent)
   myShortcuts << QKeySequence::Redo;
   myShortcuts << QKeySequence::Open;
   myShortcuts << QKeySequence::Close;
+
+  //Initialize event listening
+  Events_Loop* aLoop = Events_Loop::loop();
+  static Events_ID aStateResponseEventId =
+      Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE);
+  aLoop->registerListener(this, aStateResponseEventId, NULL, true);
 }
 
 XGUI_ActionsMgr::~XGUI_ActionsMgr()
@@ -61,45 +74,144 @@ void XGUI_ActionsMgr::addNestedCommands(const QString& theId, const QStringList&
   myNestedActions[theId] = theCommands;
 }
 
+QStringList XGUI_ActionsMgr::nestedCommands(const QString& theId) const
+{
+  if (myNestedActions.contains(theId))
+    return myNestedActions[theId];
+  return QStringList();
+}
+
+bool XGUI_ActionsMgr::isNested(const QString& theId) const
+{
+  foreach(QString aId, myNestedActions.keys())
+  {
+    QStringList aList = myNestedActions[aId];
+    if (aList.contains(theId))
+      return true;
+  }
+  return false;
+}
+
 void XGUI_ActionsMgr::update()
 {
+  FeaturePtr anActiveFeature = FeaturePtr();
   if (myOperationMgr->hasOperation()) {
     ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
-    FeaturePtr aFeature = anOperation->feature();
-    if(aFeature) {
+    anActiveFeature = anOperation->feature();
+    if(anActiveFeature.get()) {
       setAllEnabled(false);
-      QString aFeatureId = QString::fromStdString(aFeature->getKind());
+      QString aFeatureId = QString::fromStdString(anActiveFeature->getKind());
       setActionEnabled(aFeatureId, true);
-      setNestedStackEnabled(anOperation);
     }
+    setNestedStackEnabled(anOperation);
   } else {
     setAllEnabled(true);
     setNestedCommandsEnabled(false);
   }
+  // TODO(SBH): Get defaults state of actions from XML and remove the following method
   updateByDocumentKind();
   updateCheckState();
+  updateByPlugins(anActiveFeature);
 }
 
-void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
+void XGUI_ActionsMgr::updateCheckState()
 {
-  foreach(QString eachAction, myActions.keys())
-  {
-    setActionEnabled(eachAction, isEnabled);
+  QString eachCommand = QString();
+  foreach(eachCommand, myActions.keys()) {
+    setActionChecked(eachCommand, false);
+  }
+  QStringList ltActiveCommands = myOperationMgr->operationList();
+  foreach(eachCommand, ltActiveCommands) {
+    setActionChecked(eachCommand, true);
   }
 }
 
-void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation)
+void XGUI_ActionsMgr::updateOnViewSelection()
 {
-  if(!theOperation || !theOperation->feature())
+  XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+  if (aSelection->getSelected().size() == 0 || !myOperationMgr->hasOperation())
     return;
-  FeaturePtr aFeature = theOperation->feature();
-  QString aFeatureId = QString::fromStdString(aFeature->getKind());
-  bool isNestedEnabled = theOperation->isNestedOperationsEnabled();
-  setNestedCommandsEnabled(isNestedEnabled, aFeatureId);
+  ModuleBase_Operation* anOperation = myOperationMgr->currentOperation();
+  FeaturePtr anActiveFeature = anOperation->feature();
+  if(!anActiveFeature.get())
+    return;
+  QString aFeatureId = QString::fromStdString(anActiveFeature->getKind());
 
-  setNestedStackEnabled(myOperationMgr->previousOperation(theOperation));
+  SessionPtr aMgr = ModelAPI_Session::get();
+  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
+  foreach(QString aId, nestedCommands(aFeatureId)) {
+    std::list<ModelAPI_Validator*> aValidators;
+    std::list<std::list<std::string> > anArguments;
+    if (!anArguments.empty()) {
+      std::list<std::string> firstArg = anArguments.front();
+    }
+    aFactory->validators(aId.toStdString(), aValidators, anArguments);
+    std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
+    std::list<std::list<std::string> >::iterator aValidatorArgs = anArguments.begin();
+    for (; aValidator != aValidators.end(); aValidator++, aValidatorArgs++) {
+      if (!(*aValidator))
+        continue;
+      const ModuleBase_SelectionValidator* aSelValidator =
+          dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
+      if (!aSelValidator)
+        continue;
+      setActionEnabled(aId, aSelValidator->isValid(aSelection, *aValidatorArgs));
+
+    }
+  }
+}
+
+QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence)
+{
+  if (theKeySequence.isEmpty()) {
+    return QKeySequence();
+  }
+  QKeySequence aResult(theKeySequence);
+  if (myShortcuts.contains(aResult)) {
+    QString aMessage = tr("Shortcut %1 is already defined. Ignore.").arg(theKeySequence);
+    Events_Error::send(aMessage.toStdString());
+    return QKeySequence();
+  }
+  myShortcuts.append(aResult);
+  return aResult;
+}
+
+void XGUI_ActionsMgr::processEvent(const std::shared_ptr<Events_Message>& theMessage)
+{
+  const Events_ID kResponseEvent =
+      Events_Loop::loop()->eventByName(EVENT_FEATURE_STATE_RESPONSE);
+  if (theMessage->eventID() == kResponseEvent) {
+    std::shared_ptr<ModelAPI_FeatureStateMessage> aStateMessage =
+        std::dynamic_pointer_cast<ModelAPI_FeatureStateMessage>(theMessage);
+    if (!aStateMessage.get())
+      return;
+    std::list<std::string> aFeaturesList = aStateMessage->features();
+    std::list<std::string>::iterator it = aFeaturesList.begin();
+    for( ; it != aFeaturesList.end(); ++it) {
+      QString anActionId = QString::fromStdString(*it);
+      bool theDefaultState = false;
+      if (myActions.contains(anActionId)) {
+        theDefaultState = myActions[anActionId]->isEnabled();
+      }
+      setActionEnabled(anActionId, aStateMessage->state(*it, theDefaultState));
+    }
+  } else if (theMessage.get()) {
+    #ifdef _DEBUG
+    std::cout << "XGUI_ActionsMgr::processEvent: unhandled message caught: " << std::endl
+              << theMessage->eventID().eventText() << std::endl;
+    #endif
+  }
+}
+
+void XGUI_ActionsMgr::setAllEnabled(bool isEnabled)
+{
+  foreach(QString eachAction, myActions.keys())
+  {
+    setActionEnabled(eachAction, isEnabled);
+  }
 }
 
+
 //!
 void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& theParent)
 {
@@ -116,6 +228,17 @@ void XGUI_ActionsMgr::setNestedCommandsEnabled(bool theEnabled, const QString& t
   }
 }
 
+void XGUI_ActionsMgr::setNestedStackEnabled(ModuleBase_Operation* theOperation)
+{
+  if(!theOperation || !theOperation->feature())
+    return;
+  FeaturePtr aFeature = theOperation->feature();
+  QString aFeatureId = QString::fromStdString(aFeature->getKind());
+  setNestedCommandsEnabled(true, aFeatureId);
+
+  setNestedStackEnabled(myOperationMgr->previousOperation(theOperation));
+}
+
 void XGUI_ActionsMgr::setActionChecked(const QString& theId, const bool theChecked)
 {
   if (myActions.contains(theId)) {
@@ -126,6 +249,13 @@ void XGUI_ActionsMgr::setActionChecked(const QString& theId, const bool theCheck
   }
 }
 
+void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabled)
+{
+  if (myActions.contains(theId)) {
+    myActions[theId]->setEnabled(theEnabled);
+  }
+}
+
 /*
  * Disables all actions which have the Document Kind different to
  * the current document's kind
@@ -152,54 +282,12 @@ void XGUI_ActionsMgr::updateByDocumentKind()
   }
 }
 
-void XGUI_ActionsMgr::setActionEnabled(const QString& theId, const bool theEnabled)
-{
-  if (myActions.contains(theId)) {
-    myActions[theId]->setEnabled(theEnabled);
-  }
-}
-
-void XGUI_ActionsMgr::updateCheckState()
-{
-  QString eachCommand = QString();
-  foreach(eachCommand, myActions.keys()) {
-    setActionChecked(eachCommand, false);
-  }
-  QStringList ltActiveCommands = myOperationMgr->operationList();
-  foreach(eachCommand, ltActiveCommands) {
-    setActionChecked(eachCommand, true);
-  }
-}
-
-QStringList XGUI_ActionsMgr::nestedCommands(const QString& theId) const
-{
-  if (myNestedActions.contains(theId))
-    return myNestedActions[theId];
-  return QStringList();
-}
-
-bool XGUI_ActionsMgr::isNested(const QString& theId) const
-{
-  foreach(QString aId, myNestedActions.keys())
-  {
-    QStringList aList = myNestedActions[aId];
-    if (aList.contains(theId))
-      return true;
-  }
-  return false;
-}
-
-QKeySequence XGUI_ActionsMgr::registerShortcut(const QString& theKeySequence)
+void XGUI_ActionsMgr::updateByPlugins(FeaturePtr anActiveFeature)
 {
-  if (theKeySequence.isEmpty()) {
-    return QKeySequence();
-  }
-  QKeySequence aResult(theKeySequence);
-  if (myShortcuts.contains(aResult)) {
-    QString aMessage = tr("Shortcut %1 is already defined. Ignore.").arg(theKeySequence);
-    Events_Error::send(aMessage.toStdString());
-    return QKeySequence();
-  }
-  myShortcuts.append(aResult);
-  return aResult;
+  static Events_ID aStateRequestEventId = Events_Loop::loop()->eventByName(
+      EVENT_FEATURE_STATE_REQUEST);
+  std::shared_ptr<ModelAPI_FeatureStateMessage> aMsg =
+      std::make_shared<ModelAPI_FeatureStateMessage>(aStateRequestEventId, this);
+  aMsg->setFeature(anActiveFeature);
+  Events_Loop::loop()->send(aMsg, false);
 }
index 289b85510cfadee4bb44ee4931c707b402693143..3101cb0bd0acfd606493d24b5beea70c9bbac00e 100644 (file)
@@ -9,6 +9,9 @@
 
 #include "XGUI.h"
 
+#include <Events_Listener.h>
+#include <ModelAPI_Feature.h>
+
 #include <QObject>
 #include <QMap>
 #include <QList>
@@ -20,7 +23,7 @@ class XGUI_OperationMgr;
 class ModuleBase_Operation;
 class QAction;
 
-class XGUI_EXPORT XGUI_ActionsMgr : public QObject
+class XGUI_EXPORT XGUI_ActionsMgr : public QObject, public Events_Listener
 {
 Q_OBJECT
 
@@ -41,7 +44,8 @@ Q_OBJECT
 
   QKeySequence registerShortcut(const QString& theKeySequence);
 
-  void updateByDocumentKind();
+  //! Redefinition of Events_Listener method
+  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
  public slots:
   //! Update workbench actions according to OperationMgr state:
@@ -51,19 +55,25 @@ Q_OBJECT
   void update();
   //! Sets all commands checked if it's operation is active.
   void updateCheckState();
+  //! Updates actions according to current selection in the viewer
+  void updateOnViewSelection();
 
  protected:
   //! Sets all actions to isEnabled state.
   void setAllEnabled(bool isEnabled);
-  //! Sets to isEnabled state all siblings of the given operation and it's parents recursively
-  void setNestedStackEnabled(ModuleBase_Operation* theOperation);
   //! Sets all nested actions to isEnabled state for the command with given ID.
   //! If ID is empty - all nested actions will be affected.
   void setNestedCommandsEnabled(bool isEnabled, const QString& theParent = QString());
+  //! Sets to enabled state all siblings of the given operation and it's parents recursively
+  void setNestedStackEnabled(ModuleBase_Operation* theOperation);
   //! Sets the action with theId to theChecked state.
   void setActionChecked(const QString& theId, const bool theChecked);
   //! Sets the action with theId to theEnabled state.
   void setActionEnabled(const QString& theId, const bool theEnabled);
+  //! Updates actions according to their "document" tag
+  void updateByDocumentKind();
+  //! Asks plugins about their features state, using the Events system
+  void updateByPlugins(FeaturePtr theActiveFeature);
 
  private:
   QMap<QString, QAction*> myActions;
index d28799f32951288e52ae673e08d4a2a25099d214..39d1254f3269a728d718c417ebe8550860631878 100644 (file)
@@ -97,8 +97,10 @@ QIcon XGUI_Workshop::featureIcon(const FeaturePtr& theFeature)
   ModelAPI_ExecState aState = theFeature->data()->execState();
   switch(aState) {
     case ModelAPI_StateDone:
-    case ModelAPI_StateNothing:
+    case ModelAPI_StateNothing: {
       anIcon = QIcon(anIconString);
+    }
+    break;
     case ModelAPI_StateMustBeUpdated: {
       anIcon = ModuleBase_Tools::lighter(anIconString);
     }
@@ -143,7 +145,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
           SLOT(onContextMenuCommand(const QString&, bool)));
 
   myViewerProxy = new XGUI_ViewerProxy(this);
-  connect(myViewerProxy, SIGNAL(selectionChanged()), this, SLOT(updateCommandsOnViewSelection()));
+  connect(myViewerProxy, SIGNAL(selectionChanged()),
+          myActionsMgr,  SLOT(updateOnViewSelection()));
 
   myModuleConnector = new XGUI_ModuleConnector(this);
 
@@ -158,11 +161,6 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector)
   connect(myOperationMgr, SIGNAL(operationAborted(ModuleBase_Operation*)), 
           SLOT(onOperationAborted(ModuleBase_Operation*)));
   connect(myMainWindow, SIGNAL(exitKeySequence()), SLOT(onExit()));
-  // TODO(sbh): It seems that application works properly without update on operationStarted
-  connect(myOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)),
-          myActionsMgr,   SLOT(update()));
-  connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
-          myActionsMgr,   SLOT(update()));
   connect(this, SIGNAL(errorOccurred(const QString&)), myErrorDlg, SLOT(addError(const QString&)));
 }
 
@@ -1074,22 +1072,6 @@ void XGUI_Workshop::updateCommandStatus()
   myActionsMgr->update();
 }
 
-//******************************************************
-QList<QAction*> XGUI_Workshop::getModuleCommands() const
-{
-  QList<QAction*> aCommands;
-  if (isSalomeMode()) {  // update commands in SALOME mode
-    aCommands = salomeConnector()->commandList();
-  } else {
-    AppElements_MainMenu* aMenuBar = myMainWindow->menuObject();
-    foreach(AppElements_Command* aCmd, aMenuBar->features())
-    {
-      aCommands.append(aCmd);
-    }
-  }
-  return aCommands;
-}
-
 //******************************************************
 QDockWidget* XGUI_Workshop::createObjectBrowser(QWidget* theParent)
 {
@@ -1339,46 +1321,6 @@ void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
 }
 
 
-//**************************************************************
-void XGUI_Workshop::updateCommandsOnViewSelection()
-{
-  XGUI_Selection* aSelection = mySelector->selection();
-  if (aSelection->getSelected().size() == 0)
-    return;
-
-  // Restrict validators to manage only nested (child) features
-  // of the current feature i.e. if current feature is Sketch -
-  // Sketch Features & Constraints can be validated.
-  QStringList aNestedIds;
-  if(myOperationMgr->hasOperation()) {
-    FeaturePtr aFeature = myOperationMgr->currentOperation()->feature();
-    if(aFeature) {
-      aNestedIds << myActionsMgr->nestedCommands(QString::fromStdString(aFeature->getKind()));
-    }
-  }
-  SessionPtr aMgr = ModelAPI_Session::get();
-  ModelAPI_ValidatorsFactory* aFactory = aMgr->validators();
-  QList<QAction*> aActions = getModuleCommands();
-  foreach(QAction* aAction, aActions) {
-    QString aId = aAction->data().toString();
-    if(!aNestedIds.contains(aId))
-      continue;
-    std::list<ModelAPI_Validator*> aValidators;
-    std::list<std::list<std::string> > anArguments;
-    aFactory->validators(aId.toStdString(), aValidators, anArguments);
-    std::list<ModelAPI_Validator*>::iterator aValidator = aValidators.begin();
-    for (; aValidator != aValidators.end(); aValidator++) {
-      if (*aValidator) {
-        const ModuleBase_SelectionValidator* aSelValidator =
-            dynamic_cast<const ModuleBase_SelectionValidator*>(*aValidator);
-        if (aSelValidator) {
-          aAction->setEnabled(aSelValidator->isValid(aSelection));
-        }
-      }
-    }
-  }
-}
-
 //**************************************************************
 void XGUI_Workshop::registerValidators() const
 {
index 82fd0ed871d51473c49fba596a9805c5ee4b6278..c35db675bea7811d3e401c589b12d92e52e2b25c 100644 (file)
@@ -91,7 +91,6 @@ Q_OBJECT
   {
     return myActionsMgr;
   }
-  ;
 
   //! Returns property panel widget
   XGUI_PropertyPanel* propertyPanel() const
@@ -196,7 +195,6 @@ signals:
 
  public slots:
   void updateCommandStatus();
-  void updateCommandsOnViewSelection();
 
   void onNew();
   void onOpen();
@@ -241,8 +239,6 @@ signals:
 
   void validateOperation(const QString& theOperationId);
 
-  QList<QAction*> getModuleCommands() const;
-
   void displayAllResults();
   void displayDocumentResults(DocumentPtr theDoc);
   void displayGroupResults(DocumentPtr theDoc, std::string theGroup);