Salome HOME
It replaces direct names of constraints to the specific kind.
[modules/shaper.git] / src / PartSet / PartSet_OperationConstraint.h
1 // File:        PartSet_OperationConstraint.h
2 // Created:     20 Apr 2014
3 // Author:      Natalia ERMOLAEVA
4
5 #ifndef PartSet_OperationConstraint_H
6 #define PartSet_OperationConstraint_H
7
8 #include "PartSet.h"
9
10 #include <PartSet_OperationSketchBase.h>
11
12 #include <SketchPlugin_ConstraintLength.h>
13
14 #include <QObject>
15
16 /*!
17  \class PartSet_OperationConstraint
18  * \brief The operation for the sketch constraint feature creation
19 */
20 class PARTSET_EXPORT PartSet_OperationConstraint : public PartSet_OperationSketchBase
21 {
22   Q_OBJECT
23
24 public:
25   /// Returns the operation type key
26   static std::string Type() { return SKETCH_CONSTRAINT_LENGTH_KIND; }
27
28 public:
29   /// Constructor
30   /// \param theId the feature identifier
31   /// \param theParent the operation parent
32   /// \param theFeature the parent feature
33   PartSet_OperationConstraint(const QString& theId, QObject* theParent,
34                               boost::shared_ptr<ModelAPI_Feature> theSketchFeature);
35   /// Destructor
36   virtual ~PartSet_OperationConstraint();
37
38   /// Returns that this operator can be started above already running one.
39    /// The runned operation should be the sketch feature modified operation
40   /// \param theOperation the previous running operation
41   virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
42
43   /// Initializes some fields accorging to the feature
44   /// \param theSelected the list of selected presentations
45   /// \param theHighlighted the list of highlighted presentations
46   virtual void init(boost::shared_ptr<ModelAPI_Feature> theFeature,
47                     const std::list<XGUI_ViewerPrs>& theSelected,
48                     const std::list<XGUI_ViewerPrs>& theHighlighted);
49
50   /// Returns the operation sketch feature
51   /// \returns the sketch instance
52   virtual boost::shared_ptr<ModelAPI_Feature> sketch() const;
53
54   /// Gives the current selected objects to be processed by the operation
55   /// \param theEvent the mouse event
56   /// \param theView a viewer to have the viewer the eye position
57   /// \param theSelected the list of selected presentations
58   /// \param theHighlighted the list of highlighted presentations
59  virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
60                             const std::list<XGUI_ViewerPrs>& theSelected,
61                             const std::list<XGUI_ViewerPrs>& theHighlighted);
62   /// Gives the current mouse point in the viewer
63   /// \param thePoint a point clicked in the viewer
64   /// \param theEvent the mouse event
65   virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
66
67 protected:
68   /// \brief Virtual method called when operation is started
69   /// Virtual method called when operation started (see start() method for more description)
70   /// After the parent operation body perform, set sketch feature to the created line feature
71   virtual void startOperation();
72
73   /// Virtual method called when operation aborted (see abort() method for more description)
74   /// Before the feature is aborted, it should be hidden from the viewer
75   virtual void abortOperation();
76
77   /// Virtual method called when operation stopped - committed or aborted.
78   /// Restore the multi selection state
79   virtual void stopOperation();
80
81   /// Virtual method called after operation committed (see commit() method for more description)
82   virtual void afterCommitOperation();
83
84   /// Creates an operation new feature
85   /// In addition to the default realization it appends the created line feature to
86   /// the sketch feature
87   /// \param theFlushMessage the flag whether the create message should be flushed
88   /// \returns the created feature
89   virtual boost::shared_ptr<ModelAPI_Feature> createFeature(const bool theFlushMessage = true);
90
91   /// Set the feature for the constraint
92   /// \param theFeature the line feature
93   void setFeature(boost::shared_ptr<ModelAPI_Feature> theFeature);
94
95   /// Set the value for the constraint
96   /// \param theValue the constraint value
97   void setValue(const double theValue);
98
99 private:
100   boost::shared_ptr<ModelAPI_Feature> mySketch; ///< the sketch feature
101 };
102
103 #endif