The operation should be applyed if the apply state is true in the operation manager, otherwise, it is aborted.
The isOkEnabled, setOkEnabled methods should not be avaialabe in the property panel because this state is updated according to operation manager state by workshop object.
canAbortOperation is renamed to canStopOperation, because it is possible that the given operation is commited or aborted.
/// \return State of editing mode flag
bool isEditingMode() const { return myIsEditing; }
- /// Set Enable/Disable state of Ok button
- /// \param theEnabled Enable/Disable state of Ok button
- virtual void setOkEnabled(bool theEnabled) = 0;
-
- /// \return Enable/disable state of Ok button
- virtual bool isOkEnabled() const = 0;
-
/// Set Enable/Disable state of Cancel button
/// \param theEnabled Enable/Disable state of Cancel button
virtual void setCancelEnabled(bool theEnabled) = 0;
aPnt2dWgt->setPoint(aPoint->x(), aPoint->y());
PartSet_Tools::setConstraints(mySketchMgr->activeSketch(), theOperation->feature(),
aWgt->attributeID(), aPoint->x(), aPoint->y());
- theOperation->propertyPanel()->activateNextWidget(aPnt2dWgt);
+ aPanel->activateNextWidget(aPnt2dWgt);
}
}
}
#include <XGUI_ModuleConnector.h>
#include <XGUI_SelectionMgr.h>
#include <XGUI_Selection.h>
-#include <XGUI_PropertyPanel.h>
#include <XGUI_OperationMgr.h>
#include <ModuleBase_DoubleSpinBox.h>
// the Ok button should be disabled in the property panel by moving the mouse point in the viewer
// this leads that the user does not try to click Ok and it avoids an incorrect situation that the
// line is moved to the cursor to the Ok button
- myWorkshop->propertyPanel()->setOkEnabled(false);
+ myWorkshop->operationMgr()->setApplyEnabled(false);
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
void PartSet_WidgetPoint2dDistance::onMouseMove(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
myWorkshop->operationMgr()->setLockValidating(true);
- myWorkshop->propertyPanel()->setOkEnabled(false);
+ myWorkshop->operationMgr()->setApplyEnabled(false);
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theWnd->v3dView());
return;
ModuleBase_Operation* anOperation = currentOperation();
if(anOperation && (!myIsValidationLock)) {
- bool isValid = anOperation->isValid();
- emit operationValidated(isValid);
+ setApplyEnabled(anOperation->isValid());
}
}
+void XGUI_OperationMgr::setApplyEnabled(const bool theEnabled)
+{
+ myIsApplyEnabled = theEnabled;
+ emit applyEnableChanged(theEnabled);
+}
+
+bool XGUI_OperationMgr::isApplyEnabled() const
+{
+ return myIsApplyEnabled;
+}
+
+bool XGUI_OperationMgr::canStopOperation()
+{
+ ModuleBase_Operation* anOperation = currentOperation();
+ if(operationsCount() > 1) //in case of nested (sketch) operation no confirmation needed
+ return true;
+ if (anOperation && anOperation->isModified()) {
+ QString aMessage = tr("%1 operation will be aborted.").arg(anOperation->id());
+ int anAnswer = QMessageBox::question(qApp->activeWindow(),
+ tr("Abort operation"),
+ aMessage,
+ QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Cancel);
+ return anAnswer == QMessageBox::Ok;
+ }
+ return true;
+}
+
bool XGUI_OperationMgr::commitOperation()
{
if (hasOperation() && currentOperation()->isValid()) {
ModuleBase_Operation* aCurrentOp = currentOperation();
if (aCurrentOp) {
if (!aCurrentOp->isGranted(theId)) {
- if (canAbortOperation()) {
- aCurrentOp->abort();
+ if (canStopOperation()) {
+ if (myIsApplyEnabled)
+ aCurrentOp->commit();
+ else
+ aCurrentOp->abort();
} else {
aCanStart = false;
}
void XGUI_OperationMgr::onAbortOperation()
{
- if (hasOperation() && canAbortOperation()) {
+ if (hasOperation() && canStopOperation()) {
currentOperation()->abort();
}
}
-bool XGUI_OperationMgr::canAbortOperation()
-{
- ModuleBase_Operation* anOperation = currentOperation();
- if(operationsCount() > 1) //in case of nested (sketch) operation no confirmation needed
- return true;
- if (anOperation && anOperation->isModified()) {
- QString aMessage = tr("%1 operation will be aborted.").arg(anOperation->id());
- int anAnswer = QMessageBox::question(qApp->activeWindow(),
- tr("Abort operation"),
- aMessage,
- QMessageBox::Ok | QMessageBox::Cancel,
- QMessageBox::Cancel);
- return anAnswer == QMessageBox::Ok;
- }
- return true;
-}
-
void XGUI_OperationMgr::onOperationStarted()
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
/// \param theId id of the operation which is going to start
bool canStartOperation(QString theId);
- bool canStopOperation();
-
- /// Returns true if the operation can be aborted
- bool canAbortOperation();
-
/// Blocking/unblocking enabling of Ok button in property panel.
/// It is used when operation can not be validated even all attributes are valid
void setLockValidating(bool toLock) { myIsValidationLock = toLock; }
/// Returns state of validation locking
bool isValidationLocked() const { return myIsValidationLock; }
- public slots:
+ /// Sets apply state to the value and emit signal about this state is changed
+ /// \param theEnabled the state value
+ void setApplyEnabled(const bool theEnabled);
+
+ /// Returns enable apply state
+ /// \return theEnabled a boolean value
+ bool isApplyEnabled() const;
+
+ public slots:
/// Slot that commits the current operation.
void onCommitOperation();
/// Slot that aborts the current operation.
/// Emitted when current operation is aborted
void operationAborted(ModuleBase_Operation* theOperation);
- /// Signal is emitted after the validate methods calls.
- void operationValidated(bool);
+ /// Signal is emitted after the apply enable state changed.
+ void applyEnableChanged(bool);
/// Signal is emitted after the current operation is filled with existing preselection.
void operationActivatedByPreselection();
protected:
+ /// Returns true if the operation can be aborted
+ bool canStopOperation();
/// Commits the current operatin if it is valid
bool commitOperation();
/// Lock/Unlock access to Ok button in property panel
bool myIsValidationLock;
+ /// Lock/Unlock access to Ok button in property panel
+ bool myIsApplyEnabled;
};
#endif
emit noMoreWidgets();
}
-void XGUI_PropertyPanel::setOkEnabled(bool theEnabled)
-{
- QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
- anOkBtn->setEnabled(theEnabled);
-}
-
-bool XGUI_PropertyPanel::isOkEnabled() const
-{
- QPushButton* anOkBtn = findChild<QPushButton*>(PROP_PANEL_OK);
- return anOkBtn->isEnabled();
-}
-
void XGUI_PropertyPanel::setCancelEnabled(bool theEnabled)
{
QPushButton* anCancelBtn = findChild<QPushButton*>(PROP_PANEL_CANCEL);
/// \brief Enable/Disable stretch area in the panel
void setStretchEnabled(bool isEnabled);
- /// Set Enable/Disable state of Ok button
- /// \param theEnabled Enable/Disable state of Ok button
- virtual void setOkEnabled(bool theEnabled);
-
- /// \return Enable/disable state of Ok button
- virtual bool isOkEnabled() const;
-
/// Set Enable/Disable state of Cancel button
/// \param theEnabled Enable/Disable state of Cancel button
virtual void setCancelEnabled(bool theEnabled);
connect(aCancelBtn, SIGNAL(clicked()), myOperationMgr, SLOT(onAbortOperation()));
connect(myPropertyPanel, SIGNAL(keyReleased(QKeyEvent*)), myOperationMgr,
SLOT(onKeyReleased(QKeyEvent*)));
- connect(myOperationMgr, SIGNAL(operationValidated(bool)), myPropertyPanel,
+ connect(myOperationMgr, SIGNAL(applyEnableChanged(bool)), myPropertyPanel,
SLOT(setAcceptEnabled(bool)));
}