From c74be352dac5794f26e2da39eef54ee61844b68f Mon Sep 17 00:00:00 2001 From: vsv Date: Wed, 3 Dec 2014 12:33:51 +0300 Subject: [PATCH] Redefinition of SetSelected method in Displayer --- src/PartSet/PartSet_Module.cpp | 5 ++-- src/XGUI/XGUI_Displayer.cpp | 52 ++++++++++++++++++++-------------- 2 files changed, 32 insertions(+), 25 deletions(-) diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ca49036a6..38e9671dd 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -351,6 +351,7 @@ void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* return; } + QObjectPtrList aSelObjects = getSumList(aHighlighted, aSelected); if ((aHighlighted.size() == 1) && (aSelected.size() == 0)) { // Move by selected shape (vertex). Can be used only for single selection foreach(ModuleBase_ViewerPrs aPrs, aHighlighted) { @@ -370,8 +371,7 @@ void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* } } else { // Provide multi-selection. Can be used only for features - QList aObjects = getSumList(aHighlighted, aSelected); - foreach (ObjectPtr aObj, aObjects) { + foreach (ObjectPtr aObj, aSelObjects) { FeaturePtr aFeature = ModelAPI_Feature::feature(aObj); if (aFeature && (!myEditingFeatures.contains(aFeature))) myEditingFeatures.append(aFeature); @@ -387,7 +387,6 @@ void PartSet_Module::onMousePressed(ModuleBase_IViewWindow* theWnd, QMouseEvent* get2dPoint(theWnd, theEvent, myCurX, myCurY); myDragDone = false; myWorkshop->viewer()->enableSelection(false); - launchEditing(); } else if (isSketchOpe && isEditing) { diff --git a/src/XGUI/XGUI_Displayer.cpp b/src/XGUI/XGUI_Displayer.cpp index 3a46b77b1..6cd90a2fd 100644 --- a/src/XGUI/XGUI_Displayer.cpp +++ b/src/XGUI/XGUI_Displayer.cpp @@ -242,20 +242,29 @@ void XGUI_Displayer::stopSelection(const QObjectPtrList& theResults, const bool void XGUI_Displayer::setSelected(const QObjectPtrList& theResults, const bool isUpdateViewer) { Handle(AIS_InteractiveContext) aContext = AISContext(); - // we need to unhighligth objects manually in the current local context - // in couple with the selection clear (TODO) - Handle(AIS_LocalContext) aLocalContext = aContext->LocalContext(); - if (!aLocalContext.IsNull()) - aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView()); - - aContext->ClearSelected(); - foreach(ObjectPtr aResult, theResults) - { - if (isVisible(aResult)) { - AISObjectPtr anObj = myResult2AISObjectMap[aResult]; - Handle(AIS_InteractiveObject) anAIS = anObj->impl(); - if (!anAIS.IsNull()) - aContext->SetSelected(anAIS, false); + if (aContext.IsNull()) + return; + if (aContext->HasOpenedContext()) { + aContext->UnhilightSelected(); + aContext->ClearSelected(); + foreach(ObjectPtr aResult, theResults) { + if (isVisible(aResult)) { + AISObjectPtr anObj = myResult2AISObjectMap[aResult]; + Handle(AIS_InteractiveObject) anAIS = anObj->impl(); + if (!anAIS.IsNull()) + aContext->SetSelected(anAIS, false); + } + } + } else { + aContext->UnhilightCurrents(); + aContext->ClearCurrents(); + foreach(ObjectPtr aResult, theResults) { + if (isVisible(aResult)) { + AISObjectPtr anObj = myResult2AISObjectMap[aResult]; + Handle(AIS_InteractiveObject) anAIS = anObj->impl(); + if (!anAIS.IsNull()) + aContext->SetCurrentObject(anAIS, false); + } } } if (isUpdateViewer) @@ -348,10 +357,9 @@ void XGUI_Displayer::openLocalContext() aContext->AddFilter(aIt.Value()); } // Restore selection - //AIS_ListIteratorOfListOfInteractive aIt(aAisList); - //for(; aIt.More(); aIt.Next()) { - // if (aContext->IsDisplayed(aIt.Value())) - // aContext->SetSelected(aIt.Value(), false); + //AIS_ListIteratorOfListOfInteractive aIt2(aAisList); + //for(; aIt2.More(); aIt2.Next()) { + // aContext->SetSelected(aIt2.Value(), false); //} } } @@ -396,10 +404,10 @@ void XGUI_Displayer::closeLocalContexts(const bool isUpdateViewer) myActiveSelectionModes.clear(); // Restore selection - //AIS_ListIteratorOfListOfInteractive aIt(aAisList); - //for(; aIt.More(); aIt.Next()) { - // if (aContext->IsDisplayed(aIt.Value())) - // aContext->SetCurrentObject(aIt.Value(), false); + //AIS_ListIteratorOfListOfInteractive aIt2(aAisList); + //for(; aIt2.More(); aIt2.Next()) { + // if (aContext->IsDisplayed(aIt2.Value())) + // aContext->SetCurrentObject(aIt2.Value(), false); //} } } -- 2.39.2