Back to index

salome-gui  6.5.0
SUIT_ViewModel.h
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 #ifndef SUIT_VIEWMODEL_H
00024 #define SUIT_VIEWMODEL_H
00025 
00026 #include "SUIT.h"
00027 
00028 #include <QObject>
00029 #include <QMap>
00030 
00031 class QMenu;
00032 
00033 class SUIT_Desktop;
00034 class SUIT_ViewWindow;
00035 class SUIT_ViewManager;
00036 
00037 #ifdef WIN32
00038 #pragma warning( disable:4251 )
00039 #endif
00040 
00046 class SUIT_EXPORT SUIT_ViewModel : public QObject
00047 {
00048         Q_OBJECT
00049 public:
00050   enum HotOperation { PAN, ZOOM, ROTATE, FIT_AREA };
00051   enum InteractionStyle { STANDARD, KEY_FREE };
00052 
00053   typedef QMap<HotOperation, Qt::KeyboardModifiers> StatesMap;
00054   typedef QMap<HotOperation, Qt::MouseButtons>      ButtonsMap;
00055 
00056   typedef QMap<InteractionStyle, StatesMap>         InteractionStyle2StatesMap;
00057   typedef QMap<InteractionStyle, ButtonsMap>        InteractionStyle2ButtonsMap;
00058   
00059   SUIT_ViewModel();
00060   virtual ~SUIT_ViewModel();
00061 
00062   virtual SUIT_ViewWindow* createView( SUIT_Desktop* theDesktop );
00063 
00064   virtual void      setViewManager(SUIT_ViewManager* theViewManager);
00065   SUIT_ViewManager* getViewManager() const;
00066 
00067   virtual QString   getType() const { return "SUIT_ViewModel"; }
00068 
00069   virtual void      contextMenuPopup( QMenu* ) {}
00070 
00071   static void       setHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
00072                                   Qt::KeyboardModifiers theState, Qt::MouseButtons theButton );
00073   static void       getHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
00074                                   Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton );
00075 
00076 protected:
00077   SUIT_ViewManager* myViewManager;
00078 
00079 public:
00080   static InteractionStyle2StatesMap  myStateMap;
00081   static InteractionStyle2ButtonsMap myButtonMap;
00082 };
00083 
00084 #ifdef WIN32
00085 #pragma warning( default:4251 )
00086 #endif
00087 
00088 extern "C"
00089 {
00090   typedef SUIT_ViewModel* (*VIEWMODEL_CREATE_FUNC)();
00091 }
00092 
00093 #define VIEWMODEL_CREATE_NAME   "createViewModel"
00094 
00095 #endif