Salome HOME
Working with pre-selection in all operations
[modules/shaper.git] / src / ModuleBase / ModuleBase_IModule.h
1 #ifndef ModuleBase_IModule_H\r
2 #define ModuleBase_IModule_H\r
3 \r
4 #include "ModuleBase.h"
5 #include "ModuleBase_IWorkshop.h"\r
6 \r
7 #include <QString>\r
8 #include <QObject>\r
9 \r
10 \r
11 class QAction;\r
12 class Config_WidgetAPI;\r
13 class ModuleBase_ModelWidget;\r
14 class ModuleBase_Operation;\r
15 class ModuleBase_IWorkshop;\r
16 \r
17 /**\r
18  * Interface to a module\r
19  */\r
20 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject\r
21 {\r
22  public:\r
23 \r
24    ModuleBase_IModule(ModuleBase_IWorkshop* theParent): QObject(theParent), myWorkshop(theParent) {}\r
25 \r
26   virtual ~ModuleBase_IModule() {}\r
27 \r
28   /// Reads description of features from XML file \r
29   virtual void createFeatures() = 0;\r
30 \r
31   /// Called on creation of menu item in desktop\r
32   virtual void featureCreated(QAction*) = 0;\r
33 \r
34   /// Creates an operation and send it to loop\r
35   /// \param theCmdId the operation name\r
36   virtual void launchOperation(const QString& theCmdId);\r
37 \r
38   /// Called when it is necessary to update a command state (enable or disable it)\r
39   //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
40 \r
41   /// Creates custom widgets for property panel\r
42   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
43                                       Config_WidgetAPI* theWidgetApi,\r
44                                       QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
45   {\r
46     return 0;\r
47   }\r
48 \r
49   ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
50 \r
51  protected:\r
52   /// Sends the operation for launching\r
53   /// \param theOperation the operation\r
54   void sendOperation(ModuleBase_Operation* theOperation);\r
55 \r
56   /// Creates a new operation\r
57   /// \param theCmdId the operation name\r
58   /// \param theFeatureKind a kind of feature to get the feature xml description\r
59   virtual ModuleBase_Operation* createOperation(const std::string& theCmdId,\r
60                                         const std::string& theFeatureKind = "") = 0;\r
61 \r
62 \r
63 protected:\r
64 \r
65   ModuleBase_IWorkshop* myWorkshop;\r
66 \r
67 };\r
68 \r
69 //! This function must return a new module instance.\r
70 extern "C" {\r
71 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
72 }\r
73 \r
74 #define CREATE_MODULE "createModule"\r
75 \r
76 #endif //ModuleBase_IModule\r