]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue 1303 Re-ordering of Sketcher menus: additional structure for feature info to...
authornds <nds@opencascade.com>
Wed, 13 Apr 2016 07:24:59 +0000 (10:24 +0300)
committernds <nds@opencascade.com>
Wed, 13 Apr 2016 07:25:31 +0000 (10:25 +0300)
src/XGUI/XGUI_MenuGroup.cpp
src/XGUI/XGUI_MenuGroup.h
src/XGUI/XGUI_MenuMgr.cpp
src/XGUI/XGUI_MenuMgr.h
src/XGUI/XGUI_MenuWorkbench.cpp
src/XGUI/XGUI_MenuWorkbench.h

index e0bc02e2de3c275db5487a24eb097d0405452e6c..c2ce5b20f938efb1e42031ca3e110f31b9a8d4af 100755 (executable)
@@ -6,6 +6,17 @@
 
 #include <XGUI_MenuGroup.h>
 
-XGUI_MenuGroup::XGUI_MenuGroup()
+XGUI_MenuGroup::XGUI_MenuGroup(const std::string& theName)
+: myName(theName)
 {
 }
+
+void XGUI_MenuGroup::setFeatureInfo(const std::shared_ptr<Config_FeatureMessage>& theMessage)
+{
+  myFeatureInfo.push_back(theMessage);
+}
+
+const std::list<std::shared_ptr<Config_FeatureMessage> >& XGUI_MenuGroup::featureInfo() const
+{
+  return myFeatureInfo;
+}
index d4d08329e273d5e93f253c47ee0cd34df5fb8623..c1748f3132ed2dad75b0798aa6b1d47bef13fc19 100755 (executable)
@@ -9,6 +9,11 @@
 
 #include "XGUI.h"
 
+#include <string>
+#include <list>
+
+class Config_FeatureMessage;
+
 /**
 * \ingroup GUI
 * A class for management of menu actions (features). The actions should be arranged like they are
@@ -19,9 +24,24 @@ class XGUI_EXPORT XGUI_MenuGroup
 {
  public:
   /// Constructor
-  XGUI_MenuGroup();
+  XGUI_MenuGroup(const std::string& theName);
   virtual ~XGUI_MenuGroup() {}
+
+  /// Returns a name of the workbench
+  /// \return workbench name
+  std::string getName() const { return myName; }
+
+  /// Stores XML information for the feature kind
+  /// \param theMessage a container of the feature XML properties
+  virtual void setFeatureInfo(const std::shared_ptr<Config_FeatureMessage>& theMessage);
+
+  /// Returns container of existing features
+  /// \returns list
+  const std::list<std::shared_ptr<Config_FeatureMessage> >& featureInfo() const;
+
+private:
+  std::string myName; /// a name of the workbench
+  std::list<std::shared_ptr<Config_FeatureMessage> > myFeatureInfo; /// container of existing features
 };
 
 #endif /* XGUI_MENUGROUP_H_ */
-
index 1e55b62187c618175d1da70c834e36880d520af1..8dff16c1f295fbd9ce53bd3039a810b6608eaa7e 100755 (executable)
@@ -8,6 +8,8 @@
 #include <XGUI_Workshop.h>
 #include <XGUI_ActionsMgr.h>
 #include <XGUI_OperationMgr.h>
+#include <XGUI_MenuWorkbench.h>
+#include <XGUI_MenuGroup.h>
 
 #include <Events_Loop.h>
 #include <Config_FeatureMessage.h>
@@ -58,6 +60,15 @@ void XGUI_MenuMgr::addFeature(const std::shared_ptr<Config_FeatureMessage>& theM
 #endif
     return;
   }
+  {
+    std::string aWchName = theMessage->workbenchId();
+    std::shared_ptr<XGUI_MenuWorkbench> aWorkbench = findWorkbench(aWchName);
+
+    std::string aGroupName = theMessage->groupId();
+    std::shared_ptr<XGUI_MenuGroup> aGroup = aWorkbench->findGroup(aGroupName);
+
+    aGroup->setFeatureInfo(theMessage);
+  }
 
   ActionInfo aFeatureInfo;
   aFeatureInfo.initFrom(theMessage);
@@ -126,3 +137,20 @@ void XGUI_MenuMgr::addFeature(const std::shared_ptr<Config_FeatureMessage>& theM
   myWorkshop->module()->actionCreated(aCommand);
 #endif
 }
+
+std::shared_ptr<XGUI_MenuWorkbench> XGUI_MenuMgr::findWorkbench(std::string& theWorkbenchName)
+{
+  std::list< std::shared_ptr<XGUI_MenuWorkbench> >::const_iterator anIt = myWorkbenches.begin(),
+                                                                   aLast = myWorkbenches.end();
+  std::shared_ptr<XGUI_MenuWorkbench> aResultWorkbench;
+  for (; anIt != aLast && !aResultWorkbench; anIt++) {
+    std::shared_ptr<XGUI_MenuWorkbench> aWorkbench = *anIt;
+    if (aWorkbench->getName() == theWorkbenchName)
+      aResultWorkbench = aWorkbench;
+  }
+  if (!aResultWorkbench) {
+    aResultWorkbench = std::shared_ptr<XGUI_MenuWorkbench>(new XGUI_MenuWorkbench(theWorkbenchName));
+    myWorkbenches.push_back(aResultWorkbench);
+  }
+  return aResultWorkbench;
+}
index dc5ddfb9cedce89a23f58a928523540c579b20a6..74bf04407e24190d75f761875723414830e04879 100755 (executable)
 
 #include <Events_Listener.h>
 
