Salome HOME
Merge from OCC_development_generic_2006
[modules/gui.git] / src / SVTK / SVTK_ViewModel.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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/
18 //
19 #ifndef SVTK_VIEWMODEL_H
20 #define SVTK_VIEWMODEL_H
21
22 #include "SVTK.h"
23 #include "SUIT_ViewModel.h"
24 #include "SVTK_ViewModelBase.h"
25
26 #include "SALOME_Prs.h"
27 #include "SALOME_InteractiveObject.hxx"
28
29 #include <qcolor.h>
30
31 class SVTK_ViewWindow;
32
33 //! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View 
34 class SVTK_EXPORT SVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View 
35 {
36   Q_OBJECT;
37
38 public:
39   typedef SVTK_ViewWindow TViewWindow;
40   
41   //! Define string representation of the viewer type
42   static QString Type() { return "VTKViewer"; }
43
44   SVTK_Viewer();
45   virtual ~SVTK_Viewer();
46
47   //! See #SUIT_ViewModel::createView
48   virtual SUIT_ViewWindow* createView(SUIT_Desktop*);
49
50   //! See #SUIT_ViewModel::createView
51   virtual void setViewManager(SUIT_ViewManager* theViewManager);
52
53   //! See #SUIT_ViewModel::contextMenuPopup
54   virtual void contextMenuPopup( QPopupMenu* );
55
56   //! See #SUIT_ViewModel::getType
57   virtual QString getType() const { return Type(); }
58
59   //! Get background color of the viewer
60   QColor backgroundColor() const;
61
62   //! Set background color to the viewer
63   void setBackgroundColor( const QColor& );
64
65   //! Get size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
66   int trihedronSize() const;
67
68   //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
69   void setTrihedronSize( const int );
70
71 public:
72   void enableSelection(bool isEnabled);
73   bool isSelectionEnabled() const { return mySelectionEnabled; }
74
75   void enableMultiselection(bool isEnable);
76   bool isMultiSelectionEnabled() const { return myMultiSelectionEnabled; }
77
78   int  getSelectionCount() const;
79
80   /* Reimplemented from SALOME_View */
81
82   //! See #SALOME_View::Display( const SALOME_Prs* )
83   void Display( const SALOME_VTKPrs* ); 
84
85   //! See #SALOME_View::Erase( const SALOME_VTKPrs*, const bool = false )
86   void Erase( const SALOME_VTKPrs*, const bool = false );
87
88   //! See #SALOME_View::EraseAll( const bool = false )
89   void EraseAll( const bool = false );
90
91   //! See #SALOME_View::CreatePrs( const char* entry = 0 )
92   SALOME_Prs* CreatePrs( const char* entry = 0 );
93
94   //! See #SALOME_View::BeforeDisplay( SALOME_Displayer* d )
95   virtual void BeforeDisplay( SALOME_Displayer* d );
96
97   //! See #SALOME_View::AfterDisplay( SALOME_Displayer* d )
98   virtual void AfterDisplay( SALOME_Displayer* d );
99
100   //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& )
101   virtual bool isVisible( const Handle(SALOME_InteractiveObject)& );
102
103   //! See #SALOME_View::Repaint()
104   virtual void Repaint();
105
106 protected slots:
107   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
108   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
109   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
110
111   void onDumpView();
112   void onShowToolbar();
113   void onChangeBgColor();
114
115 private:
116   QColor myBgColor;
117   int    myTrihedronSize;
118   bool   mySelectionEnabled;
119   bool   myMultiSelectionEnabled;
120 };
121
122 #endif