Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[modules/gui.git] / src / SUIT / SUIT_ViewModel.cxx
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 // SUIT_ViewModel.cxx: implementation of the SUIT_ViewModel class.
20 //
21
22 #include "SUIT_ViewModel.h"
23
24 SUIT_ViewModel::StatesMap SUIT_ViewModel::myStateMap;
25 SUIT_ViewModel::ButtonsMap SUIT_ViewModel::myButtonMap;
26
27 static bool isInitialized = false;
28
29 /*!Constructor.*/
30 SUIT_ViewModel::SUIT_ViewModel()
31 {
32   if (!isInitialized) {
33     isInitialized = true;
34
35     SUIT_ViewModel::myStateMap[ZOOM]  = Qt::ControlButton;
36     SUIT_ViewModel::myButtonMap[ZOOM] = Qt::LeftButton;
37
38     SUIT_ViewModel::myStateMap[PAN]   = Qt::ControlButton;
39     SUIT_ViewModel::myButtonMap[PAN]  = Qt::MidButton;
40
41     SUIT_ViewModel::myStateMap[ROTATE]  = Qt::ControlButton;
42     SUIT_ViewModel::myButtonMap[ROTATE] = Qt::RightButton;
43
44     SUIT_ViewModel::myStateMap[FIT_AREA]  = Qt::ControlButton;
45     SUIT_ViewModel::myButtonMap[FIT_AREA] = Qt::RightButton;
46   }
47   myViewManager = 0;
48 }
49
50 /*!Destructor..*/
51 SUIT_ViewModel::~SUIT_ViewModel()
52 {
53 }
54
55 /*!Create new instance of view window on desktop \a theDesktop.
56  *\retval SUIT_ViewWindow* - created view window pointer.
57  */
58 SUIT_ViewWindow* SUIT_ViewModel::createView(SUIT_Desktop* theDesktop)
59 {
60   return new SUIT_ViewWindow(theDesktop);
61 }
62
63 /*! Sets hot button
64  *\param theOper - hot operation
65  *\param theState - adding state to state map operations.
66  *\param theButton - adding state to button map operations.
67  */
68 void SUIT_ViewModel::setHotButton(HotOperation theOper, Qt::ButtonState theState,
69                                   Qt::ButtonState theButton)
70 {
71   myStateMap[theOper]  = theState;
72   myButtonMap[theOper] = theButton;
73 }
74
75 /*! Gets hot button for operation \a theOper.
76  *\param theOper - input hot operation
77  *\param theState - output state from state map operations.
78  *\param theButton - output state from button map operations.
79 */
80 void SUIT_ViewModel::getHotButton(HotOperation theOper, Qt::ButtonState& theState,
81                                   Qt::ButtonState& theButton)
82 {
83   theState  = myStateMap[theOper];
84   theButton = myButtonMap[theOper];
85 }