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/ or email : webmaster.salome@opencascade.com
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 application 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 /*! Performs some finalization of life cycle of this application.
64 For instance, the application can force its documents(s) to close. */
65 virtual void closeApplication();
67 //! Returns active Study. If Application supports wirking with several studies this method should be redefined
68 virtual SUIT_Study* activeStudy() const;
70 //! Returns Name of application. Using is not defined.
71 virtual QString applicationName() const = 0;
73 virtual QString applicationVersion() const;
75 //! Shows the application's main widget. For non GUI application must be redefined.
78 //! Opens document <theFileName> into active Study. If Study is empty - creates it.
79 virtual bool useFile( const QString& theFileName);
81 //! Loads document <theName> into active Study. If Study is empty - creates it.
82 virtual bool useStudy( const QString& theName);
84 //! Creates new empty Study if active Study = 0
85 virtual void createEmptyStudy();
87 /*! Returns number of Studies.
88 * Must be redefined in Applications which support several studies for one Application instance. */
89 virtual int getNbStudies() const;
91 SUIT_ResourceMgr* resourceMgr() const;
93 /*! Returns instance of data object Convertor class according to given Viewer.
94 If convertation is not supported returns 0. */
95 virtual SUIT_Convertor* getConvertor(const SUIT_ViewModel* theViewer) { return 0; }
97 //! Puts the message to the status bar
98 void putInfo ( const QString&, const int = 0 );
100 //! Invokes application-specific "Open/Save File" dialog and returns the selected file name.
101 virtual QString getFileName( bool open, const QString& initial, const QString& filters,
102 const QString& caption, QWidget* parent ) = 0;
104 //! Invokes application-specific "Select Directory" dialog and returns the selected directory name.
105 virtual QString getDirectory( const QString& initial, const QString& caption, QWidget* parent ) = 0;
108 void applicationClosed( SUIT_Application* );
109 void activated( SUIT_Application* );
112 SUIT_Application* startApplication( int, char** ) const;
113 SUIT_Application* startApplication( const QString&, int, char** ) const;
115 virtual void setDesktop( SUIT_Desktop* );
117 //! Creates a new Study instance. Must be redefined in new application according to its Study type.
118 virtual SUIT_Study* createNewStudy();
119 virtual void setActiveStudy( SUIT_Study* );
121 /** @name Create tool functions*/ //@{
122 int createTool( const QString& );
123 int createTool( const int, const int, const int = -1 );
124 int createTool( const int, const QString&, const int = -1 );
125 int createTool( QAction*, const int, const int = -1, const int = -1 );
126 int createTool( QAction*, const QString&, const int = -1, const int = -1 );//@}
128 /** @name Create menu functions*/ //@{
129 int createMenu( const QString&, const int, const int = -1, const int = -1, const int = -1 );
130 int createMenu( const QString&, const QString&, const int = -1, const int = -1, const int = -1 );
131 int createMenu( const int, const int, const int = -1, const int = -1 );
132 int createMenu( const int, const QString&, const int = -1, const int = -1 );
133 int createMenu( QAction*, const int, const int = -1, const int = -1, const int = -1 );
134 int createMenu( QAction*, const QString&, const int = -1, const int = -1, const int = -1 );//@}
136 /** @name Set menu shown functions*/ //@{
137 void setMenuShown( QAction*, const bool );
138 void setMenuShown( const int, const bool );//@}
139 /** @name Set tool shown functions*/ //@{
140 void setToolShown( QAction*, const bool );
141 void setToolShown( const int, const bool );//@}
143 void setActionShown( QAction*, const bool );
144 void setActionShown( const int, const bool );
146 static QAction* separator();
147 QAction* action( const int ) const;
148 int actionId( const QAction* ) const;
149 int registerAction( const int, QAction* );
150 QAction* createAction( const int, const QString&, const QIconSet&, const QString&,
151 const QString&, const int, QObject* = 0,
152 const bool = false, QObject* = 0, const char* = 0 );
155 virtual void onDesktopActivated();
159 SUIT_Desktop* myDesktop;
160 QMap<int, QAction*> myActionMap;
162 QLabel* myStatusLabel;
165 //! This function must return a new application instance.
168 //jfa 22.06.2005:typedef SUIT_Application* (*APP_CREATE_FUNC)( int, char** );
169 typedef SUIT_Application* (*APP_CREATE_FUNC)();
172 #define APP_CREATE_NAME "createApplication"