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
21 class Config_WidgetAPI;
\r
22 class ModuleBase_ModelWidget;
\r
23 class ModuleBase_Operation;
\r
24 class ModuleBase_IWorkshop;
\r
28 * Interface to a module
\r
30 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
\r
36 /// \param theParent instance of workshop intrface
\r
37 ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
\r
39 virtual ~ModuleBase_IModule() {}
\r
41 /// Reads description of features from XML file
\r
42 virtual void createFeatures();
\r
44 /// Called on creation of menu item in desktop
\r
45 virtual void actionCreated(QAction*);
\r
47 /// Launching of a edit operation on the feature
\r
48 /// \param theFeature feature for editing
\r
49 virtual void editFeature(FeaturePtr theFeature);
\r
51 /// Creates an operation and send it to loop
\r
52 /// \param theCmdId the operation name
\r
53 virtual void launchOperation(const QString& theCmdId);
\r
55 /// Realizes some functionality by an operation start
\r
56 /// \param theOperation a started operation
\r
57 virtual void operationStarted(ModuleBase_Operation* theOperation) {}
\r
59 /// Realizes some functionality by an operation resume
\r
60 /// \param theOperation a resumed operation
\r
61 virtual void operationResumed(ModuleBase_Operation* theOperation) {}
\r
63 /// Realizes some functionality by an operation stop
\r
64 virtual void operationStopped(ModuleBase_Operation* theOperation) {}
\r
66 /// Realizes some functionality by an operation commit
\r
67 virtual void operationCommitted(ModuleBase_Operation* theOperation) {}
\r
69 /// Realizes some functionality by an operation abort
\r
70 virtual void operationAborted(ModuleBase_Operation* theOperation) {}
\r
72 /// Add menu atems for viewer into the given menu
\r
73 /// \param theMenu a popup menu to be shown in the viewer
\r
74 virtual void addViewerItems(QMenu* theMenu) const {}
\r
76 /// Add menu atems for object browser into the given menu
\r
77 /// \param theMenu a popup menu to be shown in the object browser
\r
78 virtual void addObjectBrowserItems(QMenu* theMenu) const {};
\r
80 /// Called when it is necessary to update a command state (enable or disable it)
\r
81 //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
\r
83 /// Creates custom widgets for property panel
\r
84 /// \param theType a type of widget
\r
85 /// \param theParent the parent object
\r
86 /// \param theWidgetApi the widget configuation. The attribute of the model widget is obtained from
\r
87 /// \param theParentId is Id of a parent of the current attribute
\r
88 /// \param theModelWidgets list of widget objects
\r
89 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
\r
90 Config_WidgetAPI* theWidgetApi, std::string theParentId)
\r
95 /// Returns current workshop
\r
96 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
\r
98 /// Call back forlast tuning of property panel before operation performance
\r
99 /// It is called as on clearing of property panel as on filling with new widgets
\r
100 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}
\r
102 //! Returns True if there are available Undos and there is not an active operation
\r
103 virtual bool canUndo() const;
\r
105 //! Returns True if there are available Redos and there is not an active operation
\r
106 virtual bool canRedo() const;
\r
108 /// Returns whether the object can be displayed at the bounds of the active operation.
\r
109 /// Display only current operation results
\r
110 /// \param theObject a model object
\r
111 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
\r
113 /// Reacts to the delete action in module
\r
114 /// \returns true if the action is processed
\r
115 virtual bool deleteObjects() { return false; };
\r
118 /// Called on call of command corresponded to a feature
\r
119 void onFeatureTriggered();
\r
122 /// Called on selection changed event
\r
123 virtual void onSelectionChanged() {}
\r
126 /// Sends the operation for launching
\r
127 /// \param theOperation the operation
\r
128 void sendOperation(ModuleBase_Operation* theOperation);
\r
130 /// Creates a new operation
\r
131 /// \param theCmdId the operation name
\r
132 virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);
\r
134 /// Register validators for this module
\r
135 virtual void registerValidators() {}
\r
137 /// Register selection filters for this module
\r
138 virtual void registerFilters() {}
\r
140 /// Register properties of this module
\r
141 virtual void registerProperties() {}
\r
143 /// Returns new instance of operation object (used in createOperation for customization)
\r
144 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
\r
148 /// Reference to workshop
\r
149 ModuleBase_IWorkshop* myWorkshop;
\r
151 /// Map of features in XML
\r
152 std::map<std::string, std::string> myFeaturesInFiles;
\r
157 //! This function must return a new module instance.
\r
159 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
\r
162 #define CREATE_MODULE "createModule"
\r
164 #endif //ModuleBase_IModule
\r