Salome HOME
Parent object parameter added to constructor.
[modules/gui.git] / src / SUIT / SUIT_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 SUIT_VIEWMODEL_H
20 #define SUIT_VIEWMODEL_H
21
22 #include "SUIT.h"
23 #include "SUIT_Desktop.h"
24 #include "SUIT_ViewWindow.h"
25 #include "SUIT_ViewManager.h"
26
27 #include <qobject.h>
28 #include <qcursor.h>
29
30 #ifdef WIN32
31 #pragma warning( disable:4251 )
32 #endif
33 /*!
34  * This object manages the definition and behaviour of a View Window. \n
35  * In case of definition of this object in an external lib that lib must \n
36  * have an exported function "createViewModel" which returns newly created \n
37  * instance of SUIT_ViewModel.
38  */
39 class SUIT_EXPORT SUIT_ViewModel : public QObject
40 {
41         Q_OBJECT
42 public:
43   enum HotOperation { PAN, ZOOM, ROTATE, FIT_AREA };
44
45   typedef QMap<HotOperation, Qt::ButtonState> StatesMap;
46   typedef QMap<HotOperation, Qt::ButtonState> ButtonsMap;
47   
48         SUIT_ViewModel();
49         virtual ~SUIT_ViewModel();
50
51         virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
52
53         virtual void      setViewManager(SUIT_ViewManager* theViewManager) { myViewManager = theViewManager; }
54         SUIT_ViewManager* getViewManager() const { return myViewManager; }
55
56   virtual QString   getType() const { return "SUIT_ViewModel"; }
57
58   virtual void      contextMenuPopup(QPopupMenu*) {}
59
60   static void       setHotButton(HotOperation theOper, Qt::ButtonState theState,
61                                                        Qt::ButtonState theButton);
62   static void       getHotButton(HotOperation theOper, Qt::ButtonState& theState,
63                                                        Qt::ButtonState& theButton);
64
65 protected:
66         SUIT_ViewManager* myViewManager;
67
68 public:
69   static StatesMap  myStateMap;
70   static ButtonsMap myButtonMap;
71 };
72
73 #ifdef WIN32
74 #pragma warning( default:4251 )
75 #endif
76
77 extern "C"
78 {
79   typedef SUIT_ViewModel* (*VIEWMODEL_CREATE_FUNC)();
80 }
81
82 #define VIEWMODEL_CREATE_NAME   "createViewModel"
83
84 #endif