From: nds Date: Thu, 6 Apr 2017 10:17:24 +0000 (+0300) Subject: Issue #2061 arc edit problem: correction for center of arc(last described problem) X-Git-Tag: V_2.7.0~48 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=42f3a3fe18aca3931fdd2a2caa3f07002fe7817b;p=modules%2Fshaper.git Issue #2061 arc edit problem: correction for center of arc(last described problem) --- diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index e13d7cb1f..963b53c62 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -204,12 +204,18 @@ void PartSet_Module::deactivateSelectionFilters() void PartSet_Module::storeSelection() { - sketchMgr()->storeSelection(); + // cash is used only to restore selection, so it should be filled in storeSelection and + // after applying immediatelly cleared in restoreSelection + myCurrentSelection.clear(); + sketchMgr()->storeSelection(false, myCurrentSelection); } void PartSet_Module::restoreSelection() { - sketchMgr()->restoreSelection(); + // cash is used only to restore selection, so it should be filled in storeSelection and + // after applying immediatelly cleared in restoreSelection + sketchMgr()->restoreSelection(myCurrentSelection); + myCurrentSelection.clear(); } void PartSet_Module::registerValidators() diff --git a/src/PartSet/PartSet_Module.h b/src/PartSet/PartSet_Module.h index 649e3d3e2..79aa314f3 100755 --- a/src/PartSet/PartSet_Module.h +++ b/src/PartSet/PartSet_Module.h @@ -6,6 +6,7 @@ #include "PartSet.h" #include "PartSet_Tools.h" #include "PartSet_OverconstraintListener.h" +#include "PartSet_SketcherMgr.h" #include #include @@ -437,6 +438,9 @@ private: /// backup of the visible state to restore them by operation stop QMap myHasConstraintShown; + /// backup of selection in the viewer, it is used only to store selection before + /// redisplay and restore it after + PartSet_SketcherMgr::FeatureToSelectionMap myCurrentSelection; QModelIndex myActivePartIndex; }; diff --git a/src/PartSet/PartSet_SketcherMgr.cpp b/src/PartSet/PartSet_SketcherMgr.cpp index 7d593a110..6128e4038 100755 --- a/src/PartSet/PartSet_SketcherMgr.cpp +++ b/src/PartSet/PartSet_SketcherMgr.cpp @@ -276,7 +276,7 @@ void PartSet_SketcherMgr::onBeforeValuesChangedInPropertyPanel() myModule->sketchReentranceMgr()->isInternalEditActive()) return; // it is necessary to save current selection in order to restore it after the values are modifed - storeSelection(); + storeSelection(false); ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); @@ -358,7 +358,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE ModuleBase_ISelection* aSelect = aWorkshop->selection(); bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier); - storeSelection(!aHasShift); + storeSelection(!aHasShift, myCurrentSelection); if (myCurrentSelection.empty()) { if (isSketchOpe && (!isSketcher)) @@ -448,7 +448,7 @@ void PartSet_SketcherMgr::onMouseReleased(ModuleBase_IViewWindow* theWnd, QMouse /// the previous selection is lost by mouse release in the viewer(Select method), but /// it is still stored in myCurrentSelection. So, it is possible to restore selection /// It is important for drag(edit with mouse) of sketch entities. - restoreSelection(); + restoreSelection(myCurrentSelection); myCurrentSelection.clear(); } } @@ -585,7 +585,7 @@ void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEve //Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations // 5. it is necessary to save current selection in order to restore it after the features moving - restoreSelection(); + restoreSelection(myCurrentSelection); // 6. restore the update viewer flag and call this update aDisplayer->enableUpdateViewer(isEnableUpdateViewer); aDisplayer->updateViewer(); @@ -1693,7 +1693,8 @@ void PartSet_SketcherMgr::visualizeFeature(const FeaturePtr& theFeature, Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY)); } -void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) +void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly, + PartSet_SketcherMgr::FeatureToSelectionMap& theCurrentSelection) { if (!myCurrentSketch.get()) return; @@ -1710,7 +1711,7 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) } // 1. it is necessary to save current selection in order to restore it after the features moving - myCurrentSelection.clear(); + theCurrentSelection.clear(); QList::const_iterator anIt = aStoredPrs.begin(), aLast = aStoredPrs.end(); @@ -1735,8 +1736,8 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) std::set aSelectedAttributes; std::set aSelectedResults; SelectionInfo anInfo; - if (myCurrentSelection.find(aFeature) != myCurrentSelection.end()) - anInfo = myCurrentSelection.find(aFeature).value(); + if (theCurrentSelection.find(aFeature) != theCurrentSelection.end()) + anInfo = theCurrentSelection.find(aFeature).value(); TopoDS_Shape aFirstShape; ResultPtr aFirstResult = aFeature->firstResult(); @@ -1757,25 +1758,26 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly) anInfo.myAttributes, anInfo.myResults, anInfo.myLocalSelectedShapes); } } - myCurrentSelection[aFeature] = anInfo; + theCurrentSelection[aFeature] = anInfo; } - //qDebug(QString(" storeSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str()); + //qDebug(QString(" storeSelection: %1").arg(theCurrentSelection.size()).toStdString().c_str()); } -void PartSet_SketcherMgr::restoreSelection() +void PartSet_SketcherMgr::restoreSelection( + PartSet_SketcherMgr::FeatureToSelectionMap& theCurrentSelection) { if (!myCurrentSketch.get()) return; - //qDebug(QString("restoreSelection: %1").arg(myCurrentSelection.size()).toStdString().c_str()); + //qDebug(QString("restoreSelection: %1").arg(theCurrentSelection.size()).toStdString().c_str()); ModuleBase_IWorkshop* aWorkshop = myModule->workshop(); XGUI_ModuleConnector* aConnector = dynamic_cast(aWorkshop); - FeatureToSelectionMap::const_iterator aSIt = myCurrentSelection.begin(), - aSLast = myCurrentSelection.end(); + FeatureToSelectionMap::const_iterator aSIt = theCurrentSelection.begin(), + aSLast = theCurrentSelection.end(); SelectMgr_IndexedMapOfOwner anOwnersToSelect; anOwnersToSelect.Clear(); for (; aSIt != aSLast; aSIt++) { - getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection, + getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, theCurrentSelection, anOwnersToSelect); } aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false); diff --git a/src/PartSet/PartSet_SketcherMgr.h b/src/PartSet/PartSet_SketcherMgr.h index db177e582..08d8ffd79 100644 --- a/src/PartSet/PartSet_SketcherMgr.h +++ b/src/PartSet/PartSet_SketcherMgr.h @@ -81,6 +81,18 @@ class PARTSET_EXPORT PartSet_SketcherMgr : public QObject bool myIsInitialized; /// the state whether the point is set double myCurX, myCurY; /// the point coordinates }; + +public: + /// Struct to define selection model information to store/restore selection + struct SelectionInfo + { + std::set myAttributes; /// the selected attributes + std::set myResults; /// the selected results + TopoDS_Shape myFirstResultShape; /// the first shape of feature result + TopTools_MapOfShape myLocalSelectedShapes; /// shapes of local selection + }; + typedef QMap FeatureToSelectionMap; + public: /// Constructor /// \param theModule a pointer to PartSet module @@ -218,10 +230,12 @@ public: /// It obtains the selected attributes. /// The highlighted objects can be processes as the selected ones /// \param theHighlightedOnly a boolean flag - void storeSelection(const bool theHighlightedOnly = false); + /// \param theCurrentSelection a container filled by the current selection + void storeSelection(const bool theHighlightedOnly, FeatureToSelectionMap& theCurrentSelection); /// Restores previously saved selection state - void restoreSelection(); + /// \param theCurrentSelection a container filled by the current selection + void restoreSelection(FeatureToSelectionMap& theCurrentSelection); /// Return error state of the sketch feature, true if the error has happened /// \return boolean value @@ -317,16 +331,6 @@ private: ModuleBase_IWorkshop* theWorkshop, bool& theCanCommitOperation); - struct SelectionInfo - { - std::set myAttributes; - std::set myResults; - TopoDS_Shape myFirstResultShape; - TopTools_MapOfShape myLocalSelectedShapes; - }; - - typedef QMap FeatureToSelectionMap; - /// Applyes the current selection to the object in the workshop viewer /// It includes the selection in all modes of activation, even local context - vertexes, edges /// It gets all results of the feature, find an AIS object in the viewer and takes all BRep