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