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