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()
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_ISelection* aSelect = aWorkshop->selection();
bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
- storeSelection(!aHasShift);
+ storeSelection(!aHasShift, myCurrentSelection);
if (myCurrentSelection.empty()) {
if (isSketchOpe && (!isSketcher))
/// 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();
}
}
//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();
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;
}
// 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();
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();
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<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++) {
- getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, myCurrentSelection,
+ getSelectionOwners(aSIt.key(), myCurrentSketch, aWorkshop, theCurrentSelection,
anOwnersToSelect);
}
aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
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
/// 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
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