Salome HOME
6d205706eb1682a877ac30e16b9cb5ace5655032
[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 <SalomeApp_Application.h>
34 #include <SVTK_ViewModel.h>
35 #include <SVTK_ViewWindow.h>
36
37 SMESHGUI_Displayer::SMESHGUI_Displayer( SalomeApp_Application* app )
38 : LightApp_Displayer(),
39   myApp( app )
40 {
41 }
42
43 SMESHGUI_Displayer::~SMESHGUI_Displayer()
44 {
45 }
46
47 SALOME_Prs* SMESHGUI_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
48 {
49   SALOME_Prs* prs = 0;
50
51   SALOME_View* aViewFrame = theViewFrame ? theViewFrame : GetActiveView();
52
53   if ( aViewFrame )
54   {
55     SVTK_Viewer* vtk_viewer = dynamic_cast<SVTK_Viewer*>( aViewFrame );
56     if( vtk_viewer )
57     {
58       SUIT_ViewWindow* wnd = vtk_viewer->getViewManager()->getActiveView();
59       SMESH_Actor* anActor = SMESH::FindActorByEntry( wnd, entry.latin1() );
60       if( !anActor )
61         anActor = SMESH::CreateActor( study()->studyDS(), entry.latin1(), true );
62       if( anActor )
63       {
64         SMESH::DisplayActor( wnd, anActor );
65         prs = LightApp_Displayer::buildPresentation( entry.latin1(), aViewFrame );
66       }
67       if( prs )
68         UpdatePrs( prs );
69       else if( anActor )
70         SMESH::RemoveActor( vtk_viewer->getViewManager()->getActiveView(), anActor );
71     }
72   }
73
74   return prs;
75 }
76
77 SalomeApp_Study* SMESHGUI_Displayer::study() const
78 {
79   return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
80 }