From: nds Date: Thu, 29 Jan 2015 09:57:51 +0000 (+0300) Subject: Issue #389 Undo/redo problem on sketch line creation X-Git-Tag: V_1.0.0~13^2~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d848810f5b81a9902d01979f4ae5a6bb3062f765;p=modules%2Fshaper.git Issue #389 Undo/redo problem on sketch line creation The Sketch result was displayed after Redo operation, sub-Sketch feature(line) was not displayed. --- diff --git a/src/ModuleBase/ModuleBase_IModule.cpp b/src/ModuleBase/ModuleBase_IModule.cpp index e44ee809d..fd2686df3 100644 --- a/src/ModuleBase/ModuleBase_IModule.cpp +++ b/src/ModuleBase/ModuleBase_IModule.cpp @@ -109,6 +109,11 @@ void ModuleBase_IModule::actionCreated(QAction* theFeature) connect(theFeature, SIGNAL(triggered(bool)), this, SLOT(onFeatureTriggered())); } +bool ModuleBase_IModule::canDisplayObject(const ObjectPtr& theObject) const +{ + ModuleBase_Operation* anOperation = myWorkshop->currentOperation(); + return anOperation && anOperation->hasObject(theObject); +} void ModuleBase_IModule::onFeatureTriggered() { diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 29cdc430d..202ad5dd2 100644 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -87,6 +87,11 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// It is called as on clearing of property panel as on filling with new widgets virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {} + /// Returns whether the object can be displayed at the bounds of the active operation. + /// Display only current operation results + /// \param theObject a model object + virtual bool canDisplayObject(const ObjectPtr& theObject) const; + public slots: /// Called on call of command corresponded to a feature void onFeatureTriggered(); diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 7b14c01d9..b05715c38 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -187,6 +187,26 @@ void PartSet_Module::operationStopped(ModuleBase_Operation* theOperation) myWorkshop->viewer()->removeSelectionFilter(myDocumentShapeFilter); } +bool PartSet_Module::canDisplayObject(const ObjectPtr& theObject) const +{ + bool aCanDisplay = false; + if (mySketchMgr->activeSketch()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + + if (aFeature.get() != NULL) { + if (aFeature == mySketchMgr->activeSketch()) { + aCanDisplay = false; + } + else { + aCanDisplay = mySketchMgr->sketchOperationIdList().contains(aFeature->getKind().c_str()); + } + } + } + else { + aCanDisplay = ModuleBase_IModule::canDisplayObject(theObject); + } + return aCanDisplay; +} void PartSet_Module::propertyPanelDefined(ModuleBase_Operation* theOperation) { diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 9723d53e3..afefc6a0a 100644 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -71,6 +71,12 @@ public: /// \param theOperation a stopped operation virtual void operationStopped(ModuleBase_Operation* theOperation); + /// 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 + /// \param theObject a model object + virtual bool canDisplayObject(const ObjectPtr& theObject) const; + public slots: /// SLOT, that is called by no more widget signal emitted by property panel /// Set a specific flag to restart the sketcher operation diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index 0b79b084e..8ad6e0be4 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -32,6 +32,9 @@ class QMouseEvent; /** * A class for management of sketch operations + At the time of the sketcher operation active, only the sketch sub-feature results are + displayed in the viewer. After the sketch create/edit operation is finished, the sub-feature + are hidden, the sketch feature result is displayed */ class PARTSET_EXPORT PartSet_SketcherMgr : public QObject { diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index cab65bc08..b68482a9d 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -41,6 +41,7 @@ const int MOUSE_SENSITIVITY_IN_PIXEL = 10; ///< defines the local context mouse selection sensitivity +//#ifdef DEBUG_DISPLAY // Workaround for bug #25637 void displayedObjects(const Handle(AIS_InteractiveContext)& theAIS, AIS_ListOfInteractive& theList) @@ -85,6 +86,14 @@ void XGUI_Displayer::display(ObjectPtr theObject, bool isUpdateViewer) if (isVisible(theObject)) { redisplay(theObject, isUpdateViewer); } else { +#ifdef DEBUG_DISPLAY + FeaturePtr aFeature = ModelAPI_Feature::feature(theObject); + if (aFeature.get() != NULL) { + qDebug(QString("display feature: %1, displayed: %2"). + arg(aFeature->data()->name().c_str()). + arg(displayedObjects().size()).toStdString().c_str()); + } +#endif AISObjectPtr anAIS; GeomPresentablePtr aPrs = std::dynamic_pointer_cast(theObject); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 7b234a365..ef5c0de7c 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -480,6 +480,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr::const_iterator aIt; for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) { ObjectPtr aObj = (*aIt); + bool aHide = !aObj->data() || !aObj->data()->isValid(); if (!aHide) { // check that this is not hidden result ResultPtr aRes = std::dynamic_pointer_cast(aObj); @@ -499,8 +500,7 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptrhasOperation()) { ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - // Display only current operation results if operation has preview - if (aOperation->hasObject(aObj)/* && aOperation->hasPreview()*/) { + if (myModule->canDisplayObject(aObj)) { displayObject(aObj); // Deactivate object of current operation from selection if (myDisplayer->isActive(aObj)) @@ -522,17 +522,15 @@ void XGUI_Workshop::onFeatureCreatedMsg(const std::shared_ptr(*aIt); if (aPart) { aHasPart = true; // If a feature is created from the aplication's python console // it doesn't stored in the operation mgr and doesn't displayed - } else if (myOperationMgr->hasOperation()) { - ModuleBase_Operation* aOperation = myOperationMgr->currentOperation(); - if (aOperation->hasObject(*aIt)) { // Display only current operation results - displayObject(*aIt); - isDisplayed = true; - } + } else if (myModule->canDisplayObject(*aIt)) { + displayObject(*aIt); + isDisplayed = true; } } if (myObjectBrowser)