Salome HOME
PAL10125 - by double click on reference original object becomes selected
[modules/gui.git] / src / SUIT / SUIT_ViewModel.h
1 #ifndef SUIT_VIEWMODEL_H
2 #define SUIT_VIEWMODEL_H
3
4 #include "SUIT.h"
5 #include "SUIT_Desktop.h"
6 #include "SUIT_ViewWindow.h"
7 #include "SUIT_ViewManager.h"
8
9 #include <qobject.h>
10 #include <qcursor.h>
11
12 #ifdef WIN32
13 #pragma warning( disable:4251 )
14 #endif
15 /*!
16  * This object manages the definition and behaviour of a View Window. \n
17  * In case of definition of this object in an external lib that lib must \n
18  * have an exported function "createViewModel" which returns newly created \n
19  * instance of SUIT_ViewModel.
20  */
21 class SUIT_EXPORT SUIT_ViewModel : public QObject
22 {
23         Q_OBJECT
24 public:
25   enum HotOperation { PAN, ZOOM, ROTATE, FIT_AREA };
26
27   typedef QMap<HotOperation, Qt::ButtonState> StatesMap;
28   typedef QMap<HotOperation, Qt::ButtonState> ButtonsMap;
29   
30         SUIT_ViewModel();
31         virtual ~SUIT_ViewModel();
32
33         virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop);
34
35         virtual void      setViewManager(SUIT_ViewManager* theViewManager) { myViewManager = theViewManager; }
36         SUIT_ViewManager* getViewManager() const { return myViewManager; }
37
38   virtual QString   getType() const { return "SUIT_ViewModel"; }
39
40   virtual void      contextMenuPopup(QPopupMenu*) {}
41
42   static void       setHotButton(HotOperation theOper, Qt::ButtonState theState,
43                                                        Qt::ButtonState theButton);
44   static void       getHotButton(HotOperation theOper, Qt::ButtonState& theState,
45                                                        Qt::ButtonState& theButton);
46
47 protected:
48         SUIT_ViewManager* myViewManager;
49
50 public:
51   static StatesMap  myStateMap;
52   static ButtonsMap myButtonMap;
53 };
54
55 #ifdef WIN32
56 #pragma warning( default:4251 )
57 #endif
58
59 extern "C"
60 {
61   typedef SUIT_ViewModel* (*VIEWMODEL_CREATE_FUNC)();
62 }
63
64 #define VIEWMODEL_CREATE_NAME   "createViewModel"
65
66 #endif