Back to index

salome-gui  6.5.0
SUIT_ViewManager.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_VIEWMANAGER_H
00024 #define SUIT_VIEWMANAGER_H
00025 
00026 #include "SUIT.h"
00027 
00028 #include "SUIT_PopupClient.h"
00029 
00030 #include <QObject>
00031 #include <QPixmap>
00032 #include <QVector>
00033 #include <QPointer>
00034 
00035 class QMenu;
00036 class QMouseEvent;
00037 class QWheelEvent;
00038 class QKeyEvent;
00039 
00040 class SUIT_Study;
00041 class SUIT_Desktop;
00042 class SUIT_ViewModel;
00043 class SUIT_ViewWindow;
00044 
00045 #ifdef WIN32
00046 #pragma warning( disable:4251 )
00047 #endif
00048 
00049 class SUIT_EXPORT SUIT_ViewManager : public QObject, public SUIT_PopupClient
00050 {
00051   Q_OBJECT
00052 public:
00053   SUIT_ViewManager( SUIT_Study*,
00054                     SUIT_Desktop*,
00055                     SUIT_ViewModel* = 0 );
00056   virtual ~SUIT_ViewManager();
00057 
00058   virtual QString  popupClientType() const { return getType(); }
00059   virtual void     contextMenuPopup( QMenu* );
00060 
00061   void             setViewModel(SUIT_ViewModel* theViewModel);
00062   SUIT_ViewModel*  getViewModel() { return myViewModel; }
00063 
00064   SUIT_Study*      study() const;
00065 
00066   QString          getType() const;
00067   SUIT_ViewWindow* getActiveView() { return myActiveView; }
00068 
00069   int              getViewsCount() { return myViews.count(); }
00070   QVector<SUIT_ViewWindow*> getViews() const;
00071 
00072   QString          getTitle() const { return myTitle; }
00073   virtual void     setTitle( const QString& );
00074 
00075   QPixmap          getIcon() const { return myIcon; }
00076   virtual void     setIcon( const QPixmap& );
00077 
00078   SUIT_ViewWindow* createViewWindow();
00079 
00080   bool             isVisible() const;
00081   virtual void     setShown( const bool );
00082   virtual void     setDestructiveClose( const bool );
00083 
00084   int              getId() const;
00085 
00086   int              getGlobalId() const;
00087 
00088 public slots:
00089   void             createView();
00090   void             closeAllViews();
00091 
00092 signals:
00093   void             lastViewClosed(SUIT_ViewManager*);
00094   void             tryCloseView(SUIT_ViewWindow*);
00095   void             deleteView(SUIT_ViewWindow*);
00096   void             viewCreated(SUIT_ViewWindow*);
00097   void             mousePress(SUIT_ViewWindow*, QMouseEvent*);
00098   void             mouseRelease(SUIT_ViewWindow*, QMouseEvent*);
00099   void             mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
00100   void             mouseMove(SUIT_ViewWindow*, QMouseEvent*);
00101   void             wheel(SUIT_ViewWindow*, QWheelEvent*);
00102   void             keyPress(SUIT_ViewWindow*, QKeyEvent*);
00103   void             keyRelease(SUIT_ViewWindow*, QKeyEvent*);
00104   void             activated(SUIT_ViewManager*);
00105 
00106 protected slots:
00107   void             onWindowActivated(SUIT_ViewWindow*);
00108   void             onClosingView( SUIT_ViewWindow* );
00109   void             onMousePressed(SUIT_ViewWindow*, QMouseEvent* );
00110   void             onDeleteStudy();
00111 
00112 private slots:
00113   void             onContextMenuRequested( QContextMenuEvent* e );
00114 
00115 protected:
00119   virtual bool     insertView(SUIT_ViewWindow* theView);
00120 
00122   virtual void     removeView(SUIT_ViewWindow* theView);
00123 
00125   virtual void     closeView(SUIT_ViewWindow* theView);
00126 
00128   virtual void     setViewName(SUIT_ViewWindow* theView );
00129   QString          prepareTitle( const QString&, const int, const int );
00130 
00131   static int       useNewId( const QString& );
00132 
00133 protected:
00134   typedef QPointer<SUIT_ViewWindow> ViewWindow;
00135 
00136 protected:
00137   SUIT_Desktop*               myDesktop;
00138   SUIT_ViewModel*             myViewModel;
00139   QVector<ViewWindow>         myViews;
00140   SUIT_ViewWindow*            myActiveView;
00141 
00142   int                         myId;
00143   QPixmap                     myIcon;
00144   QString                     myTitle;
00145   SUIT_Study*                 myStudy;
00146 
00147   static QMap<QString, int>   _ViewMgrId;
00148 };
00149 
00150 #ifdef WIN32
00151 #pragma warning( default:4251 )
00152 #endif
00153 
00154 #endif