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
22 class Config_WidgetAPI;
\r
23 class ModuleBase_ModelWidget;
\r
24 class ModuleBase_Operation;
\r
25 class ModuleBase_IWorkshop;
\r
26 class ModuleBase_IDocumentDataModel;
\r
30 * Interface to a module
\r
32 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
\r
38 /// \param theParent instance of workshop intrface
\r
39 ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
\r
41 virtual ~ModuleBase_IModule() {}
\r
43 // Add default selection filters of the module to the current viewer
\r
44 virtual void activateSelectionFilters() {};
\r
46 // Remove default selection filters of the module from the current viewer
\r
47 virtual void deactivateSelectionFilters() {};
\r
49 /// Reads description of features from XML file
\r
50 virtual void createFeatures();
\r
52 /// Called on creation of menu item in desktop
\r
53 virtual void actionCreated(QAction*);
\r
55 /// Launching of a edit operation on the feature
\r
56 /// \param theFeature feature for editing
\r
57 virtual void editFeature(FeaturePtr theFeature);
\r
59 /// Creates an operation and send it to loop
\r
60 /// \param theCmdId the operation name
\r
61 virtual void launchOperation(const QString& theCmdId);
\r
63 /// Realizes some functionality by an operation start
\r
64 /// \param theOperation a started operation
\r
65 virtual void onOperationStarted(ModuleBase_Operation* theOperation) {}
\r
67 /// Realizes some functionality by an operation resume
\r
68 /// By default it emits operationResumed signal
\r
69 /// \param theOperation a resumed operation
\r
70 virtual void onOperationResumed(ModuleBase_Operation* theOperation);
\r
72 /// Realizes some functionality by an operation stop
\r
73 virtual void onOperationStopped(ModuleBase_Operation* theOperation) {}
\r
75 /// Realizes some functionality by an operation commit
\r
76 virtual void onOperationCommitted(ModuleBase_Operation* theOperation) {}
\r
78 /// Realizes some functionality by an operation abort
\r
79 virtual void onOperationAborted(ModuleBase_Operation* theOperation) {}
\r
81 /// Realizes some functionality by an operation start
\r
82 /// \param theOperation a started operation
\r
83 virtual ModuleBase_Operation* currentOperation() const = 0;
\r
85 /// Add menu atems for viewer into the given menu
\r
86 /// \param theMenu a popup menu to be shown in the viewer
\r
87 /// \param theStdActions a map of standard actions
\r
88 /// \return true if items are added and there is no necessity to provide standard menu
\r
89 virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const { return false; }
\r
91 /// Add menu atems for object browser into the given menu
\r
92 /// \param theMenu a popup menu to be shown in the object browser
\r
93 virtual void addObjectBrowserMenu(QMenu* theMenu) const {};
\r
95 /// Called when it is necessary to update a command state (enable or disable it)
\r
96 //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
\r
98 /// Creates custom widgets for property panel
\r
99 /// \param theType a type of widget
\r
100 /// \param theParent the parent object
\r
101 /// \param theWidgetApi the widget configuation. The attribute of the model widget is obtained from
\r
102 /// \param theParentId is Id of a parent of the current attribute
\r
103 /// \param theModelWidgets list of widget objects
\r
104 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
\r
105 Config_WidgetAPI* theWidgetApi, std::string theParentId)
\r
110 /// Returns current workshop
\r
111 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
\r
113 /// Call back forlast tuning of property panel before operation performance
\r
114 /// It is called as on clearing of property panel as on filling with new widgets
\r
115 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}
\r
117 //! Returns True if there are available Undos and there is not an active operation
\r
118 virtual bool canUndo() const;
\r
120 //! Returns True if there are available Redos and there is not an active operation
\r
121 virtual bool canRedo() const;
\r
123 /// Returns whether the object can be displayed. The default realization returns true.
\r
124 /// \param theObject a model object
\r
125 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
\r
127 /// Returns true if selection for the object can be activate.
\r
128 /// By default a result or feature of the current operation can not be activated
\r
129 /// \param theObject a model object
\r
130 virtual bool canActivateSelection(const ObjectPtr& theObject) const;
\r
132 /// Reacts to the delete action in module
\r
133 /// \returns true if the action is processed
\r
134 virtual bool deleteObjects() { return false; };
\r
136 /// Returns data model object for representation of data tree in Object browser
\r
137 virtual ModuleBase_IDocumentDataModel* dataModel() const = 0;
\r
139 /// Returns a list of modes, where the AIS objects should be activated
\r
140 /// \param theModes a list of modes
\r
141 virtual void activeSelectionModes(QIntList& theModes) {}
\r
143 /// This method is called on object browser creation for customisation of module specific features
\r
144 /// \param theObjectBrowser a pinter on Object Browser widget
\r
145 virtual void customizeObjectBrowser(QWidget* theObjectBrowser) {}
\r
147 /// Creates a new operation
\r
148 /// \param theCmdId the operation name
\r
149 virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);
\r
151 /// Sends the operation for launching
\r
152 /// \param theOperation the operation
\r
153 virtual void sendOperation(ModuleBase_Operation* theOperation);
\r
156 void operationLaunched();
\r
158 void operationResumed(ModuleBase_Operation* theOp);
\r
161 /// Called on call of command corresponded to a feature
\r
162 virtual void onFeatureTriggered();
\r
164 /// Slolt called on object display
\r
165 /// \param theObject a data object
\r
166 /// \param theAIS a presentation object
\r
167 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) {}
\r
169 /// Slot called on before object erase
\r
170 /// \param theObject a data object
\r
171 /// \param theAIS a presentation object
\r
172 virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS) {}
\r
175 /// Called on selection changed event
\r
176 virtual void onSelectionChanged() {}
\r
179 /// Register validators for this module
\r
180 virtual void registerValidators() {}
\r
182 /// Register selection filters for this module
\r
183 virtual void registerFilters() {}
\r
185 /// Register properties of this module
\r
186 virtual void registerProperties() {}
\r
188 /// Returns new instance of operation object (used in createOperation for customization)
\r
189 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
\r
193 /// Reference to workshop
\r
194 ModuleBase_IWorkshop* myWorkshop;
\r
196 /// Map of features in XML
\r
197 std::map<std::string, std::string> myFeaturesInFiles;
\r
202 //! This function must return a new module instance.
\r
204 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
\r
207 #define CREATE_MODULE "createModule"
\r
209 #endif //ModuleBase_IModule
\r