From 8cdca8ee162a03856ab76af2da857be999a402d8 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 16 Dec 2010 16:52:14 +0000 Subject: [PATCH] Additional fix for issue 0020977: EDF 1520 SMESH: Create a clipping plane on several groups (note 0009988) --- src/SMESHGUI/SMESHGUI.cxx | 56 ++++++++++++++++++++++++++- src/SMESHGUI/SMESHGUI_ClippingDlg.cxx | 30 ++++++++++---- 2 files changed, 77 insertions(+), 9 deletions(-) diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 8d50908bd..c78fd71d1 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -5439,7 +5439,15 @@ void SMESHGUI::restoreVisualParameters (int savePoint) aPlaneInfo.PlaneId = aPlaneId; aPlaneInfo.ActorList.push_back( aSmeshActor ); aPlaneInfo.ViewManager = vman; - aPlaneInfoList.push_back( aPlaneInfo ); + + // to make the list sorted by plane id + anIter = aPlaneInfoList.begin(); + for( ; anIter != aPlaneInfoList.end(); anIter++ ) { + const TPlaneInfo& aPlaneInfoRef = *anIter; + if( aPlaneInfoRef.PlaneId > aPlaneId ) + break; + } + aPlaneInfoList.insert( anIter, aPlaneInfo ); } } } @@ -5450,6 +5458,52 @@ void SMESHGUI::restoreVisualParameters (int savePoint) } // for names/parameters iterator } // for entries iterator + // take into account planes with empty list of actors referred to them + QList aVMList; + getApp()->viewManagers(SVTK_Viewer::Type(), aVMList); + + TPlaneDataMap::const_iterator aPlaneDataIter = aPlaneDataMap.begin(); + for( ; aPlaneDataIter != aPlaneDataMap.end(); aPlaneDataIter++ ) { + int aViewId = aPlaneDataIter->first; + if( aViewId >= 0 && aViewId < aVMList.count() ) { + SUIT_ViewManager* aViewManager = aVMList.at( aViewId ); + + const TPlaneDataList& aPlaneDataList = aPlaneDataIter->second; + + TPlaneInfoList& aPlaneInfoList = aPlaneInfoMap[ aViewId ]; + TPlaneDataList::const_iterator anIter2 = aPlaneDataList.begin(); + for( ; anIter2 != aPlaneDataList.end(); anIter2++ ) { + const TPlaneData& aPlaneData = *anIter2; + int aPlaneId = aPlaneData.Id; + + bool anIsFound = false; + TPlaneInfoList::const_iterator anIter3 = aPlaneInfoList.begin(); + for( ; anIter3 != aPlaneInfoList.end(); anIter3++ ) { + const TPlaneInfo& aPlaneInfo = *anIter3; + if( aPlaneInfo.PlaneId == aPlaneId ) { + anIsFound = true; + break; + } + } + + if( !anIsFound ) { + TPlaneInfo aPlaneInfo; // ActorList field is empty + aPlaneInfo.PlaneId = aPlaneId; + aPlaneInfo.ViewManager = aViewManager; + + // to make the list sorted by plane id + TPlaneInfoList::iterator anIter4 = aPlaneInfoList.begin(); + for( ; anIter4 != aPlaneInfoList.end(); anIter4++ ) { + const TPlaneInfo& aPlaneInfoRef = *anIter4; + if( aPlaneInfoRef.PlaneId > aPlaneId ) + break; + } + aPlaneInfoList.insert( anIter4, aPlaneInfo ); + } + } + } + } + // add clipping planes to actors according to the restored parameters // and update the clipping plane map TPlaneInfoMap::const_iterator anIter1 = aPlaneInfoMap.begin(); diff --git a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx index ac190be77..486a859ac 100644 --- a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx @@ -194,7 +194,8 @@ private: struct TSetVisibility { TSetVisibility(int theIsVisible): myIsVisible(theIsVisible){} void operator()(SMESH::TPlaneData& thePlaneData){ - thePlaneData.Plane.GetPointer()->myActor->SetVisibility(myIsVisible); + bool anIsEmpty = thePlaneData.ActorList.empty(); + thePlaneData.Plane.GetPointer()->myActor->SetVisibility(myIsVisible && !anIsEmpty); } int myIsVisible; }; @@ -261,11 +262,22 @@ SMESH::OrientedPlane* SMESHGUI_ClippingDlg::AddPlane (SMESH::TActorList vtkFloatingPointType aBounds[6]; vtkFloatingPointType anOrigin[3]; - bool anIsOk = SMESH::ComputeClippingPlaneParameters( theActorList, - aNormal, - theDistance, - aBounds, - anOrigin ); + + bool anIsOk = false; + if( theActorList.empty() ) { + // to support planes with empty actor list we should create + // a nullified plane that will be initialized later + anOrigin[0] = anOrigin[1] = anOrigin[2] = 0; + aBounds[0] = aBounds[2] = aBounds[4] = 0; + aBounds[1] = aBounds[3] = aBounds[5] = 0; + anIsOk = true; + } + else + anIsOk = SMESH::ComputeClippingPlaneParameters( theActorList, + aNormal, + theDistance, + aBounds, + anOrigin ); if( !anIsOk ) return NULL; @@ -545,8 +557,10 @@ void SMESHGUI_ClippingDlg::ClickOnApply() SMESH::TPlaneData aPlaneData = *anIter2; SMESH::TPlane aPlane = aPlaneData.Plane; SMESH::TActorList anActorList = aPlaneData.ActorList; - if( anActorList.empty() ) - continue; + + // the check is disabled to support planes with empty actor list + //if( anActorList.empty() ) + // continue; SMESH::OrientedPlane* anOrientedPlane = SMESH::OrientedPlane::New(myViewWindow); anOrientedPlane->ShallowCopy(aPlane.GetPointer()); -- 2.39.2