]> SALOME platform Git repositories - modules/shaper.git/blob - src/PartSet/PartSet_Module.h
Salome HOME
8f0a0b086d86b13e44640dc61f0df152035fafb1
[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 <XGUI_Module.h>
7 #include <XGUI_Command.h>
8
9 #include <QMap>
10 #include <QObject>
11
12 #include <string>
13
14 #include <boost/shared_ptr.hpp>
15
16 class QMouseEvent;
17 class QKeyEvent;
18 class PartSet_Listener;
19 class ModelAPI_Feature;
20
21 class PARTSET_EXPORT PartSet_Module: public QObject, public XGUI_Module
22 {
23 Q_OBJECT
24
25 public:
26   PartSet_Module(XGUI_Workshop* theWshop);
27   virtual ~PartSet_Module();
28
29   virtual void createFeatures();
30   virtual void featureCreated(XGUI_Command* theFeature);
31   virtual QStringList nestedFeatures(QString theFeature);
32   std::string featureFile(const std::string&);
33
34   /// Creates an operation and send it to loop
35   /// \param theCmdId the operation name
36   virtual void launchOperation(const QString& theCmdId);
37
38   /// Displays or erase the current operation preview, if it has it.
39   /// \param theF
40   /// \param isDisplay the state whether the presentation should be displayed or erased
41   void visualizePreview(boost::shared_ptr<ModelAPI_Feature> theFeature, bool isDisplay);
42
43 public slots:
44   void onFeatureTriggered();
45   /// SLOT, that is called after the operation is started. Perform some specific for module
46   /// actions, e.g. connect the sketch feature to the viewer selection and show the sketch preview.
47   void onOperationStarted();
48   /// SLOT, that is called after the operation is stopped. Disconnect the sketch feature
49   /// from the viewer selection and show the sketch preview.
50   void onOperationStopped(ModuleBase_Operation* theOperation);
51
52   /// SLOT, that is called by the selection in the viewer is changed.
53   /// The selection is sent to the current operation if it listens selection.
54   void onSelectionChanged();
55   /// SLOT, that is called by mouse click in the viewer.
56   /// The mouse released point is sent to the current operation to be processed.
57   /// \param theEvent the mouse event
58   void onMouseReleased(QMouseEvent* theEvent);
59   /// SLOT, that is called by the selection in the viewer is changed.
60   /// The mouse moved point is sent to the current operation to be processed.
61   /// \param theEvent the mouse event
62   void onMouseMoved(QMouseEvent* theEvent);
63
64   /// SLOT, that is called by the key in the viewer is clicked.
65   /// \param theEvent the mouse event
66   void onKeyRelease(QKeyEvent*);
67
68   /// SLOT, to apply to the current viewer the operation
69   /// \param theX the X projection value
70   /// \param theY the Y projection value
71   /// \param theZ the Z projection value
72   void onPlaneSelected(double theX, double theY, double theZ);
73
74   void onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
75
76   /// SLOT, to visualize the feature in another local context mode
77   /// \param theFeature the feature to be put in another local context mode
78   /// \param theMode the mode appeared on the feature
79   void onFeatureConstructed(boost::shared_ptr<ModelAPI_Feature> theFeature,
80                             int theMode);
81 protected:
82   /// Creates a new operation
83   /// \param theCmdId the operation name
84   ModuleBase_Operation* createOperation(const QString& theCmdId);
85
86   /// Sends the operation
87   /// \param theOperation the operation
88   void sendOperation(ModuleBase_Operation* theOperation);
89
90 private:
91   XGUI_Workshop* myWorkshop;
92   PartSet_Listener* myListener;
93
94   std::map<std::string, std::string> myFeaturesInFiles;
95 };
96
97 #endif