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