Union of the stopped(), started() signals processing of the operation.
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()
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<PartSet_OperationSketchBase*>(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<ModuleBase_PropPanelOperation*>(sender());
+ ModuleBase_PropPanelOperation* anOperation = dynamic_cast<ModuleBase_PropPanelOperation*>(theOperation);
if (!anOperation)
return;
public slots:
void onFeatureTriggered();
- void onBeforeOperationStart();
- void onOperationStopped();
+ void onOperationStarted();
+ void onOperationStopped(ModuleBase_Operation* theOperation);
void onVisualizePreview(bool isDisplay);
private:
#include <QMessageBox>
-/*!
- \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;
}
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;
/**\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);
void onOperationStopped();
private:
- typedef QList<ModuleBase_Operation*> Operations;
- Operations myOperations;
+ typedef QList<ModuleBase_Operation*> 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
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*)));
}
//******************************************************
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<QWidget*>(XGUI::PROP_PANEL_WDG);
- qDeleteAll(aPropWidget->children());
-
- anOperation->start();
-
- XGUI_WidgetFactory aFactory = XGUI_WidgetFactory(anOperation);
- aFactory.createWidget(aPropWidget);
- myMainWindow->setPropertyPannelTitle(anOperation->description());
- }*/
}
return;
}
}
-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<QWidget*>(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<QWidget*>(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();
+}
+
/*
*
*/
myPartSetModule->featureCreated(aCommand);
}
-/*
- *
- */
-/*void XGUI_Workshop::fillPropertyPanel(ModuleBase_PropPanelOperation* theOperation)
-{
- connectWithOperation(theOperation);
- QWidget* aPropWidget = myMainWindow->findChild<QWidget*>(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
QPushButton* aCancelBtn = aPanel->findChild<QPushButton*>(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)));
void connectWithOperation(ModuleBase_Operation* theOperation);
protected slots:
- void onBeforeOperationStart();
- void onAfterOperationStart();
+ void onOperationStarted();
+ void onOperationStopped(ModuleBase_Operation* theOperation);
private:
void initMenu();
XGUI_SelectionMgr* mySelector;
XGUI_Displayer* myDisplayer;
- XGUI_OperationMgr* myOperationMgr;
+ XGUI_OperationMgr* myOperationMgr; ///< manager to manipulate through the operations
};
#endif