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 /// Called when it is necessary to update a command state (enable or disable it)
\r
51 //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
\r
53 /// Creates custom widgets for property panel
\r
54 virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
\r
55 Config_WidgetAPI* theWidgetApi, std::string theParentId,
\r
56 QList<ModuleBase_ModelWidget*>& theModelWidgets)
\r
61 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
\r
63 /// Call back forlast tuning of property panel before operation performance
\r
64 /// It is called as on clearing of property panel as on filling with new widgets
\r
65 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}
\r
68 void onFeatureTriggered();
\r
71 /// SLOT, that is called after the operation is started. Connect on the focus activated signal
\r
72 virtual void onOperationStarted(ModuleBase_Operation* theOperation) {}
\r
74 /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
\r
75 /// by the operation start
\r
76 virtual void onOperationStopped(ModuleBase_Operation* theOperation) {}
\r
78 virtual void onOperationResumed(ModuleBase_Operation* theOperation) {}
\r
80 virtual void onOperationComitted(ModuleBase_Operation* theOperation) {}
\r
82 virtual void onOperationAborted(ModuleBase_Operation* theOperation) {}
\r
85 /// Called on selection changed event
\r
86 virtual void onSelectionChanged() {}
\r
88 /// SLOT, that is called by mouse press in the viewer.
\r
89 /// The mouse released point is sent to the current operation to be processed.
\r
90 /// \param theEvent the mouse event
\r
91 //virtual void onMousePressed(QMouseEvent* theEvent) {}
\r
93 /// SLOT, that is called by mouse release in the viewer.
\r
94 /// The mouse released point is sent to the current operation to be processed.
\r
95 /// \param theEvent the mouse event
\r
96 //virtual void onMouseReleased(QMouseEvent* theEvent) {}
\r
98 /// SLOT, that is called by mouse move in the viewer.
\r
99 /// The mouse moved point is sent to the current operation to be processed.
\r
100 /// \param theEvent the mouse event
\r
101 //virtual void onMouseMoved(QMouseEvent* theEvent) {}
\r
103 /// SLOT, that is called by the mouse double click in the viewer.
\r
104 /// \param theEvent the mouse event
\r
105 //virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}
\r
107 /// SLOT, that is called by the key in the viewer is clicked.
\r
108 /// \param theEvent the mouse event
\r
109 //virtual void onKeyRelease(QKeyEvent* theEvent) {}
\r
112 /// Sends the operation for launching
\r
113 /// \param theOperation the operation
\r
114 void sendOperation(ModuleBase_Operation* theOperation);
\r
116 /// Creates a new operation
\r
117 /// \param theCmdId the operation name
\r
118 /// \param theFeatureKind a kind of feature to get the feature xml description
\r
119 virtual ModuleBase_Operation* createOperation(const std::string& theFeatureId);
\r
121 /// Register validators for this module
\r
122 virtual void registerValidators() {}
\r
124 /// Register selection filters for this module
\r
125 virtual void registerFilters() {}
\r
127 /// Returns new instance of operation object (used in createOperation for customization)
\r
128 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
\r
132 ModuleBase_IWorkshop* myWorkshop;
\r
133 std::map<std::string, std::string> myFeaturesInFiles;
\r
138 //! This function must return a new module instance.
\r
140 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
\r
143 #define CREATE_MODULE "createModule"
\r
145 #endif //ModuleBase_IModule
\r