Salome HOME
correct previous integration (Porting to Python 2.6)
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_Displayer.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SMESH SMESHGUI : Displayer for SMESH module
23 // File   : SMESHGUI_Displayer.cxx
24 // Author : Alexander SOLOVYOV, Open CASCADE S.A.S.
25 // SMESH includes
26 //
27 #include "SMESHGUI_Displayer.h"
28
29 #include "SMESHGUI_VTKUtils.h"
30
31 // SALOME GUI includes
32 #include <SalomeApp_Study.h>
33 #include <SalomeApp_Application.h>
34 #include <SUIT_ViewManager.h>
35 #include <SVTK_ViewModel.h>
36 #include <SVTK_ViewWindow.h>
37
38 SMESHGUI_Displayer::SMESHGUI_Displayer( SalomeApp_Application* app )
39 : LightApp_Displayer(),
40   myApp( app )
41 {
42 }
43
44 SMESHGUI_Displayer::~SMESHGUI_Displayer()
45 {
46 }
47
48 SALOME_Prs* SMESHGUI_Displayer::buildPresentation( const QString& entry, SALOME_View* theViewFrame )
49 {
50   SALOME_Prs* prs = 0;
51
52   SALOME_View* aViewFrame = theViewFrame ? theViewFrame : GetActiveView();
53
54   if ( aViewFrame )
55   {
56     SVTK_Viewer* vtk_viewer = dynamic_cast<SVTK_Viewer*>( aViewFrame );
57     if( vtk_viewer )
58     {
59       SUIT_ViewWindow* wnd = vtk_viewer->getViewManager()->getActiveView();
60       SMESH_Actor* anActor = SMESH::FindActorByEntry( wnd, entry.toLatin1().data() );
61       if( !anActor )
62         anActor = SMESH::CreateActor( study()->studyDS(), entry.toLatin1().data(), true );
63       if( anActor )
64       {
65         SMESH::DisplayActor( wnd, anActor );
66         prs = LightApp_Displayer::buildPresentation( entry.toLatin1().data(), aViewFrame );
67       }
68       if( prs )
69         UpdatePrs( prs );
70       else if( anActor )
71         SMESH::RemoveActor( vtk_viewer->getViewManager()->getActiveView(), anActor );
72     }
73   }
74
75   return prs;
76 }
77
78 SalomeApp_Study* SMESHGUI_Displayer::study() const
79 {
80   return dynamic_cast<SalomeApp_Study*>( myApp->activeStudy() );
81 }
82
83 bool SMESHGUI_Displayer::canBeDisplayed( const QString& /*entry*/, const QString& viewer_type ) const
84 {
85   return viewer_type==SVTK_Viewer::Type();
86 }