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