Salome HOME
Join modifications from branch BR_DEBUG_3_2_0b1
[modules/gui.git] / src / SUIT / SUIT_ViewManager.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/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef SUIT_VIEWMANAGER_H
20 #define SUIT_VIEWMANAGER_H
21
22 #include "SUIT.h"
23 #include "SUIT_ViewWindow.h"
24 #include "SUIT_PopupClient.h"
25
26 #include <qobject.h>
27 #include <qptrvector.h>
28
29 class SUIT_Study;
30 class SUIT_Desktop;
31 class SUIT_ViewModel;
32
33 class QPopupMenu;
34
35 #ifdef WIN32
36 #pragma warning( disable:4251 )
37 #endif
38
39 class SUIT_EXPORT SUIT_ViewManager : public QObject, public SUIT_PopupClient
40 {
41   Q_OBJECT
42 public:
43   SUIT_ViewManager( SUIT_Study*,
44                     SUIT_Desktop*,
45                     SUIT_ViewModel* = 0 );
46   virtual ~SUIT_ViewManager();
47
48   virtual QString  popupClientType() const { return getType(); }
49   virtual void     contextMenuPopup( QPopupMenu* );
50   
51   void             setViewModel(SUIT_ViewModel* theViewModel);
52   SUIT_ViewModel*  getViewModel() { return myViewModel; }
53   
54   SUIT_Study*      study() const;
55
56   QString          getType() const; 
57   SUIT_ViewWindow* getActiveView() { return myActiveView; }
58   
59   int              getViewsCount() { return myViews.count(); }
60   QPtrVector<SUIT_ViewWindow> getViews() { return myViews; }  
61
62   QString          getTitle() const { return myTitle;}
63   void             setTitle(QString theTitle) { myTitle = theTitle; }
64
65   SUIT_ViewWindow* createViewWindow();
66
67   virtual void     setShown( const bool );
68
69 public slots:
70   void             createView();
71   void             closeAllViews();
72   
73 signals:
74   void             lastViewClosed(SUIT_ViewManager*);
75   void             deleteView(SUIT_ViewWindow*);
76   void             viewCreated(SUIT_ViewWindow*);
77   void             mousePress(SUIT_ViewWindow*, QMouseEvent*);
78   void             mouseRelease(SUIT_ViewWindow*, QMouseEvent*);
79   void             mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
80   void             mouseMove(SUIT_ViewWindow*, QMouseEvent*);
81   void             wheel(SUIT_ViewWindow*, QWheelEvent*);
82   void             keyPress(SUIT_ViewWindow*, QKeyEvent*);
83   void             keyRelease(SUIT_ViewWindow*, QKeyEvent*);
84   void             activated(SUIT_ViewManager*);
85   
86 protected slots:
87   void             onWindowActivated(SUIT_ViewWindow*);
88   void             onDeleteView(SUIT_ViewWindow* theView);
89   void             onMousePressed(SUIT_ViewWindow* theView, QMouseEvent* theEvent);
90   void             onDeleteStudy();
91
92 private slots:
93   void             onContextMenuRequested( QContextMenuEvent* e );
94   
95 protected:
96   /*! Inserts the View into internal Views Vector.\n
97    *  Returns true if view has been added successfully
98    */
99   virtual bool     insertView(SUIT_ViewWindow* theView);
100   
101   /*! Removes the View from internal Views Vector.*/
102   virtual void     removeView(SUIT_ViewWindow* theView);
103   
104   /*! Used to set unique name for the view.*/
105   virtual void     setViewName(SUIT_ViewWindow* theView);
106
107 protected:
108   SUIT_Desktop*               myDesktop;
109   SUIT_ViewModel*             myViewModel;
110   QPtrVector<SUIT_ViewWindow> myViews;
111   SUIT_ViewWindow*            myActiveView;
112
113   QString                     myTitle;
114   SUIT_Study*                 myStudy;
115 };
116
117 #ifdef WIN32
118 #pragma warning( default:4251 )
119 #endif
120
121 #endif