#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;
+}
#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
{
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_ */
-
#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>
#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);
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;
+}
#include <Events_Listener.h>
+#include <string>
+#include <list>
+#include <memory>
+
+class XGUI_MenuWorkbench;
class XGUI_Workshop;
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_ */
#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;
}
#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
{
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_ */