Salome HOME
Initial version
[modules/gui.git] / src / SUIT / SUIT_ViewModel.cxx
1 // SUIT_ViewModel.cxx: implementation of the SUIT_ViewModel class.
2 //
3 //////////////////////////////////////////////////////////////////////
4
5 #include "SUIT_ViewModel.h"
6
7 //////////////////////////////////////////////////////////////////////
8 // Construction/Destruction
9 //////////////////////////////////////////////////////////////////////
10 SUIT_ViewModel::StatesMap SUIT_ViewModel::myStateMap;
11 SUIT_ViewModel::ButtonsMap SUIT_ViewModel::myButtonMap;
12
13 static bool isInitialized = false;
14
15 SUIT_ViewModel::SUIT_ViewModel()
16 {
17   if (!isInitialized) {
18     isInitialized = true;
19
20     SUIT_ViewModel::myStateMap[ZOOM]  = Qt::ControlButton;
21     SUIT_ViewModel::myButtonMap[ZOOM] = Qt::LeftButton;
22
23     SUIT_ViewModel::myStateMap[PAN]   = Qt::ControlButton;
24     SUIT_ViewModel::myButtonMap[PAN]  = Qt::MidButton;
25
26     SUIT_ViewModel::myStateMap[ROTATE]  = Qt::ControlButton;
27     SUIT_ViewModel::myButtonMap[ROTATE] = Qt::RightButton;
28
29     SUIT_ViewModel::myStateMap[FIT_AREA]  = Qt::ControlButton;
30     SUIT_ViewModel::myButtonMap[FIT_AREA] = Qt::RightButton;
31   }
32   myViewManager = 0;
33 }
34
35 SUIT_ViewModel::~SUIT_ViewModel()
36 {
37 }
38
39 //***************************************************************
40 SUIT_ViewWindow* SUIT_ViewModel::createView(SUIT_Desktop* theDesktop)
41 {
42   return new SUIT_ViewWindow(theDesktop);
43 }
44
45 //*********************************************************************
46 void SUIT_ViewModel::setHotButton(HotOperation theOper, Qt::ButtonState theState,
47              Qt::ButtonState theButton)
48 {
49   myStateMap[theOper]  = theState;
50   myButtonMap[theOper] = theButton;
51 }
52
53 //*********************************************************************
54 void SUIT_ViewModel::getHotButton(HotOperation theOper, Qt::ButtonState& theState,
55              Qt::ButtonState& theButton)
56 {
57   theState  = myStateMap[theOper];
58   theButton = myButtonMap[theOper];
59 }