From: nds Date: Thu, 24 Apr 2014 05:39:17 +0000 (+0400) Subject: refs #30 - Sketch base GUI: create, draw lines X-Git-Tag: V_0.2~131 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a5447b393b33d446093667fc41f253de20e7e2a5;p=modules%2Fshaper.git refs #30 - Sketch base GUI: create, draw lines Union of the stopped(), started() signals processing of the operation. --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index f82eee4b2..99bd4c85b 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -34,7 +34,9 @@ PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop) myWorkshop = theWshop; XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr(); - connect(anOperationMgr, SIGNAL(beforeOperationStart()), this, SLOT(onBeforeOperationStart())); + connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted())); + connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), + this, SLOT(onOperationStopped(ModuleBase_Operation*))); } PartSet_Module::~PartSet_Module() @@ -110,22 +112,21 @@ void PartSet_Module::onVisualizePreview(bool isDisplay) myWorkshop->displayer()->Erase(anOperation->feature(), aPreviewOp->preview()); } -void PartSet_Module::onBeforeOperationStart() +void PartSet_Module::onOperationStarted() { ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation(); PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); if (aPreviewOp) { - connect(anOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped())); connect(aPreviewOp, SIGNAL(visualizePreview(bool)), this, SLOT(onVisualizePreview(bool))); connect(myWorkshop->mainWindow()->viewer(), SIGNAL(selectionChanged()), aPreviewOp, SLOT(onViewSelectionChanged())); } } -void PartSet_Module::onOperationStopped() +void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation) { - ModuleBase_PropPanelOperation* anOperation = dynamic_cast(sender()); + ModuleBase_PropPanelOperation* anOperation = dynamic_cast(theOperation); if (!anOperation) return; diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index dc22f1f44..e343e4373 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -22,8 +22,8 @@ public: public slots: void onFeatureTriggered(); - void onBeforeOperationStart(); - void onOperationStopped(); + void onOperationStarted(); + void onOperationStopped(ModuleBase_Operation* theOperation); void onVisualizePreview(bool isDisplay); private: diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index ae5aeb047..bca019e31 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -4,46 +4,31 @@ #include -/*! - \brief Constructor - */ XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent) : QObject(theParent) { } -/*! - \brief Destructor - */ XGUI_OperationMgr::~XGUI_OperationMgr() { } -/*! - \brief Returns the current operation or NULL - * \return the current operation - */ ModuleBase_Operation* XGUI_OperationMgr::currentOperation() const { return myOperations.count() > 0 ? myOperations.last() : 0; } -/*! - \brief Sets the current operation or NULL - * \return the current operation - */ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation) { if (!canStartOperation(theOperation)) return false; myOperations.append(theOperation); - emit beforeOperationStart(); connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped())); - theOperation->start(); + connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted())); - emit afterOperationStart(); + theOperation->start(); return true; } @@ -80,7 +65,10 @@ void XGUI_OperationMgr::onOperationStopped() if (!aSenderOperation || !anOperation || aSenderOperation != anOperation ) return; + emit operationStopped(anOperation); + myOperations.removeAll(anOperation); + anOperation->deleteLater(); // get last operation which can be resumed ModuleBase_Operation* aResultOp = 0; diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 4fabac821..b45b84d3c 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -11,23 +11,34 @@ /**\class XGUI_OperationMgr * \ingroup GUI * \brief Operation manager. Servers to manupulate to the workshop operations. Contains a stack - * of started operations and uses the upper one as a current. + * of started operations. In simple case, if only one operration is started, the stack contains + * one operation. It is possible for some kind of operations to start them above already + * started one. In that case, the previous active operation becames suspended, a new one - active. + * The new operation is added to the top of the stack. Then it is finished, it is removed from + * the stack and the previous operation is activated. */ class XGUI_EXPORT XGUI_OperationMgr : public QObject { Q_OBJECT public: + /// Constructor + /// \param theParent the parent XGUI_OperationMgr(QObject* theParent); + /// Destructor virtual ~XGUI_OperationMgr(); + /// Returns the current operation or NULL + /// \return the current operation ModuleBase_Operation* currentOperation() const; + /// Sets the current operation or NULL + /// \return the current operation bool startOperation(ModuleBase_Operation* theOperation); void commitCurrentOperation(); signals: - void beforeOperationStart(); - void afterOperationStart(); + void operationStarted(); + void operationStopped(ModuleBase_Operation* theOperation); protected: bool canStartOperation(ModuleBase_Operation* theOperation); @@ -36,8 +47,9 @@ protected slots: void onOperationStopped(); private: - typedef QList Operations; - Operations myOperations; + typedef QList Operations; ///< definition for a list of operations + Operations myOperations; ///< a stack of started operations. The active operation is on top, + // others are suspended and started by the active is finished }; #endif diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index f606615a7..6a2bb4f13 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -50,8 +50,9 @@ XGUI_Workshop::XGUI_Workshop() mySelector = new XGUI_SelectionMgr(this); myDisplayer = new XGUI_Displayer(myMainWindow->viewer()); myOperationMgr = new XGUI_OperationMgr(this); - connect(myOperationMgr, SIGNAL(beforeOperationStart()), this, SLOT(onBeforeOperationStart())); - connect(myOperationMgr, SIGNAL(afterOperationStart()), this, SLOT(onAfterOperationStart())); + connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted())); + connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), + this, SLOT(onOperationStopped(ModuleBase_Operation*))); } //****************************************************** @@ -156,33 +157,11 @@ void XGUI_Workshop::processEvent(const Event_Message* theMessage) ModuleBase_PropPanelOperation* anOperation = (ModuleBase_PropPanelOperation*)(aPartSetMsg->pointer()); - if (myOperationMgr->startOperation(anOperation)) - { - if (anOperation->isPerformedImmediately()) - { + if (myOperationMgr->startOperation(anOperation)) { + if (anOperation->isPerformedImmediately()) { myOperationMgr->commitCurrentOperation(); updateCommandStatus(); } - /*if(anOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel - //connectToPropertyPanel(anOperation); - - anOperation->start(); - - if (anOperation->isPerformedImmediately()) { - anOperation->commit(); - updateCommandStatus(); - } - } else { - connectToPropertyPanel(anOperation); - QWidget* aPropWidget = myMainWindow->findChild(XGUI::PROP_PANEL_WDG); - qDeleteAll(aPropWidget->children()); - - anOperation->start(); - - XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(anOperation); - aFactory.createWidget(aPropWidget); - myMainWindow->setPropertyPannelTitle(anOperation->description()); - }*/ } return; } @@ -194,34 +173,37 @@ void XGUI_Workshop::processEvent(const Event_Message* theMessage) } -void XGUI_Workshop::onBeforeOperationStart() +void XGUI_Workshop::onOperationStarted() { ModuleBase_PropPanelOperation* aOperation = (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation()); if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel - //myPartSetModule->connectToPropertyPanel(aOperation); } else { connectWithOperation(aOperation); QWidget* aPropWidget = myMainWindow->findChild(XGUI::PROP_PANEL_WDG); qDeleteAll(aPropWidget->children()); - } -} -void XGUI_Workshop::onAfterOperationStart() -{ - ModuleBase_PropPanelOperation* aOperation = - (ModuleBase_PropPanelOperation*)(myOperationMgr->currentOperation()); + myMainWindow->showPropertyPanel(); - if(aOperation->xmlRepresentation().isEmpty()) { //!< No need for property panel - } else { XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(aOperation); - QWidget* aPropWidget = myMainWindow->findChild(XGUI::PROP_PANEL_WDG); aFactory.createWidget(aPropWidget); myMainWindow->setPropertyPannelTitle(aOperation->description()); } } +/** + * + */ +void XGUI_Workshop::onOperationStopped(ModuleBase_Operation* theOperation) +{ + myMainWindow->hidePropertyPanel(); + updateCommandStatus(); + + XGUI_MainMenu* aMenu = myMainWindow->menuObject(); + aMenu->restoreCommandState(); +} + /* * */ @@ -259,20 +241,6 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage) myPartSetModule->featureCreated(aCommand); } -/* - * - */ -/*void XGUI_Workshop::fillPropertyPanel(ModuleBase_PropPanelOperation* theOperation) -{ - connectWithOperation(theOperation); - QWidget* aPropWidget = myMainWindow->findChild(XGUI::PROP_PANEL_WDG); - qDeleteAll(aPropWidget->children()); - theOperation->start(); - XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(theOperation); - aFactory.createWidget(aPropWidget); - myMainWindow->setPropertyPannelTitle(theOperation->description()); -}*/ - /* * Makes a signal/slot connections between Property Panel * and given operation. The given operation becomes a @@ -286,13 +254,7 @@ void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation) QPushButton* aCancelBtn = aPanel->findChild(XGUI::PROP_PANEL_CANCEL); connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort())); - connect(theOperation, SIGNAL(started()), myMainWindow, SLOT(showPropertyPanel())); - connect(theOperation, SIGNAL(stopped()), myMainWindow, SLOT(hidePropertyPanel())); - connect(theOperation, SIGNAL(stopped()), this, SLOT(updateCommandStatus())); - XGUI_MainMenu* aMenu = myMainWindow->menuObject(); - connect(theOperation, SIGNAL(stopped()), aMenu, SLOT(restoreCommandState())); - XGUI_Command* aCommand = aMenu->feature(theOperation->operationId()); //Abort operation on uncheck the command connect(aCommand, SIGNAL(toggled(bool)), theOperation, SLOT(setRunning(bool))); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index a1c79c0b3..68b961589 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -75,8 +75,8 @@ protected: void connectWithOperation(ModuleBase_Operation* theOperation); protected slots: - void onBeforeOperationStart(); - void onAfterOperationStart(); + void onOperationStarted(); + void onOperationStopped(ModuleBase_Operation* theOperation); private: void initMenu(); @@ -90,7 +90,7 @@ private: XGUI_SelectionMgr* mySelector; XGUI_Displayer* myDisplayer; - XGUI_OperationMgr* myOperationMgr; + XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations }; #endif