From: asl Date: Thu, 1 Dec 2005 10:05:59 +0000 (+0000) Subject: Improvement: now in rules you can use "canBeDisplayed" parameter. It is true, if... X-Git-Tag: BR_3_1_0_deb~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=50f34a611b2821ac28baee1de7701a205441e271;p=modules%2Fvisu.git Improvement: now in rules you can use "canBeDisplayed" parameter. It is true, if current object can be displayed in active viewer. The result of this check is calculated by new virtual method LightApp_Displayer::canBeDisplayed. GEOM, SMESH, VISU overrides it in order to provide information, what object can be displayed in what viewer --- diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 50856975..13ec0762 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -624,11 +624,11 @@ OnDisplayPrs() if(aPrsObject){ if(MYDEBUG) MESSAGE("VisuGUI::OnDisplayPrs : Prs3d object"); //UpdateViewer( this, aPrsObject ); - displayer()->Display( anIO->getEntry() ); - SVTK_ViewWindow* vw = GetViewWindow( this, /*create=*/true ); - if ( vw ) { - vw->highlight(anIO, 1); + if ( vw ) + { + displayer()->Display( anIO->getEntry() ); + vw->highlight(anIO, 1); } continue; } @@ -2494,13 +2494,13 @@ createPopupMenus() QString aPrsVisible = "(($type in {'VISU::TMESH' " + aPrsAll + "}) and isVisible)"; QString aPrsInvisible = "(($type in {'VISU::TMESH' " + aPrsAll + "})" + andInvisible + ")"; - QString anEraseRule = "selcount>0 and (" + aPrsVisible + + QString anEraseRule = "selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsVisible + " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveVisible + ")))"; - QString aDisplayRule = "selcount>0 and (" + aPrsInvisible + + QString aDisplayRule = "selcount>0 and ({true} in $canBeDisplayed) and (" + aPrsInvisible + " or (client='ObjectBrowser' and (" + aTableOrCont + orCurveInvisible + ")))"; - QString aDOnlyRule = "selcount>0 and (($type in {'VISU::TMESH' " + aPrsAll + "})" + QString aDOnlyRule = "selcount>0 and ({true} in $canBeDisplayed) and (($type in {'VISU::TMESH' " + aPrsAll + "})" " or (client='ObjectBrowser' and ((type='VISU::TTABLE' and nbChildren>0) or" " ($type in {'VISU::TCURVE' 'VISU::TCONTAINER'}))))"; diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx index 0d604a34..bcfffa77 100644 --- a/src/VISUGUI/VisuGUI_Displayer.cxx +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -212,3 +212,30 @@ SPlot2d_Prs* VisuGUI_Displayer::buildTable( Plot2d_ViewWindow* wnd, VISU::Table_ } return prs; } + +bool VisuGUI_Displayer::canBeDisplayed( const QString& entry, const QString& viewer_type ) const +{ + SalomeApp_Study* study = dynamic_cast( myApp->activeStudy() ); + if( !study ) + return false; + + _PTR(SObject) obj = study->studyDS()->FindObjectID( entry.latin1() ); + CORBA::Object_var anObj = VISU::ClientSObjectToObject( obj ); + if( CORBA::is_nil( anObj ) ) + return false; + + if( viewer_type==SVTK_Viewer::Type() ) + { + VISU::Prs3d_i* thePrs = dynamic_cast( VISU::GetServant( anObj ).in() ); + return thePrs; + } + else if( viewer_type==SPlot2d_Viewer::Type() ) + { + VISU::Curve_i* aCurve = dynamic_cast( VISU::GetServant( anObj ).in() ); + VISU::Container_i* aCont = dynamic_cast( VISU::GetServant( anObj ).in() ); + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant( anObj ).in() ); + return aCurve || aCont || aTable; + } + else + return false; +} diff --git a/src/VISUGUI/VisuGUI_Displayer.h b/src/VISUGUI/VisuGUI_Displayer.h index 62a24725..f762ba0a 100644 --- a/src/VISUGUI/VisuGUI_Displayer.h +++ b/src/VISUGUI/VisuGUI_Displayer.h @@ -45,6 +45,7 @@ public: ~VisuGUI_Displayer(); virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 ); + virtual bool canBeDisplayed( const QString& /*entry*/, const QString& /*viewer_type*/ ) const; protected: bool addCurve ( SPlot2d_Prs*, Plot2d_ViewWindow*, VISU::Curve_i* ) const;