X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSUIT%2FSUIT_ViewModel.cxx;h=5e74e75beafbbb161dee9b3c594063845ce4598d;hb=efe3cdefadc31ad9cdaa9fd7fc368e2931cebdf1;hp=49bef3db856718c439122bed2f9d9d81bac73696;hpb=aa05f2a1b23a54321ea7248ae9ac3463652c734e;p=modules%2Fgui.git diff --git a/src/SUIT/SUIT_ViewModel.cxx b/src/SUIT/SUIT_ViewModel.cxx index 49bef3db8..5e74e75be 100755 --- a/src/SUIT/SUIT_ViewModel.cxx +++ b/src/SUIT/SUIT_ViewModel.cxx @@ -1,48 +1,67 @@ -// Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D -// +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // Lesser General Public License for more details. // -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // + // SUIT_ViewModel.cxx: implementation of the SUIT_ViewModel class. // - #include "SUIT_ViewModel.h" +#include "SUIT_ViewWindow.h" -SUIT_ViewModel::StatesMap SUIT_ViewModel::myStateMap; -SUIT_ViewModel::ButtonsMap SUIT_ViewModel::myButtonMap; +SUIT_ViewModel::InteractionStyle2StatesMap SUIT_ViewModel::myStateMap; +SUIT_ViewModel::InteractionStyle2ButtonsMap SUIT_ViewModel::myButtonMap; static bool isInitialized = false; /*!Constructor.*/ SUIT_ViewModel::SUIT_ViewModel() { - if (!isInitialized) { + if ( !isInitialized ) + { isInitialized = true; - SUIT_ViewModel::myStateMap[ZOOM] = Qt::ControlButton; - SUIT_ViewModel::myButtonMap[ZOOM] = Qt::LeftButton; + // standard interaction style + SUIT_ViewModel::myStateMap[STANDARD][ZOOM] = Qt::ControlModifier; + SUIT_ViewModel::myButtonMap[STANDARD][ZOOM] = Qt::LeftButton; + + SUIT_ViewModel::myStateMap[STANDARD][PAN] = Qt::ControlModifier; + SUIT_ViewModel::myButtonMap[STANDARD][PAN] = Qt::MidButton; + + SUIT_ViewModel::myStateMap[STANDARD][ROTATE] = Qt::ControlModifier; + SUIT_ViewModel::myButtonMap[STANDARD][ROTATE] = Qt::RightButton; + + SUIT_ViewModel::myStateMap[STANDARD][FIT_AREA] = Qt::ControlModifier; + SUIT_ViewModel::myButtonMap[STANDARD][FIT_AREA] = Qt::RightButton; + + // "key free" interaction style + SUIT_ViewModel::myStateMap[KEY_FREE][ZOOM] = Qt::NoModifier; + SUIT_ViewModel::myButtonMap[KEY_FREE][ZOOM] = Qt::RightButton; - SUIT_ViewModel::myStateMap[PAN] = Qt::ControlButton; - SUIT_ViewModel::myButtonMap[PAN] = Qt::MidButton; + SUIT_ViewModel::myStateMap[KEY_FREE][PAN] = Qt::NoModifier; + SUIT_ViewModel::myButtonMap[KEY_FREE][PAN] = Qt::MidButton; - SUIT_ViewModel::myStateMap[ROTATE] = Qt::ControlButton; - SUIT_ViewModel::myButtonMap[ROTATE] = Qt::RightButton; + SUIT_ViewModel::myStateMap[KEY_FREE][ROTATE] = Qt::NoModifier; + SUIT_ViewModel::myButtonMap[KEY_FREE][ROTATE] = Qt::LeftButton; - SUIT_ViewModel::myStateMap[FIT_AREA] = Qt::ControlButton; - SUIT_ViewModel::myButtonMap[FIT_AREA] = Qt::RightButton; + SUIT_ViewModel::myStateMap[KEY_FREE][FIT_AREA] = Qt::NoModifier; // unused + SUIT_ViewModel::myButtonMap[KEY_FREE][FIT_AREA] = Qt::NoButton; // unused } myViewManager = 0; } @@ -60,16 +79,32 @@ SUIT_ViewWindow* SUIT_ViewModel::createView(SUIT_Desktop* theDesktop) return new SUIT_ViewWindow(theDesktop); } +/*!Set view manager. + \param theViewManager view manager + */ +void SUIT_ViewModel::setViewManager(SUIT_ViewManager* theViewManager) +{ + myViewManager = theViewManager; +} + +/*!Get view manager. + \return view manager + */ +SUIT_ViewManager* SUIT_ViewModel::getViewManager() const +{ + return myViewManager; +} + /*! Sets hot button *\param theOper - hot operation *\param theState - adding state to state map operations. *\param theButton - adding state to button map operations. */ -void SUIT_ViewModel::setHotButton(HotOperation theOper, Qt::ButtonState theState, - Qt::ButtonState theButton) +void SUIT_ViewModel::setHotButton( InteractionStyle theInteractionStyle, HotOperation theOper, + Qt::KeyboardModifiers theState, Qt::MouseButtons theButton ) { - myStateMap[theOper] = theState; - myButtonMap[theOper] = theButton; + myStateMap[theInteractionStyle][theOper] = theState; + myButtonMap[theInteractionStyle][theOper] = theButton; } /*! Gets hot button for operation \a theOper. @@ -77,9 +112,9 @@ void SUIT_ViewModel::setHotButton(HotOperation theOper, Qt::ButtonState theState *\param theState - output state from state map operations. *\param theButton - output state from button map operations. */ -void SUIT_ViewModel::getHotButton(HotOperation theOper, Qt::ButtonState& theState, - Qt::ButtonState& theButton) +void SUIT_ViewModel::getHotButton( InteractionStyle theInteractionStyle, HotOperation theOper, + Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton ) { - theState = myStateMap[theOper]; - theButton = myButtonMap[theOper]; + theState = myStateMap[theInteractionStyle][theOper]; + theButton = myButtonMap[theInteractionStyle][theOper]; }