Salome HOME
Commit of the current operation if the preselection is activated.
[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"\r
5 #include "ModuleBase_IWorkshop.h"\r
6 \r
7 #include <ModelAPI_Feature.h>\r
8 \r
9 #include <QString>\r
10 #include <QObject>\r
11 \r
12 #include <string>\r
13 #include <map>\r
14 \r
15 class QAction;\r
16 class QMouseEvent;\r
17 class QKeyEvent;\r
18 class Config_WidgetAPI;\r
19 class ModuleBase_ModelWidget;\r
20 class ModuleBase_Operation;\r
21 class ModuleBase_IWorkshop;\r
22 \r
23 /**\r
24  * Interface to a module\r
25  */\r
26 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject\r
27 {\r
28   Q_OBJECT\r
29  public:\r
30 \r
31    ModuleBase_IModule(ModuleBase_IWorkshop* theParent);\r
32 \r
33   virtual ~ModuleBase_IModule() {}\r
34 \r
35   /// Reads description of features from XML file \r
36   virtual void createFeatures();\r
37 \r
38   /// Called on creation of menu item in desktop\r
39   virtual void actionCreated(QAction*);\r
40 \r
41   /// Called when user selects feature for editing\r
42   virtual void editFeature(FeaturePtr theFeature);\r
43 \r
44   /// Creates an operation and send it to loop\r
45   /// \param theCmdId the operation name\r
46   virtual void launchOperation(const QString& theCmdId);\r
47 \r
48   /// Realizes some functionality by an operation start\r
49   /// \param theOperation a started operation\r
50   virtual void operationStarted(ModuleBase_Operation* theOperation) {}\r
51 \r
52   /// Realizes some functionality by an operation resume\r
53   /// \param theOperation a resumed operation\r
54   virtual void operationResumed(ModuleBase_Operation* theOperation) {}\r
55 \r
56   /// Realizes some functionality by an operation stop\r
57   virtual void operationStopped(ModuleBase_Operation* theOperation) {}\r
58 \r
59   /// Realizes some functionality by an operation commit\r
60   virtual void operationCommitted(ModuleBase_Operation* theOperation) {}\r
61 \r
62   /// Realizes some functionality by an operation abort\r
63   virtual void operationAborted(ModuleBase_Operation* theOperation) {}\r
64 \r
65   /// Called when it is necessary to update a command state (enable or disable it)\r
66   //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
67 \r
68   /// Creates custom widgets for property panel\r
69   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
70                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,\r
71                                       QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
72   {\r
73     return 0;\r
74   }\r
75 \r
76   ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
77 \r
78   /// Call back forlast tuning of property panel before operation performance\r
79   /// It is called as on clearing of property panel as on filling with new widgets\r
80   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}\r
81 \r
82 public slots:\r
83   void onFeatureTriggered();\r
84 \r
85 protected slots:\r
86   /// Called on selection changed event\r
87   virtual void onSelectionChanged() {}\r
88 \r
89   /// SLOT, that is called by mouse press in the viewer.\r
90   /// The mouse released point is sent to the current operation to be processed.\r
91   /// \param theEvent the mouse event\r
92   //virtual void onMousePressed(QMouseEvent* theEvent) {}\r
93 \r
94   /// SLOT, that is called by mouse release in the viewer.\r
95   /// The mouse released point is sent to the current operation to be processed.\r
96   /// \param theEvent the mouse event\r
97   //virtual void onMouseReleased(QMouseEvent* theEvent) {}\r
98   \r
99   /// SLOT, that is called by mouse move in the viewer.\r
100   /// The mouse moved point is sent to the current operation to be processed.\r
101   /// \param theEvent the mouse event\r
102   //virtual void onMouseMoved(QMouseEvent* theEvent) {}\r
103 \r
104   /// SLOT, that is called by the mouse double click in the viewer.\r
105   /// \param theEvent the mouse event\r
106   //virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}\r
107 \r
108   /// SLOT, that is called by the key in the viewer is clicked.\r
109   /// \param theEvent the mouse event\r
110   //virtual void onKeyRelease(QKeyEvent* theEvent) {}\r
111 \r
112  protected:\r
113   /// Sends the operation for launching\r
114   /// \param theOperation the operation\r
115   void sendOperation(ModuleBase_Operation* theOperation);\r
116 \r
117   /// Creates a new operation\r
118   /// \param theCmdId the operation name\r
119   /// \param theFeatureKind a kind of feature to get the feature xml description\r
120   virtual ModuleBase_Operation* createOperation(const std::string& theFeatureId);\r
121 \r
122   /// Register validators for this module\r
123   virtual void registerValidators() {}\r
124 \r
125   /// Register selection filters for this module\r
126   virtual void registerFilters() {}\r
127 \r
128   /// Returns new instance of operation object (used in createOperation for customization)\r
129   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
130 \r
131 protected:\r
132 \r
133   ModuleBase_IWorkshop* myWorkshop;\r
134   std::map<std::string, std::string> myFeaturesInFiles;\r
135 };\r
136 \r
137 \r
138 \r
139 //! This function must return a new module instance.\r
140 extern "C" {\r
141 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
142 }\r
143 \r
144 #define CREATE_MODULE "createModule"\r
145 \r
146 #endif //ModuleBase_IModule\r