+#include <string>
+#include <list>
+#include <memory>
+
+class XGUI_MenuWorkbench;
 class XGUI_Workshop;
 class Config_FeatureMessage;
 
@@ -20,23 +25,29 @@ class Config_FeatureMessage;
 * in XML file. It listens the read feature of XML and fills internal structure of menu workbenches
 * and groups of feature. After, it creates menues and tools in the module.
 */
-class XGUI_EXPORT XGUI_MenuMgr : public Events_Listener
+class XGUI_MenuMgr : public Events_Listener
 {
  public:
   /// Constructor
   /// \param the current workshop
-  XGUI_MenuMgr(XGUI_Workshop* theWorkshop);
-  virtual ~XGUI_MenuMgr() {}
+  XGUI_EXPORT XGUI_MenuMgr(XGUI_Workshop* theWorkshop);
+  XGUI_EXPORT virtual ~XGUI_MenuMgr() {}
 
-  //! Redefinition of Events_Listener method
-  virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
+  /// Redefinition of Events_Listener method
+  XGUI_EXPORT virtual void processEvent(const std::shared_ptr<Events_Message>& theMessage);
 
 protected:
   /// Process event "Add a feature"
   void addFeature(const std::shared_ptr<Config_FeatureMessage>& theMessage);
 
+  /// Finds or creates a workbench for the given name
+  /// \param theWorkbenchName a name defined in XML
+  /// \return an instance of workbench
+  std::shared_ptr<XGUI_MenuWorkbench> findWorkbench(std::string& theWorkbenchName);
+
 private:
   XGUI_Workshop* myWorkshop; /// the current workshop
+  std::list< std::shared_ptr<XGUI_MenuWorkbench> > myWorkbenches; /// container of existing workbenchs
 };
 
 #endif /* XGUI_MENUMGR_H_ */
index 297d643e66fa18a118930d71304d4457aefb37ce..8107893fc21877e6fb71b4cac8c140c1674166c7 100755 (executable)
@@ -6,6 +6,31 @@
 
 #include <XGUI_MenuWorkbench.h>
 
-XGUI_MenuWorkbench::XGUI_MenuWorkbench()
+#include <XGUI_MenuGroup.h>
+
+XGUI_MenuWorkbench::XGUI_MenuWorkbench(const std::string& theName)
+: myName(theName)
+{
+}
+
+std::shared_ptr<XGUI_MenuGroup> XGUI_MenuWorkbench::findGroup(const std::string& theGroupName)
+{
+  std::list< std::shared_ptr<XGUI_MenuGroup> >::const_iterator anIt = myGroups.begin(),
+                                                              aLast = myGroups.end();
+  std::shared_ptr<XGUI_MenuGroup> aResultGroup = 0;
+  for (; anIt != aLast && !aResultGroup; anIt++) {
+    std::shared_ptr<XGUI_MenuGroup> aGroup = *anIt;
+    if (aGroup->getName() == theGroupName)
+      aResultGroup = aGroup;
+  }
+  if (!aResultGroup) {
+    aResultGroup = std::shared_ptr<XGUI_MenuGroup>(new XGUI_MenuGroup(theGroupName));
+    myGroups.push_back(aResultGroup);
+  }
+  return aResultGroup;
+}
+
+const std::list<std::shared_ptr<XGUI_MenuGroup> >& XGUI_MenuWorkbench::groups() const
 {
+  return myGroups;
 }
index 11597bb17a7f23564106936904a009bfbdddad4c..079fe3d3597d1cc6f04542e3f544dd966abbd94b 100755 (executable)
@@ -9,6 +9,12 @@
 
 #include "XGUI.h"
 
+#include <string>
+#include <list>
+#include <memory>
+
+class XGUI_MenuGroup;
+
 /**
 * \ingroup GUI
 * A class for management of menu actions (features). The actions should be arranged like they are
@@ -19,9 +25,26 @@ class XGUI_EXPORT XGUI_MenuWorkbench
 {
  public:
   /// Constructor
-  XGUI_MenuWorkbench();
+  XGUI_MenuWorkbench(const std::string& theName);
   /// Destructor
   virtual ~XGUI_MenuWorkbench() {}
+
+  /// Returns a name of the workbench
+  /// \return workbench name
+  std::string getName() const { return myName; }
+
+  /// Finds or creates a group for the given name
+  /// \param theGroupName a name defined in XML
+  /// \return an instance of group
+  std::shared_ptr<XGUI_MenuGroup> findGroup(const std::string& theGroupName);
+
+  /// Returns container of existing groups
+  /// \returns list
+  const std::list<std::shared_ptr<XGUI_MenuGroup> >& groups() const;
+
+private:
+  std::string myName; /// a name of the workbench
+  std::list<std::shared_ptr<XGUI_MenuGroup> > myGroups; /// container of existing groups
 };
 
 #endif /* XGUI_MENUWORKBENCH_H_ */