Salome HOME
722e4387d30f3638ee32d1883bed576668d21483
[modules/gui.git] / src / CAM / CAM_Application.h
1 // Copyright (C) 2007-2022  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef CAM_APPLICATION_H
24 #define CAM_APPLICATION_H
25
26 #include "CAM.h"
27
28 #include <STD_Application.h>
29 #include <QList>
30
31 class QMenu;
32 class CAM_Module;
33
34 #ifdef WIN32
35 #pragma warning( disable:4251 )
36 #endif
37
38 class CAM_EXPORT CAM_Application : public STD_Application  
39 {
40   Q_OBJECT
41
42 public:
43   typedef QList<CAM_Module*> ModuleList;
44   typedef struct { QString name;  QString version; } ModuleShortInfo;
45   typedef QList<ModuleShortInfo> ModuleShortInfoList;
46
47 public:
48   CAM_Application( const bool = true );
49   virtual ~CAM_Application();
50
51   virtual void        start();
52
53   CAM_Module*         activeModule() const;
54   CAM_Module*         module( const QString& ) const;
55
56   ModuleList          modules() const;
57   void                modules( ModuleList& ) const;
58   void                modules( QStringList&, const bool loaded = true ) const;
59
60   virtual void        addModule( CAM_Module* );
61
62   virtual void        loadModules();
63   virtual CAM_Module* loadModule( const QString&, const bool = true );
64
65   virtual bool        activateModule( const QString& );
66
67   bool                activateOperation( const QString& modName, int actionId );
68   bool                activateOperation( const QString& modName, const QString& actionId );
69   bool                activateOperation( const QString& modName, const QString& actionId,
70                                          const QString& pluginName );
71
72   virtual void        contextMenuPopup( const QString&, QMenu*, QString& );
73
74   static QString      moduleName( const QString& );
75   static QString      moduleTitle( const QString& );
76   static QString      moduleIcon( const QString& );
77   static QString      moduleDescription( const QString& );
78   static QString      moduleLibrary( const QString&, const bool = true );
79   static QString      moduleDisplayer( const QString& );
80
81   virtual void        createEmptyStudy();
82
83   static ModuleShortInfoList getVersionInfo();
84
85 protected:
86   virtual SUIT_Study* createNewStudy();
87   virtual void        updateCommandsStatus();
88
89   virtual bool        checkModule( const QString& );
90   virtual void        moduleAdded( CAM_Module* );
91   virtual void        beforeCloseDoc( SUIT_Study* );
92   virtual void        afterCloseDoc();
93   virtual bool        activateModule( CAM_Module* = 0 );
94
95   virtual void        setActiveStudy( SUIT_Study* );
96
97   virtual bool        abortAllOperations();
98
99 private:
100   void                readModuleList();
101
102 private:
103   enum { stUnknown = 0, stNoGui, stInaccessible, stReady };
104   typedef struct { 
105     QString name, title, icon, library, version, description, displayer;
106     int status;
107   } ModuleInfo;
108   typedef QList<ModuleInfo> ModuleInfoList;
109
110 private:
111   CAM_Module*           myModule;        //!< active module
112   ModuleList            myModules;       //!< loaded modules list
113   static ModuleInfoList myInfoList;      //!< modules info list
114   bool                  myAutoLoad;      //!< auto loading flag
115   bool                  myBlocked;       //!< "blocked" flag, internal usage
116 };
117
118 #ifdef WIN32
119 #pragma warning( default:4251 )
120 #endif
121
122 #endif