An additional condition for Apply button validity.
return aMgr->hasModuleDocument() && aMgr->canRedo() && !aMgr->isOperation();
}
+bool ModuleBase_IModule::canCommitOperation() const
+{
+ return true;
+}
+
void ModuleBase_IModule::onFeatureTriggered()
{
QAction* aCmd = dynamic_cast<QAction*>(sender());
//! Returns True if there are available Redos and there is not an active operation\r
virtual bool canRedo() const;\r
\r
+ /// Returns True if the current operation can be committed. By default it is true.\r
+ /// \return a boolean value\r
+ virtual bool canCommitOperation() const;\r
+\r
/// Returns whether the object can be displayed. The default realization returns true.\r
/// \param theObject a model object\r
virtual bool canDisplayObject(const ObjectPtr& theObject) const;\r
return aCanRedo;
}
+bool PartSet_Module::canCommitOperation() const
+{
+ return mySketchMgr->canCommitOperation();
+}
+
bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const
{
// the sketch manager put the restriction to the objects display
/// \return the boolean result
virtual bool canRedo() const;
+ /// Returns True if the current operation can be committed. Asks the sketch manager.
+ /// \return a boolean value
+ virtual bool canCommitOperation() const;
+
/// Returns whether the object can be displayed at the bounds of the active operation.
/// Display only current operation results for usual operation and ask the sketcher manager
/// if it is a sketch operation
#include "PartSet_WidgetSketchLabel.h"
#include <ModuleBase_WidgetEditor.h>
+#include <ModuleBase_ModelWidget.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_Displayer.h>
#include <XGUI_ContextMenuMgr.h>
#include <XGUI_Selection.h>
#include <XGUI_SelectionMgr.h>
-#include <ModuleBase_ModelWidget.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_PropertyPanel.h>
#include <XGUI_ViewerProxy.h>
+#include <XGUI_OperationMgr.h>
#include <ModuleBase_IViewer.h>
#include <ModuleBase_IWorkshop.h>
// redisplayed before this update, the feature presentation jumps from reset value to current.
myIsMouseOverWindow = true;
myIsPropertyPanelValueChanged = false;
+ operationMgr()->onValidateOperation();
#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
qDebug(QString("onEnterViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
#endif
myIsMouseOverViewProcessed = false;
myIsMouseOverWindow = false;
myIsPropertyPanelValueChanged = false;
+ operationMgr()->onValidateOperation();
#ifdef DEBUG_MOUSE_OVER_WINDOW_FLAGS
qDebug(QString("onLeaveViewPort: %1").arg(mouseOverWindowFlagsInfo()).toStdString().c_str());
#endif
// visualize the current operation feature
myIsPropertyPanelValueChanged = true;
+ operationMgr()->onValidateOperation();
ModuleBase_Operation* aOperation = getCurrentOperation();
// the feature is to be erased here, but it is correct to call canDisplayObject because
// there can be additional check (e.g. editor widget in distance constraint)
connectToPropertyPanel(false);
myIsPropertyPanelValueChanged = false;
myIsMouseOverViewProcessed = true;
+ operationMgr()->onValidateOperation();
}
void PartSet_SketcherMgr::commitNestedSketch(ModuleBase_Operation* theOperation)
return isNestedCreateOperation(getCurrentOperation());
}
+bool PartSet_SketcherMgr::canCommitOperation() const
+{
+ bool aCanCommit = true;
+
+ if (isNestedCreateOperation(getCurrentOperation()) && !canDisplayCurrentCreatedFeature())
+ aCanCommit = false;
+
+ return aCanCommit;
+}
+
bool PartSet_SketcherMgr::canDisplayObject(const ObjectPtr& theObject) const
{
bool aCanDisplay = true;
return QString("myIsPropertyPanelValueChanged = %1, myIsMouseOverWindow = %2")
.arg(myIsPropertyPanelValueChanged).arg(myIsMouseOverWindow);
}
+
+XGUI_OperationMgr* PartSet_SketcherMgr::operationMgr() const
+{
+ ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+
+ return aWorkshop->operationMgr();
+}
class ModuleBase_IViewWindow;
class ModuleBase_ModelWidget;
class ModuleBase_Operation;
+class XGUI_OperationMgr;
class QMouseEvent;
/**
/// \return the boolean result
bool canRedo() const;
+ /// Returns False only if the sketch creating feature can not be visualized.
+ /// \return a boolean value
+ bool canCommitOperation() const;
+
/// Returns whether the object can be displayed at the bounds of the active operation.
/// Display only current operation results for usual operation and ask the sketcher manager
/// if it is a sketch operation
/// \return a string value
QString mouseOverWindowFlagsInfo() const;
+ XGUI_OperationMgr* operationMgr() const;
+
private:
PartSet_Module* myModule;
#include "XGUI_OperationMgr.h"
#include "ModuleBase_Operation.h"
+#include "ModuleBase_IWorkshop.h"
+#include "ModuleBase_IModule.h"
#include <QMessageBox>
#include <QApplication>
#include <QKeyEvent>
-XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent)
- : QObject(theParent), myIsValidationLock(false), myIsApplyEnabled(false)
+XGUI_OperationMgr::XGUI_OperationMgr(QObject* theParent,
+ ModuleBase_IWorkshop* theWorkshop)
+: QObject(theParent), myIsValidationLock(false), myIsApplyEnabled(false),
+ myWorkshop(theWorkshop)
{
}
return;
ModuleBase_Operation* anOperation = currentOperation();
if(anOperation) {
- setApplyEnabled(!myIsValidationLock && anOperation->isValid());
+ bool aCanCommit = myWorkshop->module()->canCommitOperation();
+ setApplyEnabled(!myIsValidationLock && aCanCommit && anOperation->isValid());
}
}
class QKeyEvent;
+class ModuleBase_IWorkshop;
+
/**\class XGUI_OperationMgr
* \ingroup GUI
* \brief Operation manager. Servers to manipulate to the workshop operations. Contains a stack
public:
/// Constructor
/// \param theParent the parent
- XGUI_OperationMgr(QObject* theParent);
+ XGUI_OperationMgr(QObject* theParent, ModuleBase_IWorkshop* theWorkshop);
/// Destructor
virtual ~XGUI_OperationMgr();
+ void setWorkshop(ModuleBase_IWorkshop* theWorkshop)
+ { myWorkshop = theWorkshop; };
+
/// Returns the current operation or NULL
/// \return the current operation
ModuleBase_Operation* currentOperation() const;
Operations myOperations; ///< a stack of started operations. The active operation is on top,
// others are suspended and started by the active is finished
+ /// Current workshop
+ ModuleBase_IWorkshop* myWorkshop;
+
+
/// Lock/Unlock access to Ok button in property panel
bool myIsValidationLock;
/// Lock/Unlock access to Ok button in property panel
mySelector = new XGUI_SelectionMgr(this);
//connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(updateModuleCommands()));
- myOperationMgr = new XGUI_OperationMgr(this);
+ myOperationMgr = new XGUI_OperationMgr(this, 0);
myActionsMgr = new XGUI_ActionsMgr(this);
myErrorDlg = new XGUI_ErrorDialog(QApplication::desktop());
myContextMenuMgr = new XGUI_ContextMenuMgr(this);
myActionsMgr, SLOT(updateOnViewSelection()));
myModuleConnector = new XGUI_ModuleConnector(this);
+ myOperationMgr->setWorkshop(moduleConnector());
connect(myOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)),
SLOT(onOperationStarted(ModuleBase_Operation*)));