From 3f704cabf936ddcdbd9e4b9ff16a1f7e27e08309 Mon Sep 17 00:00:00 2001 From: dmv Date: Thu, 6 Nov 2008 08:17:40 +0000 Subject: [PATCH] "Show", "Hide", "Show only" are in the popup of the table and Plot2DView objects at the same time. --- src/VISUGUI/Makefile.am | 1 - src/VISUGUI/VisuGUI.cxx | 13 +++-- src/VISUGUI/VisuGUI_Displayer.cxx | 6 ++- src/VISUGUI/VisuGUI_Selection.cxx | 86 +++++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_Selection.h | 4 ++ src/VISUGUI/VisuGUI_ViewTools.cxx | 3 ++ 6 files changed, 106 insertions(+), 7 deletions(-) diff --git a/src/VISUGUI/Makefile.am b/src/VISUGUI/Makefile.am index 6abacc7d..08666612 100644 --- a/src/VISUGUI/Makefile.am +++ b/src/VISUGUI/Makefile.am @@ -43,7 +43,6 @@ salomeinclude_HEADERS= \ VisuGUI_Selection.h \ VisuGUI_Tools.h \ VisuGUI_ViewTools.h \ - VisuGUI_PopupTools.h \ VisuGUI_NameDlg.h \ VisuGUI_FileDlg.h \ VisuGUI_CursorDlg.h \ diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index ebe2c5c3..67e3c84a 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -851,6 +851,8 @@ VisuGUI aViewWindow->Repaint(); break; } + else + displayer()->Display(anIO->getEntry()); case VISU::TCURVE: case VISU::TCONTAINER: case VISU::TTABLE: @@ -2781,18 +2783,19 @@ VisuGUI // display/erase commands QString andInvisible = " and (((not isVisible) and isActiveView) or (not isActiveView))"; - QString aTableOrCont = "(type='VISU::TTABLE' and nbChildren>0) or type='VISU::TCONTAINER'"; + QString aTableOrContHide = "(($type in {'VISU::TTABLE' 'VISU::TPOINTMAP3D' 'VISU::TCONTAINER'}) and isPlot2dViewer and hasCurves and isThereAreVisibleCurves)"; + QString aTableOrContShow = "(($type in {'VISU::TTABLE' 'VISU::TPOINTMAP3D' 'VISU::TCONTAINER'}) and isPlot2dViewer and hasCurves and isThereAreHiddenCurves)"; QString orCurveVisible = "or (type='VISU::TCURVE' and isVisible)"; QString orCurveInvisible = "or (type='VISU::TCURVE'" + andInvisible + ")"; - QString aPrsVisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "}) and isVisible)"; - QString aPrsInvisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "})" + andInvisible + ")"; + QString aPrsVisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "}) and isVisible and (not isPlot2dViewer))"; + QString aPrsInvisible = "(($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "})" + andInvisible + " and (not isPlot2dViewer))"; QString aComponent = "( selcount=1 and canBeDisplayed and isVisuComponent )"; QString anEraseRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsVisible + - " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveVisible + "))) ) or " + aComponent; + " or (client='ObjectBrowser' and (" + aTableOrContHide + orCurveVisible + "))) ) or " + aComponent; QString aDisplayRule = "( selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsInvisible + - " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + "))) ) or " + aComponent; + " or (client='ObjectBrowser' and (" + aTableOrContShow + orCurveInvisible + "))) ) or " + aComponent; QString aDOnlyRule = "( selcount>0 and ({true} in $canBeDisplayed) and (($type in {'VISU::TMESH' 'VISU::TPOINTMAP3D'" + aPrsAll + "})" " or (client='ObjectBrowser' and ((type='VISU::TTABLE' and nbChildren>0) or" diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx index df6fbc23..c6afa229 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -149,7 +149,11 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& theEntry, SALOM aPlot2dPrs = buildContainer( aViewWindow, aContainer ); break; } - case VISU::TPOINTMAP3D: + case VISU::TPOINTMAP3D: { + VISU::Table_i* aTable = dynamic_cast(aBaseServant); + aPlot2dPrs = buildTable( aViewWindow, aTable ); + break; + } case VISU::TTABLE: { VISU::Table_i* aTable = dynamic_cast(aBaseServant); aPlot2dPrs = buildTable( aViewWindow, aTable ); diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index e2ceec1f..b04bbecc 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -38,6 +38,7 @@ #include "SalomeApp_Study.h" #include "LightApp_Study.h" +#include "LightApp_Displayer.h" using namespace VISU; @@ -69,6 +70,10 @@ QVariant VisuGUI_Selection::parameter( const int ind, const QString& p ) const else if ( p == "mediumResolution" ) val = QVariant( mediumResolution( ind ) ); else if ( p == "lowResolution" ) val = QVariant( lowResolution( ind ) ); else if ( p == "resolutionState" ) val = QVariant( resolutionState( ind ) ); + else if ( p == "isThereAreVisibleCurves" ) val = QVariant( findDisplayedCurves( ind, false ) ); + else if ( p == "isThereAreHiddenCurves" ) val = QVariant( findDisplayedCurves( ind, true ) ); + else if ( p == "hasCurves" ) val = QVariant( hasCurves( ind ) ); + else if ( p == "isPlot2dViewer" ) val = QVariant( Plot2dViewerType( ind ) ); } return val; @@ -575,3 +580,84 @@ bool VisuGUI_Selection::isVisuComponent( const int ind ) const return dynamic_cast( VISU::GetServant( anObj ).in() ); } + +//--------------------------------------------------------------------------- +bool VisuGUI_Selection::findDisplayedCurves( const int ind, bool findHidden ) const +{ + // findHidden == false - find at least one Visible curve in the childs of ind + // findHidden == true - find at least one Hidden curve in the childs of ind + SalomeApp_Study* aSStudy = GetStudy(); + if ( !aSStudy ) + return false; + + QString entryId; + _PTR(Study) aStudy = GetCStudy( aSStudy ); + if ( aStudy ){ + _PTR(SObject) SO = aStudy->FindObjectID( (const char*) entry( ind ).toLatin1() ); + if ( SO ){ + for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) { + _PTR(SObject) refSO; + if ( Iter->Value()->ReferencedObject(refSO) ) + entryId = refSO->GetID().c_str(); + else + entryId = Iter->Value()->GetID().c_str(); + + LightApp_Displayer* displayer = LightApp_Displayer::FindDisplayer( myModule->moduleName(), false ); + if ( displayer->IsDisplayed( entryId ) && findHidden == false ) + return true; + else if ( !displayer->IsDisplayed( entryId ) && findHidden == true ) + return true; + } + } + } + return false; +} + +//--------------------------------------------------------------------------- +bool VisuGUI_Selection::hasCurves( const int ind ) const +{ + SalomeApp_Study* aSStudy = GetStudy(); + if ( !aSStudy ) + return false; + + QString entryId; + _PTR(Study) aStudy = GetCStudy( aSStudy ); + if ( aStudy ){ + _PTR(SObject) SO = aStudy->FindObjectID( (const char*) entry( ind ).toLatin1() ); + if ( SO ){ + for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) { + _PTR(SObject) refSO; + if ( Iter->Value()->ReferencedObject(refSO) ) { + // reference on curve + } + else + refSO = Iter->Value(); + + CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(refSO); + if(!CORBA::is_nil(aCORBAObject)){ + PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject); + if(VISU::Curve_i* aCurve = dynamic_cast(aServant.in())) + return true; + } + } + } + } + return false; +} + +//--------------------------------------------------------------------------- +bool VisuGUI_Selection::Plot2dViewerType( const int ind ) const +{ + QString viewerType; + SUIT_Session* session = SUIT_Session::session(); + if( SUIT_Application* app = session->activeApplication() ) + if( LightApp_Application* sApp = dynamic_cast( app ) ) + if( SUIT_ViewManager* vman = sApp->activeViewManager() ) + if( SUIT_ViewModel* vmod = vman->getViewModel() ) { + viewerType = vmod->getType(); + if (viewerType ==SPlot2d_Viewer::Type()) + return true; + } + return false; +} + diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h index 184547e3..2f0a7af4 100644 --- a/src/VISUGUI/VisuGUI_Selection.h +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -68,6 +68,10 @@ private: QString resolutionState( const int ) const; private: + bool findDisplayedCurves( const int, bool ) const; + bool hasCurves( const int ) const; + bool Plot2dViewerType( const int ) const; + int nbChild( const int, const bool ) const; SalomeApp_Study* GetStudy() const; diff --git a/src/VISUGUI/VisuGUI_ViewTools.cxx b/src/VISUGUI/VisuGUI_ViewTools.cxx index 165bfffe..aabc2623 100644 --- a/src/VISUGUI/VisuGUI_ViewTools.cxx +++ b/src/VISUGUI/VisuGUI_ViewTools.cxx @@ -169,6 +169,9 @@ namespace VISU if(theDoRepaint) aViewWindow->Repaint(); } + } else { + if (VISU::Table_i* aTable = dynamic_cast(theBase)) + PlotTable(theModule, aTable, VISU::eErase ); } } break; -- 2.39.2