INCLUDE(FindQt5)
INCLUDE(FindPython)
+ADD_SUBDIRECTORY (src/Config)
ADD_SUBDIRECTORY (src/Event)
ADD_SUBDIRECTORY (src/Model)
ADD_SUBDIRECTORY (src/ModelAPI)
-ADD_SUBDIRECTORY (src/Config)
+ADD_SUBDIRECTORY (src/ModuleBase)
ADD_SUBDIRECTORY (src/PartSet)
ADD_SUBDIRECTORY (src/PartSetPlugin)
+ADD_SUBDIRECTORY (src/PyConsole)
ADD_SUBDIRECTORY (src/PyEvent)
ADD_SUBDIRECTORY (src/PyInterp)
-ADD_SUBDIRECTORY (src/PyConsole)
ADD_SUBDIRECTORY (src/XGUI)
Config_FeatureReader.h
Config_WidgetAPI.h
Config_WidgetReader.h
- Config_WidgetMessage.h
+ Config_PointerMessage.h
)
SET(PROJECT_SOURCES
Config_FeatureReader.cpp
Config_WidgetAPI.cpp
Config_WidgetReader.cpp
- Config_WidgetMessage.cpp
+ Config_PointerMessage.cpp
)
SET(XML_RESOURCES
const static char* NODE_WORKBENCH = "workbench";
const static char* NODE_GROUP = "group";
const static char* NODE_FEATURE = "feature";
-const static char* NODE_WIDGET = "value";
+const static char* NODE_DOUBLE_WDG = "value";
const static char* _ID = "id";
//const static char* WORKBENCH_ID = "id";
const static char* FEATURE_ICON = "icon";
const static char* FEATURE_KEYSEQUENCE = "keysequence";
+// doublevalue properties:
+const static char* DOUBLE_WDG_MIN = "min";
+const static char* DOUBLE_WDG_MAX = "max";
+const static char* DOUBLE_WDG_STEP = "step";
+const static char* DOUBLE_WDG_DFLT = "default";
+
/*
* Hardcoded xml entities of plugins.xml
*/
--- /dev/null
+/*
+ * Config_PointerMessage.cpp
+ *
+ * Created on: Mar 21, 2014
+ * Author: sbh
+ */
+
+#include <Config_PointerMessage.h>
+
+Config_PointerMessage::Config_PointerMessage(const Event_ID theId, const void* theParent)
+ : Event_Message(theId, theParent), myPointer(0)
+{
+
+}
+
+Config_PointerMessage::~Config_PointerMessage()
+{
+
+}
+
+void* Config_PointerMessage::pointer() const
+{
+ return myPointer;
+}
+
+void Config_PointerMessage::setPointer(void* pointer)
+{
+ myPointer = pointer;
+}
--- /dev/null
+/*
+ * Config_PointerMessage.h
+ *
+ * Created on: Mar 21, 2014
+ * Author: sbh
+ */
+
+#ifndef PARTSET_MESSAGE_H_
+#define PARTSET_MESSAGE_H_
+
+#include <Config.h>
+#include <Event_Message.h>
+
+/*
+ * A general class to pass pointers over the event loop.
+ */
+class CONFIG_EXPORT Config_PointerMessage: public Event_Message
+{
+public:
+ Config_PointerMessage(const Event_ID theId, const void* theParent = 0);
+ virtual ~Config_PointerMessage();
+
+ void* pointer() const;
+ void setPointer(void* pointer);
+
+private:
+ void* myPointer;
+};
+
+#endif /* PARTSET_MESSAGE_H_ */
return result;
}
+std::string Config_WidgetAPI::widgetId()
+{
+ return getProperty("id");
+}
+
std::string Config_WidgetAPI::widgetTooltip()
{
return getProperty("tooltip");
std::string widgetType();
+ std::string widgetId();
std::string widgetIcon();
std::string widgetLabel();
std::string widgetTooltip();
+++ /dev/null
-/*
- * Config_WidgetMessage.cpp
- *
- * Created on: Mar 21, 2014
- * Author: sbh
- */
-
-#include <Config_WidgetMessage.h>
-
-Config_WidgetMessage::Config_WidgetMessage(const Event_ID theId, const void* theParent)
- : Event_Message(theId, theParent)
-{
-
-}
-
-Config_WidgetMessage::~Config_WidgetMessage()
-{
-}
-
-const std::string& Config_WidgetMessage::featureId() const
-{
- return myFeatureId;
-}
-
-void Config_WidgetMessage::setFeatureId(const std::string& theFeatureId)
-{
- myFeatureId = theFeatureId;
-}
-
-const std::string& Config_WidgetMessage::xmlRepresentation() const
-{
- return myXMLRepr;
-}
-
-void Config_WidgetMessage::setXmlRepresentation(const std::string& theXmlRep)
-{
- myXMLRepr = theXmlRep;
-}
+++ /dev/null
-/*
- * Config_WidgetMessage.h
- *
- * Created on: Mar 21, 2014
- * Author: sbh
- */
-
-#ifndef PARTSET_MESSAGE_H_
-#define PARTSET_MESSAGE_H_
-
-#include <Config.h>
-
-#include <Event_Message.h>
-#include <string>
-
-class CONFIG_EXPORT Config_WidgetMessage: public Event_Message
-{
-public:
- Config_WidgetMessage(const Event_ID theId, const void* theParent = 0);
- virtual ~Config_WidgetMessage();
-
- const std::string& featureId() const;
- const std::string& xmlRepresentation() const;
- void setFeatureId(const std::string& featureId);
- void setXmlRepresentation(const std::string& xmlRepresentation);
-
- std::string myFeatureId;
- std::string myXMLRepr;
-};
-
-#endif /* PARTSET_MESSAGE_H_ */
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.11)
+
+INCLUDE(Common)
+SET(CMAKE_AUTOMOC ON)
+
+SET(PROJECT_HEADERS
+ ModuleBase.h
+ ModuleBase_Operation.h
+)
+
+SET(PROJECT_SOURCES
+ ModuleBase_Operation.cpp
+)
+
+SET(PROJECT_LIBRARIES
+ ModelAPI
+ ${Qt5Widgets_LIBRARIES}
+)
+
+SET(PROJECT_AUTOMOC
+ ${CMAKE_CURRENT_BINARY_DIR}/ModuleBase_automoc.cpp
+)
+
+#QT5_ADD_RESOURCES(PROJECT_COMPILED_RESOURCES ${PROJECT_RESOURCES})
+#QT5_ADD_TRANSLATION(QM_RESOURCES ${TEXT_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/ModelAPI)
+
+ADD_DEFINITIONS(-DMODULEBASE_EXPORTS)
+ADD_LIBRARY(ModuleBase SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
+TARGET_LINK_LIBRARIES(ModuleBase ${PROJECT_LIBRARIES})
+
+INSTALL(TARGETS ModuleBase DESTINATION bin)
--- /dev/null
+#ifndef MODULEBASE_H
+#define MODULEBASE_H
+
+#if defined MODULEBASE_EXPORTS
+#if defined WIN32
+#define MODULEBASE_EXPORT __declspec( dllexport )
+#else
+#define MODULEBASE_EXPORT
+#endif
+#else
+#if defined WIN32
+#define MODULEBASE_EXPORT __declspec( dllimport )
+#else
+#define MODULEBASE_EXPORT
+#endif
+#endif
+
+#endif //MODULEBASE_H
--- /dev/null
+/*
+ * ModuleBase_Operation.cpp
+ *
+ * Created on: Apr 2, 2014
+ * Author: sbh
+ */
+
+#include "ModuleBase_Operation.h"
+
+#include <ModelAPI_AttributeDouble.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_Feature.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_PluginManager.h>
+
+/*!
+ \brief Constructor
+ \param XGUI_Workshop - workshop for this operation
+
+ Constructs an empty operation. Constructor should work very fast because many
+ operators may be created after starting workshop but only several from them
+ may be used. As result this constructor stores given workshop in myApp field
+ and set Waiting status.
+ */
+ModuleBase_Operation::ModuleBase_Operation(const QString& theId, QObject* parent)
+ : QObject(parent),
+ myFlags(Transaction),
+ myState(Waiting),
+ myExecStatus(Rejected),
+ myOperationId(theId)
+{
+ myFeature = ModelAPI_PluginManager::get()->createFeature(theId.toStdString());
+}
+
+/*!
+ * \brief Destructor
+ */
+ModuleBase_Operation::~ModuleBase_Operation()
+{
+
+}
+
+/*!
+ * \brief Unique name of the operation
+ *
+ * Returns string name of the operation.
+ */
+QString ModuleBase_Operation::operationId() const
+{
+ return myOperationId;
+}
+
+/*!
+ * \brief Gets state of operation
+ * \return Value from OperationState enumeration
+ *
+ * Gets state of operation (see OperationState enumeration)
+ */
+ModuleBase_Operation::OperationState ModuleBase_Operation::state() const
+{
+ return myState;
+}
+
+/*!
+ * \brief Verifies whether operation is an ran one (state()==Running)
+ * \return TRUE if operation is active, FALSE otherwise
+ *
+ * Verifies whether operation is an running. Returns TRUE if state of operator
+ * is Running
+ */
+bool ModuleBase_Operation::isRunning() const
+{
+ return state() == Running;
+}
+
+/*!
+ * \brief Verifies whether given operator is valid for this one
+ * \param theOtherOp - other operation
+ * \return Returns TRUE if the given operator is valid for this one
+ *
+ * Verifies whether given operator is valid for this one (i.e. can be started "above"
+ * this operator)
+ */
+bool ModuleBase_Operation::isValid(ModuleBase_Operation*) const
+{
+ return false;
+}
+
+/*!
+ * \brief Verifies whether this operator can be always started above any already running one
+ * \return Returns TRUE if current operation must not be checked for ActiveOperation->IsValid( this )
+ *
+ * This method must be redefined in derived operation if operation of derived class
+ * must be always can start above any launched one. Default implementation returns FALSE,
+ * so it is being checked for IsValid, but some operations may overload IsGranted()
+ * In this case they will always start, no matter what operation is running.
+ */
+bool ModuleBase_Operation::isGranted() const
+{
+ return false;
+}
+
+/*
+ * Returns pointer to the root document.
+ */
+std::shared_ptr<ModelAPI_Document> ModuleBase_Operation::document() const
+{
+ return ModelAPI_PluginManager::get()->rootDocument();
+}
+
+/*!
+ * \brief Sets slot which is called when operation is started
+ * \param theReceiver - object containing slot
+ * \param theSlot - slot of theReceiver object
+ * \return TR if slot was connected successfully, FALSE otherwise
+ *
+ * Sets slot which is called when operation is started. There is no point in
+ * using this method. It would be better to inherit own operator from base
+ * one and redefine startOperation method
+ */
+bool ModuleBase_Operation::setSlot(const QObject* theReceiver, const char* theSlot)
+{
+ return connect(this, SIGNAL(callSlot()), theReceiver, theSlot);
+}
+
+/*!
+ * \brief Sets the flags of operation
+ * \param f - flags of operation to be set
+ *
+ * Sets flags of operation (see Flags enumeration)
+ */
+void ModuleBase_Operation::setFlags(const int f)
+{
+ myFlags = myFlags | f;
+}
+
+/*!
+ * \brief Clears the flags of operation
+ * \param f - flags of operation to be cleared
+ *
+ * Clears flags of operation (see Flags enumeration)
+ */
+void ModuleBase_Operation::clearFlags(const int f)
+{
+ myFlags = myFlags & ~f;
+}
+
+/*!
+ * \brief Test the flags of operation
+ * \param f - flags of operation to be tested
+ *
+ * Returns TRUE if the specified flags set in the operation (see Flags enumeration)
+ */
+bool ModuleBase_Operation::testFlags(const int f) const
+{
+ return (myFlags & f) == f;
+}
+
+/*!
+ * \brief Gets execution status
+ * \return Execution status
+ *
+ * Gets execution status
+ */
+int ModuleBase_Operation::execStatus() const
+{
+ return myExecStatus;
+}
+
+/*!
+ * \brief Returns XML representation of the operation's widget.
+ * \return XML QString
+ *
+ * Returns XML representation of the operation's widget.
+ */
+const QString& ModuleBase_Operation::xmlRepresentation() const
+{
+ return myXmlRepr;
+}
+
+/*!
+ * \brief Sets XML representation of the operation's widget.
+ * \param xmlRepr - XML QString
+ *
+ * Sets XML representation of the operation's widget.
+ */
+void ModuleBase_Operation::setXmlRepresentation(const QString& xmlRepr)
+{
+ myXmlRepr = xmlRepr;
+}
+
+/*!
+ * \brief Starts operation
+ *
+ * Public slot. Verifies whether operation can be started and starts operation.
+ * This slot is not virtual and cannot be redefined. Redefine startOperation method
+ * to change behavior of operation. There is no point in using this method. It would
+ * be better to inherit own operator from base one and redefine startOperation method
+ * instead.
+ */
+void ModuleBase_Operation::start()
+{
+ //document()->start(this);
+ document()->startOperation();
+
+ startOperation();
+ emit started();
+}
+
+/*!
+ * \brief Aborts operation
+ *
+ * Public slot. Aborts operation. This slot is not virtual and cannot be redefined.
+ * Redefine abortOperation method to change behavior of operation instead
+ */
+void ModuleBase_Operation::abort()
+{
+ abortOperation();
+ myState = Waiting;
+ emit aborted();
+
+ stopOperation();
+ emit stopped();
+
+ document()->abortOperation();
+}
+
+/*!
+ * \brief Commits operation
+ *
+ * Public slot. Commits operation. This slot is not virtual and cannot be redefined.
+ * Redefine commitOperation method to change behavior of operation instead
+ */
+void ModuleBase_Operation::commit()
+{
+ commitOperation();
+ myState = Waiting;
+ emit committed();
+
+ stopOperation();
+ emit stopped();
+
+ document()->finishOperation();
+}
+
+/*!
+ * \brief Stores a real value in model.
+ * \param theValue - to store
+ *
+ * Public slot. Passes theValue into the model.
+ */
+void ModuleBase_Operation::storeReal(double theValue)
+{
+ QString anId = sender()->objectName();
+ std::shared_ptr<ModelAPI_Object> aData = myFeature->data();
+ std::shared_ptr<ModelAPI_AttributeDouble> aReal = aData->real(anId.toStdString());
+ aReal->setValue(theValue);
+}
+
+/*!
+ * \brief Verifies whether operator is ready to start.
+ * \return TRUE if operation is ready to start
+ *
+ * Default implementation returns TRUE. Redefine this method to add own verifications
+ */
+bool ModuleBase_Operation::isReadyToStart() const
+{
+ return true;
+}
+
+/*!
+ * \brief Virtual method called when operation is started
+ *
+ * Virtual method called when operation started (see start() method for more description)
+ * Default implementation calls corresponding slot and commits immediately.
+ */
+void ModuleBase_Operation::startOperation()
+{
+ //emit callSlot();
+ //commit();
+}
+
+/*!
+ * \brief Virtual method called when operation is started
+ *
+ * Virtual method called when operation stopped - committed or aborted.
+ */
+void ModuleBase_Operation::stopOperation()
+{
+}
+
+/*!
+ * \brief Virtual method called when operation aborted
+ *
+ * Virtual method called when operation aborted (see abort() method for more description)
+ */
+void ModuleBase_Operation::abortOperation()
+{
+}
+
+/*!
+ * \brief Virtual method called when operation committed
+ *
+ * Virtual method called when operation committed (see commit() method for more description)
+ */
+void ModuleBase_Operation::commitOperation()
+{
+}
+
+/*!
+ * \brief Sets execution status
+ * \param theStatus - execution status
+ *
+ * Sets myExecStatus to the given value
+ */
+void ModuleBase_Operation::setExecStatus(const int theVal)
+{
+ myExecStatus = (ExecStatus) theVal;
+}
+
+/*!
+ * \brief Sets state of operation
+ * \param theState - state of operation to be set
+ *
+ * Sets state of operation (see OperationState enumeration)
+ */
+void ModuleBase_Operation::setState(const ModuleBase_Operation::OperationState theState)
+{
+ myState = theState;
+}
--- /dev/null
+/*
+ * ModuleBase_Operation.h
+ *
+ * Created on: Apr 2, 2014
+ * Author: sbh
+ */
+
+
+#ifndef MODULEBASE_OPERATION_H
+#define MODULEBASE_OPERATION_H
+
+#include <ModuleBase.h>
+
+#include <QObject>
+#include <QString>
+
+#include <memory>
+
+class SUIT_Study;
+class XGUI_Workshop;
+class ModelAPI_Feature;
+class ModelAPI_Document;
+
+/*!
+ \class ModuleBase_Operation
+ * \brief Base class for all operations
+ *
+ * Base class for all operations. If you perform an action it is reasonable to create
+ * operation intended for this. This is a base class for all operations which provides
+ * mechanism for correct starting operations, starting operations above already started
+ * ones, committing operations and so on. To create own operation it is reasonable to
+ * inherit it from this class and redefines virtual methods to provide own behavior
+ * Main virtual methods are
+ * - virtual bool isReadyToStart();
+ * - virtual void startOperation();
+ * - virtual void abortOperation();
+ * - virtual void commitOperation();
+ */
+
+class MODULEBASE_EXPORT ModuleBase_Operation: public QObject
+{
+Q_OBJECT
+
+public:
+ /*! Enum describes state of operation */
+ enum OperationState
+ {
+ Waiting, //!< Operation is not used (it is not run or suspended)
+ Running, //!< Operation is started
+ };
+
+ /*!
+ * Enum describes execution status of operation. Execution status often used after
+ * ending work of operation which was started from this one. In this case this
+ * operation can ask previously started operation whether it finished successfully.
+ */
+ enum ExecStatus
+ {
+ Rejected, //!< Operation has not performed any action (modification of data model for example)
+ Accepted //!< Operation has performed an actions and must be stopped
+ };
+
+ /*!
+ * Enum describes setting of the operation.
+ */
+ enum Flags
+ {
+ None = 0x00, //!< None options
+ Transaction = 0x01 //!< Automatically open (commit/abort) transaction during start (commit/abort).
+ };
+
+public:
+ ModuleBase_Operation(const QString& theId = "", QObject* parent = 0);
+ virtual ~ModuleBase_Operation();
+
+ // Operation processing.
+ virtual QString operationId() const;
+
+ OperationState state() const;
+ bool isRunning() const;
+ virtual bool isValid(ModuleBase_Operation* theOtherOp) const;
+ virtual bool isGranted() const;
+
+ bool setSlot(const QObject* theReceiver, const char* theSlot);
+
+ void setFlags(const int);
+ void clearFlags(const int);
+ bool testFlags(const int) const;
+
+ int execStatus() const;
+
+ // Widget processing.
+ const QString& xmlRepresentation() const;
+ void setXmlRepresentation(const QString& xmlRepr);
+
+signals:
+ void started();
+ void aborted();
+ void committed();
+ void stopped(); //!< operation aborted or committed
+
+ void callSlot();
+
+public slots:
+ void start();
+ void abort();
+ void commit();
+
+ // Data model operations.
+ void storeReal(double);
+
+protected:
+ virtual bool isReadyToStart() const;
+
+ virtual void startOperation();
+ virtual void stopOperation();
+ virtual void abortOperation();
+ virtual void commitOperation();
+
+ void setExecStatus(const int);
+ void setState(const OperationState);
+
+ std::shared_ptr<ModelAPI_Document> document() const;
+
+private:
+ int myFlags; //!< Operation flags
+ OperationState myState; //!< Operation state
+ ExecStatus myExecStatus; //!< Execution status
+
+ //!< Next fields could be extracted into a subclass;
+ QString myOperationId;
+ QString myXmlRepr;
+ std::shared_ptr<ModelAPI_Feature> myFeature;
+};
+
+#endif
)
SET(PROJECT_LIBRARIES
+ ModuleBase
Config
${Qt5Widgets_LIBRARIES}
)
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)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/Config)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/Event)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/XGUI
+ ${CMAKE_SOURCE_DIR}/src/Config
+ ${CMAKE_SOURCE_DIR}/src/Event
+ ${CMAKE_SOURCE_DIR}/src/ModuleBase
+)
ADD_DEFINITIONS(-DPARTSET_EXPORTS)
ADD_LIBRARY(PartSet SHARED
# The Qt5Widgets_LIBRARIES variable also includes QtGui and QtCore
TARGET_LINK_LIBRARIES(PartSet ${PROJECT_LIBRARIES})
+ADD_DEPENDENCIES(PartSet ModuleBase)
+
INSTALL(TARGETS PartSet DESTINATION bin)
#include <PartSet_Module.h>
-#include <Config_WidgetMessage.h>
+#include <ModuleBase_Operation.h>
+#include <Config_PointerMessage.h>
#include <Config_ModuleReader.h>
#include <Config_WidgetReader.h>
#include <Event_Loop.h>
void PartSet_Module::featureCreated(XGUI_Command* theFeature)
{
QString aFtId = theFeature->getId();
- theFeature->connectTo(this, SLOT(onCommandTriggered()));
+ theFeature->connectTo(this, SLOT(onFeatureTriggered()));
}
-void PartSet_Module::onCommandTriggered()
+void PartSet_Module::onFeatureTriggered()
{
Config_ModuleReader aModuleReader = Config_ModuleReader();
aModuleReader.readAll();
Config_WidgetReader aWdgReader = Config_WidgetReader(aPluginName);
aWdgReader.readAll();
XGUI_Command* aCmd = dynamic_cast<XGUI_Command*>(sender());
- std::string aCmdId = aCmd->getId().toStdString();
- std::string aXMLWidgetCfg = aWdgReader.featureWidgetCfg(aCmdId);
+ QString aCmdId = aCmd->getId();
+ std::string aXmlCfg = aWdgReader.featureWidgetCfg(aCmdId.toStdString());
//TODO(sbh): Implement static method to extract event id [SEID]
static Event_ID aModuleEvent = Event_Loop::eventByName("PartSetModuleEvent");
- Config_WidgetMessage aMessage(aModuleEvent, this);
- aMessage.setFeatureId(aCmdId);
- aMessage.setXmlRepresentation(aXMLWidgetCfg);
+ Config_PointerMessage aMessage(aModuleEvent, this);
+ ModuleBase_Operation* aPartSetOp = new ModuleBase_Operation(aCmdId, this);
+ aPartSetOp->setXmlRepresentation(QString::fromStdString(aXmlCfg));
+ aMessage.setPointer(aPartSetOp);
Event_Loop::loop()->send(aMessage);
}
virtual void featureCreated(XGUI_Command* theFeature);
public slots:
- void onCommandTriggered();
+ void onFeatureTriggered();
private:
XGUI_Workshop* myWorkshop;
PyInterp
PyEvent
ModelAPI
+ ModuleBase
)
QT5_ADD_RESOURCES(PROJECT_COMPILED_RESOURCES ${PROJECT_RESOURCES})
${PROJECT_SOURCE_DIR}/src/PyInterp
${PROJECT_SOURCE_DIR}/src/PyConsole
${PROJECT_SOURCE_DIR}/src/ModelAPI
+ ${PROJECT_SOURCE_DIR}/src/ModuleBase
${CAS_INCLUDE_DIRS})
LINK_DIRECTORIES($ENV{PYTHON_LIB_DIR})
#include <QPushButton>
#include <QScrollArea>
#include <QComboBox>
-
+#include <QAction>
XGUI_MainWindow::XGUI_MainWindow(QWidget* parent)
: QMainWindow(parent),
- myObjectBrowser(0),
- myPythonConsole(0)
+ myObjectBrowser(NULL),
+ myPythonConsole(NULL),
+ myPropertyPanelDock(NULL)
{
setWindowTitle(tr("New Geom"));
myMenuBar = new XGUI_MainMenu(this);
myPythonConsole->parentWidget()->hide();
}
+void XGUI_MainWindow::showPropertyPanel()
+{
+ QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+ aViewAct->setEnabled(true);
+ myPropertyPanelDock->show();
+ myPropertyPanelDock->raise();
+}
+
+void XGUI_MainWindow::hidePropertyPanel()
+{
+ QAction* aViewAct = myPropertyPanelDock->toggleViewAction();
+ aViewAct->setEnabled(false);
+ myPropertyPanelDock->hide();
+}
+
/*
* Creates dock widgets, places them in corresponding area
* and tabifies if necessary.
{
QDockWidget* aObjDock = createObjectBrowser();
addDockWidget(Qt::LeftDockWidgetArea, aObjDock);
- QDockWidget* aPropPanelDock = createPropertyPanel();
- addDockWidget(Qt::LeftDockWidgetArea, aPropPanelDock);
+ myPropertyPanelDock = createPropertyPanel();
+ addDockWidget(Qt::LeftDockWidgetArea, myPropertyPanelDock);
+ hidePropertyPanel(); //<! Invisible by default
- tabifyDockWidget(aPropPanelDock, aObjDock);
+ tabifyDockWidget(aObjDock, myPropertyPanelDock);
}
aPropPanel->setWidget(aContent);
QWidget* aCustomWidget = new QWidget(aContent);
- aCustomWidget->setObjectName("PropertyPanelWidget");
+ aCustomWidget->setObjectName("property_panel_widget");
aMainLay->addWidget(aCustomWidget);
aMainLay->addStretch(1);
aBtnLay->addWidget(aBtn);
aBtnLay->addStretch(1);
aBtn = new QPushButton(QIcon(":pictures/button_ok.png"), "", aFrm);
+ aBtn->setObjectName("property_panel_ok");
aBtn->setFlat(true);
aBtnLay->addWidget(aBtn);
aBtn = new QPushButton(QIcon(":pictures/button_cancel.png"), "", aFrm);
+ aBtn->setObjectName("property_panel_cancel");
aBtn->setFlat(true);
aBtnLay->addWidget(aBtn);
return myViewer;
}
+public slots:
void showPythonConsole();
void hidePythonConsole();
+ void showPropertyPanel();
+ void hidePropertyPanel();
private:
void createDockWidgets();
XGUI_MainMenu* myMenuBar;
XGUI_ObjectsBrowser* myObjectBrowser;
+ QDockWidget* myPropertyPanelDock;
XGUI_Viewer* myViewer;
*/
#include <XGUI_WidgetFactory.h>
+#include <ModuleBase_Operation.h>
+#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <QWidget>
#include <QDebug>
#endif
-XGUI_WidgetFactory::XGUI_WidgetFactory(const std::string& theXml)
+XGUI_WidgetFactory::XGUI_WidgetFactory(ModuleBase_Operation* theOperation)
+ : myOperation(theOperation)
{
- myWidgetApi = new Config_WidgetAPI(theXml);
+ QString aXml = myOperation->xmlRepresentation();
+ myWidgetApi = new Config_WidgetAPI(aXml.toStdString());
}
XGUI_WidgetFactory::~XGUI_WidgetFactory()
do {
std::string aWdgType = myWidgetApi->widgetType();
QWidget* aWidget = NULL;
- if (aWdgType == "value") {
- aWidget = valueWidget();
+ if (aWdgType == NODE_DOUBLE_WDG) {
+ aWidget = doubleSpinBoxWidget();
} else {
#ifdef _DEBUG
qDebug() << "XGUI_WidgetFactory::fillWidget: find bad widget type";
theParent->setLayout(aWidgetLay);
}
-QWidget* XGUI_WidgetFactory::valueWidget()
+QWidget* XGUI_WidgetFactory::doubleSpinBoxWidget()
{
QWidget* result = new QWidget();
QHBoxLayout* aControlLay = new QHBoxLayout(result);
aControlLay->addWidget(aLabel);
QDoubleSpinBox* aBox = new QDoubleSpinBox(result);
+ QString anObjName = QString::fromStdString(myWidgetApi->widgetId());
+ aBox->setObjectName(anObjName);
bool isOk = false;
- double aMinVal = qs(myWidgetApi->getProperty("min")).toDouble(&isOk);
+ std::string aProp = myWidgetApi->getProperty(DOUBLE_WDG_MIN);
+ double aMinVal = qs(aProp).toDouble(&isOk);
if (isOk) {
aBox->setMinimum(aMinVal);
}
- double aMaxVal = qs(myWidgetApi->getProperty("max")).toDouble(&isOk);
+ aProp = myWidgetApi->getProperty(DOUBLE_WDG_MAX);
+ double aMaxVal = qs(aProp).toDouble(&isOk);
if (isOk) {
aBox->setMaximum(aMaxVal);
}
- double aStepVal = qs(myWidgetApi->getProperty("step")).toDouble(&isOk);
+ aProp = myWidgetApi->getProperty(DOUBLE_WDG_STEP);
+ double aStepVal = qs(aProp).toDouble(&isOk);
if (isOk) {
aBox->setSingleStep(aStepVal);
}
- double aDefVal = qs(myWidgetApi->getProperty("default")).toDouble(&isOk);
+ aProp = myWidgetApi->getProperty(DOUBLE_WDG_DFLT);
+ double aDefVal = qs(aProp).toDouble(&isOk);
if (isOk) {
aBox->setValue(aDefVal);
}
aBox->setToolTip(aTTip);
aControlLay->addWidget(aBox);
aControlLay->setStretch(1, 1);
-
result->setLayout(aControlLay);
+ connectWidget(aBox, NODE_DOUBLE_WDG);
+ return result;
+}
+
+bool XGUI_WidgetFactory::connectWidget(QWidget* theWidget, const QString& theType)
+{
+ bool result = false;
+ if (theType == NODE_DOUBLE_WDG) {
+ result = QObject::connect(theWidget, SIGNAL(valueChanged(double)),
+ myOperation, SLOT(storeReal(double)));
+ }
return result;
}
#define XGUI_WIDGETFACTORY_H_
#include <QString>
-#include <string>
class QWidget;
class Config_WidgetAPI;
+class ModuleBase_Operation;
class XGUI_WidgetFactory
{
public:
- XGUI_WidgetFactory(const std::string&);
+ XGUI_WidgetFactory(ModuleBase_Operation*);
virtual ~XGUI_WidgetFactory();
void fillWidget(QWidget* theParent);
protected:
- QWidget* valueWidget();
+ QWidget* doubleSpinBoxWidget();
+
+ bool connectWidget(QWidget*, const QString&);
private:
QString qs(const std::string& theStdString) const;
Config_WidgetAPI* myWidgetApi;
+ ModuleBase_Operation* myOperation;
};
#endif /* XGUI_WIDGETFACTORY_H_ */
#include "XGUI_Workshop.h"
#include "XGUI_Viewer.h"
#include "XGUI_WidgetFactory.h"
+#include "ModuleBase_Operation.h"
#include <Event_Loop.h>
#include <Config_FeatureMessage.h>
-#include <Config_WidgetMessage.h>
+#include <Config_PointerMessage.h>
#include <QApplication>
#include <QFileDialog>
#include <QMessageBox>
#include <QMdiSubWindow>
+#include <QPushButton>
#ifdef _DEBUG
#include <QDebug>
#endif
XGUI_Workshop::XGUI_Workshop()
- : QObject()
+ : QObject(),
+ myCurrentOperation(NULL),
+ myPartSetModule(NULL)
{
myMainWindow = new XGUI_MainWindow();
- myPartSetModule = NULL;
}
//******************************************************
addFeature(aFeatureMsg);
return;
}
- const Config_WidgetMessage* aPartSetMsg = dynamic_cast<const Config_WidgetMessage*>(theMessage);
+ const Config_PointerMessage* aPartSetMsg =
+ dynamic_cast<const Config_PointerMessage*>(theMessage);
if (aPartSetMsg) {
fillPropertyPanel(aPartSetMsg);
return;
/*
*
*/
-void XGUI_Workshop::fillPropertyPanel(const Config_WidgetMessage* theMessage)
+void XGUI_Workshop::fillPropertyPanel(const Config_PointerMessage* theMessage)
{
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>("PropertyPanelWidget");
- if (!aPropWidget) {
- #ifdef _DEBUG
- qDebug() << "XGUI_Workshop::fillPropertyPanel: " << "Unable to find property panel";
- #endif
- return;
- }
+ ModuleBase_Operation* anOperation = (ModuleBase_Operation*)(theMessage->pointer());
+ connectToPropertyPanel(anOperation);
+ QWidget* aPropWidget = myMainWindow->findChild<QWidget*>("property_panel_widget");
qDeleteAll(aPropWidget->children());
- std::string aXml = theMessage->xmlRepresentation();
- XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(aXml);
+ anOperation->start();
+ XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(anOperation);
aFactory.fillWidget(aPropWidget);
}
+void XGUI_Workshop::connectToPropertyPanel(ModuleBase_Operation* theOperation)
+{
+ if(myCurrentOperation) {
+ //FIXME: Ask user about aborting of current operation?
+ myCurrentOperation->abort();
+ myCurrentOperation->deleteLater();
+ }
+ myCurrentOperation = theOperation;
+
+ QPushButton* aOkBtn = myMainWindow->findChild<QPushButton*>("property_panel_ok");
+ connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
+ QPushButton* aCancelBtn = myMainWindow->findChild<QPushButton*>("property_panel_cancel");
+ connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
+
+ connect(theOperation, SIGNAL(started()), myMainWindow, SLOT(showPropertyPanel()));
+ connect(theOperation, SIGNAL(stopped()), myMainWindow, SLOT(hidePropertyPanel()));
+}
+
//******************************************************
void XGUI_Workshop::onExit()
{
class XGUI_Command;
class XGUI_Module;
class XGUI_Workbench;
+class ModuleBase_Operation;
class Config_FeatureMessage;
-class Config_WidgetMessage;
+class Config_PointerMessage;
class XGUI_Workshop: public QObject, public Event_Listener
{
protected:
//Event-loop processing methods:
void addFeature(const Config_FeatureMessage*);
- void fillPropertyPanel(const Config_WidgetMessage*);
+ void fillPropertyPanel(const Config_PointerMessage*);
+
+ void connectToPropertyPanel(ModuleBase_Operation* theOperation);
private:
void initMenu();
XGUI_MainWindow* myMainWindow;
XGUI_Module* myPartSetModule;
+
+ ModuleBase_Operation* myCurrentOperation;
};
#endif