\r
#include <string>\r
\r
+/// Event ID that feature is loaded (comes with Config_FeatureMessage)\r
+static const char * EVENT_FEATURE_LOADED = "FeatureLoaded";\r
+\r
/*\r
* Class to pass a feature entry extracted from xml file.\r
* Example of the feature entry:\r
const char* theEventGenerated)
: Config_XMLReader(theXmlFile),
myLibraryName(theLibraryName),
- myEventGenerated(theEventGenerated ? theEventGenerated : "FeatureEvent")
+ myEventGenerated(theEventGenerated ? theEventGenerated : EVENT_FEATURE_LOADED)
{
}
std::string myLibraryName;
std::list<std::string> myFeatures;
- /// event generated on feature data sending, by default it is "FeatureEvent"
+ /// event generated on feature data sending, by default it is EVENT_FEATURE_LOADED
const char* myEventGenerated;
};
ModuleBase_WidgetFactory.h
ModuleBase_WidgetPoint2D.h
ModuleBase_WidgetSwitch.h
+ ModuleBase_IModelWidget.h
+ ModuleBase_MetaWidget.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetFactory.cpp
ModuleBase_WidgetPoint2D.cpp
ModuleBase_WidgetSwitch.cpp
+ ModuleBase_MetaWidget.cpp
)
SET(PROJECT_LIBRARIES
--- /dev/null
+/*
+ * ModuleBase_IModelWidget.h
+ *
+ * Created on: Apr 30, 2014
+ * Author: sbh
+ */
+
+#ifndef MODULEBASE_IMODELWIDGET_H_
+#define MODULEBASE_IMODELWIDGET_H_
+
+#include <ModuleBase.h>
+#include <QWidget>
+#include <QString>
+
+/*
+ * Common interface for widgets in the property panel.
+ * Every widget are able to save/restore data from the
+ * model and/or to contain other widgets.
+ *
+ * Also, there are some methods to simplify and accelerate
+ * searching of children.
+ */
+class ModuleBase_IModelWidget
+{
+public:
+ //! Interface for saving widget's data into the data model
+ MODULEBASE_EXPORT virtual bool storeValue() = 0;
+ //! Interface for loading widget's data from the data model
+ MODULEBASE_EXPORT virtual bool restoreValue() = 0;
+};
+
+#endif /* MODULEBASE_IMODELWIDGET_H_ */
--- /dev/null
+/*
+ *
+ */
+
+#include <ModuleBase_MetaWidget.h>
+#include <QMetaObject>
+
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
+ModuleBase_MetaWidget::ModuleBase_MetaWidget(const QString& theId,
+ QWidget* theWrapped,
+ boost::shared_ptr<ModelAPI_Feature> theFeature)
+ : myId(theId), myWrappedWidget(theWrapped), myFeature(theFeature)
+{
+
+}
+
+ModuleBase_MetaWidget::~ModuleBase_MetaWidget()
+{
+
+}
+
+bool ModuleBase_MetaWidget::storeValue()
+{
+ #ifdef _DEBUG
+ std::cout << "ModuleBase_MetaWidget::storeValue"
+ << myWrappedWidget->metaObject()->className() << std::endl;
+ #endif
+ return true;
+}
+
+bool ModuleBase_MetaWidget::restoreValue()
+{
+ #ifdef _DEBUG
+ std::cout << "ModuleBase_MetaWidget::restoreValue"
+ << myWrappedWidget->metaObject()->className() << std::endl;
+ #endif
+ return true;
+}
--- /dev/null
+/*
+ * ModuleBase_IModelWidget.h
+ *
+ * Created on: Apr 30, 2014
+ * Author: sbh
+ */
+
+#ifndef MODULEBASE_METAWIDGET_H_
+#define MODULEBASE_METAWIDGET_H_
+
+#include <ModuleBase_IModelWidget.h>
+#include <ModuleBase.h>
+
+#include <ModelAPI_Feature.h>
+
+#include <QWidget>
+#include <QString>
+
+#include <boost/shared_ptr.hpp>
+
+/*
+ *
+ */
+class ModuleBase_MetaWidget : public ModuleBase_IModelWidget
+{
+public:
+ MODULEBASE_EXPORT ModuleBase_MetaWidget(const QString& theId,
+ QWidget* theWrapped,
+ boost::shared_ptr<ModelAPI_Feature>);
+ virtual ~ModuleBase_MetaWidget();
+ //! Interface for saving widget's data into the data model
+ MODULEBASE_EXPORT virtual bool storeValue();
+ //! Interface for loading widget's data from the data model
+ MODULEBASE_EXPORT virtual bool restoreValue();
+
+private:
+ QString myId;
+ QWidget* myWrappedWidget;
+ boost::shared_ptr<ModelAPI_Feature> myFeature;
+};
+
+#endif /* MODULEBASE_METAWIDGET_H_ */
#define ModuleBase_WidgetCustom_H
#include <ModuleBase.h>
+#include <ModuleBase_IModelWidget.h>
#include <QObject>
*/
#include <ModuleBase_WidgetFactory.h>
-
-#include <ModuleBase_WidgetSwitch.h>
-
+#include <ModuleBase_MetaWidget.h>
#include <ModuleBase_PropPanelOperation.h>
#include <ModuleBase_WidgetPoint2D.h>
+#include <ModuleBase_WidgetSwitch.h>
+
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
aControlLay->setStretch(1, 1);
result->setLayout(aControlLay);
connectWidget(aBox, WDG_DOUBLEVALUE);
+ ModuleBase_MetaWidget* aWrappedWdg =
+ new ModuleBase_MetaWidget(anObjName, aBox, myOperation->feature());
+ myWidgets.append(aWrappedWdg);
return result;
}
#define ModuleBase_WidgetFactory_H_
#include <ModuleBase.h>
+#include <ModuleBase_IModelWidget.h>
+
#include <QString>
+#include <QList>
class QObject;
class QWidget;
void createWidget(QWidget* theParent);
+ QList<ModuleBase_IModelWidget*> getWrappedWidgets() const
+ {
+ return myWidgets;
+ }
+
protected:
//Widgets
QWidget* createWidgetByType(const std::string& theType, QWidget* theParent = NULL);
Config_WidgetAPI* myWidgetApi;
ModuleBase_PropPanelOperation* myOperation;
-
+ QList<ModuleBase_IModelWidget*> myWidgets;
};
#endif /* ModuleBase_WidgetFactory_H_ */
XGUI_SalomeConnector.h
XGUI_ActionsMgr.h
XGUI_ErrorDialog.h
+ XGUI_PropertyPanel.h
)
SET(PROJECT_AUTOMOC
XGUI_SelectionMgr.cpp
XGUI_ActionsMgr.cpp
XGUI_ErrorDialog.cpp
+ XGUI_PropertyPanel.cpp
)
SET(PROJECT_RESOURCES
const static char* PROP_PANEL = "property_panel_dock";
const static char* PROP_PANEL_OK = "property_panel_ok";
const static char* PROP_PANEL_CANCEL = "property_panel_cancel";
-const static char* PROP_PANEL_WDG = "property_panel_widget";
};
int anAnswer = QMessageBox::question(0, tr("Operation launch"),
tr("Previous operation is not finished and will be aborted"),
QMessageBox::Ok, QMessageBox::Cancel);
- if (anAnswer == QMessageBox::Ok)
+ if (anAnswer == QMessageBox::Ok) {
aCurrentOp->abort();
- else
+ } else {
aCanStart = false;
+ }
}
return aCanStart;
}
--- /dev/null
+/*
+ * XGUI_PropertyPanel.cpp
+ *
+ * Created on: Apr 29, 2014
+ * Author: sbh
+ */
+
+#include <XGUI_Constants.h>
+#include <XGUI_PropertyPanel.h>
+
+#include <ModuleBase_PropPanelOperation.h>
+
+#include <QWidget>
+#include <QVBoxLayout>
+#include <QFrame>
+#include <QPushButton>
+#include <QIcon>
+#include <QVBoxLayout>
+
+#ifdef _DEBUG
+#include <iostream>
+#endif
+
+XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
+{
+ this->setWindowTitle(tr("Property Panel"));
+ QAction* aViewAct = this->toggleViewAction();
+ this->setObjectName(XGUI::PROP_PANEL);
+
+ QWidget* aContent = new QWidget(this);
+ QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
+ aMainLay->setContentsMargins(3, 3, 3, 3);
+ this->setWidget(aContent);
+
+ QFrame* aFrm = new QFrame(aContent);
+ aFrm->setFrameStyle(QFrame::Sunken);
+ aFrm->setFrameShape(QFrame::Panel);
+ QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
+ aBtnLay->setContentsMargins(0, 0, 0, 0);
+ aMainLay->addWidget(aFrm);
+
+ QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
+ aBtn->setFlat(true);
+ aBtnLay->addWidget(aBtn);
+ aBtnLay->addStretch(1);
+ aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
+ aBtn->setObjectName(XGUI::PROP_PANEL_OK);
+ aBtn->setFlat(true);
+ aBtnLay->addWidget(aBtn);
+ aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
+ aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
+ aBtn->setFlat(true);
+ aBtnLay->addWidget(aBtn);
+
+ myCustomWidget = new QWidget(aContent);
+ aMainLay->addWidget(myCustomWidget);
+ aMainLay->addStretch(1);
+}
+
+XGUI_PropertyPanel::~XGUI_PropertyPanel()
+{
+}
+
+void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_IModelWidget*>& theWidgets)
+{
+ myWidgets = theWidgets;
+}
+
+QWidget* XGUI_PropertyPanel::contentWidget()
+{
+ return myCustomWidget;
+}
+
+void XGUI_PropertyPanel::updateContentWidget()
+{
+ foreach(ModuleBase_IModelWidget* eachWidget, myWidgets) {
+ eachWidget->restoreValue();
+ }
+}
--- /dev/null
+/*
+ * XGUI_PropertyPanel.h
+ *
+ * Created on: Apr 29, 2014
+ * Author: sbh
+ */
+
+#ifndef XGUI_PROPERTYPANEL_H_
+#define XGUI_PROPERTYPANEL_H_
+
+#include <ModuleBase_IModelWidget.h>
+
+#include <QDockWidget>
+#include <QList>
+
+class XGUI_PropertyPanel: public QDockWidget
+{
+ Q_OBJECT
+public:
+ XGUI_PropertyPanel(QWidget* theParent);
+ virtual ~XGUI_PropertyPanel();
+
+ QWidget* contentWidget();
+ void setModelWidgets(const QList<ModuleBase_IModelWidget*>& theWidgets);
+
+public slots:
+ void updateContentWidget();
+
+private:
+ QWidget* myCustomWidget;
+
+ QList<ModuleBase_IModelWidget*> myWidgets;
+};
+
+#endif /* XGUI_PROPERTYPANEL_H_ */
#include "XGUI_SalomeConnector.h"
#include "XGUI_ActionsMgr.h"
#include "XGUI_ErrorDialog.h"
+#include "XGUI_PropertyPanel.h"
+#include <Model_Events.h>
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Feature.h>
#include <ModelAPI_Data.h>
myCurrentFile(QString()),
myPartSetModule(NULL),
mySalomeConnector(theConnector),
- myPropertyPanelDock(0),
+ myPropertyPanel(0),
myObjectBrowser(0),
myDisplayer(0)
{
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Error::errorID()); //!< Listening application errors.
//TODO(sbh): Implement static method to extract event id [SEID]
- Events_ID aFeatureId = aLoop->eventByName("FeatureEvent");
+ Events_ID aFeatureId = aLoop->eventByName(EVENT_FEATURE_LOADED);
aLoop->registerListener(this, aFeatureId);
Events_ID aPartSetId = aLoop->eventByName("PartSetModuleEvent");
aLoop->registerListener(this, aPartSetId);
+ Events_ID aFeatureUpdatedId = aLoop->eventByName(EVENT_FEATURE_UPDATED);
+ aLoop->registerListener(this, aFeatureUpdatedId);
activateModule();
if (myMainWindow) {
myMainWindow->show();
updateCommandStatus();
}
onNew();
- // Testing of document creation
- //boost::shared_ptr<ModelAPI_PluginManager> aMgr = ModelAPI_PluginManager::get();
- //boost::shared_ptr<ModelAPI_Feature> aPoint1 = aMgr->rootDocument()->addFeature("Point");
- //boost::shared_ptr<ModelAPI_Feature> aPart = aMgr->rootDocument()->addFeature("Part");
- //aPart->execute();
- //aMgr->setCurrentDocument(aPart->data()->docRef("PartDocument")->value());
- //boost::shared_ptr<ModelAPI_Feature> aPoint2 = aMgr->rootDocument()->addFeature("Point");
- //aPoint2 = aMgr->rootDocument()->addFeature("Point");
-
- //aPart = aMgr->rootDocument()->addFeature("Part");
- //aPart->execute();
}
//******************************************************
//******************************************************
void XGUI_Workshop::processEvent(const Events_Message* theMessage)
{
- static Events_ID aFeatureId = Events_Loop::loop()->eventByName("FeatureEvent");
- if (theMessage->eventID() == aFeatureId) {
+ static Events_ID aFeatureLoadedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_LOADED);
+ if (theMessage->eventID() == aFeatureLoadedId) {
const Config_FeatureMessage* aFeatureMsg = dynamic_cast<const Config_FeatureMessage*>(theMessage);
addFeature(aFeatureMsg);
return;
}
+ static Events_ID aFeatureUpdatedId = Events_Loop::loop()->eventByName(EVENT_FEATURE_UPDATED);
+ if (theMessage->eventID() == aFeatureUpdatedId)
+ {
+ myPropertyPanel->updateContentWidget();
+ }
const Config_PointerMessage* aPartSetMsg = dynamic_cast<const Config_PointerMessage*>(theMessage);
if (aPartSetMsg) {
ModuleBase_PropPanelOperation* anOperation =
}
const Events_Error* anAppError = dynamic_cast<const Events_Error*>(theMessage);
if (anAppError) {
- emit errorOccurred(QString::fromLatin1(anAppError->description()));
- myErrorDlg->show();
- myErrorDlg->raise();
- myErrorDlg->activateWindow();
+ emit errorOccurred(QString::fromLatin1(anAppError->description()));
+ myErrorDlg->show();
+ myErrorDlg->raise();
+ myErrorDlg->activateWindow();
}
-#ifdef _DEBUG
- qDebug() << "XGUI_Workshop::ProcessEvent: "
- << "Catch message, but it can not be processed.";
-#endif
-
}
//******************************************************
if(!aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel
connectWithOperation(aOperation);
- QWidget* aPropWidget = myPropertyPanelDock->findChild<QWidget*>(XGUI::PROP_PANEL_WDG);
- qDeleteAll(aPropWidget->children());
showPropertyPanel();
ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
- aFactory.createWidget(aPropWidget);
- setPropertyPannelTitle(aOperation->description());
+ aFactory.createWidget(myPropertyPanel->contentWidget());
+ myPropertyPanel->setModelWidgets(aFactory.getWrappedWidgets());
+ myPropertyPanel->setWindowTitle(aOperation->description());
}
}
*/
void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
{
- QPushButton* aOkBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
+ QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
- QPushButton* aCancelBtn = myPropertyPanelDock->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
+ QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
QAction* aCommand = 0;
return aObjDock;
}
-//******************************************************
-QDockWidget* XGUI_Workshop::createPropertyPanel(QWidget* theParent)
-{
- QDockWidget* aPropPanel = new QDockWidget(theParent);
- aPropPanel->setWindowTitle(tr("Property Panel"));
- QAction* aViewAct = aPropPanel->toggleViewAction();
- aPropPanel->setObjectName(XGUI::PROP_PANEL);
-
- QWidget* aContent = new QWidget(aPropPanel);
- QVBoxLayout* aMainLay = new QVBoxLayout(aContent);
- aMainLay->setContentsMargins(3, 3, 3, 3);
- aPropPanel->setWidget(aContent);
-
- QFrame* aFrm = new QFrame(aContent);
- aFrm->setFrameStyle(QFrame::Sunken);
- aFrm->setFrameShape(QFrame::Panel);
- QHBoxLayout* aBtnLay = new QHBoxLayout(aFrm);
- aBtnLay->setContentsMargins(0, 0, 0, 0);
- aMainLay->addWidget(aFrm);
-
- QPushButton* aBtn = new QPushButton(QIcon(":pictures/button_help.png"), "", aFrm);
- aBtn->setFlat(true);
- aBtnLay->addWidget(aBtn);
- aBtnLay->addStretch(1);
- aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
- aBtn->setObjectName(XGUI::PROP_PANEL_OK);
- aBtn->setFlat(true);
- aBtnLay->addWidget(aBtn);
- aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
- aBtn->setObjectName(XGUI::PROP_PANEL_CANCEL);
- aBtn->setFlat(true);
- aBtnLay->addWidget(aBtn);
-
- QWidget* aCustomWidget = new QWidget(aContent);
- aCustomWidget->setObjectName(XGUI::PROP_PANEL_WDG);
- aMainLay->addWidget(aCustomWidget);
- aMainLay->addStretch(1);
-
- return aPropPanel;
-}
-
-//******************************************************
-void XGUI_Workshop::setPropertyPannelTitle(const QString& theTitle)
-{
- myPropertyPanelDock->setWindowTitle(theTitle);
-}
-
//******************************************************
/*
* Creates dock widgets, places them in corresponding area
myMainWindow;
QDockWidget* aObjDock = createObjectBrowser(aDesktop);
aDesktop->addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
- myPropertyPanelDock = createPropertyPanel(aDesktop);
- aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
+ myPropertyPanel = new XGUI_PropertyPanel(aDesktop);
+ aDesktop->addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanel);
hidePropertyPanel(); //<! Invisible by default
hideObjectBrowser();
- aDesktop->tabifyDockWidget(aObjDock, myPropertyPanelDock);
+ aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
}
//******************************************************
void XGUI_Workshop::showPropertyPanel()
{
- QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+ QAction* aViewAct = myPropertyPanel->toggleViewAction();
//<! Restore ability to close panel from the window's menu
aViewAct->setEnabled(true);
- myPropertyPanelDock->show();
- myPropertyPanelDock->raise();
+ myPropertyPanel->show();
+ myPropertyPanel->raise();
}
//******************************************************
void XGUI_Workshop::hidePropertyPanel()
{
- QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+ QAction* aViewAct = myPropertyPanel->toggleViewAction();
//<! Do not allow to show empty property panel
aViewAct->setEnabled(false);
- myPropertyPanelDock->hide();
+ myPropertyPanel->hide();
}
//******************************************************
class XGUI_ObjectsBrowser;
class XGUI_ActionsMgr;
class XGUI_ErrorDialog;
+class XGUI_PropertyPanel;
class ModuleBase_Operation;
class ModuleBase_PropPanelOperation;
// Creates Dock widgets: Object browser and Property panel
void createDockWidgets();
- void setPropertyPannelTitle(const QString& theTitle);
QString myCurrentFile;
XGUI_MainWindow* myMainWindow;
XGUI_Module* myPartSetModule;
XGUI_ObjectsBrowser* myObjectBrowser;
- QDockWidget* myPropertyPanelDock;
+ XGUI_PropertyPanel* myPropertyPanel;
XGUI_SelectionMgr* mySelector;
XGUI_Displayer* myDisplayer;
XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations