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