--- /dev/null
+// 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 <SVTK_ViewModel.h>
+#include <SVTK_ViewWindow.h>
+
+#include <SPlot2d_ViewModel.h>
+#include <SPlot2d_Prs.h>
+#include <Plot2d_ViewWindow.h>
+
+#include <SalomeApp_Study.h>
+
+#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<SVTK_Viewer*>( aViewFrame );
+ if( vtk_viewer )
+ {
+ SVTK_ViewWindow* wnd = dynamic_cast<SVTK_ViewWindow*>( vtk_viewer->getViewManager()->getActiveView() );
+ if( wnd )
+ {
+ VISU::Prs3d_i* thePrs = dynamic_cast<VISU::Prs3d_i*>( VISU::GetServant( anObj ).in() );
+ if( thePrs )
+ {
+ buildPrs3d( wnd, thePrs );
+ prs = LightApp_Displayer::buildPresentation( entry, aViewFrame );
+ }
+ }
+ }
+
+ SPlot2d_Viewer* plot_viewer = dynamic_cast<SPlot2d_Viewer*>( aViewFrame );
+ if( plot_viewer )
+ {
+ Plot2d_ViewWindow* wnd = dynamic_cast<Plot2d_ViewWindow*>( plot_viewer->getViewManager()->getActiveView() );
+ if( !wnd )
+ return 0;
+
+ VISU::Curve_i* aCurve = dynamic_cast<VISU::Curve_i*>( VISU::GetServant( anObj ).in() );
+ SPlot2d_Prs* iprs = 0;
+ if( aCurve )
+ iprs = buildCurve( wnd, aCurve );
+
+ VISU::Container_i* aCont = dynamic_cast<VISU::Container_i*>( VISU::GetServant( anObj ).in() );
+ if( aCont )
+ iprs = buildContainer( wnd, aCont );
+
+ VISU::Table_i* aTable = dynamic_cast<VISU::Table_i*>(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<SPlot2d_Viewer*>( 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::Curve_i*>(VISU::GetServant(aCurve).in());
+ addCurve( prs, wnd, theCurve );
+ }
+ }
+ }
+ if( prs->getCurves().count()==0 )
+ {
+ delete prs;
+ prs = 0;
+ }
+ return prs;
+}
--- /dev/null
+// 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 <LightApp_Displayer.h>
+#include <VISU_Prs3d_i.hh>
+#include <VISU_Table_i.hh>
+
+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