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