Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / ModuleBase / ModuleBase_IModule.h
1 #ifndef ModuleBase_IModule_H
2 #define ModuleBase_IModule_H
3
4 #include "ModuleBase.h"
5 #include "ModuleBase_IWorkshop.h"
6
7 #include <QString>
8 #include <QObject>
9
10
11 class QAction;
12 class QMouseEvent;\r
13 class QKeyEvent;\r
14 class Config_WidgetAPI;
15 class ModuleBase_ModelWidget;
16 class ModuleBase_Operation;
17 class ModuleBase_IWorkshop;
18
19 /**
20  * Interface to a module
21  */
22 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
23 {
24   Q_OBJECT
25  public:
26
27    ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
28
29   virtual ~ModuleBase_IModule() {}
30
31   /// Reads description of features from XML file 
32   virtual void createFeatures() = 0;
33
34   /// Called on creation of menu item in desktop
35   virtual void featureCreated(QAction*) = 0;
36
37   /// Creates an operation and send it to loop
38   /// \param theCmdId the operation name
39   virtual void launchOperation(const QString& theCmdId);
40
41   /// Called when it is necessary to update a command state (enable or disable it)
42   //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
43
44   /// Creates custom widgets for property panel
45   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
46                                       Config_WidgetAPI* theWidgetApi,
47                                       QList<ModuleBase_ModelWidget*>& theModelWidgets)
48   {
49     return 0;
50   }
51
52   ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
53
54 protected slots:
55
56   /// Called on selection changed event
57   virtual void onSelectionChanged() {}
58
59   /// SLOT, that is called by mouse press in the viewer.\r
60   /// The mouse released point is sent to the current operation to be processed.\r
61   /// \param theEvent the mouse event\r
62   virtual void onMousePressed(QMouseEvent* theEvent) {}\r
63 \r
64   /// SLOT, that is called by mouse release in the viewer.\r
65   /// The mouse released point is sent to the current operation to be processed.\r
66   /// \param theEvent the mouse event\r
67   virtual void onMouseReleased(QMouseEvent* theEvent) {}\r
68   \r
69   /// SLOT, that is called by mouse move in the viewer.\r
70   /// The mouse moved point is sent to the current operation to be processed.\r
71   /// \param theEvent the mouse event\r
72   virtual void onMouseMoved(QMouseEvent* theEvent) {}\r
73 \r
74   /// SLOT, that is called by the mouse double click in the viewer.\r
75   /// \param theEvent the mouse event\r
76   virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}\r
77 \r
78   /// SLOT, that is called by the key in the viewer is clicked.\r
79   /// \param theEvent the mouse event\r
80   virtual void onKeyRelease(QKeyEvent* theEvent) {}\r
81
82  protected:
83   /// Sends the operation for launching
84   /// \param theOperation the operation
85   void sendOperation(ModuleBase_Operation* theOperation);
86
87   /// Creates a new operation
88   /// \param theCmdId the operation name
89   /// \param theFeatureKind a kind of feature to get the feature xml description
90   virtual ModuleBase_Operation* createOperation(const std::string& theCmdId,
91                                         const std::string& theFeatureKind = "") = 0;
92
93
94 protected:
95
96   ModuleBase_IWorkshop* myWorkshop;
97
98 };
99
100 //! This function must return a new module instance.
101 extern "C" {
102 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
103 }
104
105 #define CREATE_MODULE "createModule"
106
107 #endif //ModuleBase_IModule