Back to index

salome-gui  6.5.0
SUIT_Application.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_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   virtual void          viewManagers( const QString&, QList<SUIT_ViewManager*>& ) const = 0;
00116   QAction*              action( const int ) const;
00117 
00118 signals:
00119   void                  applicationClosed( SUIT_Application* );
00120   void                  activated( SUIT_Application* );
00121   void                  infoChanged( QString );
00122 
00123 public slots:
00124   virtual void          updateCommandsStatus();
00125   virtual void          onHelpContextModule( const QString&, const QString&, const QString& = QString() );
00126 
00127 private slots:
00128   void                  onInfoClear();
00129 
00130 protected:
00131   SUIT_Application*     startApplication( int, char** ) const;
00132   SUIT_Application*     startApplication( const QString&, int, char** ) const;
00133 
00134   virtual void          setDesktop( SUIT_Desktop* );
00135 
00137   virtual SUIT_Study*   createNewStudy();
00138   virtual void          setActiveStudy( SUIT_Study* );
00139    //@{
00141   int                   createTool( const QString& );
00142   int                   createTool( const int, const int, const int = -1 );
00143   int                   createTool( const int, const QString&, const int = -1 );
00144   int                   createTool( QAction*, const int, const int = -1, const int = -1 );
00145   int                   createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
00146  //@{
00148   int                   createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
00149   int                   createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
00150   int                   createMenu( const int, const int, const int = -1, const int = -1 );
00151   int                   createMenu( const int, const QString&, const int = -1, const int = -1 );
00152   int                   createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
00153   int                   createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
00154  //@{
00156   void                  setMenuShown( QAction*, const bool );
00157   void                  setMenuShown( const int, const bool );//@} //@{
00159   void                  setToolShown( QAction*, const bool );
00160   void                  setToolShown( const int, const bool );//@}
00161 
00162   void                  setActionShown( QAction*, const bool );
00163   void                  setActionShown( const int, const bool );
00164 
00165   static QAction*       separator();
00166   int                   actionId( const QAction* ) const;
00167 
00168   QList<QAction*>       actions() const;
00169   QList<int>            actionIds() const;
00170 
00171   int                   registerAction( const int, QAction* );
00172   QAction*              createAction( const int, const QString&, const QIcon&, const QString&,
00173                                       const QString&, const int, QObject* = 0,
00174                                       const bool = false, QObject* = 0, const char* = 0,
00175                                   const QString& = QString() );
00176 
00177 protected slots:
00178   virtual void          onDesktopActivated();
00179 
00180 private:
00181   SUIT_Study*           myStudy;
00182   SUIT_Desktop*         myDesktop;
00183   QMap<int, QAction*>   myActionMap;
00184   SUIT_ShortcutMgr*     myShortcutMgr;
00185 
00186   QLabel*               myStatusLabel;
00187 };
00188 
00190 extern "C"
00191 {
00192   //jfa 22.06.2005:typedef SUIT_Application* (*APP_CREATE_FUNC)( int, char** );
00193   typedef SUIT_Application* (*APP_CREATE_FUNC)();
00194 }
00195 
00196 #define APP_CREATE_NAME "createApplication"
00197 
00198 #ifdef WIN32
00199 #pragma warning ( default:4251 )
00200 #endif
00201 
00202 #endif