]> SALOME platform Git repositories - modules/gui.git/blob - src/SUIT/SUIT_ViewModel.cxx
Salome HOME
4061961857d147fc5efe7d862f7c73f01d7a8e96
[modules/gui.git] / src / SUIT / SUIT_ViewModel.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 //  This library is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU Lesser General Public
8 //  License as published by the Free Software Foundation; either
9 //  version 2.1 of the License.
10 //
11 //  This library is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 //  Lesser General Public License for more details.
15 //
16 //  You should have received a copy of the GNU Lesser General Public
17 //  License along with this library; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 // SUIT_ViewModel.cxx: implementation of the SUIT_ViewModel class.
23 //
24 #include "SUIT_ViewModel.h"
25 #include "SUIT_ViewWindow.h"
26
27 SUIT_ViewModel::StatesMap SUIT_ViewModel::myStateMap;
28 SUIT_ViewModel::ButtonsMap SUIT_ViewModel::myButtonMap;
29
30 static bool isInitialized = false;
31
32 /*!Constructor.*/
33 SUIT_ViewModel::SUIT_ViewModel()
34 {
35   if ( !isInitialized )
36   {
37     isInitialized = true;
38
39     SUIT_ViewModel::myStateMap[ZOOM]  = Qt::ControlModifier;
40     SUIT_ViewModel::myButtonMap[ZOOM] = Qt::LeftButton;
41
42     SUIT_ViewModel::myStateMap[PAN]   = Qt::ControlModifier;
43     SUIT_ViewModel::myButtonMap[PAN]  = Qt::MidButton;
44
45     SUIT_ViewModel::myStateMap[ROTATE]  = Qt::ControlModifier;
46     SUIT_ViewModel::myButtonMap[ROTATE] = Qt::RightButton;
47
48     SUIT_ViewModel::myStateMap[FIT_AREA]  = Qt::ControlModifier;
49     SUIT_ViewModel::myButtonMap[FIT_AREA] = Qt::RightButton;
50   }
51   myViewManager = 0;
52 }
53
54 /*!Destructor..*/
55 SUIT_ViewModel::~SUIT_ViewModel()
56 {
57 }
58
59 /*!Create new instance of view window on desktop \a theDesktop.
60  *\retval SUIT_ViewWindow* - created view window pointer.
61  */
62 SUIT_ViewWindow* SUIT_ViewModel::createView(SUIT_Desktop* theDesktop)
63 {
64   return new SUIT_ViewWindow(theDesktop);
65 }
66
67 /*!Set view manager.
68   \param theViewManager view manager
69  */
70 void SUIT_ViewModel::setViewManager(SUIT_ViewManager* theViewManager)
71 {
72   myViewManager = theViewManager;
73 }
74
75 /*!Get view manager.
76   \return view manager
77  */
78 SUIT_ViewManager* SUIT_ViewModel::getViewManager() const
79 {
80   return myViewManager;
81 }
82
83 /*! Sets hot button
84  *\param theOper - hot operation
85  *\param theState - adding state to state map operations.
86  *\param theButton - adding state to button map operations.
87  */
88 void SUIT_ViewModel::setHotButton( HotOperation theOper, Qt::KeyboardModifier theState, Qt::MouseButton theButton )
89 {
90   myStateMap[theOper]  = theState;
91   myButtonMap[theOper] = theButton;
92 }
93
94 /*! Gets hot button for operation \a theOper.
95  *\param theOper - input hot operation
96  *\param theState - output state from state map operations.
97  *\param theButton - output state from button map operations.
98 */
99 void SUIT_ViewModel::getHotButton( HotOperation theOper, Qt::KeyboardModifier& theState, Qt::MouseButton& theButton )
100 {
101   theState  = myStateMap[theOper];
102   theButton = myButtonMap[theOper];
103 }