]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
a91f679439004b9e13ceb390b999ccde5dd5b555
[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 #include <StdSelect_FaceFilter.hxx>
12
13 #include <QMap>
14 #include <QObject>
15
16 #include <string>
17
18 #include <boost/shared_ptr.hpp>
19
20 class QMouseEvent;
21 class QKeyEvent;
22 class PartSet_Listener;
23 class ModelAPI_Feature;
24 class XGUI_ViewerPrs;
25 class XGUI_Workshop;
26 class ModuleBase_Operation;
27 class GeomAPI_AISObject;
28
29 class PARTSET_EXPORT PartSet_Module : public ModuleBase_IModule
30 {
31 Q_OBJECT
32
33  public:
34   PartSet_Module(ModuleBase_IWorkshop* theWshop);
35   virtual ~PartSet_Module();
36
37   /// Reads description of features from XML file 
38   virtual void createFeatures();
39
40   /// Called on creation of menu item in desktop
41   virtual void featureCreated(QAction* theFeature);
42
43   std::string featureFile(const std::string&);
44
45   /// Creates an operation and send it to loop
46   /// \param theCmdId the operation name
47   //virtual void launchOperation(const QString& theCmdId);
48
49   /// Updates current operation preview, if it has it.
50   /// \param theCmdId the operation name
51   void updateCurrentPreview(const std::string& theCmdId);
52
53   /// Creates custom widgets for property panel
54   virtual QWidget* createWidgetByType(const std::string& theType, QWidget* theParent,
55                                       Config_WidgetAPI* theWidgetApi,
56                                       QList<ModuleBase_ModelWidget*>& theModelWidgets);
57
58   XGUI_Workshop* xWorkshop() const;
59
60
61   /// Returns list of selection modes for the given object for sketch operation
62   static QIntList sketchSelectionModes(ObjectPtr theFeature);
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, Defines Sketch editing mode
119   void setSketchingMode();
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   Handle(StdSelect_FaceFilter) myPlaneFilter;
152 };
153
154 #endif