Salome HOME
Update comments
[modules/gui.git] / src / SUIT / SUIT_Application.h
1 #ifndef SUIT_APPLICATION_H
2 #define SUIT_APPLICATION_H
3
4 #include "SUIT.h"
5 #include "SUIT_Study.h"
6
7 #include <qobject.h>
8 #include <qwidget.h>
9
10 class QAction;
11 class SUIT_Desktop;
12 class SUIT_Convertor;
13 class SUIT_ViewModel;
14 class SUIT_ResourceMgr;
15 /*! \class QObject
16  * \brief For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
17  */
18 /*!
19   An <b>Application</b> is a class which defines application configuration and behaviour.
20   For example Application object defines what Viewers are used in this application, what auxilliary windows
21   are present, how user can dial with them. Also Application object defines an sertain type of data structure by 
22   holding of pointer on an instance of SUIT_Study class (which represents Document data structure). In other words
23   Application defines type of sata structure, type of used Viewers, type of main GUI widget (Desktop),
24   and other auxilliary tools.
25 */
26
27 class SUIT_EXPORT SUIT_Application : public QObject
28 {
29   Q_OBJECT
30
31 public:
32   SUIT_Application();
33   virtual ~SUIT_Application();
34
35   //! Returns main widget (Desktop) of the application (if it exists)
36   virtual SUIT_Desktop* desktop();
37
38   /*! Returns FALSE if applic ation can not be closed (because of non saved data for example). 
39       This method called by SUIT_Session whin closing of application was requested. */
40   virtual bool          isPossibleToClose();
41
42   virtual void          closeApplication();
43
44   //! Returns active Study. If Application supports wirking with several studies this method should be redefined
45   virtual SUIT_Study*   activeStudy() const;
46
47   //! Returns Name of application. Using is not defined.
48   virtual QString       applicationName() const = 0;
49
50   virtual QString       applicationVersion() const;
51
52   //! Shows the application's main widget. For non GUI application must be redefined.
53   virtual void          start();
54
55   //! Opens document <theFileName> into active Study. If Study is empty - creates it.
56   virtual bool          useFile( const QString& theFileName);
57
58   //! Loads document <theName> into active Study. If Study is empty - creates it.
59   virtual bool          useStudy( const QString& theName);
60
61   //! Creates new empty Study if active Study = 0
62   virtual void          createEmptyStudy();
63
64   /*! Returns number of Studies. 
65    *  Must be redefined in Applications which support several studies for one Application instance. */
66   virtual int           getNbStudies() const;
67
68   SUIT_ResourceMgr*     resourceMgr() const;
69
70   /*! Returns instance of data object Convertor class according to given Viewer. 
71       If convertation is not supported returns 0. */
72   virtual SUIT_Convertor* getConvertor(const SUIT_ViewModel* theViewer) { return 0; }
73
74   //! Puts the message to the status bar  
75   void putInfo ( const QString&, const int = 0 );
76
77   //! Invokes application-specific "Open/Save File" dialog and returns the selected file name.
78   virtual QString getFileName( bool open, const QString& initial, const QString& filters, 
79                                const QString& caption, QWidget* parent ) = 0;
80
81   //! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
82   virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
83
84 signals:
85   void                  applicationClosed( SUIT_Application* );
86   void                  activated( SUIT_Application* );
87
88 protected:
89   SUIT_Application*     startApplication( int, char** ) const;
90   SUIT_Application*     startApplication( const QString&, int, char** ) const;
91
92   void                  setDesktop( SUIT_Desktop* );
93
94   //! Creates a new Study instance. Must be redefined in new application according to its Study type.
95   virtual SUIT_Study*   createNewStudy();
96   virtual void          setActiveStudy( SUIT_Study* );
97   
98   /** @name Create tool functions*/ //@{
99   int                   createTool( const QString& );
100   int                   createTool( const int, const int, const int = -1 );
101   int                   createTool( const int, const QString&, const int = -1 );
102   int                   createTool( QAction*, const int, const int = -1, const int = -1 );
103   int                   createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
104
105   /** @name Create menu functions*/ //@{
106   int                   createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
107   int                   createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
108   int                   createMenu( const int, const int, const int = -1, const int = -1 );
109   int                   createMenu( const int, const QString&, const int = -1, const int = -1 );
110   int                   createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
111   int                   createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
112
113   /** @name Set menu shown functions*/ //@{
114   void                  setMenuShown( QAction*, const bool );
115   void                  setMenuShown( const int, const bool );//@}
116   /** @name Set tool shown functions*/ //@{
117   void                  setToolShown( QAction*, const bool );
118   void                  setToolShown( const int, const bool );//@}
119
120   static QAction*       separator();
121   QAction*              action( const int ) const;
122   int                   actionId( const QAction* ) const;
123   void                  registerAction( const int, QAction* );
124   QAction*              createAction( const int, const QString&, const QIconSet&, const QString&,
125                                       const QString&, const int, QObject* = 0,
126                                       const bool = false, QObject* = 0, const char* = 0 );
127
128 protected slots:
129   virtual void          onDesktopActivated();
130
131 private:
132   SUIT_Study*           myStudy;
133   SUIT_Desktop*         myDesktop;
134 };
135
136 //! This function must return a new application instance.
137 extern "C"
138 {
139   //jfa 22.06.2005:typedef SUIT_Application* (*APP_CREATE_FUNC)( int, char** );
140   typedef SUIT_Application* (*APP_CREATE_FUNC)();
141 }
142
143 #define APP_CREATE_NAME "createApplication"
144
145 #endif