From 6b4c00c2dd4e2e9f92dc592b848c972d096f3167 Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 7 Nov 2005 06:08:56 +0000 Subject: [PATCH] PAL9391 - display/erase objects from other module --- src/VISUGUI/Makefile.in | 3 +- src/VISUGUI/VisuGUI.cxx | 9 +- src/VISUGUI/VisuGUI_Displayer.cxx | 207 +++++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_Displayer.h | 60 +++++++++ src/VISUGUI/VisuGUI_PopupTools.cxx | 2 +- src/VISUGUI/VisuGUI_Tools.cxx | 8 +- src/VISUGUI/VisuGUI_Tools.h | 8 ++ 7 files changed, 290 insertions(+), 7 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_Displayer.cxx create mode 100644 src/VISUGUI/VisuGUI_Displayer.h diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 88fccafa..2bcb2ea5 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -70,7 +70,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_CutPlanesDlg.cxx \ VisuGUI_StreamLinesDlg.cxx \ VisuGUI_VectorsDlg.cxx \ - VisuGUI_DialogRunner.cxx + VisuGUI_DialogRunner.cxx \ + VisuGUI_Displayer.cxx LIB_MOC = VisuGUI.h \ VisuGUI_Selection.h \ diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index 0a521376..97b41971 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -103,6 +103,7 @@ #include "VisuGUI_Plot3DDlg.h" #include "VisuGUI_CubeAxesDlg.h" #include "VisuGUI_OffsetDlg.h" +#include "VisuGUI_Displayer.h" #include "VISU_ScalarMap_i.hh" #include "VisuGUI_ScalarBarDlg.h" @@ -147,7 +148,8 @@ static int MYDEBUG = 0; ////////////////////////////////////////////////// VisuGUI::VisuGUI(): - SalomeApp_Module( "VISU" ) + SalomeApp_Module( "VISU" ), + myDisplayer( 0 ) { } @@ -2930,5 +2932,8 @@ VisuGUI LightApp_Displayer* VisuGUI::displayer() { - return 0; + if( !myDisplayer ) + myDisplayer = new VisuGUI_Displayer( dynamic_cast( getApp()->activeStudy() ) ); + + return myDisplayer; } diff --git a/src/VISUGUI/VisuGUI_Displayer.cxx b/src/VISUGUI/VisuGUI_Displayer.cxx new file mode 100644 index 00000000..09c43537 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Displayer.cxx @@ -0,0 +1,207 @@ +// VISU VISUGUI : Displayer for VISU module +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Displayer.cxx +// Author : Alexander SOLOVYOV +// Module : VISU +// $Header: /home/server/cvs/VISU/VISU_SRC/src/VISUGUI/VisuGUI_Displayer.cxx + +#include "VisuGUI_Displayer.h" +#include "VisuGUI_Tools.h" +#include "VISU_Actor.h" + +#include +#include + +#include +#include +#include + +#include + +#include "VISU_ViewManager_i.hh" + +VisuGUI_Displayer::VisuGUI_Displayer( SalomeApp_Study* st ) +: LightApp_Displayer(), + myStudy( st ) +{ +} + +VisuGUI_Displayer::~VisuGUI_Displayer() +{ +} + +SALOME_Prs* VisuGUI_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame ) +{ + SALOME_Prs* prs = 0; + + SALOME_View* aViewFrame = theViewFrame ? theViewFrame : GetActiveView(); + + if ( myStudy && aViewFrame ) + { + CORBA::Object_var anObj = VISU::ClientSObjectToObject( myStudy->studyDS()->FindObjectID( entry.latin1() ) ); + if( CORBA::is_nil( anObj ) ) + return 0; + + SVTK_Viewer* vtk_viewer = dynamic_cast( aViewFrame ); + if( vtk_viewer ) + { + SVTK_ViewWindow* wnd = dynamic_cast( vtk_viewer->getViewManager()->getActiveView() ); + if( wnd ) + { + VISU::Prs3d_i* thePrs = dynamic_cast( VISU::GetServant( anObj ).in() ); + if( thePrs ) + { + buildPrs3d( wnd, thePrs ); + prs = LightApp_Displayer::buildPresentation( entry, aViewFrame ); + } + } + } + + SPlot2d_Viewer* plot_viewer = dynamic_cast( aViewFrame ); + if( plot_viewer ) + { + Plot2d_ViewWindow* wnd = dynamic_cast( plot_viewer->getViewManager()->getActiveView() ); + if( !wnd ) + return 0; + + VISU::Curve_i* aCurve = dynamic_cast( VISU::GetServant( anObj ).in() ); + SPlot2d_Prs* iprs = 0; + if( aCurve ) + iprs = buildCurve( wnd, aCurve ); + + VISU::Container_i* aCont = dynamic_cast( VISU::GetServant( anObj ).in() ); + if( aCont ) + iprs = buildContainer( wnd, aCont ); + + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant( anObj ).in() ); + if( aTable ) + iprs = buildTable( wnd, aTable ); + + if( iprs ) + prs = new SPlot2d_Prs( iprs ); + + if( prs ) + UpdatePrs( prs ); + } + } + return prs; +} + +void VisuGUI_Displayer::buildPrs3d( SVTK_ViewWindow* wnd, VISU::Prs3d_i* thePrs ) const +{ + VISU_Actor* newAct = VISU::FindActor( wnd, thePrs ); + if( !newAct ) + { + VISU_Actor* a = thePrs->CreateActor(); + if( a ) + newAct = a->GetParent(); + } + if( newAct && newAct ) + { + wnd->AddActor( newAct ); + wnd->Repaint(); + } +} + +bool VisuGUI_Displayer::addCurve( SPlot2d_Prs* prs, Plot2d_ViewWindow* wnd, VISU::Curve_i* c ) const +{ + if( !prs || !wnd || !c ) + return false; + + QString entry = c->GetSObject()->GetID(); + SPlot2d_Viewer* vv = dynamic_cast( wnd->getModel() ); + if( !vv ) + return false; + + SPlot2d_Curve* curve = vv->getCurveByIO( vv->FindIObject( entry.latin1() ) ); + if( !curve ) + { + curve = c->CreatePresentation(); + VISU::UpdateCurve( c, 0, curve, VISU::eDisplay ); + } + if( curve ) + prs->AddObject( curve ); + + return curve!=0; +} + +SPlot2d_Prs* VisuGUI_Displayer::buildCurve( Plot2d_ViewWindow* wnd, VISU::Curve_i* c ) const +{ + SPlot2d_Prs* prs = new SPlot2d_Prs(); + if( !addCurve( prs, wnd, c ) ) + { + delete prs; + prs = 0; + } + return prs; +} + +SPlot2d_Prs* VisuGUI_Displayer::buildContainer( Plot2d_ViewWindow* wnd, VISU::Container_i* c ) const +{ + SPlot2d_Prs* prs = new SPlot2d_Prs(); + + int nbCurves = c ? c->GetNbCurves() : 0; + for( int k=1; k<=nbCurves; k++ ) + { + VISU::Curve_i* theCurve = c->GetCurve( k ); + if( theCurve && theCurve->IsValid() ) + addCurve( prs, wnd, theCurve ); + } + if( prs->getCurves().count()==0 ) + { + delete prs; + prs = 0; + } + return prs; +} + +SPlot2d_Prs* VisuGUI_Displayer::buildTable( Plot2d_ViewWindow* wnd, VISU::Table_i* t ) const +{ + SPlot2d_Prs* prs = new SPlot2d_Prs(); + _PTR(SObject) TableSO = myStudy->studyDS()->FindObjectID( t->GetEntry().latin1() ); + + if( !TableSO ) + return prs; + + _PTR(ChildIterator) Iter = myStudy->studyDS()->NewChildIterator( TableSO ); + for( ; Iter->More(); Iter->Next() ) + { + CORBA::Object_var childObject = VISU::ClientSObjectToObject( Iter->Value() ); + if( !CORBA::is_nil( childObject ) ) + { + CORBA::Object_ptr aCurve = VISU::Curve::_narrow( childObject ); + if( !CORBA::is_nil( aCurve ) ) + { + VISU::Curve_i* theCurve = dynamic_cast(VISU::GetServant(aCurve).in()); + addCurve( prs, wnd, theCurve ); + } + } + } + if( prs->getCurves().count()==0 ) + { + delete prs; + prs = 0; + } + return prs; +} diff --git a/src/VISUGUI/VisuGUI_Displayer.h b/src/VISUGUI/VisuGUI_Displayer.h new file mode 100644 index 00000000..288b66b7 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Displayer.h @@ -0,0 +1,60 @@ +// VISU VISUGUI : Displayer for VISU module +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI_Displayer.h +// Author : Alexander SOLOVYOV +// Module : VISU +// $Header: /home/server/cvs/VISU/VISU_SRC/src/VISUGUI/VisuGUI_Displayer.h + +#ifndef VISUGUI_DISPLAYER_HEADER +#define VISUGUI_DISPLAYER_HEADER + +#include +#include +#include + +class SalomeApp_Study; +class SVTK_ViewWindow; +class Plot2d_ViewWindow; +class SPlot2d_Prs; + +class VisuGUI_Displayer : public LightApp_Displayer +{ +public: + VisuGUI_Displayer( SalomeApp_Study* ); + ~VisuGUI_Displayer(); + + virtual SALOME_Prs* buildPresentation( const QString&, SALOME_View* = 0 ); + +protected: + bool addCurve ( SPlot2d_Prs*, Plot2d_ViewWindow*, VISU::Curve_i* ) const; + virtual void buildPrs3d ( SVTK_ViewWindow*, VISU::Prs3d_i* ) const; + virtual SPlot2d_Prs* buildCurve ( Plot2d_ViewWindow*, VISU::Curve_i* ) const; + virtual SPlot2d_Prs* buildContainer( Plot2d_ViewWindow*, VISU::Container_i* ) const; + virtual SPlot2d_Prs* buildTable ( Plot2d_ViewWindow*, VISU::Table_i* ) const; + +private: + SalomeApp_Study* myStudy; +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_PopupTools.cxx b/src/VISUGUI/VisuGUI_PopupTools.cxx index 0e1c308f..39f904b0 100644 --- a/src/VISUGUI/VisuGUI_PopupTools.cxx +++ b/src/VISUGUI/VisuGUI_PopupTools.cxx @@ -49,7 +49,7 @@ QtxValue VisuGUI_Selection::param( const int ind, const QString& p ) const else if ( p == "nbTimeStamps" ) val = QtxValue( nbTimeStamps( ind ) ); else if ( p == "nbChildren" ) val = QtxValue( nbChildren( ind ) ); else if ( p == "nbNamedChildren") val = QtxValue( nbNamedChildren( ind ) ); -// else if ( p == "isVisible" ) val = QtxValue( isVisible( ind ) ); + else if ( p == "isVisible" ) val = QtxValue( isVisible( ind ) ); else if ( p == "isShrunk" ) val = QtxValue( isShrunk( ind ) ); else if ( p == "hasActor" ) val = QtxValue( hasActor( ind ) ); else if ( p == "isShading" ) val = QtxValue( isShading( ind ) ); diff --git a/src/VISUGUI/VisuGUI_Tools.cxx b/src/VISUGUI/VisuGUI_Tools.cxx index 9c3f7088..191964a2 100644 --- a/src/VISUGUI/VisuGUI_Tools.cxx +++ b/src/VISUGUI/VisuGUI_Tools.cxx @@ -960,7 +960,7 @@ namespace VISU int theDisplaying) { if ( theDisplaying == VISU::eErase ) { - if ( plotCurve ) + if ( plotCurve && aPlot ) aPlot->eraseCurve( plotCurve, false ); } else if ( theDisplaying == VISU::eDisplay || theDisplaying == VISU::eDisplayOnly ) { @@ -983,12 +983,14 @@ namespace VISU plotCurve->setColor( QColor( (int)(color.R*255.), (int)(color.G*255.), (int)(color.B*255.) ) ); } plotCurve->setAutoAssign( theCurve->IsAuto() ); - aPlot->displayCurve( plotCurve, false ); + if( aPlot ) + aPlot->displayCurve( plotCurve, false ); } else { Plot2d_Curve* crv = theCurve->CreatePresentation(); if ( crv ) { - aPlot->displayCurve( crv, false ); + if( aPlot ) + aPlot->displayCurve( crv, false ); theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); SALOMEDS::Color newColor; diff --git a/src/VISUGUI/VisuGUI_Tools.h b/src/VISUGUI/VisuGUI_Tools.h index 9bde033e..3f36c793 100644 --- a/src/VISUGUI/VisuGUI_Tools.h +++ b/src/VISUGUI/VisuGUI_Tools.h @@ -45,6 +45,8 @@ class SUIT_ViewWindow; class VISU_Actor; class SVTK_ViewWindow; class SPlot2d_Viewer; +class SPlot2d_Curve; +class Plot2d_ViewFrame; class CAM_Module; class LightApp_SelectionMgr; class SalomeApp_Study; @@ -178,6 +180,12 @@ namespace VISU { void CreatePlot( SalomeApp_Module* theModule, _PTR(SObject) theSobj ); + void UpdateCurve( VISU::Curve_i*, + Plot2d_ViewFrame* frame, + SPlot2d_Curve*, + int theDisplaying ); + //parameter frame may be 0, in this case there is only update without display/erase + // Others void CreateMesh (const SalomeApp_Module* theModule, const Handle(SALOME_InteractiveObject)& theIO); -- 2.39.2