void PartSet_SketcherMgr::onMouseMoved(ModuleBase_IViewWindow* theWnd, QMouseEvent* theEvent)
{
if (myIsDragging) {
- // the selection should be switched off in order to do not deselect moved objects by the
- // mouse release
+ ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
+ // 1. it is necessary to save current selection in order to restore it after the features moving
+ FeatureToSelectionMap aCurrentSelection;
+ getCurrentSelection(myFeature2AttributeMap, myCurrentSketch, aWorkshop, aCurrentSelection);
+
+ // 2. the enable selection in the viewer should be temporary switched off in order to ignore
+ // mouse press signal in the viewer(it call Select for AIS context and the dragged objects are
+ // deselected). This flag should be restored in the slot, processed the mouse release signal.
ModuleBase_IViewer* aViewer = myModule->workshop()->viewer();
aViewer->enableSelection(false);
double dX = aX - myCurX;
double dY = aY - myCurY;
- ModuleBase_IWorkshop* aWorkshop = myModule->workshop();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(aWorkshop);
XGUI_Displayer* aDisplayer = aConnector->workshop()->displayer();
+ // 3. the flag to disable the update viewer should be set in order to avoid blinking in the
+ // viewer happens by deselect/select the modified objects. The flag should be restored after
+ // the selection processing. The update viewer should be also called.
bool isEnableUpdateViewer = aDisplayer->enableUpdateViewer(false);
static Events_ID aMoveEvent = Events_Loop::eventByName(EVENT_OBJECT_MOVED);
FeatureToAttributesMap::const_iterator anIt = myFeature2AttributeMap.begin(),
aLast = myFeature2AttributeMap.end();
- FeatureToSelectionMap aCurrentSelection;
+ // 4. the features and attributes modification(move)
for (; anIt != aLast; anIt++) {
FeaturePtr aFeature = anIt.key();
AttributePtr anAttr;
if (!anAttributes.empty()) {
anAttr = anAttributes.first();
}
-
- // save the previous selection
- getCurrentSelection(aFeature, myCurrentSketch, aWorkshop, aCurrentSelection);
- // save the previous selection: end
-
// Process selection by attribute: the priority to the attribute
if (anAttr.get() != NULL) {
std::string aAttrId = anAttr->id();
Events_Loop::loop()->flush(aMoveEvent); // up all move events - to be processed in the solver
//Events_Loop::loop()->flush(aUpdateEvent); // up update events - to redisplay presentations
- // restore the previous selection
+ // 5. it is necessary to save current selection in order to restore it after the features moving
FeatureToSelectionMap::const_iterator aSIt = aCurrentSelection.begin(),
aSLast = aCurrentSelection.end();
SelectMgr_IndexedMapOfOwner anOwnersToSelect;
anOwnersToSelect);
aConnector->workshop()->selector()->setSelectedOwners(anOwnersToSelect, false);
}
- // restore the previous selection: end
+ // 6. restore the update viewer flag and call this update
aDisplayer->enableUpdateViewer(isEnableUpdateViewer);
aDisplayer->updateViewer();
myDragDone = true;
myPlaneFilter->setPlane(thePln->impl<gp_Pln>());
}
+void PartSet_SketcherMgr::getCurrentSelection(const FeatureToAttributesMap& theFeatureToAttributes,
+ const FeaturePtr& theSketch,
+ ModuleBase_IWorkshop* theWorkshop,
+ FeatureToSelectionMap& theSelection)
+{
+ FeatureToAttributesMap::const_iterator anIt = theFeatureToAttributes.begin(),
+ aLast = theFeatureToAttributes.end();
+ for (; anIt != aLast; anIt++) {
+ FeaturePtr aFeature = anIt.key();
+ getCurrentSelection(aFeature, theSketch, theWorkshop, theSelection);
+ }
+}
+
void PartSet_SketcherMgr::getCurrentSelection(const FeaturePtr& theFeature,
const FeaturePtr& theSketch,
ModuleBase_IWorkshop* theWorkshop,
FeatureToSelectionMap& theSelection)
- //std::set<AttributePtr>& theSelectedAttributes,
- //std::set<ResultPtr>& theSelectedResults)
{
if (theFeature.get() == NULL)
return;
double& theX, double& theY);
+ typedef QList<AttributePtr> AttributeList;
+ typedef QMap<FeaturePtr, AttributeList> FeatureToAttributesMap;
typedef std::map<FeaturePtr, std::pair<std::set<AttributePtr>, std::set<ResultPtr> > >
FeatureToSelectionMap;
+ /// Obtains the current selection of the object in the workshop viewer by a map of feature to attributes
+ /// It calls the next method for each feature
+ /// \param theFeatureToAttributes a map of feature to attributes
+ /// \param theSketch a current sketch feature
+ /// \param theWorkshop a workshop to have an access to AIS context and displayer
+ /// \param theSelection a container for the selection, to save results and attributres for a feature
+ static void getCurrentSelection(const FeatureToAttributesMap& theFeatureToAttributes,
+ const FeaturePtr& theSketch,
+ ModuleBase_IWorkshop* theWorkshop,
+ FeatureToSelectionMap& theSelection);
+
/// Obtains the current selection of the object in the workshop viewer
/// It includes the selection in all modes of activation, even local context - vertices, edges
/// It gets all results of the feature, find an AIS object in the viewer and takes all BRep
CompositeFeaturePtr myCurrentSketch;
- typedef QList<AttributePtr> AttributeList;
- typedef QMap<FeaturePtr, AttributeList> FeatureToAttributesMap;
FeatureToAttributesMap myFeature2AttributeMap; /// a map of a feature to attributes
Handle(ModuleBase_ShapeInPlaneFilter) myPlaneFilter;