From 0e05260101533fc2566ce52ae228f7dfcbfe5f50 Mon Sep 17 00:00:00 2001 From: vsv Date: Fri, 18 Dec 2015 16:03:35 +0300 Subject: [PATCH] Debug of CompSolid selection --- src/ModuleBase/ModuleBase_ResultPrs.cpp | 49 +++++++++++++------------ src/XGUI/XGUI_SelectionMgr.cpp | 9 ++--- 2 files changed, 30 insertions(+), 28 deletions(-) diff --git a/src/ModuleBase/ModuleBase_ResultPrs.cpp b/src/ModuleBase/ModuleBase_ResultPrs.cpp index ed92d8eb3..2d08104de 100755 --- a/src/ModuleBase/ModuleBase_ResultPrs.cpp +++ b/src/ModuleBase/ModuleBase_ResultPrs.cpp @@ -63,7 +63,7 @@ ModuleBase_ResultPrs::ModuleBase_ResultPrs(ResultPtr theResult) // Activate individual repaintng if this is a part of compsolid ResultCompSolidPtr aCompSolid = ModelAPI_Tools::compSolidOwner(myResult); - //SetAutoHilight(aCompSolid.get() == NULL); + SetAutoHilight(aCompSolid.get() == NULL); } @@ -135,8 +135,8 @@ void ModuleBase_ResultPrs::ComputeSelection(const Handle(SelectMgr_Selection)& a aDeflection, myDrawer->HLRAngle(), 9, 500); for (aSelection->Init(); aSelection->More(); aSelection->Next()) { - Handle(SelectMgr_EntityOwner) anOwner - = Handle(SelectMgr_EntityOwner)::DownCast (aSelection->Sensitive()->BaseSensitive()->OwnerId()); + Handle(SelectMgr_EntityOwner) anOwner = + Handle(SelectMgr_EntityOwner)::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId()); anOwner->Set(this); } return; @@ -184,25 +184,24 @@ TopoDS_Shape ModuleBase_ResultPrs::getSelectionShape() const void ModuleBase_ResultPrs::HilightSelected(const Handle(PrsMgr_PresentationManager3d)& thePM, const SelectMgr_SequenceOfOwner& theOwners) { - if (hasCompSolidSelectionMode()) { - TopoDS_Shape aShape = getSelectionShape(); - Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM ); - aSelectionPrs->Clear(); - - StdPrs_WFDeflectionShape::Add(aSelectionPrs, aShape, myDrawer); - - aSelectionPrs->SetDisplayPriority(9); - aSelectionPrs->Highlight(Aspect_TOHM_COLOR, aSelectionPrs->HighlightColor()); - aSelectionPrs->Display(); - thePM->Highlight(this); - } else { - Handle(SelectMgr_EntityOwner) anOwner; - for (int i = 1; i <= theOwners.Length(); i++) { - anOwner = theOwners.Value(i); - if (!anOwner->IsSelected()) { // anOwner is not selected - anOwner->SetSelected(true); - AIS_Selection::Select(anOwner); - } + Handle(SelectMgr_EntityOwner) anOwner; + Handle(ModuleBase_BRepOwner) aCompOwner; + for (int i = 1; i <= theOwners.Length(); i++) { + anOwner = theOwners.Value(i); + aCompOwner = Handle(ModuleBase_BRepOwner)::DownCast(anOwner); + if (aCompOwner.IsNull()) + anOwner->Hilight(thePM); + else { + TopoDS_Shape aShape = aCompOwner->Shape(); + Handle( Prs3d_Presentation ) aSelectionPrs = GetSelectPresentation( thePM ); + aSelectionPrs->Clear(); + + StdPrs_WFDeflectionShape::Add(aSelectionPrs, aShape, myDrawer); + + aSelectionPrs->SetDisplayPriority(9); + aSelectionPrs->Highlight(Aspect_TOHM_COLOR, aSelectionPrs->HighlightColor()); + aSelectionPrs->Display(); + thePM->Highlight(this); } } } @@ -211,7 +210,11 @@ void ModuleBase_ResultPrs::HilightOwnerWithColor(const Handle(PrsMgr_Presentatio const Quantity_NameOfColor theColor, const Handle(SelectMgr_EntityOwner)& theOwner) { - TopoDS_Shape aShape = getSelectionShape(); + Handle(StdSelect_BRepOwner) aOwner = Handle(StdSelect_BRepOwner)::DownCast(theOwner); + if (aOwner.IsNull()) + return; + + TopoDS_Shape aShape = aOwner->Shape(); if (!aShape.IsNull()) { thePM->Color(this, theColor); diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index 6136e93f8..770cc5935 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -107,11 +107,10 @@ void XGUI_SelectionMgr::onViewerSelection() QObjectPtrList aFeatures; Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext(); if (!aContext.IsNull()) { - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { - Handle(AIS_InteractiveObject) anIO = aContext->SelectedInteractive(); - ObjectPtr aResult = myWorkshop->displayer()->getObject(anIO); - if (aResult) - aFeatures.append(aResult); + QList aPresentations = selection()->getSelected(ModuleBase_ISelection::Viewer); + foreach(ModuleBase_ViewerPrs aPrs, aPresentations) { + if (aPrs.object().get()) + aFeatures.append(aPrs.object()); } } bool aBlocked = myWorkshop->objectBrowser()->blockSignals(true); -- 2.39.2