Additional fix for issue 0020977: EDF 1520 SMESH: Create a clipping plane on several groups (note 0009988)

This commit is contained in:
ouv 2010-12-16 16:52:14 +00:00
parent 8ddabc36e2
commit 8cdca8ee16
2 changed files with 77 additions and 9 deletions

View File

@ -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<SUIT_ViewManager*> 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();

View File

@ -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());