]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #30 - Sketch base GUI: create, draw lines
authornds <natalia.donis@opencascade.com>
Fri, 16 May 2014 15:51:55 +0000 (19:51 +0400)
committernds <natalia.donis@opencascade.com>
Fri, 16 May 2014 15:51:55 +0000 (19:51 +0400)
It is important to connect to the operation manager to avoid double commit() for all connected operations (sketch, line are connected if apply is pressed in the top sketch line creation operation)

src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_Workshop.cpp

index 00419c69238d19063e84d0aa1c41cb39cce61bf2..792d5846777c786955ced5668b1878c2d9b34566 100644 (file)
@@ -87,6 +87,20 @@ bool XGUI_OperationMgr::canStopOperation()
   return anAnswer == QMessageBox::Ok;
 }
 
+void XGUI_OperationMgr::onCommitOperation()
+{
+  ModuleBase_Operation* anOperation = currentOperation();
+  if (anOperation)
+    anOperation->commit();
+}
+
+void XGUI_OperationMgr::onAbortOperation()
+{
+  ModuleBase_Operation* anOperation = currentOperation();
+  if (anOperation)
+    anOperation->abort();
+}
+
 void XGUI_OperationMgr::onOperationStopped()
 {
   ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
index 41323570ec46fc3e6fcf12566182c9c84e0e48a6..d57ca5cca7ea707356f7680ae08642c242fea9ce 100644 (file)
@@ -70,6 +70,11 @@ protected:
   bool canStopOperation();
 
 protected slots:
+  /// Slot that commits the current operation.
+  void onCommitOperation();
+  /// Slot that aborts the current operation.
+  void onAbortOperation();
+
   /// Slot that is called by an operation stop. Removes the stopped operation form the stack.
   /// If there is a suspended operation, restart it.
   void onOperationStopped();
index 9b391a44e4a37ceff33e15b60cc10e4ebea39641..7298f0aefe07ff3972fa82276c620f9481a3b1a0 100644 (file)
@@ -336,11 +336,6 @@ void XGUI_Workshop::addFeature(const Config_FeatureMessage* theMessage)
  */
 void XGUI_Workshop::connectWithOperation(ModuleBase_Operation* theOperation)
 {
-  QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
-  connect(aOkBtn, SIGNAL(clicked()), theOperation, SLOT(commit()));
-  QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
-  connect(aCancelBtn, SIGNAL(clicked()), theOperation, SLOT(abort()));
-
   QAction* aCommand = 0;
   if (isSalomeMode()) {
     aCommand = salomeConnector()->command(theOperation->getDescription()->operationId());
@@ -629,6 +624,11 @@ void XGUI_Workshop::createDockWidgets()
   hidePropertyPanel(); //<! Invisible by default
   hideObjectBrowser();
   aDesktop->tabifyDockWidget(aObjDock, myPropertyPanel);
+
+  QPushButton* aOkBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_OK);
+  connect(aOkBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onCommitOperation()));
+  QPushButton* aCancelBtn = myPropertyPanel->findChild<QPushButton*>(XGUI::PROP_PANEL_CANCEL);
+  connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
 }
 
 //******************************************************