ModuleBase_OperationFeature* aCurOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
- QString anOperationKind = aCurOperation ? aCurOperation->getDescription()->operationId() : "";
+ QString aCurOperationKind = aCurOperation ? aCurOperation->getDescription()->operationId() : "";
bool isCommitted;
if (!myWorkshop->canStartOperation(theCmdId, isCommitted))
if (aMessage.get()) {
setReentrantPreSelection(aMessage);
}
- else if (anOperationKind.isEmpty() || anOperationKind == theCmdId) {
+ else if (canUsePreselection(aCurOperationKind, theCmdId)) {
// restore of previous opeation is absent or new launched operation has the same kind
aFOperation->initSelection(aPreSelected);
}
return true;
}
+bool ModuleBase_IModule::canUsePreselection(const QString& thePreviousOperationKind,
+ const QString& theStartedOperationKind)
+{
+ // no previous operation
+ if (thePreviousOperationKind.isEmpty())
+ return true;
+ // edit operation
+ if (thePreviousOperationKind.endsWith(ModuleBase_OperationFeature::EditSuffix()))
+ return true;
+
+ // reentrant operation
+ if (thePreviousOperationKind == theStartedOperationKind)
+ return true;
+
+ return false;
+}
+
bool ModuleBase_IModule::canUndo() const
{
SessionPtr aMgr = ModelAPI_Session::get();
/// \param theObject a model object
virtual bool canDisplayObject(const ObjectPtr& theObject) const;
+ /// Returns whether the started operation may use preselection of the previous one
+ /// Cases are: previous operation is null, edit operation, previuos and started operations
+ /// kinds are the same
+ /// \param thePreviousOperationKind a kind of previous operation
+ /// \param theStartedOperationKind a kind of a started operation
+ virtual bool canUsePreselection(const QString& thePreviousOperationKind,
+ const QString& theStartedOperationKind);
+
/// Make some functionality after the objects are hidden in viewer
/// \param theObjects a list of hidden objects
//virtual void processHiddenObject(const std::list<ObjectPtr>& theObjects) {};
return mySketchMgr->canDisplayObject(theObject);
}
+bool PartSet_Module::canUsePreselection(const QString& thePreviousOperationKind,
+ const QString& theStartedOperationKind)
+{
+ if (ModuleBase_IModule::canUsePreselection(thePreviousOperationKind, theStartedOperationKind))
+ return true;
+
+ return mySketchMgr->isNestedSketchFeature(theStartedOperationKind);
+}
+
/*void PartSet_Module::processHiddenObject(const std::list<ObjectPtr>& theObjects)
{
mySketchMgr->processHiddenObject(theObjects);
/// \param theObject a model object
virtual bool canDisplayObject(const ObjectPtr& theObject) const;
+ /// Returns parent result if accepted, true if the started operation is a nested operation
+ /// of the previous operation
+ /// \param thePreviousOperationKind a kind of previous operation
+ /// \param theStartedOperationKind a kind of a new operation
+ virtual bool canUsePreselection(const QString& thePreviousOperationKind,
+ const QString& theStartedOperationKind);
+
/// Make some functionality after the objects are hidden in viewer
/// \param theObjects a list of hidden objects
//virtual void processHiddenObject(const std::list<ObjectPtr>& theObjects);
return aNestedSketch;
}
+bool PartSet_SketcherMgr::isNestedSketchFeature(const QString& theFeatureKind) const
+{
+ bool aNestedSketch = false;
+
+ FeaturePtr anActiveSketch = activeSketch();
+ if (anActiveSketch.get()) {
+ ModuleBase_Operation* aSketchOperation = operationMgr()->findOperation(
+ anActiveSketch->getKind().c_str());
+ if (aSketchOperation) {
+ QStringList aGrantedOpIds = aSketchOperation->grantedOperationIds();
+ aNestedSketch = aGrantedOpIds.contains(theFeatureKind);
+ }
+ }
+ return aNestedSketch;
+}
+
bool PartSet_SketcherMgr::isNestedCreateOperation(ModuleBase_Operation* theOperation,
const CompositeFeaturePtr& theSketch) const
{
/// \return the boolean result
bool isNestedSketchOperation(ModuleBase_Operation* theOperation) const;
+ /// Returns true if the feature kind belongs to list of granted features of Sketch
+ /// operation. An operation of a sketch should be started before.
+ /// \param theOperation an operation
+ /// \return the boolean result
+ bool isNestedSketchFeature(const QString& theFeatureKind) const;
+
/// Returns true if the operation is a create and nested sketch operationn
/// \param theOperation a checked operation
/// \param theSketch a sketch feature
// 6. Update sketcher actions
XGUI_ActionsMgr* anActMgr = aWorkshop->actionsMgr();
+
myWorkshop->updateCommandStatus();
+ aWorkshop->selector()->clearSelection();
myWorkshop->viewer()->update();
}