]> SALOME platform Git repositories - modules/shaper.git/blob - src/ModuleBase/ModuleBase_IModule.h
Salome HOME
202ad5dd2e67e75dab5814097f567410f991b116
[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    /// Constructor\r
34    /// \param theParent instance of workshop intrface\r
35    ModuleBase_IModule(ModuleBase_IWorkshop* theParent);\r
36 \r
37   virtual ~ModuleBase_IModule() {}\r
38 \r
39   /// Reads description of features from XML file \r
40   virtual void createFeatures();\r
41 \r
42   /// Called on creation of menu item in desktop\r
43   virtual void actionCreated(QAction*);\r
44 \r
45   /// Launching of a edit operation on the feature \r
46   /// \param theFeature feature for editing\r
47   virtual void editFeature(FeaturePtr theFeature);\r
48 \r
49   /// Creates an operation and send it to loop\r
50   /// \param theCmdId the operation name\r
51   virtual void launchOperation(const QString& theCmdId);\r
52 \r
53   /// Realizes some functionality by an operation start\r
54   /// \param theOperation a started operation\r
55   virtual void operationStarted(ModuleBase_Operation* theOperation) {}\r
56 \r
57   /// Realizes some functionality by an operation resume\r
58   /// \param theOperation a resumed operation\r
59   virtual void operationResumed(ModuleBase_Operation* theOperation) {}\r
60 \r
61   /// Realizes some functionality by an operation stop\r
62   virtual void operationStopped(ModuleBase_Operation* theOperation) {}\r
63 \r
64   /// Realizes some functionality by an operation commit\r
65   virtual void operationCommitted(ModuleBase_Operation* theOperation) {}\r
66 \r
67   /// Realizes some functionality by an operation abort\r
68   virtual void operationAborted(ModuleBase_Operation* theOperation) {}\r
69 \r
70   /// Creates custom widgets for property panel\r
71   /// \param theType a type of widget\r
72   /// \param theParent the parent object\r
73   /// \param theWidgetApi the widget configuation. The attribute of the model widget is obtained from\r
74   /// \param theParentId is Id of a parent of the current attribute\r
75   /// \param theModelWidgets list of widget objects\r
76   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,\r
77                                       Config_WidgetAPI* theWidgetApi, std::string theParentId,\r
78                                       QList<ModuleBase_ModelWidget*>& theModelWidgets)\r
79   {\r
80     return 0;\r
81   }\r
82 \r
83   /// Returns current workshop\r
84   ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
85 \r
86   /// Call back forlast tuning of property panel before operation performance\r
87   /// It is called as on clearing of property panel as on filling with new widgets\r
88   virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}\r
89 \r
90   /// Returns whether the object can be displayed at the bounds of the active operation.\r
91   /// Display only current operation results\r
92   /// \param theObject a model object\r
93   virtual bool canDisplayObject(const ObjectPtr& theObject) const;\r
94 \r
95 public slots:\r
96   /// Called on call of command corresponded to a feature\r
97   void onFeatureTriggered();\r
98 \r
99 protected slots:\r
100   /// Called on selection changed event\r
101   virtual void onSelectionChanged() {}\r
102 \r
103  protected:\r
104   /// Sends the operation for launching\r
105   /// \param theOperation the operation\r
106   void sendOperation(ModuleBase_Operation* theOperation);\r
107 \r
108   /// Creates a new operation\r
109   /// \param theCmdId the operation name\r
110   virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);\r
111 \r
112   /// Register validators for this module\r
113   virtual void registerValidators() {}\r
114 \r
115   /// Register selection filters for this module\r
116   virtual void registerFilters() {}\r
117 \r
118   /// Returns new instance of operation object (used in createOperation for customization)\r
119   virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);\r
120 \r
121 protected:\r
122 \r
123   /// Reference to workshop\r
124   ModuleBase_IWorkshop* myWorkshop;\r
125 \r
126   /// Map of features in XML\r
127   std::map<std::string, std::string> myFeaturesInFiles;\r
128 };\r
129 \r
130 \r
131 \r
132 //! This function must return a new module instance.\r
133 extern "C" {\r
134 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
135 }\r
136 \r
137 #define CREATE_MODULE "createModule"\r
138 \r
139 #endif //ModuleBase_IModule\r