Version: 6.3.1

src/SUIT/SUIT_Application.h

Go to the documentation of this file.
00001 // Copyright (C) 2007-2011  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_APPLICATION_H
00024 #define SUIT_APPLICATION_H
00025 
00026 #include "SUIT.h"
00027 
00028 #include <QObject>
00029 #include <QMap>
00030 
00031 class QIcon;
00032 class QLabel;
00033 class QString;
00034 class QAction;
00035 class QWidget;
00036 
00037 class SUIT_Desktop;
00038 class SUIT_ViewManager;
00039 class SUIT_ResourceMgr;
00040 class SUIT_ShortcutMgr;
00041 class SUIT_Study;
00042 
00043 #ifdef WIN32
00044 #pragma warning ( disable:4251 )
00045 #endif
00046 
00059 class SUIT_EXPORT SUIT_Application : public QObject
00060 {
00061   Q_OBJECT
00062 
00063 public:
00064   SUIT_Application();
00065   virtual ~SUIT_Application();
00066 
00068   virtual SUIT_Desktop* desktop();
00069 
00072   virtual bool          isPossibleToClose( bool& );
00073 
00076   virtual void          closeApplication();
00077 
00079   virtual SUIT_Study*   activeStudy() const;
00080 
00082   virtual QString       applicationName() const = 0;
00083 
00084   virtual QString       applicationVersion() const;
00085 
00087   virtual void          start();
00088 
00090   virtual bool          useFile( const QString& theFileName);
00091 
00093   virtual void          createEmptyStudy();
00094 
00097   virtual int           getNbStudies() const;
00098 
00099   SUIT_ResourceMgr*     resourceMgr() const;
00100 
00101   SUIT_ShortcutMgr*     shortcutMgr() const;
00102 
00104   void putInfo ( const QString&, const int = 0 );
00105 
00107   virtual QString getFileName( bool open, const QString& initial, const QString& filters, 
00108                                const QString& caption, QWidget* parent ) = 0;
00109 
00111   virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
00112 
00113 
00114   virtual int     viewManagerId ( const SUIT_ViewManager* ) const = 0;
00115 
00116 signals:
00117   void                  applicationClosed( SUIT_Application* );
00118   void                  activated( SUIT_Application* );
00119   void                  infoChanged( QString );
00120 
00121 public slots:
00122   virtual void          updateCommandsStatus();
00123   virtual void          onHelpContextModule( const QString&, const QString&, const QString& = QString() );
00124 
00125 private slots:
00126   void                  onInfoClear();
00127 
00128 protected:
00129   SUIT_Application*     startApplication( int, char** ) const;
00130   SUIT_Application*     startApplication( const QString&, int, char** ) const;
00131 
00132   virtual void          setDesktop( SUIT_Desktop* );
00133 
00135   virtual SUIT_Study*   createNewStudy();
00136   virtual void          setActiveStudy( SUIT_Study* );
00137    //@{
00139   int                   createTool( const QString& );
00140   int                   createTool( const int, const int, const int = -1 );
00141   int                   createTool( const int, const QString&, const int = -1 );
00142   int                   createTool( QAction*, const int, const int = -1, const int = -1 );
00143   int                   createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
00144  //@{
00146   int                   createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
00147   int                   createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
00148   int                   createMenu( const int, const int, const int = -1, const int = -1 );
00149   int                   createMenu( const int, const QString&, const int = -1, const int = -1 );
00150   int                   createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
00151   int                   createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
00152  //@{
00154   void                  setMenuShown( QAction*, const bool );
00155   void                  setMenuShown( const int, const bool );//@} //@{
00157   void                  setToolShown( QAction*, const bool );
00158   void                  setToolShown( const int, const bool );//@}
00159 
00160   void                  setActionShown( QAction*, const bool );
00161   void                  setActionShown( const int, const bool );
00162 
00163   static QAction*       separator();
00164   QAction*              action( const int ) const;
00165   int                   actionId( const QAction* ) const;
00166 
00167   QList<QAction*>       actions() const;
00168   QList<int>            actionIds() const;
00169 
00170   int                   registerAction( const int, QAction* );
00171   QAction*              createAction( const int, const QString&, const QIcon&, const QString&,
00172                                       const QString&, const int, QObject* = 0,
00173                                       const bool = false, QObject* = 0, const char* = 0,
00174                           const QString& = QString() );
00175 
00176 protected slots:
00177   virtual void          onDesktopActivated();
00178 
00179 private:
00180   SUIT_Study*           myStudy;
00181   SUIT_Desktop*         myDesktop;
00182   QMap<int, QAction*>   myActionMap;
00183   SUIT_ShortcutMgr*     myShortcutMgr;
00184 
00185   QLabel*               myStatusLabel;
00186 };
00187 
00189 extern "C"
00190 {
00191   //jfa 22.06.2005:typedef SUIT_Application* (*APP_CREATE_FUNC)( int, char** );
00192   typedef SUIT_Application* (*APP_CREATE_FUNC)();
00193 }
00194 
00195 #define APP_CREATE_NAME "createApplication"
00196 
00197 #ifdef WIN32
00198 #pragma warning ( default:4251 )
00199 #endif
00200 
00201 #endif
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS