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