Salome HOME
Issue #2061 arc edit problem: correction for center of arc(last described problem)
authornds <nds@opencascade.com>
Thu, 6 Apr 2017 10:17:24 +0000 (13:17 +0300)
committernds <nds@opencascade.com>
Thu, 6 Apr 2017 10:20:29 +0000 (13:20 +0300)
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_SketcherMgr.cpp
src/PartSet/PartSet_SketcherMgr.h

index e13d7cb1f4f3c78f61bd3704d41b4c4af104254c..963b53c6277340cb7dfe12bca8885b1f639c712e 100755 (executable)
@@ -204,12 +204,18 @@ void PartSet_Module::deactivateSelectionFilters()
 
 void PartSet_Module::storeSelection()
 {
 
 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()
 {
 }
 
 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()
 }
 
 void PartSet_Module::registerValidators()
index 649e3d3e289e2c0e8af307c434b5874ef4c4eecf..79aa314f35fba86d399fd251dc722a375683a569 100755 (executable)
@@ -6,6 +6,7 @@
 #include "PartSet.h"
 #include "PartSet_Tools.h"
 #include "PartSet_OverconstraintListener.h"
 #include "PartSet.h"
 #include "PartSet_Tools.h"
 #include "PartSet_OverconstraintListener.h"
+#include "PartSet_SketcherMgr.h"
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_Definitions.h>
 
 #include <ModuleBase_IModule.h>
 #include <ModuleBase_Definitions.h>
@@ -437,6 +438,9 @@ private:
   /// backup of the visible state to restore them by operation stop
   QMap<PartSet_Tools::ConstraintVisibleState, bool> myHasConstraintShown;
 
   /// backup of the visible state to restore them by operation stop
   QMap<PartSet_Tools::ConstraintVisibleState, bool> 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;
 };
 
   QModelIndex myActivePartIndex;
 };
 
index 7d593a11085cda3157fcd5cc32517464cfb875a8..6128e4038f9ae45e55609ff4b37134cc7eed8d3b 100755 (executable)
@@ -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
       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<XGUI_ModuleConnector*>(aWorkshop);
 
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
@@ -358,7 +358,7 @@ void PartSet_SketcherMgr::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseE
     ModuleBase_ISelection* aSelect = aWorkshop->selection();
 
     bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
     ModuleBase_ISelection* aSelect = aWorkshop->selection();
 
     bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-    storeSelection(!aHasShift);
+    storeSelection(!aHasShift, myCurrentSelection);
 
     if (myCurrentSelection.empty()) {
       if (isSketchOpe && (!isSketcher))
 
     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.
           /// 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();
         }
       }
           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
     //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();
     // 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));
 }
 
     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;
 {
   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
   }
 
   // 1. it is necessary to save current selection in order to restore it after the features moving
-  myCurrentSelection.clear();
+  theCurrentSelection.clear();
 
   QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = aStoredPrs.begin(),
                                                 aLast = aStoredPrs.end();
 
   QList<ModuleBase_ViewerPrsPtr>::const_iterator anIt = aStoredPrs.begin(),
                                                 aLast = aStoredPrs.end();
@@ -1735,8 +1736,8 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
     std::set<AttributePtr> aSelectedAttributes;
     std::set<ResultPtr> aSelectedResults;
     SelectionInfo anInfo;
     std::set<AttributePtr> aSelectedAttributes;
     std::set<ResultPtr> 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();
 
     TopoDS_Shape aFirstShape;
     ResultPtr aFirstResult = aFeature->firstResult();
@@ -1757,25 +1758,26 @@ void PartSet_SketcherMgr::storeSelection(const bool theHighlightedOnly)
           anInfo.myAttributes, anInfo.myResults, anInfo.myLocalSelectedShapes);
       }
     }
           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;
 
 {
   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<XGUI_ModuleConnector*>(aWorkshop);
   ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
   XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(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++) {
   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);
                        anOwnersToSelect);
   }
   aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
index db177e582cbbf1eaf869f2f0aa5ffa798b62f956..08d8ffd799d77d803612480d67d9a2b5c368b658 100644 (file)
@@ -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
   };
     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<AttributePtr> myAttributes; /// the selected attributes
+    std::set<ResultPtr> myResults; /// the selected results
+    TopoDS_Shape myFirstResultShape; /// the first shape of feature result
+    TopTools_MapOfShape myLocalSelectedShapes; /// shapes of local selection
+  };
+  typedef QMap<FeaturePtr, SelectionInfo> FeatureToSelectionMap;
+
 public:
   /// Constructor
   /// \param theModule a pointer to PartSet module
 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
   /// 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
 
   /// 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
 
   /// 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);
 
                                              ModuleBase_IWorkshop* theWorkshop,
                                              bool& theCanCommitOperation);
 
-  struct SelectionInfo
-  {
-    std::set<AttributePtr> myAttributes;
-    std::set<ResultPtr> myResults;
-    TopoDS_Shape myFirstResultShape;
-    TopTools_MapOfShape myLocalSelectedShapes;
-  };
-
-  typedef QMap<FeaturePtr, SelectionInfo> 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
   /// 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