Salome HOME
add necessary include <qpixmap.h>
[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 SUIT_ViewModel::StatesMap SUIT_ViewModel::myStateMap;
8 SUIT_ViewModel::ButtonsMap SUIT_ViewModel::myButtonMap;
9
10 static bool isInitialized = false;
11
12 /*!Constructor.*/
13 SUIT_ViewModel::SUIT_ViewModel()
14 {
15   if (!isInitialized) {
16     isInitialized = true;
17
18     SUIT_ViewModel::myStateMap[ZOOM]  = Qt::ControlButton;
19     SUIT_ViewModel::myButtonMap[ZOOM] = Qt::LeftButton;
20
21     SUIT_ViewModel::myStateMap[PAN]   = Qt::ControlButton;
22     SUIT_ViewModel::myButtonMap[PAN]  = Qt::MidButton;
23
24     SUIT_ViewModel::myStateMap[ROTATE]  = Qt::ControlButton;
25     SUIT_ViewModel::myButtonMap[ROTATE] = Qt::RightButton;
26
27     SUIT_ViewModel::myStateMap[FIT_AREA]  = Qt::ControlButton;
28     SUIT_ViewModel::myButtonMap[FIT_AREA] = Qt::RightButton;
29   }
30   myViewManager = 0;
31 }
32
33 /*!Destructor..*/
34 SUIT_ViewModel::~SUIT_ViewModel()
35 {
36 }
37
38 /*!Create new instance of view window on desktop \a theDesktop.
39  *\retval SUIT_ViewWindow* - created view window pointer.
40  */
41 SUIT_ViewWindow* SUIT_ViewModel::createView(SUIT_Desktop* theDesktop)
42 {
43   return new SUIT_ViewWindow(theDesktop);
44 }
45
46 /*! Sets hot button
47  *\param theOper - hot operation
48  *\param theState - adding state to state map operations.
49  *\param theButton - adding state to button map operations.
50  */
51 void SUIT_ViewModel::setHotButton(HotOperation theOper, Qt::ButtonState theState,
52                                   Qt::ButtonState theButton)
53 {
54   myStateMap[theOper]  = theState;
55   myButtonMap[theOper] = theButton;
56 }
57
58 /*! Gets hot button for operation \a theOper.
59  *\param theOper - input hot operation
60  *\param theState - output state from state map operations.
61  *\param theButton - output state from button map operations.
62 */
63 void SUIT_ViewModel::getHotButton(HotOperation theOper, Qt::ButtonState& theState,
64                                   Qt::ButtonState& theButton)
65 {
66   theState  = myStateMap[theOper];
67   theButton = myButtonMap[theOper];
68 }