Salome HOME
Using files from package LightApp instead of files from package SalomeApp
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Displayer.cxx
1 //  SMESH SMESHGUI : Displayer for SMESH module
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
21 //
22 //
23 //
24 //  File   : SMESHGUI_Displayer.cxx
25 //  Author : Alexander SOLOVYOV
26 //  Module : SMESH
27 //  $Header: /home/server/cvs/SMESH/SMESH_SRC/src/SMESHGUI/SMESHGUI_Displayer.cxx
28
29 #include "SMESHGUI_Displayer.h"
30 #include "SMESHGUI_VTKUtils.h"
31
32 #include <SalomeApp_Study.h>
33 #include <SVTK_ViewModel.h>
34 #include <SVTK_ViewWindow.h>
35
36 SMESHGUI_Displayer::SMESHGUI_Displayer( SalomeApp_Study* st )
37 : LightApp_Displayer(),
38   myStudy( st )
39 {
40 }
41
42 SMESHGUI_Displayer::~SMESHGUI_Displayer()
43 {
44 }
45
46 SALOME_Prs* SMESHGUI_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
47 {
48   SALOME_Prs* prs = 0;
49
50   SALOME_View* aViewFrame = theViewFrame ? theViewFrame : GetActiveView();
51
52   if ( aViewFrame )
53   {
54     SVTK_Viewer* vtk_viewer = dynamic_cast<SVTK_Viewer*>( aViewFrame );
55     if( vtk_viewer )
56     {
57       SUIT_ViewWindow* wnd = vtk_viewer->getViewManager()->getActiveView();
58       SMESH_Actor* anActor = SMESH::FindActorByEntry( wnd, entry.latin1() );
59       if( !anActor )
60         anActor = SMESH::CreateActor( myStudy->studyDS(), entry.latin1(), true );
61       if( anActor )
62       {
63         SMESH::DisplayActor( wnd, anActor );
64         prs = LightApp_Displayer::buildPresentation( entry.latin1(), aViewFrame );
65       }
66       if( prs )
67         UpdatePrs( prs );
68       else if( anActor )
69         SMESH::RemoveActor( vtk_viewer->getViewManager()->getActiveView(), anActor );
70     }
71   }
72
73   return prs;
74 }