Salome HOME
Issue #251. Append Export/Import NewGeom commands in the SALOME desktop.
[modules/shaper.git] / src / PartSet / PartSet_OperationFeatureEdit.h
index ac607e47f873c310a72ebf1e4f963841ed13c504..267b494c67d2bc75b0a5833e1982e0b667481fe1 100644 (file)
@@ -7,33 +7,42 @@
 
 #include "PartSet.h"
 
-#include <PartSet_OperationSketchBase.h>
+#include <PartSet_OperationFeatureBase.h>
 #include <QObject>
 
 class QMouseEvent;
+class ModuleBase_ISelection;
 
 /*!
  \class PartSet_OperationFeatureEdit
  * \brief The operation for the sketch feature creation
-*/
-class PARTSET_EXPORT PartSet_OperationFeatureEdit : public PartSet_OperationSketchBase                                                 
+ */
+class PARTSET_EXPORT PartSet_OperationFeatureEdit : public PartSet_OperationFeatureBase
 {
-  Q_OBJECT
+Q_OBJECT
   /// Struct to define gp point, with the state is the point is initialized
   struct Point
   {
     /// Constructor
-    Point() {}
+    Point()
+    {
+      myIsInitialized = false;
+    }
     /// Constructor
     /// \param thePoint the point
     Point(gp_Pnt thePoint)
     {
       setPoint(thePoint);
     }
-    ~Point() {}
+    ~Point()
+    {
+    }
 
     /// clear the initialized flag.
-    void clear() { myIsInitialized = false; }
+    void clear()
+    {
+      myIsInitialized = false;
+    }
     /// set the point and switch on the initialized flag
     /// \param thePoint the point
     void setPoint(const gp_Pnt& thePoint)
@@ -42,61 +51,52 @@ class PARTSET_EXPORT PartSet_OperationFeatureEdit : public PartSet_OperationSket
       myPoint = thePoint;
     }
 
-    bool myIsInitialized; /// the state whether the point is set
-    gp_Pnt myPoint; /// the point
+    bool myIsInitialized;  /// the state whether the point is set
+    gp_Pnt myPoint;  /// the point
   };
 
-public:
+ public:
   /// Returns the operation type key
-  static std::string Type() { return "EditLine"; }
+  static std::string Type()
+  {
+    return "EditLine";
+  }
 
-public:
+ public:
   /// Constructor
   /// \param theId the feature identifier
   /// \param theParent the operation parent
   /// \param theFeature the parent feature
-  PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent,
-                            FeaturePtr theFeature);
+  PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent, CompositeFeaturePtr theFeature);
   /// Destructor
   virtual ~PartSet_OperationFeatureEdit();
 
-  /// Returns that this operator can be started above already running one.
-  /// The runned operation should be the sketch feature modified operation
-  /// \param theOperation the previous running operation
-  virtual bool isGranted(ModuleBase_IOperation* theOperation) const;
-
-  /// Returns the operation local selection mode
-  /// \param theFeature the feature object to get the selection mode
-  /// \return the selection mode
-  virtual std::list<int> getSelectionModes(ObjectPtr theFeature) const;
 
-  /// Initializes the operation with previously created feature. It is used in sequental operations
-  virtual void initFeature(FeaturePtr theFeature);
-
-  /// Returns the operation sketch feature
-  /// \returns the sketch instance
-  virtual FeaturePtr sketch() const;
+  /// Initialisation of operation with preliminary selection
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  /// \param theViewer a viewer to have the viewer the eye position
+  virtual void initSelection(ModuleBase_ISelection* theSelection,
+                             ModuleBase_IViewer* theViewer);
 
   /// Processes the mouse pressed in the point
   /// \param theEvent the mouse event
   /// \param theView a viewer to have the viewer the eye position
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
-  virtual void mousePressed(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<ModuleBase_ViewerPrs>& theSelected,
-                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+  virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
+
   /// Gives the current mouse point in the viewer
   /// \param theEvent the mouse event
   /// \param theView a viewer to have the viewer the eye position
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
+  virtual void mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer);
   /// Gives the current selected objects to be processed by the operation
   /// \param thePoint a point clicked in the viewer
   /// \param theEvent the mouse event
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
- virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
-                            const std::list<ModuleBase_ViewerPrs>& theSelected,
-                            const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+  virtual void mouseReleased(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
+                             ModuleBase_ISelection* theSelection);
 
   /// Processes the mouse double click in the point
   /// \param theEvent the mouse event
@@ -104,14 +104,9 @@ public:
   /// \param theSelected the list of selected presentations
   /// \param theHighlighted the list of highlighted presentations
   virtual void mouseDoubleClick(QMouseEvent* theEvent, Handle_V3d_View theView,
-                                const std::list<ModuleBase_ViewerPrs>& theSelected,
-                                const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+                                ModuleBase_ISelection* theSelection);
 
-  /// Processes the key pressed in the view
-  /// \param theKey a key value
-  virtual void keyReleased(const int theKey);
-
-protected:
+ protected:
   /// \brief Virtual method called when operation is started
   /// Virtual method called when operation started (see start() method for more description)
   /// Switch off the multi selection state
@@ -125,23 +120,37 @@ protected:
   /// Returns NULL feature. This is an operation of edition, not creation.
   /// \param theFlushMessage the flag whether the create message should be flushed
   /// \returns the created feature
-  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true, 
+    CompositeFeaturePtr theCompositeFeature = CompositeFeaturePtr());
+
+ protected:
+   void fillFeature2Attribute(const QList<ModuleBase_ViewerPrs>& thePresentations,
+                              ModuleBase_IViewer* theViewer,
+                              std::map<FeaturePtr, std::list<std::string> >& theFeature2Attribute);
 
-protected:
   /// Emits a signal about the selection blocking. Emits a signal to change the selection.
   /// If the block is true, the signal clear selection, otherwise if restore selection flag allows,
   /// the internal operation features are to be selected
   /// \param isBlocked the state whether the operation is blocked or unblocked
   /// \param isRestoreSelection the state whether the selected objects should be reselected
-  void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
+  //void blockSelection(bool isBlocked, const bool isRestoreSelection = true);
 
   /// Sends the features
-  void sendFeatures();
+  /// \param theIsAllFeatures a boolean value whether all features should be send or only the highlighted ones
+  void sendFeatures(const bool theIsAllFeatures);
+
+  /// Sends signal about the current features are to be deactivated
+  void emitFeaturesDeactivation();
+
+ private:
+  // the next map should be removed when selection is processed in the move function
+  std::map<FeaturePtr, std::list<std::string> > myHighlightedFeature2Attribute; /// a map of a feature to attributes
+  std::map<FeaturePtr, std::list<std::string> > myAllFeature2Attribute; /// a map of a feature to attributes
 
-private:
-  FeaturePtr mySketch; ///< the sketch feature
-  Point myCurPoint; ///< the current 3D point clicked or moved
-  bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
+  Point myCurPoint;  ///< the current 3D point clicked or moved
+  bool myIsBlockedSelection;  ///< the state of the last state of selection blocked signal
+  bool myIsBlockedByDoubleClick;  ///< the block value by double click is processed to avoid
+  ///< the mouse button release processing before the double click is finished
 };
 
 #endif