Back to index

salome-gui  6.5.0
SUIT_ViewModel.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 // SUIT_ViewModel.cxx: implementation of the SUIT_ViewModel class.
00024 //
00025 #include "SUIT_ViewModel.h"
00026 #include "SUIT_ViewWindow.h"
00027 
00028 SUIT_ViewModel::InteractionStyle2StatesMap SUIT_ViewModel::myStateMap;
00029 SUIT_ViewModel::InteractionStyle2ButtonsMap SUIT_ViewModel::myButtonMap;
00030 
00031 static bool isInitialized = false;
00032 
00034 SUIT_ViewModel::SUIT_ViewModel()
00035 {
00036   if ( !isInitialized )
00037   {
00038     isInitialized = true;
00039 
00040     // standard interaction style
00041     SUIT_ViewModel::myStateMap[STANDARD][ZOOM]  = Qt::ControlModifier;
00042     SUIT_ViewModel::myButtonMap[STANDARD][ZOOM] = Qt::LeftButton;
00043 
00044     SUIT_ViewModel::myStateMap[STANDARD][PAN]   = Qt::ControlModifier;
00045     SUIT_ViewModel::myButtonMap[STANDARD][PAN]  = Qt::MidButton;
00046 
00047     SUIT_ViewModel::myStateMap[STANDARD][ROTATE]  = Qt::ControlModifier;
00048     SUIT_ViewModel::myButtonMap[STANDARD][ROTATE] = Qt::RightButton;
00049 
00050     SUIT_ViewModel::myStateMap[STANDARD][FIT_AREA]  = Qt::ControlModifier;
00051     SUIT_ViewModel::myButtonMap[STANDARD][FIT_AREA] = Qt::RightButton;
00052 
00053     // "key free" interaction style
00054     SUIT_ViewModel::myStateMap[KEY_FREE][ZOOM]  = Qt::NoModifier;
00055     SUIT_ViewModel::myButtonMap[KEY_FREE][ZOOM] = Qt::LeftButton | Qt::MidButton;
00056 
00057     SUIT_ViewModel::myStateMap[KEY_FREE][PAN]   = Qt::NoModifier;
00058     SUIT_ViewModel::myButtonMap[KEY_FREE][PAN]  = Qt::MidButton;
00059 
00060     SUIT_ViewModel::myStateMap[KEY_FREE][ROTATE]  = Qt::NoModifier;
00061     SUIT_ViewModel::myButtonMap[KEY_FREE][ROTATE] = Qt::LeftButton;
00062 
00063     SUIT_ViewModel::myStateMap[KEY_FREE][FIT_AREA]  = Qt::NoModifier; // unused
00064     SUIT_ViewModel::myButtonMap[KEY_FREE][FIT_AREA] = Qt::NoButton;   // unused
00065   }
00066   myViewManager = 0;
00067 }
00068 
00070 SUIT_ViewModel::~SUIT_ViewModel()
00071 {
00072 }
00073 
00077 SUIT_ViewWindow* SUIT_ViewModel::createView(SUIT_Desktop* theDesktop)
00078 {
00079   return new SUIT_ViewWindow(theDesktop);
00080 }
00081 
00085 void SUIT_ViewModel::setViewManager(SUIT_ViewManager* theViewManager)
00086 {
00087   myViewManager = theViewManager;
00088 }
00089 
00093 SUIT_ViewManager* SUIT_ViewModel::getViewManager() const
00094 {
00095   return myViewManager;
00096 }
00097 
00103 void SUIT_ViewModel::setHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
00104                                    Qt::KeyboardModifiers theState, Qt::MouseButtons theButton )
00105 {
00106   myStateMap[theInteractionStyle][theOper]  = theState;
00107   myButtonMap[theInteractionStyle][theOper] = theButton;
00108 }
00109 
00115 void SUIT_ViewModel::getHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
00116                                    Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton )
00117 {
00118   theState  = myStateMap[theInteractionStyle][theOper];
00119   theButton = myButtonMap[theInteractionStyle][theOper];
00120 }