1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SUIT_ViewModel.cxx: implementation of the SUIT_ViewModel class.
25 #include "SUIT_ViewModel.h"
26 #include "SUIT_ViewWindow.h"
28 SUIT_ViewModel::InteractionStyle2StatesMap SUIT_ViewModel::myStateMap;
29 SUIT_ViewModel::InteractionStyle2ButtonsMap SUIT_ViewModel::myButtonMap;
31 static bool isInitialized = false;
34 SUIT_ViewModel::SUIT_ViewModel()
40 // standard interaction style
41 SUIT_ViewModel::myStateMap[STANDARD][ZOOM] = Qt::ControlModifier;
42 SUIT_ViewModel::myButtonMap[STANDARD][ZOOM] = Qt::LeftButton;
44 SUIT_ViewModel::myStateMap[STANDARD][PAN] = Qt::ControlModifier;
45 SUIT_ViewModel::myButtonMap[STANDARD][PAN] = Qt::MidButton;
47 SUIT_ViewModel::myStateMap[STANDARD][ROTATE] = Qt::ControlModifier;
48 SUIT_ViewModel::myButtonMap[STANDARD][ROTATE] = Qt::RightButton;
50 SUIT_ViewModel::myStateMap[STANDARD][FIT_AREA] = Qt::ControlModifier;
51 SUIT_ViewModel::myButtonMap[STANDARD][FIT_AREA] = Qt::RightButton;
53 // "key free" interaction style
54 SUIT_ViewModel::myStateMap[KEY_FREE][ZOOM] = Qt::NoModifier;
55 SUIT_ViewModel::myButtonMap[KEY_FREE][ZOOM] = Qt::RightButton;
57 SUIT_ViewModel::myStateMap[KEY_FREE][PAN] = Qt::NoModifier;
58 SUIT_ViewModel::myButtonMap[KEY_FREE][PAN] = Qt::MidButton;
60 SUIT_ViewModel::myStateMap[KEY_FREE][ROTATE] = Qt::NoModifier;
61 SUIT_ViewModel::myButtonMap[KEY_FREE][ROTATE] = Qt::LeftButton;
63 SUIT_ViewModel::myStateMap[KEY_FREE][FIT_AREA] = Qt::NoModifier; // unused
64 SUIT_ViewModel::myButtonMap[KEY_FREE][FIT_AREA] = Qt::NoButton; // unused
70 SUIT_ViewModel::~SUIT_ViewModel()
74 /*!Create new instance of view window on desktop \a theDesktop.
75 *\retval SUIT_ViewWindow* - created view window pointer.
77 SUIT_ViewWindow* SUIT_ViewModel::createView(SUIT_Desktop* theDesktop)
79 return new SUIT_ViewWindow(theDesktop);
83 \param theViewManager view manager
85 void SUIT_ViewModel::setViewManager(SUIT_ViewManager* theViewManager)
87 myViewManager = theViewManager;
93 SUIT_ViewManager* SUIT_ViewModel::getViewManager() const
99 *\param theOper - hot operation
100 *\param theState - adding state to state map operations.
101 *\param theButton - adding state to button map operations.
103 void SUIT_ViewModel::setHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
104 Qt::KeyboardModifiers theState, Qt::MouseButtons theButton )
106 myStateMap[theInteractionStyle][theOper] = theState;
107 myButtonMap[theInteractionStyle][theOper] = theButton;
110 /*! Gets hot button for operation \a theOper.
111 *\param theOper - input hot operation
112 *\param theState - output state from state map operations.
113 *\param theButton - output state from button map operations.
115 void SUIT_ViewModel::getHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
116 Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton )
118 theState = myStateMap[theInteractionStyle][theOper];
119 theButton = myButtonMap[theInteractionStyle][theOper];