Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[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   /// Realizes some functionality by an operation start\r
51   /// \param theOperation a started operation\r
52   virtual void operationStarted(ModuleBase_Operation* theOperation) {}\r
53 \r
54   /// Realizes some functionality by an operation resume\r
55   /// \param theOperation a resumed operation\r
56   virtual void operationResumed(ModuleBase_Operation* theOperation) {}\r
57 \r
58   /// Called when it is necessary to update a command state (enable or disable it)\r
59   //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
60 \r
61   /// Creates custom widgets for property panel\r
62   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
63                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,\r
64                                       QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
65   {\r
66     return 0;\r
67   }\r
68 \r
69   ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
70 \r
71   /// Call back forlast tuning of property panel before operation performance\r
72   /// It is called as on clearing of property panel as on filling with new widgets\r
73   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}\r
74 \r
75 public slots:\r
76   void onFeatureTriggered();\r
77 \r
78 protected slots:\r
79   /// SLOT, that is called after the operation is stopped. Switched off the modfications performed\r
80   /// by the operation start\r
81   virtual void onOperationStopped(ModuleBase_Operation* theOperation) {}\r
82 \r
83 \r
84   virtual void onOperationComitted(ModuleBase_Operation* theOperation) {}\r
85 \r
86   virtual void onOperationAborted(ModuleBase_Operation* theOperation) {}\r
87 \r
88 \r
89   /// Called on selection changed event\r
90   virtual void onSelectionChanged() {}\r
91 \r
92   /// SLOT, that is called by mouse press in the viewer.\r
93   /// The mouse released point is sent to the current operation to be processed.\r
94   /// \param theEvent the mouse event\r
95   //virtual void onMousePressed(QMouseEvent* theEvent) {}\r
96 \r
97   /// SLOT, that is called by mouse release in the viewer.\r
98   /// The mouse released point is sent to the current operation to be processed.\r
99   /// \param theEvent the mouse event\r
100   //virtual void onMouseReleased(QMouseEvent* theEvent) {}\r
101   \r
102   /// SLOT, that is called by mouse move in the viewer.\r
103   /// The mouse moved point is sent to the current operation to be processed.\r
104   /// \param theEvent the mouse event\r
105   //virtual void onMouseMoved(QMouseEvent* theEvent) {}\r
106 \r
107   /// SLOT, that is called by the mouse double click in the viewer.\r
108   /// \param theEvent the mouse event\r
109   //virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}\r
110 \r
111   /// SLOT, that is called by the key in the viewer is clicked.\r
112   /// \param theEvent the mouse event\r
113   //virtual void onKeyRelease(QKeyEvent* theEvent) {}\r
114 \r
115  protected:\r
116   /// Sends the operation for launching\r
117   /// \param theOperation the operation\r
118   void sendOperation(ModuleBase_Operation* theOperation);\r
119 \r
120   /// Creates a new operation\r
121   /// \param theCmdId the operation name\r
122   /// \param theFeatureKind a kind of feature to get the feature xml description\r
123   virtual ModuleBase_Operation* createOperation(const std::string& theFeatureId);\r
124 \r
125   /// Register validators for this module\r
126   virtual void registerValidators() {}\r
127 \r
128   /// Register selection filters for this module\r
129   virtual void registerFilters() {}\r
130 \r
131   /// Returns new instance of operation object (used in createOperation for customization)\r
132   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
133 \r
134 protected:\r
135 \r
136   ModuleBase_IWorkshop* myWorkshop;\r
137   std::map<std::string, std::string> myFeaturesInFiles;\r
138 };\r
139 \r
140 \r
141 \r
142 //! This function must return a new module instance.\r
143 extern "C" {\r
144 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
145 }\r
146 \r
147 #define CREATE_MODULE "createModule"\r
148 \r
149 #endif //ModuleBase_IModule\r