1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
\r
3 #ifndef ModuleBase_IModule_H
\r
4 #define ModuleBase_IModule_H
\r
6 #include "ModuleBase.h"
\r
7 #include "ModuleBase_IWorkshop.h"
\r
9 #include <ModelAPI_Feature.h>
\r
20 class Config_WidgetAPI;
\r
21 class ModuleBase_ModelWidget;
\r
22 class ModuleBase_Operation;
\r
23 class ModuleBase_IWorkshop;
\r
26 * Interface to a module
\r
28 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
\r
33 ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
\r
35 virtual ~ModuleBase_IModule() {}
\r
37 /// Reads description of features from XML file
\r
38 virtual void createFeatures();
\r
40 /// Called on creation of menu item in desktop
\r
41 virtual void actionCreated(QAction*);
\r
43 /// Called when user selects feature for editing
\r
44 virtual void editFeature(FeaturePtr theFeature);
\r
46 /// Creates an operation and send it to loop
\r
47 /// \param theCmdId the operation name
\r
48 virtual void launchOperation(const QString& theCmdId);
\r
50 /// Realizes some functionality by an operation start
\r
51 /// \param theOperation a started operation
\r
52 virtual void operationStarted(ModuleBase_Operation* theOperation) {}
\r
54 /// Realizes some functionality by an operation resume
\r
55 /// \param theOperation a resumed operation
\r
56 virtual void operationResumed(ModuleBase_Operation* theOperation) {}
\r
58 /// Realizes some functionality by an operation stop
\r
59 virtual void operationStopped(ModuleBase_Operation* theOperation) {}
\r
61 /// Realizes some functionality by an operation commit
\r
62 virtual void operationCommitted(ModuleBase_Operation* theOperation) {}
\r
64 /// Realizes some functionality by an operation abort
\r
65 virtual void operationAborted(ModuleBase_Operation* theOperation) {}
\r
67 /// Called when it is necessary to update a command state (enable or disable it)
\r
68 //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
\r
70 /// Creates custom widgets for property panel
\r
71 virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
\r
72 Config_WidgetAPI* theWidgetApi, std::string theParentId,
\r
73 QList<ModuleBase_ModelWidget*>& theModelWidgets)
\r
78 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
\r
80 /// Call back forlast tuning of property panel before operation performance
\r
81 /// It is called as on clearing of property panel as on filling with new widgets
\r
82 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}
\r
85 void onFeatureTriggered();
\r
88 /// Called on selection changed event
\r
89 virtual void onSelectionChanged() {}
\r
91 /// SLOT, that is called by mouse press 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 onMousePressed(QMouseEvent* theEvent) {}
\r
96 /// SLOT, that is called by mouse release in the viewer.
\r
97 /// The mouse released point is sent to the current operation to be processed.
\r
98 /// \param theEvent the mouse event
\r
99 //virtual void onMouseReleased(QMouseEvent* theEvent) {}
\r
101 /// SLOT, that is called by mouse move in the viewer.
\r
102 /// The mouse moved point is sent to the current operation to be processed.
\r
103 /// \param theEvent the mouse event
\r
104 //virtual void onMouseMoved(QMouseEvent* theEvent) {}
\r
106 /// SLOT, that is called by the mouse double click in the viewer.
\r
107 /// \param theEvent the mouse event
\r
108 //virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}
\r
110 /// SLOT, that is called by the key in the viewer is clicked.
\r
111 /// \param theEvent the mouse event
\r
112 //virtual void onKeyRelease(QKeyEvent* theEvent) {}
\r
115 /// Sends the operation for launching
\r
116 /// \param theOperation the operation
\r
117 void sendOperation(ModuleBase_Operation* theOperation);
\r
119 /// Creates a new operation
\r
120 /// \param theCmdId the operation name
\r
121 /// \param theFeatureKind a kind of feature to get the feature xml description
\r
122 virtual ModuleBase_Operation* createOperation(const std::string& theFeatureId);
\r
124 /// Register validators for this module
\r
125 virtual void registerValidators() {}
\r
127 /// Register selection filters for this module
\r
128 virtual void registerFilters() {}
\r
130 /// Returns new instance of operation object (used in createOperation for customization)
\r
131 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
\r
135 ModuleBase_IWorkshop* myWorkshop;
\r
136 std::map<std::string, std::string> myFeaturesInFiles;
\r
141 //! This function must return a new module instance.
\r
143 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
\r
146 #define CREATE_MODULE "createModule"
\r
148 #endif //ModuleBase_IModule
\r