1 // Copyright (C) 2005 OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/
19 #ifndef SUIT_APPLICATION_H
20 #define SUIT_APPLICATION_H
23 #include "SUIT_Study.h"
32 class SUIT_ResourceMgr;
37 * \brief For more information see <a href="http://doc.trolltech.com">QT documentation</a>.
40 An <b>Application</b> is a class which defines application configuration and behaviour.
41 For example Application object defines what Viewers are used in this application, what auxilliary windows
42 are present, how user can dial with them. Also Application object defines an sertain type of data structure by
43 holding of pointer on an instance of SUIT_Study class (which represents Document data structure). In other words
44 Application defines type of sata structure, type of used Viewers, type of main GUI widget (Desktop),
45 and other auxilliary tools.
48 class SUIT_EXPORT SUIT_Application : public QObject
54 virtual ~SUIT_Application();
56 //! Returns main widget (Desktop) of the application (if it exists)
57 virtual SUIT_Desktop* desktop();
59 /*! Returns FALSE if applic ation can not be closed (because of non saved data for example).
60 This method called by SUIT_Session whin closing of application was requested. */
61 virtual bool isPossibleToClose();
63 virtual void closeApplication();
65 //! Returns active Study. If Application supports wirking with several studies this method should be redefined
66 virtual SUIT_Study* activeStudy() const;
68 //! Returns Name of application. Using is not defined.
69 virtual QString applicationName() const = 0;
71 virtual QString applicationVersion() const;
73 //! Shows the application's main widget. For non GUI application must be redefined.
76 //! Opens document <theFileName> into active Study. If Study is empty - creates it.
77 virtual bool useFile( const QString& theFileName);
79 //! Loads document <theName> into active Study. If Study is empty - creates it.
80 virtual bool useStudy( const QString& theName);
82 //! Creates new empty Study if active Study = 0
83 virtual void createEmptyStudy();
85 /*! Returns number of Studies.
86 * Must be redefined in Applications which support several studies for one Application instance. */
87 virtual int getNbStudies() const;
89 SUIT_ResourceMgr* resourceMgr() const;
91 /*! Returns instance of data object Convertor class according to given Viewer.
92 If convertation is not supported returns 0. */
93 virtual SUIT_Convertor* getConvertor(const SUIT_ViewModel* theViewer) { return 0; }
95 //! Puts the message to the status bar
96 void putInfo ( const QString&, const int = 0 );
98 //! Invokes application-specific "Open/Save File" dialog and returns the selected file name.
99 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
100 const QString& caption, QWidget* parent ) = 0;
102 //! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
103 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
106 void applicationClosed( SUIT_Application* );
107 void activated( SUIT_Application* );
110 SUIT_Application* startApplication( int, char** ) const;
111 SUIT_Application* startApplication( const QString&, int, char** ) const;
113 virtual void setDesktop( SUIT_Desktop* );
115 //! Creates a new Study instance. Must be redefined in new application according to its Study type.
116 virtual SUIT_Study* createNewStudy();
117 virtual void setActiveStudy( SUIT_Study* );
119 /** @name Create tool functions*/ //@{
120 int createTool( const QString& );
121 int createTool( const int, const int, const int = -1 );
122 int createTool( const int, const QString&, const int = -1 );
123 int createTool( QAction*, const int, const int = -1, const int = -1 );
124 int createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
126 /** @name Create menu functions*/ //@{
127 int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
128 int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
129 int createMenu( const int, const int, const int = -1, const int = -1 );
130 int createMenu( const int, const QString&, const int = -1, const int = -1 );
131 int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
132 int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
134 /** @name Set menu shown functions*/ //@{
135 void setMenuShown( QAction*, const bool );
136 void setMenuShown( const int, const bool );//@}
137 /** @name Set tool shown functions*/ //@{
138 void setToolShown( QAction*, const bool );
139 void setToolShown( const int, const bool );//@}
141 void setActionShown( QAction*, const bool );
142 void setActionShown( const int, const bool );
144 static QAction* separator();
145 QAction* action( const int ) const;
146 int actionId( const QAction* ) const;
147 void registerAction( const int, QAction* );
148 QAction* createAction( const int, const QString&, const QIconSet&, const QString&,
149 const QString&, const int, QObject* = 0,
150 const bool = false, QObject* = 0, const char* = 0 );
153 virtual void onDesktopActivated();
157 SUIT_Desktop* myDesktop;
159 QLabel* myStatusLabel;
162 //! This function must return a new application instance.
165 //jfa 22.06.2005:typedef SUIT_Application* (*APP_CREATE_FUNC)( int, char** );
166 typedef SUIT_Application* (*APP_CREATE_FUNC)();
169 #define APP_CREATE_NAME "createApplication"