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 /// Reads description of features from XML file
\r
44 virtual void createFeatures();
\r
46 /// Called on creation of menu item in desktop
\r
47 virtual void actionCreated(QAction*);
\r
49 /// Launching of a edit operation on the feature
\r
50 /// \param theFeature feature for editing
\r
51 virtual void editFeature(FeaturePtr theFeature);
\r
53 /// Creates an operation and send it to loop
\r
54 /// \param theCmdId the operation name
\r
55 virtual void launchOperation(const QString& theCmdId);
\r
57 /// Realizes some functionality by an operation start
\r
58 /// \param theOperation a started operation
\r
59 virtual void onOperationStarted(ModuleBase_Operation* theOperation) {}
\r
61 /// Realizes some functionality by an operation resume
\r
62 /// By default it emits operationResumed signal
\r
63 /// \param theOperation a resumed operation
\r
64 virtual void onOperationResumed(ModuleBase_Operation* theOperation);
\r
66 /// Realizes some functionality by an operation stop
\r
67 virtual void onOperationStopped(ModuleBase_Operation* theOperation) {}
\r
69 /// Realizes some functionality by an operation commit
\r
70 virtual void onOperationCommitted(ModuleBase_Operation* theOperation) {}
\r
72 /// Realizes some functionality by an operation abort
\r
73 virtual void onOperationAborted(ModuleBase_Operation* theOperation) {}
\r
75 /// Realizes some functionality by an operation start
\r
76 /// \param theOperation a started operation
\r
77 virtual ModuleBase_Operation* currentOperation() const = 0;
\r
79 /// Add menu atems for viewer into the given menu
\r
80 /// \param theMenu a popup menu to be shown in the viewer
\r
81 /// \param theStdActions a map of standard actions
\r
82 /// \return true if items are added and there is no necessity to provide standard menu
\r
83 virtual bool addViewerMenu(QMenu* theMenu, const QMap<QString, QAction*>& theStdActions) const { return false; }
\r
85 /// Add menu atems for object browser into the given menu
\r
86 /// \param theMenu a popup menu to be shown in the object browser
\r
87 virtual void addObjectBrowserMenu(QMenu* theMenu) const {};
\r
89 /// Called when it is necessary to update a command state (enable or disable it)
\r
90 //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
\r
92 /// Creates custom widgets for property panel
\r
93 /// \param theType a type of widget
\r
94 /// \param theParent the parent object
\r
95 /// \param theWidgetApi the widget configuation. The attribute of the model widget is obtained from
\r
96 /// \param theParentId is Id of a parent of the current attribute
\r
97 /// \param theModelWidgets list of widget objects
\r
98 virtual ModuleBase_ModelWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
\r
99 Config_WidgetAPI* theWidgetApi, std::string theParentId)
\r
104 /// Returns current workshop
\r
105 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
\r
107 /// Call back forlast tuning of property panel before operation performance
\r
108 /// It is called as on clearing of property panel as on filling with new widgets
\r
109 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}
\r
111 //! Returns True if there are available Undos and there is not an active operation
\r
112 virtual bool canUndo() const;
\r
114 //! Returns True if there are available Redos and there is not an active operation
\r
115 virtual bool canRedo() const;
\r
117 /// Returns whether the object can be displayed. The default realization returns true.
\r
118 /// \param theObject a model object
\r
119 virtual bool canDisplayObject(const ObjectPtr& theObject) const;
\r
121 /// Returns true if selection for the object can be activate.
\r
122 /// By default a result or feature of the current operation can not be activated
\r
123 /// \param theObject a model object
\r
124 virtual bool canActivateSelection(const ObjectPtr& theObject) const;
\r
126 /// Reacts to the delete action in module
\r
127 /// \returns true if the action is processed
\r
128 virtual bool deleteObjects() { return false; };
\r
130 /// Returns data model object for representation of data tree in Object browser
\r
131 virtual ModuleBase_IDocumentDataModel* dataModel() const = 0;
\r
133 /// Returns a list of modes, where the AIS objects should be activated
\r
134 /// \param theModes a list of modes
\r
135 virtual void activeSelectionModes(QIntList& theModes) {}
\r
137 /// This method is called on object browser creation for customisation of module specific features
\r
138 /// \param theObjectBrowser a pinter on Object Browser widget
\r
139 virtual void customizeObjectBrowser(QWidget* theObjectBrowser) {}
\r
141 /// Creates a new operation
\r
142 /// \param theCmdId the operation name
\r
143 virtual ModuleBase_Operation* createOperation(const std::string& theCmdId);
\r
145 /// Sends the operation for launching
\r
146 /// \param theOperation the operation
\r
147 virtual void sendOperation(ModuleBase_Operation* theOperation);
\r
150 void operationLaunched();
\r
152 void operationResumed(ModuleBase_Operation* theOp);
\r
155 /// Called on call of command corresponded to a feature
\r
156 virtual void onFeatureTriggered();
\r
158 /// Slolt called on object display
\r
159 /// \param theObject a data object
\r
160 /// \param theAIS a presentation object
\r
161 virtual void onObjectDisplayed(ObjectPtr theObject, AISObjectPtr theAIS) {}
\r
163 /// Slot called on before object erase
\r
164 /// \param theObject a data object
\r
165 /// \param theAIS a presentation object
\r
166 virtual void onBeforeObjectErase(ObjectPtr theObject, AISObjectPtr theAIS) {}
\r
169 /// Called on selection changed event
\r
170 virtual void onSelectionChanged() {}
\r
173 /// Register validators for this module
\r
174 virtual void registerValidators() {}
\r
176 /// Register selection filters for this module
\r
177 virtual void registerFilters() {}
\r
179 /// Register properties of this module
\r
180 virtual void registerProperties() {}
\r
182 /// Returns new instance of operation object (used in createOperation for customization)
\r
183 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
\r
187 /// Reference to workshop
\r
188 ModuleBase_IWorkshop* myWorkshop;
\r
190 /// Map of features in XML
\r
191 std::map<std::string, std::string> myFeaturesInFiles;
\r
196 //! This function must return a new module instance.
\r
198 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
\r
201 #define CREATE_MODULE "createModule"
\r
203 #endif //ModuleBase_IModule
\r