//Hardcoded xml entities
// * Nodes
+const static char* NODE_WORKBENCH = "workbench";
+const static char* NODE_GROUP = "group";
+const static char* NODE_FEATURE = "feature";
// * Properties
-const static char* FEATURE_ID = "id";
+const static char* _ID = "id";
+//const static char* WORKBENCH_ID = "id";
+//const static char* GROUP_ID = "id";
+//const static char* FEATURE_ID = "id";
const static char* FEATURE_TEXT = "text";
const static char* FEATURE_TOOLTIP = "tooltip";
const static char* FEATURE_ICON = "icon";
const static char* FEATURE_KEYSEQUENCE = "keysequence";
-const static char* FEATURE_GROUP_NAME = "name";
-
-
Config_FeatureReader::Config_FeatureReader(const std::string& theXmlFile)
- : Config_XMLReader(theXmlFile)
+ : Config_XMLReader(theXmlFile),
+ m_fetchWidgetCfg(false)
{
#ifdef _DEBUG
if(!Event_Loop::Loop()) {
{
}
+std::string Config_FeatureReader::featureWidgetCfg(std::string theFeatureName)
+{
+ m_fetchWidgetCfg = true;
+ readAll();
+ m_fetchWidgetCfg = false;
+ return m_widgetCfg;
+}
+
void Config_FeatureReader::processNode(xmlNodePtr theNode)
{
- if(isNode(theNode,"feature")) {
- Event_Loop* aEvLoop = Event_Loop::Loop();
- Config_FeatureMessage aMessage(aEvLoop->EventByName("Feature"), this);
- fillFeature(theNode, aMessage);
- xmlNodePtr aGroupNode = theNode->parent;
- if(aGroupNode) {
- std::string aGroupName = getProperty(aGroupNode, FEATURE_GROUP_NAME);
- aMessage.m_group = aGroupName;
+ if(isNode(theNode, NODE_FEATURE, NULL)) {
+ if(m_fetchWidgetCfg) {
+ xmlBufferPtr buffer = xmlBufferCreate();
+ int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
+ m_widgetCfg = std::string((char*)buffer->content);
+ } else {
+ Event_Loop* aEvLoop = Event_Loop::Loop();
+ Config_FeatureMessage aMessage(aEvLoop->EventByName("menu_item"), this);
+ fillFeature(theNode, aMessage);
+ aEvLoop->Send(aMessage);
}
- aEvLoop->Send(aMessage);
+ }
+ //The m_last* variables always defined before fillFeature() call. XML is a tree.
+ if(isNode(theNode, NODE_GROUP, NULL)) {
+ m_lastGroup = getProperty(theNode, _ID);
+ }
+ if(isNode(theNode, NODE_WORKBENCH, NULL)) {
+ m_lastWorkbench = getProperty(theNode, _ID);
}
}
bool Config_FeatureReader::processChildren(xmlNodePtr theNode)
{
- return isNode(theNode, "workbench")
- || isNode(theNode, "group");
-// || isNode(theNode, "feature");
+ return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
}
void Config_FeatureReader::fillFeature(xmlNodePtr theRoot,
Config_FeatureMessage& outFtMessage)
{
- outFtMessage.m_id = getProperty(theRoot, FEATURE_ID);
- outFtMessage.m_text = getProperty(theRoot, FEATURE_TEXT);
- outFtMessage.m_tooltip = getProperty(theRoot, FEATURE_TOOLTIP);
- outFtMessage.m_icon = getProperty(theRoot, FEATURE_ICON);
- outFtMessage.m_keysequence = getProperty(theRoot, FEATURE_KEYSEQUENCE);
+ outFtMessage.setId(getProperty(theRoot, _ID));
+ outFtMessage.setText(getProperty(theRoot, FEATURE_TEXT));
+ outFtMessage.setTooltip(getProperty(theRoot, FEATURE_TOOLTIP));
+ outFtMessage.setIcon(getProperty(theRoot, FEATURE_ICON));
+ outFtMessage.setKeysequence(getProperty(theRoot, FEATURE_KEYSEQUENCE));
+ outFtMessage.setGroupId(m_lastGroup);
+ outFtMessage.setWorkbenchId(m_lastWorkbench);
+
}
Config_FeatureReader(const std::string& theXmlFile);
virtual ~Config_FeatureReader();
+ std::string featureWidgetCfg(std::string theFeatureName);
+
protected:
void processNode(xmlNodePtr aNode);
bool processChildren(xmlNodePtr aNode);
void fillFeature(xmlNodePtr theRoot, Config_FeatureMessage& outFeatureMessage);
+ std::string m_lastWorkbench;
+ std::string m_lastGroup;
+
+ bool m_fetchWidgetCfg;
+ std::string m_widgetCfg;
};
#endif /* CONFIG_FEATUREREADER_H_ */
/*
*
*/
-
#include "Config_Message.h"
-Config_FeatureMessage::Config_FeatureMessage(const Event_ID theId, const void* theParent) :
- Event_Message(theId, theParent)
+Config_FeatureMessage::Config_FeatureMessage(const Event_ID theId,
+ const void* theParent)
+ : Event_Message(theId, theParent)
{
- m_group = "";
m_id = "";
m_text = "";
m_tooltip = "";
m_icon = "";
m_keysequence = "";
+
+ m_groupId = "";
+ m_groupText = "";
+ m_workbenchId = "";
+ m_workbenchText = "";
+}
+
+const std::string& Config_FeatureMessage::icon() const
+{
+ return m_icon;
+}
+
+void Config_FeatureMessage::setIcon(const std::string& icon)
+{
+ m_icon = icon;
+}
+
+const std::string& Config_FeatureMessage::id() const
+{
+ return m_id;
+}
+
+void Config_FeatureMessage::setId(const std::string& id)
+{
+ m_id = id;
}
+const std::string& Config_FeatureMessage::keysequence() const
+{
+ return m_keysequence;
+}
+
+void Config_FeatureMessage::setKeysequence(const std::string& keysequence)
+{
+ m_keysequence = keysequence;
+}
+
+const std::string& Config_FeatureMessage::text() const
+{
+ return m_text;
+}
+
+void Config_FeatureMessage::setText(const std::string& text)
+{
+ m_text = text;
+}
+
+const std::string& Config_FeatureMessage::tooltip() const
+{
+ return m_tooltip;
+}
+
+const std::string& Config_FeatureMessage::groupId() const
+{
+ return m_groupId;
+}
+
+void Config_FeatureMessage::setGroupId(const std::string& groupId)
+{
+ m_groupId = groupId;
+}
+
+const std::string& Config_FeatureMessage::groupText() const
+{
+ return m_groupText;
+}
+
+void Config_FeatureMessage::setGroupText(const std::string& groupText)
+{
+ m_groupText = groupText;
+}
+
+const std::string& Config_FeatureMessage::workbenchId() const
+{
+ return m_workbenchId;
+}
+
+void Config_FeatureMessage::setWorkbenchId(const std::string& workbenchId)
+{
+ m_workbenchId = workbenchId;
+}
+
+const std::string& Config_FeatureMessage::workbenchText() const
+{
+ return m_workbenchText;
+}
+
+void Config_FeatureMessage::setWorkbenchText(const std::string& workbenchText)
+{
+ m_workbenchText = workbenchText;
+}
+
+void Config_FeatureMessage::setTooltip(const std::string& tooltip)
+{
+ m_tooltip = tooltip;
+}
class CONFIG_EXPORT Config_FeatureMessage : public Event_Message
{
-public:
std::string m_id;
std::string m_text;
std::string m_tooltip;
std::string m_icon;
std::string m_keysequence;
- std::string m_group;
+ std::string m_groupId;
+ std::string m_groupText;
+ std::string m_workbenchId;
+ std::string m_workbenchText;
public:
//const Event_ID theID, const void* theSender = 0
Config_FeatureMessage(const Event_ID theId, const void* theParent = 0);
+ //Auto-generated getters/setters
+ const std::string& icon() const;
+ const std::string& id() const;
+ const std::string& keysequence() const;
+ const std::string& text() const;
+ const std::string& tooltip() const;
+ const std::string& groupId() const;
+ const std::string& groupText() const;
+ const std::string& workbenchId() const;
+ const std::string& workbenchText() const;
+
+ void setIcon(const std::string& icon);
+ void setId(const std::string& id);
+ void setKeysequence(const std::string& keysequence);
+ void setText(const std::string& text);
+ void setTooltip(const std::string& tooltip);
+ void setGroupId(const std::string& groupId);
+ void setGroupText(const std::string& groupText);
+ void setWorkbenchId(const std::string& workbenchId);
+ void setWorkbenchText(const std::string& workbenchText);
};
-
#endif // CONFIG_MESSAGE_H
#include <iostream>
#endif
+//Hardcoded xml entities
+// * Nodes
+const static char* NODE_PLUGIN = "plugin";
+const static char* NODE_PLUGINS = "plugins";
+
+// * Properties
+const static char* PLUGINS_MODULE = "module";
+const static char* PLUGIN_CONFIG = "configuration";
+const static char* PLUGIN_LIBRARY = "library";
+
+
Config_ModuleReader::Config_ModuleReader()
: Config_XMLReader("plugins.xml"),
m_isAutoImport(false)
std::string Config_ModuleReader::getModuleName()
{
xmlNodePtr aRoot = findRoot();
- return getProperty(aRoot, "module");
+ return getProperty(aRoot, PLUGINS_MODULE);
}
/*
*/
void Config_ModuleReader::processNode(xmlNodePtr theNode)
{
- if(isNode(theNode, "plugin")) {
- std::string aPluginName = getProperty(theNode, "configuration");
+ if(isNode(theNode, NODE_PLUGIN, NULL)) {
+ std::string aPluginName = getProperty(theNode, PLUGIN_CONFIG);
if(m_isAutoImport)
importPlugin(aPluginName);
m_pluginsList.push_back(aPluginName);
bool Config_ModuleReader::processChildren(xmlNodePtr theNode)
{
- return isNode(theNode, "plugins");
+ return isNode(theNode, NODE_PLUGINS, NULL);
}
void Config_ModuleReader::importPlugin(const std::string& thePluginName)
/*
* Returns true if theNode is XML node with a given name.
*/
-bool Config_XMLReader::isNode(xmlNodePtr theNode, const char* theNodeName)
+bool Config_XMLReader::isNode(xmlNodePtr theNode, const char* theNodeName, ...)
{
- const char* emptyLine = "";
- return theNode->type == XML_ELEMENT_NODE
- && !xmlStrcmp(theNode->name, (const xmlChar *) theNodeName);
+ bool result = false;
+ const xmlChar* aName = theNode->name;
+ if(!aName || theNode->type != XML_ELEMENT_NODE)
+ return false;
+
+ if(!xmlStrcmp(aName, (const xmlChar *) theNodeName))
+ return true;
+
+ va_list args; // define argument list variable
+ va_start (args, theNodeName); // init list; point to last defined argument
+ while(true) {
+ char *anArg = va_arg (args, char *); // get next argument
+ if(anArg == NULL)
+ break;
+ if(!xmlStrcmp(aName, (const xmlChar *) anArg)) {
+ va_end (args); // cleanup the system stack
+ return true;
+ }
+ }
+ va_end (args); // cleanup the system stack
+ return false;
}
#include "Config_Message.h"
#include <string>
+#include <cstdarg>
//Forward declaration for xmlNodePtr.
typedef struct _xmlNode xmlNode;
typedef xmlNode *xmlNodePtr;
struct _xmlNode;
+
class CONFIG_EXPORT Config_XMLReader {
public:
Config_XMLReader(const std::string& theXmlFile);
xmlNodePtr node(void* theNode);
std::string getProperty(xmlNodePtr theNode, const char* property);
- bool isNode(xmlNodePtr theNode, const char* name);
+ /*
+ * Please note that this function should be called with NULL last argument.
+ * In example: isNode(aNode, "type1", ["type2", ...], NULL);
+ * ", NULL" is required to use unlimited number of arguments.
+ * TODO(sbh): find a way to simplify calling this method.
+ */
+ bool isNode(xmlNodePtr theNode, const char* name, ...);
private:
std::string m_DocumentPath;
-<plugin name="PartSet">
- <workbench>
- <group name="Part">
+<plugin>
+ <workbench id="Part">
+ <group id="Operations">
<feature id="new_part" text="Part" tooltip="Creates a new part" icon=":pictures/part_ico.png"/>
<feature id="duplicate" text="Duplicate" tooltip="Duplicate selected object" icon=":icons/duplicate.png"/>
<feature id="remove" text="Remove" tooltip="Remove selected object" icon=":icons/remove.png"/>
</group>
- <group name="Construction">
- <feature id="new_point" text="Point" tooltip="Create a new point" icon=":icons/point.png"/>
+ </workbench>
+ <workbench id="Construction">
+ <group id="Basic">
+ <feature id="new_point" text="Point" tooltip="Create a new point" icon=":icons/point.png">
+ <value id="x" type="double" label="X:" min="0" max="" step="0.1" default="0"/>
+ <value id="y" type="double" label="Y:" min="0" max="" step="0.1" default="0"/>
+ <value id="z" type="double" label="Z:" min="0" max="" step="0.1" default="0"/>
+ </feature>
<feature id="new_axis" text="Axis" tooltip="Create a new axis" icon=":icons/axis.png" keysequence=""/>
<feature id="new_plane" text="Plane" tooltip="Create a new plane" icon=":icons/plane.png" keysequence=""/>
</group>
// TO DO: make it in thread and wit husage of semaphores
map<char*, map<void*, list<Event_Listener*> > >::iterator aFindID =
- myListeners.find(theMessage.ID().EventText());
+ myListeners.find(theMessage.EventID().EventText());
if (aFindID != myListeners.end()) {
map<void*, list<Event_Listener*> >::iterator aFindSender =
aFindID->second.find(theMessage.Sender());
#include <Event_Message.hxx>
Event_Message::Event_Message(const Event_ID theID, const void* theSender) :
-myID(theID), mySender((void*)theSender)
+myEventId(theID), mySender((void*)theSender)
{
}
* Normally it is inherited by the higher-level
*/
class EVENT_EXPORT Event_Message {
- Event_ID myID; ///< identifier of the event
+ Event_ID myEventId; ///< identifier of the event
void* mySender; ///< the sender object
public:
virtual ~Event_Message() {}
//! Returns identifier of the message
- const Event_ID& ID() const {return myID;}
+ const Event_ID& EventID() const {return myEventId;}
//! Returns sender of the message or NULL if it is anonymous message
void* Sender() {return mySender;}
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
INCLUDE(Common)
+SET(CMAKE_AUTOMOC ON)
SET(PROJECT_HEADERS
PartSet.h
PartSet_Module.h
+ PartSet_Message.h
)
SET(PROJECT_SOURCES
PartSet_Module.cpp
+ PartSet_Message.cpp
)
SET(PROJECT_RESOURCES
${Qt5Widgets_LIBRARIES}
)
+SET(PROJECT_AUTOMOC
+ ${CMAKE_CURRENT_BINARY_DIR}/PartSet_automoc.cpp
+)
+
QT5_ADD_RESOURCES(PROJECT_COMPILED_RESOURCES ${PROJECT_RESOURCES})
QT5_ADD_TRANSLATION(QM_RESOURCES ${TEXT_RESOURCES})
-SOURCE_GROUP ("Generated Files" FILES ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES})
+SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESOURCES} ${QM_RESOURCES})
SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI)
--- /dev/null
+/*
+ * PartSet_Message.cpp
+ *
+ * Created on: Mar 21, 2014
+ * Author: sbh
+ */
+
+#include <PartSet_Message.h>
+
+PartSet_Message::PartSet_Message(const Event_ID theId,
+ const void* theParent)
+ : Event_Message(theId, theParent)
+{
+
+}
+
+PartSet_Message::~PartSet_Message()
+{
+}
+
--- /dev/null
+/*
+ * PartSet_Message.h
+ *
+ * Created on: Mar 21, 2014
+ * Author: sbh
+ */
+
+#ifndef PARTSET_MESSAGE_H_
+#define PARTSET_MESSAGE_H_
+
+#include <PartSet.h>
+
+#include <QString>
+
+#include <Event_Message.hxx>
+
+class PARTSET_EXPORT PartSet_Message: public Event_Message
+{
+public:
+ PartSet_Message(const Event_ID theId, const void* theParent = 0);
+ virtual ~PartSet_Message();
+};
+
+#endif /* PARTSET_MESSAGE_H_ */
#include "PartSet_Module.h"
#include <Config_ModuleReader.h>
+#include <Config_FeatureReader.h>
+
+#include <Event_Loop.hxx>
#include <QFile>
#include <QDir>
void PartSet_Module::createFeatures()
{
Config_ModuleReader* aXMLReader = new Config_ModuleReader();
- aXMLReader->getModuleName();
aXMLReader->setAutoImport(true);
aXMLReader->readAll();
delete aXMLReader;
}
+
+void PartSet_Module::featureCreated(XGUI_Command* theFeature)
+{
+ QString aFtId = theFeature->getId();
+ if(aFtId == "new_point") {
+ theFeature->connectTo(this, SLOT(onCommandTriggered()));
+ }
+}
+
+void PartSet_Module::onCommandTriggered()
+{
+ Config_ModuleReader aModuleReader = Config_ModuleReader();
+ aModuleReader.readAll();
+ std::string aPluginName = aModuleReader.pluginsList().front();
+ Config_FeatureReader* aReader = new Config_FeatureReader(aPluginName);
+ XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
+ std::string aXMLWidgetCfg =
+ aReader->featureWidgetCfg(aCmd->getId().toStdString());
+ delete aReader;
+}
#include "PartSet.h"
#include <XGUI_Module.h>
+#include <XGUI_Command.h>
-class Config_FeatureReader;
+#include <QObject>
-class PARTSET_EXPORT PartSet_Module : public XGUI_Module
+class PARTSET_EXPORT PartSet_Module : public QObject, public XGUI_Module
{
+ Q_OBJECT
public:
PartSet_Module(XGUI_Workshop* theWshop);
virtual ~PartSet_Module();
virtual void createFeatures();
+ virtual void featureCreated(XGUI_Command* theFeature);
+
+public slots:
+ void onCommandTriggered();
private:
QString myMenuXML;
-
XGUI_Workshop* myWorkshop;
};
{
}
-XGUI_Workbench* XGUI_MainMenu::addWorkbench(const QString& theTitle)
+XGUI_Workbench* XGUI_MainMenu::addWorkbench(const QString& theId,
+ const QString& theTitle)
{
- QDockWidget* aDoc = new QDockWidget(myDesktop);
- QString workbenchObjName = theTitle + "_Workbench";
- aDoc->setObjectName(workbenchObjName);
- aDoc->setFeatures(QDockWidget::DockWidgetVerticalTitleBar);
- aDoc->setAllowedAreas(Qt::TopDockWidgetArea);
- aDoc->setWindowTitle(theTitle);
- aDoc->setMinimumHeight(30);
- aDoc->setContentsMargins(0, 0, 0, 0);
-
- XGUI_Workbench* aPage = new XGUI_Workbench(aDoc);
- aDoc->setWidget(aPage);
-
- myDesktop->addDockWidget(Qt::TopDockWidgetArea, aDoc);
+ QDockWidget* aDock = new QDockWidget(myDesktop);
+ aDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar);
+ aDock->setAllowedAreas(Qt::TopDockWidgetArea);
+ QString aTitle = theTitle;
+ if(aTitle.isEmpty()){
+ aTitle = tr(theId.toLatin1().constData());
+ }
+ aDock->setWindowTitle(aTitle);
+ aDock->setMinimumHeight(30);
+ aDock->setContentsMargins(0, 0, 0, 0);
+
+ XGUI_Workbench* aPage = new XGUI_Workbench(aDock);
+ aPage->setObjectName(theId);
+ aDock->setWidget(aPage);
+
+ myDesktop->addDockWidget(Qt::TopDockWidgetArea, aDock);
if (myMenuTabs.length() > 1) {
- myDesktop->tabifyDockWidget(myMenuTabs.last(), aDoc);
+ myDesktop->tabifyDockWidget(myMenuTabs.last(), aDock);
}
- myMenuTabs.append(aDoc);
+ myMenuTabs.append(aDock);
return aPage;
}
*/
XGUI_Workbench* XGUI_MainMenu::findWorkbench(const QString& theObjName)
{
- QDockWidget* aDoc = myDesktop->findChild<QDockWidget*>(theObjName);
- if(aDoc) {
- return dynamic_cast<XGUI_Workbench*>(aDoc->widget());
- }
- return NULL;
-}
-
-
-XGUI_MenuGroupPanel* XGUI_MainMenu::addGroup(int thePageId)
-{
- XGUI_Workbench* aPage = dynamic_cast<XGUI_Workbench*>(myMenuTabs[thePageId]->widget());
- return aPage->addGroup();
+ return myDesktop->findChild<XGUI_Workbench*>(theObjName);
}
-
XGUI_MainMenu(XGUI_MainWindow *parent);
virtual ~XGUI_MainMenu();
- XGUI_Workbench* addWorkbench(const QString& theTitle);
- XGUI_Workbench* findWorkbench(const QString& theObjName);
-
- XGUI_MenuGroupPanel* addGroup(int thePageId);
+ XGUI_Workbench* addWorkbench(const QString& theId,
+ const QString& theText = "");
+ XGUI_Workbench* findWorkbench(const QString& theId);
private:
XGUI_MainWindow* myDesktop;
-
#ifndef XGUI_Module_H
#define XGUI_Module_H
-#include <QString>
-#include <QIcon>
-#include <QKeySequence>
-
#include <XGUI_Workshop.h>
+class XGUI_Command;
+
class XGUI_Module
{
public:
virtual void createFeatures() = 0;
+ virtual void featureCreated(XGUI_Command*) = 0;
};
//! This function must return a new module instance.
}
/*
- * Creates a new group in the workbench with given name.
- * If no name provided it would be defined as {workbench_name}_Group_N.
+ * Creates a new group in the workbench with given object name.
*/
-XGUI_MenuGroupPanel* XGUI_Workbench::addGroup(const QString& theName)
+XGUI_MenuGroupPanel* XGUI_Workbench::addGroup(const QString& theId)
{
- QString aGroupName = theName;
- //Generate a group name.
- if(theName.isEmpty()){
- QString aGroupName = objectName();
- aGroupName = aGroupName.replace("_Workbench", "_Group_%1");
- aGroupName = aGroupName.arg(myGroups.count());
- }
if (!myLayout->isEmpty()) {
int aNb = myLayout->count();
QLayoutItem* aItem = myLayout->itemAt(aNb - 1);
myLayout->removeItem(aItem);
}
XGUI_MenuGroupPanel* aGroup = new XGUI_MenuGroupPanel(myChildWidget);
- aGroup->setObjectName(aGroupName);
+ aGroup->setObjectName(theId);
myLayout->addWidget(aGroup);
addSeparator();
myLayout->addStretch();
/*
* Searches for already created group with given name.
*/
-XGUI_MenuGroupPanel* XGUI_Workbench::findGroup(const QString& theName)
+XGUI_MenuGroupPanel* XGUI_Workbench::findGroup(const QString& theId)
{
- QString aGroupName = theName;
XGUI_MenuGroupPanel* aPanel;
foreach(aPanel, myGroups) {
- if(aPanel->objectName() == theName) {
+ if(aPanel->objectName() == theId) {
return aPanel;
}
}
public:
XGUI_Workbench(QWidget* theParent);
- XGUI_MenuGroupPanel* addGroup(const QString& theName = "");
+ XGUI_MenuGroupPanel* addGroup(const QString& theId);
XGUI_MenuGroupPanel* findGroup(const QString& theName);
private slots:
QObject()
{
myMainWindow = new XGUI_MainWindow();
+ myPartSetModule = NULL;
}
//******************************************************
initMenu();
//Initialize event listening
Event_Loop* aLoop = Event_Loop::Loop();
- Event_ID aFeatureId = aLoop->EventByName("Feature");
+ Event_ID aFeatureId = aLoop->EventByName("menu_item");
aLoop->RegisterListener(this, aFeatureId);
+ Event_ID aPartSetId = aLoop->EventByName("partset_module");
+ aLoop->RegisterListener(this, aPartSetId);
activateModule();
myMainWindow->show();
}
XGUI_Workbench* aPage = addWorkbench(tr("GEN_MENU_TITLE"));
// File commands group
- XGUI_MenuGroupPanel* aGroup = aPage->addGroup();
+ XGUI_MenuGroupPanel* aGroup = aPage->addGroup("Default");
XGUI_Command* aCommand;
//******************************************************
void XGUI_Workshop::ProcessEvent(const Event_Message* theMessage)
{
- const Config_FeatureMessage* aMsg =
+ const Config_FeatureMessage* aFeatureMsg =
dynamic_cast<const Config_FeatureMessage*>( theMessage );
- if(aMsg) {
- addFeature(aMsg);
+ if(aFeatureMsg) {
+ addFeature(aFeatureMsg);
return;
}
#ifdef _DEBUG
*/
void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
{
- XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
- XGUI_Workbench* aPage = aMenuBar->findWorkbench(tr( "GEN_MENU_TITLE" ) + "_Workbench");
- if(!aPage) {
+ if(!theMessage) {
#ifdef _DEBUG
- qDebug() << "XGUI_Workshop::ProcessEvent: "
- << "Creating a workbench " << tr( "GEN_MENU_TITLE" );
+ qDebug() << "XGUI_Workshop::addFeature: NULL message.";
#endif
- aPage = addWorkbench(tr( "GEN_MENU_TITLE" ));
+ return;
+ }
+ //Find or create Workbench
+ XGUI_MainMenu* aMenuBar = myMainWindow->menuObject();
+ QString aWchName = QString::fromStdString(theMessage->workbenchId());
+ XGUI_Workbench* aPage = aMenuBar->findWorkbench(aWchName);
+ if(!aPage) {
+ aPage = addWorkbench(aWchName);
}
- QString aGroupName = QString::fromStdString(theMessage->m_group);
- QString aFeatureId = QString::fromStdString(theMessage->m_id);
+ //Find or create Group
+ QString aGroupName = QString::fromStdString(theMessage->groupId());
XGUI_MenuGroupPanel* aGroup = aPage->findGroup(aGroupName);
if(!aGroup) {
aGroup = aPage->addGroup(aGroupName);
}
- XGUI_Command* aCommand = aGroup->addFeature(aFeatureId,
- QString::fromStdString(theMessage->m_text),
- QString::fromStdString(theMessage->m_tooltip),
- QIcon(theMessage->m_icon.c_str())
+ //Create feature...
+ QString aFeatureId = QString::fromStdString(theMessage->id());
+ XGUI_Command* aCommand = aGroup->addFeature(
+ QString::fromStdString(theMessage->id()),
+ QString::fromStdString(theMessage->text()),
+ QString::fromStdString(theMessage->tooltip()),
+ QIcon(theMessage->icon().c_str())
//TODO(sbh): QKeySequence
);
+ myPartSetModule->featureCreated(aCommand);
}
//******************************************************
//******************************************************
bool XGUI_Workshop::activateModule()
{
- // Test of modules loading
- XGUI_Module* aModule = loadModule("PartSet");
- if (!aModule)
- return false;
- aModule->createFeatures();
- return true;
+ myPartSetModule = loadModule("PartSet");
+ if (!myPartSetModule)
+ return false;
+ myPartSetModule->createFeatures();
+ return true;
}
bool activateModule();
XGUI_MainWindow* myMainWindow;
+ XGUI_Module* myPartSetModule;
};
#endif