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
34 /// \param theParent instance of workshop intrface
\r
35 ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
\r
37 virtual ~ModuleBase_IModule() {}
\r
39 /// Reads description of features from XML file
\r
40 virtual void createFeatures();
\r
42 /// Called on creation of menu item in desktop
\r
43 virtual void actionCreated(QAction*);
\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
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
53 /// Realizes some functionality by an operation start
\r
54 /// \param theOperation a started operation
\r
55 virtual void operationStarted(ModuleBase_Operation* theOperation) {}
\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
61 /// Realizes some functionality by an operation stop
\r
62 virtual void operationStopped(ModuleBase_Operation* theOperation) {}
\r
64 /// Realizes some functionality by an operation commit
\r
65 virtual void operationCommitted(ModuleBase_Operation* theOperation) {}
\r
67 /// Realizes some functionality by an operation abort
\r
68 virtual void operationAborted(ModuleBase_Operation* theOperation) {}
\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
83 /// Returns current workshop
\r
84 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
\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
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
96 /// Called on call of command corresponded to a feature
\r
97 void onFeatureTriggered();
\r
100 /// Called on selection changed event
\r
101 virtual void onSelectionChanged() {}
\r
104 /// Sends the operation for launching
\r
105 /// \param theOperation the operation
\r
106 void sendOperation(ModuleBase_Operation* theOperation);
\r
108 /// Creates a new operation
\r
109 /// \param theCmdId the operation name
\r
110 virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);
\r
112 /// Register validators for this module
\r
113 virtual void registerValidators() {}
\r
115 /// Register selection filters for this module
\r
116 virtual void registerFilters() {}
\r
118 /// Returns new instance of operation object (used in createOperation for customization)
\r
119 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
\r
123 /// Reference to workshop
\r
124 ModuleBase_IWorkshop* myWorkshop;
\r
126 /// Map of features in XML
\r
127 std::map<std::string, std::string> myFeaturesInFiles;
\r
132 //! This function must return a new module instance.
\r
134 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
\r
137 #define CREATE_MODULE "createModule"
\r
139 #endif //ModuleBase_IModule
\r