]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_IModule.h
Salome HOME
Issue #273: Add copyright string
[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    ModuleBase_IModule(ModuleBase_IWorkshop* theParent);\r
34 \r
35   virtual ~ModuleBase_IModule() {}\r
36 \r
37   /// Reads description of features from XML file \r
38   virtual void createFeatures();\r
39 \r
40   /// Called on creation of menu item in desktop\r
41   virtual void actionCreated(QAction*);\r
42 \r
43   /// Called when user selects feature for editing\r
44   virtual void editFeature(FeaturePtr theFeature);\r
45 \r
46   /// Creates an operation and send it to loop\r
47   /// \param theCmdId the operation name\r
48   virtual void launchOperation(const QString& theCmdId);\r
49 \r
50   /// Called when it is necessary to update a command state (enable or disable it)\r
51   //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
52 \r
53   /// Creates custom widgets for property panel\r
54   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
55                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,\r
56                                       QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
57   {\r
58     return 0;\r
59   }\r
60 \r
61   ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
62 \r
63   /// Call back forlast tuning of property panel before operation performance\r
64   /// It is called as on clearing of property panel as on filling with new widgets\r
65   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}\r
66 \r
67 public slots:\r
68   void onFeatureTriggered();\r
69 \r
70 protected slots:\r
71   /// SLOT, that is called after the operation is started. Connect on the focus activated signal\r
72   virtual void onOperationStarted(ModuleBase_Operation* theOperation) {}\r
73   \r
74   /// SLOT, that is called after the operation is stopped. Switched off the modfications performed\r
75   /// by the operation start\r
76   virtual void onOperationStopped(ModuleBase_Operation* theOperation) {}\r
77 \r
78   virtual void onOperationResumed(ModuleBase_Operation* theOperation) {}\r
79 \r
80   virtual void onOperationComitted(ModuleBase_Operation* theOperation) {}\r
81 \r
82   virtual void onOperationAborted(ModuleBase_Operation* theOperation) {}\r
83 \r
84 \r
85   /// Called on selection changed event\r
86   virtual void onSelectionChanged() {}\r
87 \r
88   /// SLOT, that is called by mouse press in the viewer.\r
89   /// The mouse released point is sent to the current operation to be processed.\r
90   /// \param theEvent the mouse event\r
91   //virtual void onMousePressed(QMouseEvent* theEvent) {}\r
92 \r
93   /// SLOT, that is called by mouse release in the viewer.\r
94   /// The mouse released point is sent to the current operation to be processed.\r
95   /// \param theEvent the mouse event\r
96   //virtual void onMouseReleased(QMouseEvent* theEvent) {}\r
97   \r
98   /// SLOT, that is called by mouse move in the viewer.\r
99   /// The mouse moved point is sent to the current operation to be processed.\r
100   /// \param theEvent the mouse event\r
101   //virtual void onMouseMoved(QMouseEvent* theEvent) {}\r
102 \r
103   /// SLOT, that is called by the mouse double click in the viewer.\r
104   /// \param theEvent the mouse event\r
105   //virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}\r
106 \r
107   /// SLOT, that is called by the key in the viewer is clicked.\r
108   /// \param theEvent the mouse event\r
109   //virtual void onKeyRelease(QKeyEvent* theEvent) {}\r
110 \r
111  protected:\r
112   /// Sends the operation for launching\r
113   /// \param theOperation the operation\r
114   void sendOperation(ModuleBase_Operation* theOperation);\r
115 \r
116   /// Creates a new operation\r
117   /// \param theCmdId the operation name\r
118   /// \param theFeatureKind a kind of feature to get the feature xml description\r
119   virtual ModuleBase_Operation* createOperation(const std::string& theFeatureId);\r
120 \r
121   /// Register validators for this module\r
122   virtual void registerValidators() {}\r
123 \r
124   /// Register selection filters for this module\r
125   virtual void registerFilters() {}\r
126 \r
127   /// Returns new instance of operation object (used in createOperation for customization)\r
128   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
129 \r
130 protected:\r
131 \r
132   ModuleBase_IWorkshop* myWorkshop;\r
133   std::map<std::string, std::string> myFeaturesInFiles;\r
134 };\r
135 \r
136 \r
137 \r
138 //! This function must return a new module instance.\r
139 extern "C" {\r
140 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
141 }\r
142 \r
143 #define CREATE_MODULE "createModule"\r
144 \r
145 #endif //ModuleBase_IModule\r