From 6974c8ae08ea16284087e0f6bbf248dc41757a66 Mon Sep 17 00:00:00 2001 From: dmv Date: Thu, 6 Nov 2008 08:14:29 +0000 Subject: [PATCH] "Show", "Hide", "Show only" are in the popup of the table and Plot2DView objects at the same time. --- src/VISUGUI/VisuGUI.cxx | 17 ++-- src/VISUGUI/VisuGUI_Displayer.cxx | 5 ++ src/VISUGUI/VisuGUI_PopupTools.cxx | 120 ++++++++++++++++++++++++----- src/VISUGUI/VisuGUI_PopupTools.h | 22 +++--- src/VISUGUI/VisuGUI_ViewTools.cxx | 3 + 5 files changed, 129 insertions(+), 38 deletions(-) diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 792e8e4f..492199ed 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -818,6 +818,8 @@ VisuGUI aViewWindow->getRenderer()->ResetCameraClippingRange(); aViewWindow->Repaint(); } + else + displayer()->Display(anIO->getEntry()); break; default: { VISU::Prs3d_i* aPrs3d = VISU::GetPrs3dFromBase(aBase); @@ -2730,18 +2732,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 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 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 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 79533348..ea4e9195 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -140,6 +140,11 @@ SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& theEntry, SALOM aPlot2dPrs = buildContainer( aViewWindow, aContainer ); break; } + 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_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index a9c86e5a..b61e6499 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -38,6 +38,7 @@ #include "SalomeApp_Study.h" #include "LightApp_Study.h" +#include "LightApp_Displayer.h" using namespace VISU; @@ -70,6 +71,11 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const else if ( p == "mediumResolution" ) val = QtxValue( mediumResolution( ind ) ); else if ( p == "lowResolution" ) val = QtxValue( lowResolution( ind ) ); else if ( p == "resolutionState" ) val = QtxValue( resolutionState( ind ) ); + + else if ( p == "isThereAreVisibleCurves" ) val = QtxValue( findDisplayedCurves( ind, false ) ); + else if ( p == "isThereAreHiddenCurves" ) val = QtxValue( findDisplayedCurves( ind, true ) ); + else if ( p == "hasCurves" ) val = QtxValue( hasCurves( ind ) ); + else if ( p == "isPlot2dViewer" ) val = QtxValue( Plot2dViewerType( ind ) ); } return val; @@ -141,7 +147,6 @@ QString VisuGUI_Selection::type( const int ind ) const if ( anIsExist && aVal != "MESH" ) aResStr = "VISU::T" + aVal; } - return aResStr; } @@ -186,39 +191,36 @@ QString VisuGUI_Selection::resolutions( const int ind ) const //--------------------------------------------------------------- -QString VisuGUI_Selection::resolution( const int ind, char theResoltuion ) const +bool VisuGUI_Selection::resolution( const int ind, char theResoltuion ) const { - QString aResStr; QString aResolutions = resolutions( ind ); if(aResolutions.isEmpty()) - return aResStr; + return false; if(aResolutions.find(theResoltuion) != -1) - aResStr = "1"; + return true; else - aResStr = "0"; - - return aResStr; + return false; } //--------------------------------------------------------------- -QString VisuGUI_Selection::fullResolution( const int ind ) const +bool VisuGUI_Selection::fullResolution( const int ind ) const { return resolution( ind, 'F'); } //--------------------------------------------------------------- -QString VisuGUI_Selection::mediumResolution( const int ind ) const +bool VisuGUI_Selection::mediumResolution( const int ind ) const { return resolution( ind, 'M'); } //--------------------------------------------------------------- -QString VisuGUI_Selection::lowResolution( const int ind ) const +bool VisuGUI_Selection::lowResolution( const int ind ) const { return resolution( ind, 'L'); } @@ -493,19 +495,15 @@ int VisuGUI_Selection::nbChild( const int ind, const bool named ) const } //---------------------------------------------------------------------------- -QString VisuGUI_Selection::nbChildren( const int ind ) const +int VisuGUI_Selection::nbChildren( const int ind ) const { - QString aResStr; - aResStr.setNum( nbChild( ind, false ) ); - return aResStr; + return nbChild( ind, false ); } //---------------------------------------------------------------------------- -QString VisuGUI_Selection::nbNamedChildren( const int ind ) const +int VisuGUI_Selection::nbNamedChildren( const int ind ) const { - QString aResStr; - aResStr.setNum( nbChild( ind, true ) ); - return aResStr; + return nbChild( ind, true ); } @@ -559,9 +557,9 @@ QString VisuGUI_Selection::isShrunk( const int ind ) const //---------------------------------------------------------------------------- -QString VisuGUI_Selection::hasActor( const int ind ) const +bool VisuGUI_Selection::hasActor( const int ind ) const { - return representation( ind ).isEmpty() ? "0" : "1"; + return representation( ind ).isEmpty(); } @@ -623,3 +621,83 @@ 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( entry( ind ).latin1() ); + if ( SO ){ + for ( _PTR(ChildIterator) Iter = aStudy->NewChildIterator( SO ); Iter->More(); Iter->Next() ) { + _PTR(SObject) refSO; + if ( Iter->Value()->ReferencedObject(refSO) ) + entryId = refSO->GetID(); + else + entryId = Iter->Value()->GetID(); + + 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( entry( ind ).latin1() ); + 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_PopupTools.h b/src/VISUGUI/VisuGUI_PopupTools.h index 61a59250..80866c63 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.h +++ b/src/VISUGUI/VisuGUI_PopupTools.h @@ -52,28 +52,30 @@ private: QString medSource( const int ) const; QString nbTimeStamps( const int ) const; QString representation( const int ) const; - QString nbChildren( const int ) const; - QString nbNamedChildren( const int ) const; + int nbChildren( const int ) const; + int nbNamedChildren( const int ) const; QString isVisible( const int ) const; QString isShrunk( const int ) const; - QString hasActor( const int ) const; QString isShading( const int ) const; + bool hasActor( const int ) const; QString isScalarMapAct( const int ) const; bool isVisuComponent( const int ) const; - QString fullResolution( const int ) const; - QString mediumResolution( const int ) const; - QString lowResolution( const int ) const; + bool fullResolution( const int ) const; + bool mediumResolution( const int ) const; + bool lowResolution( const int ) const; QString resolutionState( const int ) const; private: - int nbChild( const int, const bool ) const; - SalomeApp_Study* GetStudy() const; + bool findDisplayedCurves( const int, bool ) const; + bool Plot2dViewerType( const int ) const; + bool hasCurves( const int ) const; + int nbChild( const int, const bool ) const; QString resolutions( const int ) const; - QString resolution( const int, char theResoltuion ) const; + bool resolution( const int, char theResoltuion ) const; -private: + SalomeApp_Study* GetStudy() const; SalomeApp_Module* myModule; }; diff --git a/src/VISUGUI/VisuGUI_ViewTools.cxx b/src/VISUGUI/VisuGUI_ViewTools.cxx index 5e5c8a74..5b124be1 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