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
27 * Interface to a module
\r
29 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
\r
35 /// \param theParent instance of workshop intrface
\r
36 ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
\r
38 virtual ~ModuleBase_IModule() {}
\r
40 /// Reads description of features from XML file
\r
41 virtual void createFeatures();
\r
43 /// Called on creation of menu item in desktop
\r
44 virtual void actionCreated(QAction*);
\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
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
54 /// Realizes some functionality by an operation start
\r
55 /// \param theOperation a started operation
\r
56 virtual void operationStarted(ModuleBase_Operation* theOperation) {}
\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
62 /// Realizes some functionality by an operation stop
\r
63 virtual void operationStopped(ModuleBase_Operation* theOperation) {}
\r
65 /// Realizes some functionality by an operation commit
\r
66 virtual void operationCommitted(ModuleBase_Operation* theOperation) {}
\r
68 /// Realizes some functionality by an operation abort
\r
69 virtual void operationAborted(ModuleBase_Operation* theOperation) {}
\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
84 /// Returns current workshop
\r
85 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
\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
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
97 /// Called on call of command corresponded to a feature
\r
98 void onFeatureTriggered();
\r
101 /// Called on selection changed event
\r
102 virtual void onSelectionChanged() {}
\r
105 /// Sends the operation for launching
\r
106 /// \param theOperation the operation
\r
107 void sendOperation(ModuleBase_Operation* theOperation);
\r
109 /// Creates a new operation
\r
110 /// \param theCmdId the operation name
\r
111 virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);
\r
113 /// Register validators for this module
\r
114 virtual void registerValidators() {}
\r
116 /// Register selection filters for this module
\r
117 virtual void registerFilters() {}
\r
119 /// Register properties of this module
120 virtual void registerProperties() {}
122 /// Returns new instance of operation object (used in createOperation for customization)
\r
123 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
\r
127 /// Reference to workshop
\r
128 ModuleBase_IWorkshop* myWorkshop;
\r
130 /// Map of features in XML
\r
131 std::map<std::string, std::string> myFeaturesInFiles;
\r
136 //! This function must return a new module instance.
\r
138 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
\r
141 #define CREATE_MODULE "createModule"
\r
143 #endif //ModuleBase_IModule
\r