Salome HOME
Synchronize adm files
[samples/atomsolv.git] / src / ATOMSOLVGUI / ATOMSOLVGUI_Selection.cxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "ATOMSOLVGUI_Selection.h"
21
22 #include <LightApp_DataOwner.h>
23 #include <LightApp_Displayer.h>
24 #include <SalomeApp_Study.h>
25
26 #include <OCCViewer_ViewModel.h>
27
28 #include <SUIT_Session.h>
29 #include <SUIT_ViewWindow.h>
30 #include <SUIT_ViewManager.h>
31 #include <SUIT_ViewModel.h>
32
33 #include <SALOMEDSClient_SObject.hxx>
34 #include <SALOMEDSClient_Study.hxx>
35
36 #include <SALOME_Prs.h>
37 #include <SALOME_InteractiveObject.hxx>
38
39 #include <SVTK_Prs.h>
40 #include <SALOME_Actor.h>
41
42 #include <SVTK_ViewModel.h>
43
44
45 // VTK Includes
46 #include <vtkActorCollection.h>
47
48 ATOMSOLVGUI_Selection::ATOMSOLVGUI_Selection()
49 {
50 }
51
52 ATOMSOLVGUI_Selection::~ATOMSOLVGUI_Selection()
53 {
54 }
55
56 QVariant ATOMSOLVGUI_Selection::parameter( const int ind, const QString& p ) const
57 {
58   if ( p == "displaymode" )
59     return QVariant( displayMode( ind ) );
60   
61   return LightApp_Selection::parameter( ind, p );
62 }
63
64 QString ATOMSOLVGUI_Selection::displayMode( const int index ) const
65 {
66   SALOME_View* view = LightApp_Displayer::GetActiveView();
67   QString viewType = activeViewType();
68   if ( view && viewType == SVTK_Viewer::Type() ) {
69     if ( SALOME_Prs* prs = view->CreatePrs( entry( index ).toLatin1() ) ) {
70       SVTK_Prs* vtkPrs = dynamic_cast<SVTK_Prs*>( prs );
71       vtkActorCollection* lst = vtkPrs ? vtkPrs->GetObjects() : 0;
72       if ( lst ) {
73         lst->InitTraversal();
74         vtkActor* actor = lst->GetNextActor();
75         if ( actor ) {
76           SALOME_Actor* salActor = dynamic_cast<SALOME_Actor*>( actor );
77           if ( salActor ) {
78             int dm = salActor->GetRepresentation();
79             if ( dm == 0 )
80               return "Points";
81             else if ( dm == 1 )
82               return "Wireframe";
83             else if ( dm == 2 )
84               return "Surface";
85           } // if ( salome actor )
86         } // if ( actor )
87       } // if ( lst == vtkPrs->GetObjects() )
88     }
89   }
90   return "Undefined";
91 }
92