1 #ifndef ModuleBase_IModule_H
\r
2 #define ModuleBase_IModule_H
\r
4 #include "ModuleBase.h"
\r
5 #include "ModuleBase_IWorkshop.h"
\r
7 #include <ModelAPI_Feature.h>
\r
18 class Config_WidgetAPI;
\r
19 class ModuleBase_ModelWidget;
\r
20 class ModuleBase_Operation;
\r
21 class ModuleBase_IWorkshop;
\r
24 * Interface to a module
\r
26 class MODULEBASE_EXPORT ModuleBase_IModule : public QObject
\r
31 ModuleBase_IModule(ModuleBase_IWorkshop* theParent);
\r
33 virtual ~ModuleBase_IModule() {}
\r
35 /// Reads description of features from XML file
\r
36 virtual void createFeatures();
\r
38 /// Called on creation of menu item in desktop
\r
39 virtual void actionCreated(QAction*);
\r
41 /// Called when user selects feature for editing
\r
42 virtual void editFeature(FeaturePtr theFeature);
\r
44 /// Creates an operation and send it to loop
\r
45 /// \param theCmdId the operation name
\r
46 virtual void launchOperation(const QString& theCmdId);
\r
48 /// Realizes some functionality by an operation start
\r
49 /// \param theOperation a started operation
\r
50 virtual void operationStarted(ModuleBase_Operation* theOperation) {}
\r
52 /// Realizes some functionality by an operation resume
\r
53 /// \param theOperation a resumed operation
\r
54 virtual void operationResumed(ModuleBase_Operation* theOperation) {}
\r
56 /// Realizes some functionality by an operation stop
\r
57 virtual void operationStopped(ModuleBase_Operation* theOperation) {}
\r
59 /// Realizes some functionality by an operation commit
\r
60 virtual void operationCommitted(ModuleBase_Operation* theOperation) {}
\r
62 /// Realizes some functionality by an operation abort
\r
63 virtual void operationAborted(ModuleBase_Operation* theOperation) {}
\r
65 /// Called when it is necessary to update a command state (enable or disable it)
\r
66 //virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;
\r
68 /// Creates custom widgets for property panel
\r
69 virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
\r
70 Config_WidgetAPI* theWidgetApi, std::string theParentId,
\r
71 QList<ModuleBase_ModelWidget*>& theModelWidgets)
\r
76 ModuleBase_IWorkshop* workshop() const { return myWorkshop; }
\r
78 /// Call back forlast tuning of property panel before operation performance
\r
79 /// It is called as on clearing of property panel as on filling with new widgets
\r
80 virtual void propertyPanelDefined(ModuleBase_Operation* theOperation) {}
\r
83 void onFeatureTriggered();
\r
86 /// Called on selection changed event
\r
87 virtual void onSelectionChanged() {}
\r
89 /// SLOT, that is called by mouse press in the viewer.
\r
90 /// The mouse released point is sent to the current operation to be processed.
\r
91 /// \param theEvent the mouse event
\r
92 //virtual void onMousePressed(QMouseEvent* theEvent) {}
\r
94 /// SLOT, that is called by mouse release in the viewer.
\r
95 /// The mouse released point is sent to the current operation to be processed.
\r
96 /// \param theEvent the mouse event
\r
97 //virtual void onMouseReleased(QMouseEvent* theEvent) {}
\r
99 /// SLOT, that is called by mouse move in the viewer.
\r
100 /// The mouse moved point is sent to the current operation to be processed.
\r
101 /// \param theEvent the mouse event
\r
102 //virtual void onMouseMoved(QMouseEvent* theEvent) {}
\r
104 /// SLOT, that is called by the mouse double click in the viewer.
\r
105 /// \param theEvent the mouse event
\r
106 //virtual void onMouseDoubleClick(QMouseEvent* theEvent) {}
\r
108 /// SLOT, that is called by the key in the viewer is clicked.
\r
109 /// \param theEvent the mouse event
\r
110 //virtual void onKeyRelease(QKeyEvent* theEvent) {}
\r
113 /// Sends the operation for launching
\r
114 /// \param theOperation the operation
\r
115 void sendOperation(ModuleBase_Operation* theOperation);
\r
117 /// Creates a new operation
\r
118 /// \param theCmdId the operation name
\r
119 /// \param theFeatureKind a kind of feature to get the feature xml description
\r
120 virtual ModuleBase_Operation* createOperation(const std::string& theFeatureId);
\r
122 /// Register validators for this module
\r
123 virtual void registerValidators() {}
\r
125 /// Register selection filters for this module
\r
126 virtual void registerFilters() {}
\r
128 /// Returns new instance of operation object (used in createOperation for customization)
\r
129 virtual ModuleBase_Operation* getNewOperation(const std::string& theFeatureId);
\r
133 ModuleBase_IWorkshop* myWorkshop;
\r
134 std::map<std::string, std::string> myFeaturesInFiles;
\r
139 //! This function must return a new module instance.
\r
141 typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);
\r
144 #define CREATE_MODULE "createModule"
\r
146 #endif //ModuleBase_IModule
\r