]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_IModule.h
Salome HOME
Code documentation update
[modules/shaper.git] / src / ModuleBase / ModuleBase_IModule.h
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
2 \r
3 #ifndef ModuleBase_IModule_H\r
4 #define ModuleBase_IModule_H\r
5 \r
6 #include "ModuleBase.h"\r
7 #include "ModuleBase_IWorkshop.h"\r
8 \r
9 #include <ModelAPI_Feature.h>\r
10 \r
11 #include <QString>\r
12 #include <QObject>\r
13 \r
14 #include <string>\r
15 #include <map>\r
16 \r
17 class QAction;\r
18 class QMouseEvent;\r
19 class QKeyEvent;\r
20 class Config_WidgetAPI;\r
21 class ModuleBase_ModelWidget;\r
22 class ModuleBase_Operation;\r
23 class ModuleBase_IWorkshop;\r
24 \r
25 /**\r
26  * Interface to a module\r
27  */\r
28 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject\r
29 {\r
30   Q_OBJECT\r
31  public:\r
32 \r
33    /// Constructor\r
34    /// \param theParent instance of workshop intrface\r
35    ModuleBase_IModule(ModuleBase_IWorkshop* theParent);\r
36 \r
37   virtual ~ModuleBase_IModule() {}\r
38 \r
39   /// Reads description of features from XML file \r
40   virtual void createFeatures();\r
41 \r
42   /// Called on creation of menu item in desktop\r
43   virtual void actionCreated(QAction*);\r
44 \r
45   /// Launching of a edit operation on the feature \r
46   /// \param theFeature feature for editing\r
47   virtual void editFeature(FeaturePtr theFeature);\r
48 \r
49   /// Creates an operation and send it to loop\r
50   /// \param theCmdId the operation name\r
51   virtual void launchOperation(const QString& theCmdId);\r
52 \r
53   /// Realizes some functionality by an operation start\r
54   /// \param theOperation a started operation\r
55   virtual void operationStarted(ModuleBase_Operation* theOperation) {}\r
56 \r
57   /// Realizes some functionality by an operation resume\r
58   /// \param theOperation a resumed operation\r
59   virtual void operationResumed(ModuleBase_Operation* theOperation) {}\r
60 \r
61   /// Realizes some functionality by an operation stop\r
62   virtual void operationStopped(ModuleBase_Operation* theOperation) {}\r
63 \r
64   /// Realizes some functionality by an operation commit\r
65   virtual void operationCommitted(ModuleBase_Operation* theOperation) {}\r
66 \r
67   /// Realizes some functionality by an operation abort\r
68   virtual void operationAborted(ModuleBase_Operation* theOperation) {}\r
69 \r
70   /// Creates custom widgets for property panel\r
71   /// \param theType a type of widget\r
72   /// \param theParent the parent object\r
73   /// \param theWidgetApi the widget configuation. The attribute of the model widget is obtained from\r
74   /// \param theParentId is Id of a parent of the current attribute\r
75   /// \param theModelWidgets list of widget objects\r
76   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
77                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,\r
78                                       QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
79   {\r
80     return 0;\r
81   }\r
82 \r
83   /// Returns current workshop\r
84   ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
85 \r
86   /// Call back forlast tuning of property panel before operation performance\r
87   /// It is called as on clearing of property panel as on filling with new widgets\r
88   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}\r
89 \r
90 public slots:\r
91   /// Called on call of command corresponded to a feature\r
92   void onFeatureTriggered();\r
93 \r
94 protected slots:\r
95   /// Called on selection changed event\r
96   virtual void onSelectionChanged() {}\r
97 \r
98  protected:\r
99   /// Sends the operation for launching\r
100   /// \param theOperation the operation\r
101   void sendOperation(ModuleBase_Operation* theOperation);\r
102 \r
103   /// Creates a new operation\r
104   /// \param theCmdId the operation name\r
105   virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);\r
106 \r
107   /// Register validators for this module\r
108   virtual void registerValidators() {}\r
109 \r
110   /// Register selection filters for this module\r
111   virtual void registerFilters() {}\r
112 \r
113   /// Returns new instance of operation object (used in createOperation for customization)\r
114   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
115 \r
116 protected:\r
117 \r
118   /// Reference to workshop\r
119   ModuleBase_IWorkshop* myWorkshop;\r
120 \r
121   /// Map of features in XML\r
122   std::map<std::string, std::string> myFeaturesInFiles;\r
123 };\r
124 \r
125 \r
126 \r
127 //! This function must return a new module instance.\r
128 extern "C" {\r
129 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
130 }\r
131 \r
132 #define CREATE_MODULE "createModule"\r
133 \r
134 #endif //ModuleBase_IModule\r