1 #ifndef PartSet_Module_H
2 #define PartSet_Module_H
6 #include <ModuleBase_IModule.h>
7 #include <ModuleBase_Definitions.h>
8 #include <XGUI_Command.h>
9 #include <ModelAPI_Feature.h>
16 #include <boost/shared_ptr.hpp>
20 class PartSet_Listener;
21 class ModelAPI_Feature;
23 class ModuleBase_Operation;
24 class GeomAPI_AISObject;
26 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
31 PartSet_Module(XGUI_Workshop* theWshop);
32 virtual ~PartSet_Module();
34 /// Returns the module workshop
35 /// \returns a workshop instance
36 XGUI_Workshop* workshop() const;
38 /// Reads description of features from XML file
39 virtual void createFeatures();
41 /// Called on creation of menu item in desktop
42 virtual void featureCreated(QAction* theFeature);
44 std::string featureFile(const std::string&);
46 /// Creates an operation and send it to loop
47 /// \param theCmdId the operation name
48 virtual void launchOperation(const QString& theCmdId);
50 /// Called when it is necessary to update a command state (enable or disable it)
51 //virtual bool isFeatureEnabled(const QString& theCmdId) const;
53 /// Displays or erase the current operation preview, if it has it.
54 /// \param theFeature the feature instance to be displayed
55 /// \param isDisplay the state whether the presentation should be displayed or erased
56 /// \param isUpdateViewer the flag whether the viewer should be updated
57 //void visualizePreview(FeaturePtr theFeature, bool isDisplay,
58 // const bool isUpdateViewer = true);
60 /// Activates the feature in the displayer
61 /// \param theFeature the feature instance to be displayed
62 /// \param isUpdateViewer the flag whether the viewer should be updated
63 void activateFeature(ObjectPtr theFeature, const bool isUpdateViewer);
65 /// Updates current operation preview, if it has it.
66 /// \param theCmdId the operation name
67 void updateCurrentPreview(const std::string& theCmdId);
69 /// Creates custom widgets for property panel
70 virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
71 Config_WidgetAPI* theWidgetApi,
72 QList<ModuleBase_ModelWidget*>& theModelWidgets);
75 void onFeatureTriggered();
76 /// SLOT, that is called after the operation is started. Connect on the focus activated signal
77 void onOperationStarted();
78 /// SLOT, that is called after the operation is stopped. Switched off the modfications performed
79 /// by the operation start
80 void onOperationStopped(ModuleBase_Operation* theOperation);
81 /// SLOT, that is called afetr the popup menu action clicked.
82 void onContextMenuCommand(const QString& theId, bool isChecked);
83 /// SLOT, that is called by mouse press in the viewer.
84 /// The mouse released point is sent to the current operation to be processed.
85 /// \param theEvent the mouse event
86 void onMousePressed(QMouseEvent* theEvent);
87 /// SLOT, that is called by mouse release in the viewer.
88 /// The mouse released point is sent to the current operation to be processed.
89 /// \param theEvent the mouse event
90 void onMouseReleased(QMouseEvent* theEvent);
91 /// SLOT, that is called by mouse move in the viewer.
92 /// The mouse moved point is sent to the current operation to be processed.
93 /// \param theEvent the mouse event
94 void onMouseMoved(QMouseEvent* theEvent);
96 /// SLOT, that is called by the key in the viewer is clicked.
97 /// \param theEvent the mouse event
98 void onKeyRelease(QKeyEvent* theEvent);
100 /// SLOT, that is called by the mouse double click in the viewer.
101 /// \param theEvent the mouse event
102 void onMouseDoubleClick(QMouseEvent* theEvent);
104 /// SLOT, to apply to the current viewer the operation
105 /// \param theX the X projection value
106 /// \param theY the Y projection value
107 /// \param theZ the Z projection value
108 void onPlaneSelected(double theX, double theY, double theZ);
110 /// SLOT, to fit all current viewer
113 void onRestartOperation(std::string theName, ObjectPtr theFeature);
115 /// SLOT, to switch on/off the multi selection in the viewer
116 /// \param theEnabled the enabled state
117 void onMultiSelectionEnabled(bool theEnabled);
119 /// SLOT, to stop or start selection mode for the features
120 /// \param theFeatures a list of features to be disabled
121 /// \param theToStop the boolean state whether it it stopped or non stopped
122 void onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop);
124 /// SLOT, to set selection
125 /// \param theFeatures a list of features to be selected
126 void onSetSelection(const QList<ObjectPtr>& theFeatures);
128 /// SLOT, to close the viewer local context
129 void onCloseLocalContext();
131 /// SLOT, to visualize the feature in another local context mode
132 /// \param theFeature the feature to be put in another local context mode
133 /// \param theMode the mode appeared on the feature
134 void onFeatureConstructed(ObjectPtr theFeature, int theMode);
136 /// Slot which reacts to the point 2d set to the feature. Creates a constraint
137 /// \param the feature
138 /// \param the attribute of the feature
139 void onStorePoint2D(ObjectPtr theFeature, const std::string& theAttribute);
142 /// Creates a new operation
143 /// \param theCmdId the operation name
144 /// \param theFeatureKind a kind of feature to get the feature xml description
145 ModuleBase_Operation* createOperation(const std::string& theCmdId,
146 const std::string& theFeatureKind = "");
148 /// Sends the operation
149 /// \param theOperation the operation
150 void sendOperation(ModuleBase_Operation* theOperation);
153 //! Edits the feature
154 void editFeature(FeaturePtr theFeature);
157 XGUI_Workshop* myWorkshop;
158 PartSet_Listener* myListener;
160 std::map<std::string, std::string> myFeaturesInFiles;