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