Sometimes there is a crash by line restart if the previous Line creation is aborted: in processEvent of Line feature, where the attribute of previous created feature is used to build coincidence to start point of new feature Line.
void ModuleBase_IModule::launchModal(const QString& theCmdId)
{
- if (!myWorkshop->canStartOperation(theCmdId))
+ bool isCommitted;
+ if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
return;
std::string aXmlCfg, aDescription;
}
-void ModuleBase_IModule::launchOperation(const QString& theCmdId)
+void ModuleBase_IModule::launchOperation(const QString& theCmdId,
+ const bool& isStartAfterCommitOnly)
{
/// selection should be obtained from workshop before ask if the operation can be started as
/// the canStartOperation method performs commit/abort of previous operation.
QList<ModuleBase_ViewerPrsPtr> aPreSelected =
aSelection->getSelected(ModuleBase_ISelection::AllControls);
- if (!myWorkshop->canStartOperation(theCmdId))
+ bool isCommitted;
+ if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
+ return;
+
+ /// reentrant operation(Sketch Line) should not be started if operation is aborted
+ if (isStartAfterCommitOnly && !isCommitted)
return;
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
//Do nothing on uncheck
if (aCmd->isCheckable() && !aCmd->isChecked()) {
ModuleBase_Operation* anOperation = myWorkshop->findStartedOperation(aCmd->data().toString());
- if (myWorkshop->canStopOperation(anOperation))
- myWorkshop->stopOperation(anOperation);
+ if (myWorkshop->canStopOperation(anOperation)) {
+ bool isCommitted;
+ myWorkshop->stopOperation(anOperation, isCommitted);
+ }
else {
aCmd->setChecked(true);
}
if (aInfo.get() && aInfo->isModal()) {
launchModal(aCmdId);
} else {
- launchOperation(aCmdId);
+ launchOperation(aCmdId, false);
emit operationLaunched();
}
}
void ModuleBase_IModule::editFeature(FeaturePtr theFeature)
{
std::string aFeatureId = theFeature->getKind();
- if (!myWorkshop->canStartOperation(aFeatureId.c_str()))
+ bool isCommitted;
+ if (!myWorkshop->canStartOperation(aFeatureId.c_str(), isCommitted))
return;
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
/// Creates an operation and send it to loop
/// \param theCmdId the operation name
- virtual void launchOperation(const QString& theCmdId);
+ /// \param isStartAfterCommitOnly operation is launched if there is no active operation or
+ /// it is committed
+ virtual void launchOperation(const QString& theCmdId,
+ const bool& isStartAfterCommitOnly);
/// Executes feature as a modal dialog box
/// \param theCmdId the operation name
virtual ModuleBase_Operation* currentOperation() const = 0;
//! Returns true if the operation with id theId can be started
- virtual bool canStartOperation(QString theId) = 0;
+ virtual bool canStartOperation(QString theId, bool& isCommitted) = 0;
//! Performs the operation launch
//! \param theOperation an operation to be launched
//! Commits if possible or aborts the given operation.
//! \param theOperation an aborted operation
- virtual void stopOperation(ModuleBase_Operation* theOperation) = 0;
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ virtual void stopOperation(ModuleBase_Operation* theOperation,
+ bool& isCommitted) = 0;
//! Returns AIS object by data object
//! \param theObject a data object
// the active nested sketch operation should be aborted unconditionally
// the Delete action should be additionally granted for the Sketch operation
// in order to do not abort/commit it
- if (!anOpMgr->canStartOperation(tr("Detach")))
+ bool isCommitted;
+ if (!anOpMgr->canStartOperation(tr("Detach"), isCommitted))
return; // the objects are processed but can not be deleted
anOpMgr->startOperation(anOpAction);
anOpAction = new ModuleBase_OperationAction(anAction->text(), myModule);
bool isSketchOp = PartSet_SketcherMgr::isSketchOperation(anOperation);
- if (!anOpMgr->canStartOperation(anOpAction->id()))
+ bool isCommitted;
+ if (!anOpMgr->canStartOperation(anOpAction->id(), isCommitted))
return; // the objects are processed but can not be deleted
anOpMgr->startOperation(anOpAction);
// the active nested sketch operation should be aborted unconditionally
// the Delete action should be additionally granted for the Sketch operation
// in order to do not abort/commit it
- if (!anOpMgr->canStartOperation(anOpAction->id()))
+ bool isCommitted;
+ if (!anOpMgr->canStartOperation(anOpAction->id(), isCommitted))
return true; // the objects are processed but can not be deleted
anOpMgr->startOperation(anOpAction);
return isProcessed;
}
-void PartSet_Module::onFeatureTriggered()
-{
- // is commented for imp: Unpressing the button of the current action must behave like
- // a validation if the entity can be created (instead of Cancel, as currently)
- /*QAction* aCmd = dynamic_cast<QAction*>(sender());
- if (aCmd->isCheckable() && aCmd->isChecked()) {
- // 1. check whether the delete should be processed in the module
- ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
- bool isNestedOp = myModule->sketchMgr()->isNestedCreateOperation(anOperation);
- if (isNestedOp) {
- // in case if in the viewer nothing is displayed, the create operation should not be
- // comitted even if all values of the feature are initialized
- if (!mySketchMgr->canDisplayCurrentCreatedFeature()) {
- // the action information should be saved before the operation is aborted
- // because this abort leads to update command status, which unchecks this action
- anOperation->abort();
- launchOperation(aCmd->data().toString());
- }
- }
- }*/
- ModuleBase_IModule::onFeatureTriggered();
-}
-
void PartSet_Module::editFeature(FeaturePtr theFeature)
{
storeConstraintsState(theFeature->getKind());
return true;
}
-void PartSet_Module::launchOperation(const QString& theCmdId)
+void PartSet_Module::launchOperation(const QString& theCmdId, const bool& isStartAfterCommitOnly)
{
myIsOperationIsLaunched = true;
storeConstraintsState(theCmdId.toStdString());
updateConstraintsState(theCmdId.toStdString());
- ModuleBase_IModule::launchOperation(theCmdId);
+ ModuleBase_IModule::launchOperation(theCmdId, isStartAfterCommitOnly);
myIsOperationIsLaunched = false;
}
/// Creates an operation and send it to loop
/// \param theCmdId the operation name
- virtual void launchOperation(const QString& theCmdId);
+ /// \param isStartAfterCommitOnly operation is launched if there is no active operation or
+ /// it is committed
+ virtual void launchOperation(const QString& theCmdId,
+ const bool& isStartAfterCommitOnly);
/// Realizes some functionality by an operation start
/// Displays all sketcher sub-Objects, hides sketcher result, appends selection filters
XGUI_Workshop* getWorkshop() const;
public slots:
- /// Redefines the parent method in order to customize the next case:
- /// If the sketch nested operation is active and the presentation is not visualized in the viewer,
- /// the operation should be always aborted.
- virtual void onFeatureTriggered();
-
/// Slolt called on object display
/// \param theObject a data object
/// \param theAIS a presentation object
void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
+ // Clear dragging mode
+ myIsDragging = false;
+
if (myModule->sketchReentranceMgr()->processMousePressed(theWnd, theEvent))
return;
-
//get2dPoint(theWnd, theEvent, myClickedPoint);
-
if (!(theEvent->buttons() & Qt::LeftButton))
return;
- // Clear dragging mode
- myIsDragging = false;
-
ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
ModuleBase_IViewer* aViewer = aWorkshop->viewer();
if (!aViewer->canDragByMouse())
void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
+ bool aWasDragging = myIsDragging;
+ myIsDragging = false;
+
if (myModule->sketchReentranceMgr()->processMouseReleased(theWnd, theEvent))
return;
if (aOp) {
if (isNestedSketchOperation(aOp)) {
// Only for sketcher operations
- if (myIsDragging) {
+ if (aWasDragging) {
if (myDragDone) {
myCurrentSelection.clear();
}
}
aWorkshop->viewer()->enableDrawMode(myPreviousDrawModeEnabled);
- myIsDragging = false;
ModuleBase_ModelWidget* anActiveWidget = getActiveWidget();
PartSet_MouseProcessor* aProcessor = dynamic_cast<PartSet_MouseProcessor*>(anActiveWidget);
QList<ModuleBase_ViewerPrsPtr> aPreSelected =
aSelection->getSelected(ModuleBase_ISelection::AllControls);
-
-
if (myInternalFeature.get())
copyReetntrantAttributes(myInternalFeature, aFOperation->feature(),
module()->sketchMgr()->activeSketch());
myNoMoreWidgetsAttribute = "";
myIsFlagsBlocked = true;
- module()->launchOperation(aFOperation->id());
+ /// launch has 'false' parameter to do not start new operation if the previous operation
+ /// is not committed. It is important for Line Sketch feature as it uses the previous
+ /// created feature parameter(to build coincidence), but by abort the previous is removed
+ module()->launchOperation(aFOperation->id(), true);
myIsFlagsBlocked = false;
resetFlags();
myWorkshop->setStatusBarMessage(theMessage);
}
-bool XGUI_ModuleConnector::canStartOperation(QString theId)
+bool XGUI_ModuleConnector::canStartOperation(QString theId, bool& isCommitted)
{
- return myWorkshop->operationMgr()->canStartOperation(theId);
+ return myWorkshop->operationMgr()->canStartOperation(theId, isCommitted);
}
void XGUI_ModuleConnector::processLaunchOperation(ModuleBase_Operation* theOperation)
return myWorkshop->operationMgr()->canStopOperation(theOperation);
}
-void XGUI_ModuleConnector::stopOperation(ModuleBase_Operation* theOperation)
+void XGUI_ModuleConnector::stopOperation(ModuleBase_Operation* theOperation,
+ bool& isCommitted)
{
- myWorkshop->operationMgr()->stopOperation(theOperation);
+ myWorkshop->operationMgr()->stopOperation(theOperation, isCommitted);
}
void XGUI_ModuleConnector::updateCommandStatus()
virtual ModuleBase_Operation* currentOperation() const;
//! Returns true if the operation with id theId can be started
- virtual bool canStartOperation(QString theId);
+ /// \param theId id of the operation which is going to start
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ virtual bool canStartOperation(QString theId, bool& isCommitted);
//! Performs the operation launch
//! \param theOperation an operation to be launched
//! Commits if possible or aborts the given operation.
//! \param theOperation an aborted operation
- virtual void stopOperation(ModuleBase_Operation* theOperation);
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ virtual void stopOperation(ModuleBase_Operation* theOperation,
+ bool& isCommitted);
//! Returns AIS object by data object
virtual AISObjectPtr findPresentation(const ObjectPtr& theObject) const;
aMgr->finishOperation();
}
-bool XGUI_OperationMgr::canStartOperation(const QString& theId)
+bool XGUI_OperationMgr::canStartOperation(const QString& theId, bool& isCommitted)
{
bool aCanStart = true;
+ isCommitted = false;
ModuleBase_Operation* aCurrentOp = currentOperation();
if (aCurrentOp) {
bool aGranted = aCurrentOp->isGranted(theId);
else if (canStopOperation(aCurrentOp)) {
// the started operation is granted in the parrent operation,
// e.g. current - Line in Sketch, started Circle
- stopOperation(aCurrentOp);
+ stopOperation(aCurrentOp, isCommitted);
} else {
aCanStart = false;
}
return aCanStart;
}
-void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation)
+void XGUI_OperationMgr::stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted)
{
if (XGUI_Tools::workshop(myWorkshop)->errorMgr()->isApplyEnabled() && theOperation->isModified())
- theOperation->commit();
- else
+ isCommitted = theOperation->commit();
+ else {
+ isCommitted = false;
abortOperation(theOperation);
+ }
}
void XGUI_OperationMgr::abortOperation(ModuleBase_Operation* theOperation)
/// Returns whether the operation can be started. Check if there is already started operation and
/// the granted parameter of the launched operation
/// \param theId id of the operation which is going to start
- bool canStartOperation(const QString& theId);
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ bool canStartOperation(const QString& theId, bool& isCommitted);
/// If Apply is enabled and operation has modification, it is applyed, otherwise aborted
/// \param theOperation the started operation
- void stopOperation(ModuleBase_Operation* theOperation);
+ /// \param isCommitted boolean value if the operation was committed otherwise it was aborted
+ void stopOperation(ModuleBase_Operation* theOperation, bool& isCommitted);
/// Aborts the parameter operation if it is current, else abort operations from the stack
/// of operations until the operation is found. All operations upper the parameter one are