From 7e31817b90ba5e8208ffdec5e09f2b23ec196890 Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 26 Feb 2016 19:17:21 +0300 Subject: [PATCH] Issue #1330 selection lost correction: rectangle, fillet, select a point(the line becomes auxiliary, it is redisplayed, selection is lost). The correction: to store/restore selection if the presentation is only customized. --- src/ModuleBase/ModuleBase_IModule.h | 6 ++++++ src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp | 3 --- src/PartSet/PartSet_MenuMgr.cpp | 3 --- src/PartSet/PartSet_Module.cpp | 10 ++++++++++ src/PartSet/PartSet_Module.h | 6 ++++++ src/PartSet/PartSet_SketcherMgr.cpp | 6 ++++++ src/XGUI/XGUI_Displayer.cpp | 9 +++++++++ 7 files changed, 37 insertions(+), 6 deletions(-) diff --git a/src/ModuleBase/ModuleBase_IModule.h b/src/ModuleBase/ModuleBase_IModule.h index 75a962dad..be36fede6 100755 --- a/src/ModuleBase/ModuleBase_IModule.h +++ b/src/ModuleBase/ModuleBase_IModule.h @@ -57,6 +57,12 @@ class MODULEBASE_EXPORT ModuleBase_IModule : public QObject /// Remove default selection filters of the module from the current viewer virtual void deactivateSelectionFilters() {}; + // Stores the current selection + virtual void storeSelection() {}; + + // Restores the current selection + virtual void restoreSelection() {}; + /// Reads description of features from XML file virtual void createFeatures(); diff --git a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp index 6eff484be..88062dbad 100755 --- a/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp +++ b/src/ModuleBase/ModuleBase_WidgetMultiSelector.cpp @@ -335,9 +335,6 @@ bool ModuleBase_WidgetMultiSelector::setSelection(QList& t //emit valuesChanged(); //} - /// remove unused objects from the model attribute - //removeUnusedAttributeObjects(theValues); - theValues.clear(); if (!aSkippedValues.empty()) theValues.append(aSkippedValues); diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index f39331b62..e353cb8a4 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -352,8 +352,6 @@ void PartSet_MenuMgr::setAuxiliary(const bool isChecked) anOpMgr->startOperation(anOpAction); } - myModule->sketchMgr()->storeSelection(); - if (anObjects.size() > 0) { QObjectPtrList::const_iterator anIt = anObjects.begin(), aLast = anObjects.end(); for (; anIt != aLast; anIt++) { @@ -376,7 +374,6 @@ void PartSet_MenuMgr::setAuxiliary(const bool isChecked) anOpMgr->commitOperation(); Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); - myModule->sketchMgr()->restoreSelection(); } bool PartSet_MenuMgr::canSetAuxiliary(bool& theValue) const diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 297e0ef10..a4e5d07a0 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -193,6 +193,16 @@ void PartSet_Module::deactivateSelectionFilters() } } +void PartSet_Module::storeSelection() +{ + sketchMgr()->storeSelection(); +} + +void PartSet_Module::restoreSelection() +{ + sketchMgr()->restoreSelection(); +} + void PartSet_Module::registerValidators() { //Registering of validators diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index f6c371f1f..52c677690 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -66,6 +66,12 @@ public: // Remove default selection filters of the module from the current viewer virtual void deactivateSelectionFilters(); + // Stores the current selection + virtual void storeSelection(); + + // Restores the current selection + virtual void restoreSelection(); + /// Creates custom widgets for property panel virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent, Config_WidgetAPI* theWidgetApi, std::string theParentId); diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 4c2b63a6f..dcb1a81b5 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -1574,6 +1574,9 @@ void PartSet_SketcherMgr::visualizeFeature(const FeaturePtr& theFeature, void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) { + if (!myCurrentSketch.get()) + return; + ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); ModuleBase_ISelection* aSelect = aWorkshop->selection(); QList aHighlighted = aSelect->getHighlighted(); @@ -1600,6 +1603,9 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) void PartSet_SketcherMgr::restoreSelection() { + if (!myCurrentSketch.get()) + return; + //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str()); ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index d80df1ba4..978d61549 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -322,7 +322,16 @@ bool XGUI_Displayer::redisplay(ObjectPtr theObject, bool theUpdateViewer) arg(!isEqualShapes || isCustomized).arg(isEqualShapes).arg(isCustomized).toStdString().c_str()); #endif if (!isEqualShapes || isCustomized) { + /// if shapes are equal and presentation are customized, selection should be restored + bool aNeedToRestoreSelection = isEqualShapes && isCustomized; + if (aNeedToRestoreSelection) + myWorkshop->module()->storeSelection(); + aContext->Redisplay(aAISIO, false); + + if (aNeedToRestoreSelection) + myWorkshop->module()->restoreSelection(); + aRedisplayed = true; #ifdef DEBUG_FEATURE_REDISPLAY qDebug(" Redisplay happens"); -- 2.39.2