Salome HOME
updated copyright message
[modules/gui.git] / src / SUIT / SUIT_Application.h
old mode 100755 (executable)
new mode 100644 (file)
index 1961d77..a9574a8
@@ -1,19 +1,50 @@
+// Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
 #ifndef SUIT_APPLICATION_H
 #define SUIT_APPLICATION_H
 
 #include "SUIT.h"
-#include "SUIT_Study.h"
 
-#include <qobject.h>
-#include <qwidget.h>
+#include <QObject>
+#include <QMap>
 
+class QIcon;
+class QLabel;
+class QString;
 class QAction;
+class QWidget;
+class QKeySequence;
+
 class SUIT_Desktop;
-class SUIT_Convertor;
-class SUIT_ViewModel;
+class SUIT_ViewManager;
 class SUIT_ResourceMgr;
-class QString;
-class QIconSet;
+class SUIT_ShortcutMgr;
+class SUIT_Study;
+
+#ifdef WIN32
+#pragma warning ( disable:4251 )
+#endif
+
 /*! \class QObject
  * \brief For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
  */
@@ -37,10 +68,12 @@ public:
   //! Returns main widget (Desktop) of the application (if it exists)
   virtual SUIT_Desktop* desktop();
 
-  /*! Returns FALSE if applic ation can not be closed (because of non saved data for example). 
+  /*! Returns \c false if application can not be closed (because of non saved data for example). 
       This method called by SUIT_Session whin closing of application was requested. */
-  virtual bool          isPossibleToClose();
+  virtual bool          isPossibleToClose( bool& );
 
+  /*! Performs some finalization of life cycle of this application.
+      For instance, the application can force its documents(s) to close. */
   virtual void          closeApplication();
 
   //! Returns active Study. If Application supports wirking with several studies this method should be redefined
@@ -57,9 +90,6 @@ public:
   //! Opens document <theFileName> into active Study. If Study is empty - creates it.
   virtual bool          useFile( const QString& theFileName);
 
-  //! Loads document <theName> into active Study. If Study is empty - creates it.
-  virtual bool          useStudy( const QString& theName);
-
   //! Creates new empty Study if active Study = 0
   virtual void          createEmptyStudy();
 
@@ -69,40 +99,32 @@ public:
 
   SUIT_ResourceMgr*     resourceMgr() const;
 
-  /*! Returns instance of data object Convertor class according to given Viewer. 
-      If convertation is not supported returns 0. */
-  virtual SUIT_Convertor* getConvertor(const SUIT_ViewModel* theViewer) { return 0; }
+  SUIT_ShortcutMgr*     shortcutMgr() const;
 
   //! Puts the message to the status bar  
-  void putInfo ( const QString&, const int = 0 );
+  void                  putInfo ( const QString&, const int = 0 );
 
   //! Invokes application-specific "Open/Save File" dialog and returns the selected file name.
-  virtual QString getFileName( bool open, const QString& initial, const QString& filters, 
-                              const QString& caption, QWidget* parent ) = 0;
+  virtual QString       getFileName( bool open, const QString& initial, const QString& filters, 
+                                     const QString& caption, QWidget* parent ) = 0;
 
   //! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
-  virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
+  virtual QString       getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
 
-signals:
-  void                  applicationClosed( SUIT_Application* );
-  void                  activated( SUIT_Application* );
 
-protected:
-  SUIT_Application*     startApplication( int, char** ) const;
-  SUIT_Application*     startApplication( const QString&, int, char** ) const;
+  virtual int           viewManagerId ( const SUIT_ViewManager* ) const = 0;
+  virtual void          viewManagers( const QString&, QList<SUIT_ViewManager*>& ) const = 0;
+  QAction*              action( const int ) const;
 
-  virtual void          setDesktop( SUIT_Desktop* );
+  void                  addPostRoutine( void (*theRoutine)() );
 
-  //! Creates a new Study instance. Must be redefined in new application according to its Study type.
-  virtual SUIT_Study*   createNewStudy();
-  virtual void          setActiveStudy( SUIT_Study* );
-  
   /** @name Create tool functions*/ //@{
-  int                   createTool( const QString& );
+  int                   createTool( const QString&, const QString& = QString() );
   int                   createTool( const int, const int, const int = -1 );
   int                   createTool( const int, const QString&, const int = -1 );
   int                   createTool( QAction*, const int, const int = -1, const int = -1 );
   int                   createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
+  void                  clearTool( const QString& );
 
   /** @name Create menu functions*/ //@{
   int                   createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
@@ -112,6 +134,29 @@ protected:
   int                   createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
   int                   createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
 
+signals:
+  void                  applicationClosed( SUIT_Application* );
+  void                  activated( SUIT_Application* );
+//  void                  moving();
+  void                  infoChanged( QString );
+
+public slots:
+  virtual void          updateCommandsStatus();
+  virtual void          onHelpContextModule( const QString&, const QString&, const QString& = QString() );
+
+private slots:
+  void                  onInfoClear();
+
+protected:
+  SUIT_Application*     startApplication( int, char** ) const;
+  SUIT_Application*     startApplication( const QString&, int, char** ) const;
+
+  virtual void          setDesktop( SUIT_Desktop* );
+
+  //! Creates a new Study instance. Must be redefined in new application according to its Study type.
+  virtual SUIT_Study*   createNewStudy();
+  virtual void          setActiveStudy( SUIT_Study* );
+  
   /** @name Set menu shown functions*/ //@{
   void                  setMenuShown( QAction*, const bool );
   void                  setMenuShown( const int, const bool );//@}
@@ -119,20 +164,39 @@ protected:
   void                  setToolShown( QAction*, const bool );
   void                  setToolShown( const int, const bool );//@}
 
+  void                  setActionShown( QAction*, const bool );
+  void                  setActionShown( const int, const bool );
+
   static QAction*       separator();
-  QAction*              action( const int ) const;
   int                   actionId( const QAction* ) const;
-  void                  registerAction( const int, QAction* );
-  QAction*              createAction( const int, const QString&, const QIconSet&, const QString&,
+
+  QList<QAction*>       actions() const;
+  QList<int>            actionIds() const;
+
+  int                   registerAction( const int, QAction* );
+  QAction*              createAction( const int, const QString&, const QIcon&, const QString&,
                                       const QString&, const int, QObject* = 0,
-                                      const bool = false, QObject* = 0, const char* = 0 );
+                                      const bool = false, QObject* = 0, const char* = 0,
+                                     const QString& = QString() );
+  QAction*              createAction( const int, const QString&, const QIcon&, const QString&,
+                                      const QString&, const QKeySequence&, QObject* = 0,
+                                      const bool = false, QObject* = 0, const char* = 0,
+                                     const QString& = QString() );
 
 protected slots:
   virtual void          onDesktopActivated();
+//  void                  onDesktopMoved();
 
 private:
   SUIT_Study*           myStudy;
   SUIT_Desktop*         myDesktop;
+  QMap<int, QAction*>   myActionMap;
+  SUIT_ShortcutMgr*     myShortcutMgr;
+
+  QLabel*               myStatusLabel;
+
+  typedef void (*PostRoutine)();
+  QList<PostRoutine>    myPostRoutines;
 };
 
 //! This function must return a new application instance.
@@ -144,4 +208,8 @@ extern "C"
 
 #define APP_CREATE_NAME "createApplication"
 
+#ifdef WIN32
+#pragma warning ( default:4251 )
+#endif
+
 #endif