From: asv Date: Thu, 6 Apr 2006 07:43:04 +0000 (+0000) Subject: Fixed 2 bugs with incorrect saving/restoring of clipping planes. X-Git-Tag: mergeto_OCC_debug_for_3_2_0b1_07Apr06~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=59e5e3bbf1040d33e1f44139e7a5a6cb9db81e64;p=modules%2Fvisu.git Fixed 2 bugs with incorrect saving/restoring of clipping planes. --- diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index f1dd5652..b08bb8c9 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -1700,8 +1700,11 @@ void VisuGUI_Module::storeVisualParameters(int savePoint) ip->setParameter( entry, param, "On" ); } if ( const VISU::Prs3d_i* vPrs = vActor->GetPrs3d() ) { - param = vtkParam + "ClippingPlane_"; - for ( int p = 0, nPlanes = vPrs->GetNumberOfClippingPlanes(); p < nPlanes; p++ ) { + param = vtkParam + "ClippingPlane"; + int nPlanes = vPrs->GetNumberOfClippingPlanes(); + if ( !nPlanes ) + ip->setParameter( entry, param, "Off" ); + for ( int p = 0; p < nPlanes; p++ ) { vtkPlane* plane = vPrs->GetClippingPlane( p ); float normal[3], origin[3]; plane->GetNormal( normal ); @@ -1712,7 +1715,7 @@ void VisuGUI_Module::storeVisualParameters(int savePoint) planeValue += QString::number( origin[0] ).latin1(); planeValue += gDigitsSep; planeValue += QString::number( origin[1] ).latin1(); planeValue += gDigitsSep; planeValue += QString::number( origin[2] ).latin1(); - param += QString::number( p+1 ).latin1(); + param = QString( "%1ClippingPlane_%2" ).arg( vtkParam.c_str() ).arg( p+1 ).latin1(); ip->setParameter( entry, param, planeValue ); } } @@ -1873,13 +1876,11 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint) if ( viewIndex >= 0 && viewIndex < lst.count() ) { SUIT_ViewManager* vman = lst.at( viewIndex ); SUIT_ViewModel* vmodel = vman->getViewModel(); - // SVTK and VVTK view models can be casted to SALOME_View - displayer()->Display( entry, true, dynamic_cast( vmodel ) ); - SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView(); - // vtkView->getRenderer()->ResetCameraClippingRange(); - // vtkView->Repaint(); + // both SVTK and VVTK view models can be casted to SALOME_View + displayer()->Display( entry, true, dynamic_cast( vmodel ) ); - // store displayed actor so setting of color, opacity, etc. will be much faster + // store displayed actor in a temporary map for quicker access later when restoring other parameters + SVTK_ViewWindow* vtkView = (SVTK_ViewWindow*) vman->getActiveView(); QMap viewActorMap; if ( vtkActors.contains( entry ) ) viewActorMap = vtkActors[ entry ]; @@ -1931,17 +1932,25 @@ void VisuGUI_Module::restoreVisualParameters(int savePoint) } else if ( paramName.find( "ClippingPlane" ) != std::string::npos ) { - QStringList vals = QStringList::split( gDigitsSep, val ); - if ( vals.count() == 6 && vActor->GetPrs3d() ) { - float normal[3], origin[3]; - for (int x = 0; x < 3; x++ ) { - normal[x] = vals[x].toFloat(); - origin[x] = vals[x+3].toFloat(); + VISU::Prs3d_i* prs = vActor->GetPrs3d(); + if ( !prs ) + continue; + if ( val == "Off" ) { + prs->RemoveAllClippingPlanes(); + } + else { + QStringList vals = QStringList::split( gDigitsSep, val ); + if ( vals.count() == 6 ) { // format check: 6 float values + float normal[3], origin[3]; + for (int x = 0; x < 3; x++ ) { + normal[x] = vals[x].toFloat(); + origin[x] = vals[x+3].toFloat(); + } + vtkPlane* plane = vtkPlane::New(); + plane->SetNormal( normal ); + plane->SetOrigin( origin ); + prs->AddClippingPlane( plane ); } - vtkPlane* plane = vtkPlane::New(); - plane->SetNormal( normal ); - plane->SetOrigin( origin ); - vActor->GetPrs3d()->AddClippingPlane( plane ); } } } // else ..