1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
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.
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.
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
17 // See http://www.salome-platform.org/
19 // SUIT_ViewModel.cxx: implementation of the SUIT_ViewModel class.
22 #include "SUIT_ViewModel.h"
24 SUIT_ViewModel::StatesMap SUIT_ViewModel::myStateMap;
25 SUIT_ViewModel::ButtonsMap SUIT_ViewModel::myButtonMap;
27 static bool isInitialized = false;
30 SUIT_ViewModel::SUIT_ViewModel()
35 SUIT_ViewModel::myStateMap[ZOOM] = Qt::ControlButton;
36 SUIT_ViewModel::myButtonMap[ZOOM] = Qt::LeftButton;
38 SUIT_ViewModel::myStateMap[PAN] = Qt::ControlButton;
39 SUIT_ViewModel::myButtonMap[PAN] = Qt::MidButton;
41 SUIT_ViewModel::myStateMap[ROTATE] = Qt::ControlButton;
42 SUIT_ViewModel::myButtonMap[ROTATE] = Qt::RightButton;
44 SUIT_ViewModel::myStateMap[FIT_AREA] = Qt::ControlButton;
45 SUIT_ViewModel::myButtonMap[FIT_AREA] = Qt::RightButton;
51 SUIT_ViewModel::~SUIT_ViewModel()
55 /*!Create new instance of view window on desktop \a theDesktop.
56 *\retval SUIT_ViewWindow* - created view window pointer.
58 SUIT_ViewWindow* SUIT_ViewModel::createView(SUIT_Desktop* theDesktop)
60 return new SUIT_ViewWindow(theDesktop);
64 *\param theOper - hot operation
65 *\param theState - adding state to state map operations.
66 *\param theButton - adding state to button map operations.
68 void SUIT_ViewModel::setHotButton(HotOperation theOper, Qt::ButtonState theState,
69 Qt::ButtonState theButton)
71 myStateMap[theOper] = theState;
72 myButtonMap[theOper] = theButton;
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.
80 void SUIT_ViewModel::getHotButton(HotOperation theOper, Qt::ButtonState& theState,
81 Qt::ButtonState& theButton)
83 theState = myStateMap[theOper];
84 theButton = myButtonMap[theOper];