]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
refs #80 - Sketch base GUI: create/draw point, circle and arc
authornds <natalia.donis@opencascade.com>
Tue, 10 Jun 2014 09:13:24 +0000 (13:13 +0400)
committernds <natalia.donis@opencascade.com>
Tue, 10 Jun 2014 09:13:24 +0000 (13:13 +0400)
Edit feature: rename edit line to edit feature.

src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationEditFeature.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationEditFeature.h [new file with mode: 0644]
src/PartSet/PartSet_OperationEditLine.cpp [deleted file]
src/PartSet/PartSet_OperationEditLine.h [deleted file]
src/PartSet/PartSet_OperationSketch.cpp

index a07a1f5990dfd8508477f558bda7376d77147efb..bb812080dea5ea5967af82ed346c3b5d63ba9cb0 100644 (file)
@@ -14,7 +14,7 @@ SET(PROJECT_HEADERS
        PartSet_Module.h
        PartSet_OperationConstraint.h
        PartSet_OperationCreateFeature.h
-       PartSet_OperationEditLine.h
+       PartSet_OperationEditFeature.h
        PartSet_OperationSketchBase.h
        PartSet_OperationSketch.h
        PartSet_Presentation.h
@@ -32,7 +32,7 @@ SET(PROJECT_SOURCES
        PartSet_Module.cpp
        PartSet_OperationConstraint.cpp
        PartSet_OperationCreateFeature.cpp
-       PartSet_OperationEditLine.cpp
+       PartSet_OperationEditFeature.cpp
        PartSet_OperationSketchBase.cpp
        PartSet_OperationSketch.cpp
        PartSet_Presentation.cpp
index d754eaf14d180eda34bc5970db8c6c27cf83a867..ae43f8a3a1dd50118947ead54cd83d40b1452972 100644 (file)
@@ -1,7 +1,7 @@
 #include <PartSet_Module.h>
 #include <PartSet_OperationSketch.h>
 #include <PartSet_OperationCreateFeature.h>
-#include <PartSet_OperationEditLine.h>
+#include <PartSet_OperationEditFeature.h>
 #include <PartSet_OperationConstraint.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
@@ -323,8 +323,8 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
       aSketch = aPrevOp->sketch();
     if (PartSet_OperationCreateFeature::canProcessKind(theCmdId))
       anOperation = new PartSet_OperationCreateFeature(theCmdId.c_str(), this, aSketch);
-    else if (theCmdId == PartSet_OperationEditLine::Type())
-      anOperation = new PartSet_OperationEditLine(theCmdId.c_str(), this, aSketch);
+    else if (theCmdId == PartSet_OperationEditFeature::Type())
+      anOperation = new PartSet_OperationEditFeature(theCmdId.c_str(), this, aSketch);
     else if (theCmdId == PartSet_OperationConstraint::Type())
       anOperation = new PartSet_OperationConstraint(theCmdId.c_str(), this, aSketch);
   }
diff --git a/src/PartSet/PartSet_OperationEditFeature.cpp b/src/PartSet/PartSet_OperationEditFeature.cpp
new file mode 100644 (file)
index 0000000..092df06
--- /dev/null
@@ -0,0 +1,247 @@
+// File:        PartSet_OperationEditFeature.h
+// Created:     05 May 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationEditFeature.h>
+#include <PartSet_Tools.h>
+#include <PartSet_OperationSketch.h>
+
+#include <ModuleBase_OperationDescription.h>
+#include <Model_Events.h>
+
+#include <XGUI_ViewerPrs.h>
+
+#include <SketchPlugin_Feature.h>
+#include <GeomDataAPI_Point2D.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+
+#include <Model_Events.h>
+
+#include <Events_Loop.h>
+
+#include <SketchPlugin_Line.h>
+
+#include <V3d_View.hxx>
+
+#ifdef _DEBUG
+#include <QDebug>
+#endif
+
+#include <QMouseEvent>
+
+using namespace std;
+
+PartSet_OperationEditFeature::PartSet_OperationEditFeature(const QString& theId,
+                                                 QObject* theParent,
+                                              FeaturePtr theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false)
+{
+}
+
+PartSet_OperationEditFeature::~PartSet_OperationEditFeature()
+{
+}
+
+bool PartSet_OperationEditFeature::isGranted(ModuleBase_IOperation* theOperation) const
+{
+  return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
+}
+
+std::list<int> PartSet_OperationEditFeature::getSelectionModes(FeaturePtr theFeature) const
+{
+  return PartSet_OperationSketchBase::getSelectionModes(theFeature);
+}
+
+void PartSet_OperationEditFeature::init(FeaturePtr theFeature,
+                                     const std::list<XGUI_ViewerPrs>& theSelected,
+                                     const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+  setFeature(theFeature);
+
+  if (!theHighlighted.empty()) {
+    // if there is highlighted object, we check whether it is in the list of selected objects
+    // in that case this object is a handle of the moved lines. If there no such object in the selection,
+    // the hightlighted object should moved and the selection is skipped. The skipped selection will be
+    // deselected in the viewer by blockSelection signal in the startOperation method.
+    bool isSelected = false;
+    std::list<XGUI_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
+    for (; anIt != aLast && !isSelected; anIt++) {
+      isSelected = (*anIt).feature() == feature();
+    }
+    if (!isSelected)
+      myFeatures = theHighlighted;
+    else
+      myFeatures = theSelected;
+  }
+  else
+    myFeatures = theSelected;
+}
+
+FeaturePtr PartSet_OperationEditFeature::sketch() const
+{
+  return mySketch;
+}
+
+void PartSet_OperationEditFeature::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                             const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                             const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+  if (myFeatures.size() == 1)
+  {
+    FeaturePtr aFeature;
+    if (!theHighlighted.empty())
+      aFeature = theHighlighted.front().feature();
+
+    if (aFeature && aFeature == feature()) { // continue the feature edit
+    }
+    else {
+      XGUI_ViewerPrs aFeaturePrs = myFeatures.front();
+      commit();
+      emit featureConstructed(feature(), FM_Deactivation);
+
+      bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
+      if(aHasShift && !theHighlighted.empty()) {
+        std::list<XGUI_ViewerPrs> aSelected;
+        aSelected.push_back(aFeaturePrs);
+        aSelected.push_back(theHighlighted.front());
+        emit setSelection(aSelected);
+      }
+      else if (aFeature) {
+        restartOperation(PartSet_OperationEditFeature::Type(), aFeature);
+      }
+    }
+  }
+}
+
+void PartSet_OperationEditFeature::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+{
+  if (!(theEvent->buttons() &  Qt::LeftButton))
+    return;
+
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+
+  blockSelection(true);
+  if (myCurPoint.myIsInitialized) {
+    double aCurX, aCurY;
+    PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY);
+
+    double aX, anY;
+    PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+
+    double aDeltaX = aX - aCurX;
+    double aDeltaY = anY - aCurY;
+
+    moveLinePoint(feature(), aDeltaX, aDeltaY, LINE_ATTR_START);
+    moveLinePoint(feature(), aDeltaX, aDeltaY, LINE_ATTR_END);
+
+    std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+    for (; anIt != aLast; anIt++) {
+      FeaturePtr aFeature = (*anIt).feature();
+      if (!aFeature || aFeature == feature())
+        continue;
+      moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_START);
+      moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_END);
+    }
+  }
+  sendFeatures();
+
+  myCurPoint.setPoint(aPoint);
+}
+
+void PartSet_OperationEditFeature::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                              const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                              const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+{
+  std::list<XGUI_ViewerPrs> aFeatures = myFeatures;
+  if (myFeatures.size() == 1) {
+    blockSelection(false);
+  }
+  else {
+    commit();
+    std::list<XGUI_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
+    for (; anIt != aLast; anIt++) {
+      FeaturePtr aFeature = (*anIt).feature();
+      if (aFeature)
+        emit featureConstructed(aFeature, FM_Deactivation);
+    }
+  }
+}
+
+void PartSet_OperationEditFeature::startOperation()
+{
+  // do nothing in order to do not create a new feature
+  emit multiSelectionEnabled(false);
+
+  if (myFeatures.size() > 1)
+    blockSelection(true);
+
+  myCurPoint.clear();
+}
+
+void PartSet_OperationEditFeature::stopOperation()
+{
+  emit multiSelectionEnabled(true);
+
+  blockSelection(false, myFeatures.size() > 1);
+
+  myFeatures.clear();
+}
+
+void PartSet_OperationEditFeature::blockSelection(bool isBlocked, const bool isRestoreSelection)
+{
+  if (myIsBlockedSelection == isBlocked)
+    return;
+
+  myIsBlockedSelection = isBlocked;
+  if (isBlocked) {
+    emit setSelection(std::list<XGUI_ViewerPrs>());
+    emit stopSelection(myFeatures, true);
+  }
+  else {
+    emit stopSelection(myFeatures, false);
+    if (isRestoreSelection)
+      emit setSelection(myFeatures);
+  }
+}
+
+FeaturePtr PartSet_OperationEditFeature::createFeature(const bool /*theFlushMessage*/)
+{
+  // do nothing in order to do not create a new feature
+  return FeaturePtr();
+}
+
+void PartSet_OperationEditFeature::moveLinePoint(FeaturePtr theFeature,
+                                               double theDeltaX, double theDeltaY,
+                                               const std::string& theAttribute)
+{
+  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+    return;
+
+  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
+  if (!aData->isValid())
+    return;
+  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
+        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
+
+  aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
+}
+
+void PartSet_OperationEditFeature::sendFeatures()
+{
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
+
+  std::list<FeaturePtr > aFeatures;
+  std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
+  for (; anIt != aLast; anIt++) {
+    FeaturePtr aFeature = (*anIt).feature();
+    if (!aFeature)
+      continue;
+
+    Model_FeatureUpdatedMessage aMessage(aFeature, anEvent);
+    Events_Loop::loop()->send(aMessage);
+  }
+  Events_Loop::loop()->flush(anEvent);
+  flushUpdated();
+}
+
diff --git a/src/PartSet/PartSet_OperationEditFeature.h b/src/PartSet/PartSet_OperationEditFeature.h
new file mode 100644 (file)
index 0000000..b3f5f8e
--- /dev/null
@@ -0,0 +1,147 @@
+// File:        PartSet_OperationEditFeature.h
+// Created:     05 May 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationEditFeature_H
+#define PartSet_OperationEditFeature_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <QObject>
+
+class QMouseEvent;
+
+/*!
+ \class PartSet_OperationEditFeature
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationEditFeature : public PartSet_OperationSketchBase                                                 
+{
+  Q_OBJECT
+  /// Struct to define gp point, with the state is the point is initialized
+  struct Point
+  {
+    /// Constructor
+    Point() {}
+    /// Constructor
+    /// \param thePoint the point
+    Point(gp_Pnt thePoint)
+    {
+      setPoint(thePoint);
+    }
+    ~Point() {}
+
+    /// clear the initialized flag.
+    void clear() { myIsInitialized = false; }
+    /// set the point and switch on the initialized flag
+    /// \param thePoint the point
+    void setPoint(const gp_Pnt& thePoint)
+    {
+      myIsInitialized = true;
+      myPoint = thePoint;
+    }
+
+    bool myIsInitialized; /// the state whether the point is set
+    gp_Pnt myPoint; /// the point
+  };
+
+public:
+  /// Returns the operation type key
+  static std::string Type() { return "EditLine"; }
+
+public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  /// \param theFeature the parent feature
+  PartSet_OperationEditFeature(const QString& theId, QObject* theParent,
+                            FeaturePtr theFeature);
+  /// Destructor
+  virtual ~PartSet_OperationEditFeature();
+
+  /// 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(FeaturePtr theFeature) const;
+
+  /// Initializes some fields accorging to the feature
+  /// \param theFeature the feature
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  virtual void init(FeaturePtr theFeature,
+                    const std::list<XGUI_ViewerPrs>& theSelected,
+                    const std::list<XGUI_ViewerPrs>& theHighlighted);
+
+  /// Returns the operation sketch feature
+  /// \returns the sketch instance
+  virtual FeaturePtr sketch() const;
+
+  /// 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<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+  /// 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);
+  /// 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<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_ViewerPrs>& theHighlighted);
+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
+  virtual void startOperation();
+
+  /// Virtual method called when operation stopped - committed or aborted.
+  /// Restore the multi selection state
+  virtual void stopOperation();
+
+  /// Creates an operation new feature
+  /// 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);
+
+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);
+
+  /// \brief Save the point to the line.
+  /// \param theFeature the source feature
+  /// \param theDeltaX the delta for X coordinate is moved
+  /// \param theDeltaY the delta for Y coordinate is moved
+  /// \param theAttribute the start or end attribute of the line
+  void  moveLinePoint(FeaturePtr theFeature,
+                      double theDeltaX, double theDeltaY,
+                      const std::string& theAttribute);
+  /// Sends the features
+  void sendFeatures();
+
+private:
+  FeaturePtr mySketch; ///< the sketch feature
+  std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
+  Point myCurPoint; ///< the current 3D point clicked or moved
+  bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
+};
+
+#endif
diff --git a/src/PartSet/PartSet_OperationEditLine.cpp b/src/PartSet/PartSet_OperationEditLine.cpp
deleted file mode 100644 (file)
index af46da9..0000000
+++ /dev/null
@@ -1,247 +0,0 @@
-// File:        PartSet_OperationEditLine.h
-// Created:     05 May 2014
-// Author:      Natalia ERMOLAEVA
-
-#include <PartSet_OperationEditLine.h>
-#include <PartSet_Tools.h>
-#include <PartSet_OperationSketch.h>
-
-#include <ModuleBase_OperationDescription.h>
-#include <Model_Events.h>
-
-#include <XGUI_ViewerPrs.h>
-
-#include <SketchPlugin_Feature.h>
-#include <GeomDataAPI_Point2D.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Document.h>
-
-#include <Model_Events.h>
-
-#include <Events_Loop.h>
-
-#include <SketchPlugin_Line.h>
-
-#include <V3d_View.hxx>
-
-#ifdef _DEBUG
-#include <QDebug>
-#endif
-
-#include <QMouseEvent>
-
-using namespace std;
-
-PartSet_OperationEditLine::PartSet_OperationEditLine(const QString& theId,
-                                                 QObject* theParent,
-                                              FeaturePtr theFeature)
-: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false)
-{
-}
-
-PartSet_OperationEditLine::~PartSet_OperationEditLine()
-{
-}
-
-bool PartSet_OperationEditLine::isGranted(ModuleBase_IOperation* theOperation) const
-{
-  return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
-}
-
-std::list<int> PartSet_OperationEditLine::getSelectionModes(FeaturePtr theFeature) const
-{
-  return PartSet_OperationSketchBase::getSelectionModes(theFeature);
-}
-
-void PartSet_OperationEditLine::init(FeaturePtr theFeature,
-                                     const std::list<XGUI_ViewerPrs>& theSelected,
-                                     const std::list<XGUI_ViewerPrs>& theHighlighted)
-{
-  setFeature(theFeature);
-
-  if (!theHighlighted.empty()) {
-    // if there is highlighted object, we check whether it is in the list of selected objects
-    // in that case this object is a handle of the moved lines. If there no such object in the selection,
-    // the hightlighted object should moved and the selection is skipped. The skipped selection will be
-    // deselected in the viewer by blockSelection signal in the startOperation method.
-    bool isSelected = false;
-    std::list<XGUI_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
-    for (; anIt != aLast && !isSelected; anIt++) {
-      isSelected = (*anIt).feature() == feature();
-    }
-    if (!isSelected)
-      myFeatures = theHighlighted;
-    else
-      myFeatures = theSelected;
-  }
-  else
-    myFeatures = theSelected;
-}
-
-FeaturePtr PartSet_OperationEditLine::sketch() const
-{
-  return mySketch;
-}
-
-void PartSet_OperationEditLine::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                             const std::list<XGUI_ViewerPrs>& /*theSelected*/,
-                                             const std::list<XGUI_ViewerPrs>& theHighlighted)
-{
-  if (myFeatures.size() == 1)
-  {
-    FeaturePtr aFeature;
-    if (!theHighlighted.empty())
-      aFeature = theHighlighted.front().feature();
-
-    if (aFeature && aFeature == feature()) { // continue the feature edit
-    }
-    else {
-      XGUI_ViewerPrs aFeaturePrs = myFeatures.front();
-      commit();
-      emit featureConstructed(feature(), FM_Deactivation);
-
-      bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
-      if(aHasShift && !theHighlighted.empty()) {
-        std::list<XGUI_ViewerPrs> aSelected;
-        aSelected.push_back(aFeaturePrs);
-        aSelected.push_back(theHighlighted.front());
-        emit setSelection(aSelected);
-      }
-      else if (aFeature) {
-        restartOperation(PartSet_OperationEditLine::Type(), aFeature);
-      }
-    }
-  }
-}
-
-void PartSet_OperationEditLine::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
-{
-  if (!(theEvent->buttons() &  Qt::LeftButton))
-    return;
-
-  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
-
-  blockSelection(true);
-  if (myCurPoint.myIsInitialized) {
-    double aCurX, aCurY;
-    PartSet_Tools::convertTo2D(myCurPoint.myPoint, sketch(), theView, aCurX, aCurY);
-
-    double aX, anY;
-    PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
-
-    double aDeltaX = aX - aCurX;
-    double aDeltaY = anY - aCurY;
-
-    moveLinePoint(feature(), aDeltaX, aDeltaY, LINE_ATTR_START);
-    moveLinePoint(feature(), aDeltaX, aDeltaY, LINE_ATTR_END);
-
-    std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
-    for (; anIt != aLast; anIt++) {
-      FeaturePtr aFeature = (*anIt).feature();
-      if (!aFeature || aFeature == feature())
-        continue;
-      moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_START);
-      moveLinePoint(aFeature, aDeltaX, aDeltaY, LINE_ATTR_END);
-    }
-  }
-  sendFeatures();
-
-  myCurPoint.setPoint(aPoint);
-}
-
-void PartSet_OperationEditLine::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
-                                              const std::list<XGUI_ViewerPrs>& /*theSelected*/,
-                                              const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
-{
-  std::list<XGUI_ViewerPrs> aFeatures = myFeatures;
-  if (myFeatures.size() == 1) {
-    blockSelection(false);
-  }
-  else {
-    commit();
-    std::list<XGUI_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
-    for (; anIt != aLast; anIt++) {
-      FeaturePtr aFeature = (*anIt).feature();
-      if (aFeature)
-        emit featureConstructed(aFeature, FM_Deactivation);
-    }
-  }
-}
-
-void PartSet_OperationEditLine::startOperation()
-{
-  // do nothing in order to do not create a new feature
-  emit multiSelectionEnabled(false);
-
-  if (myFeatures.size() > 1)
-    blockSelection(true);
-
-  myCurPoint.clear();
-}
-
-void PartSet_OperationEditLine::stopOperation()
-{
-  emit multiSelectionEnabled(true);
-
-  blockSelection(false, myFeatures.size() > 1);
-
-  myFeatures.clear();
-}
-
-void PartSet_OperationEditLine::blockSelection(bool isBlocked, const bool isRestoreSelection)
-{
-  if (myIsBlockedSelection == isBlocked)
-    return;
-
-  myIsBlockedSelection = isBlocked;
-  if (isBlocked) {
-    emit setSelection(std::list<XGUI_ViewerPrs>());
-    emit stopSelection(myFeatures, true);
-  }
-  else {
-    emit stopSelection(myFeatures, false);
-    if (isRestoreSelection)
-      emit setSelection(myFeatures);
-  }
-}
-
-FeaturePtr PartSet_OperationEditLine::createFeature(const bool /*theFlushMessage*/)
-{
-  // do nothing in order to do not create a new feature
-  return FeaturePtr();
-}
-
-void PartSet_OperationEditLine::moveLinePoint(FeaturePtr theFeature,
-                                               double theDeltaX, double theDeltaY,
-                                               const std::string& theAttribute)
-{
-  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
-    return;
-
-  boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
-  if (!aData->isValid())
-    return;
-  boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
-        boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(theAttribute));
-
-  aPoint->setValue(aPoint->x() + theDeltaX, aPoint->y() + theDeltaY);
-}
-
-void PartSet_OperationEditLine::sendFeatures()
-{
-  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
-
-  std::list<FeaturePtr > aFeatures;
-  std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
-  for (; anIt != aLast; anIt++) {
-    FeaturePtr aFeature = (*anIt).feature();
-    if (!aFeature)
-      continue;
-
-    Model_FeatureUpdatedMessage aMessage(aFeature, anEvent);
-    Events_Loop::loop()->send(aMessage);
-  }
-  Events_Loop::loop()->flush(anEvent);
-  flushUpdated();
-}
-
diff --git a/src/PartSet/PartSet_OperationEditLine.h b/src/PartSet/PartSet_OperationEditLine.h
deleted file mode 100644 (file)
index 1e18c15..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-// File:        PartSet_OperationEditLine.h
-// Created:     05 May 2014
-// Author:      Natalia ERMOLAEVA
-
-#ifndef PartSet_OperationEditLine_H
-#define PartSet_OperationEditLine_H
-
-#include "PartSet.h"
-
-#include <PartSet_OperationSketchBase.h>
-#include <QObject>
-
-class QMouseEvent;
-
-/*!
- \class PartSet_OperationEditLine
- * \brief The operation for the sketch feature creation
-*/
-class PARTSET_EXPORT PartSet_OperationEditLine : public PartSet_OperationSketchBase                                                 
-{
-  Q_OBJECT
-  /// Struct to define gp point, with the state is the point is initialized
-  struct Point
-  {
-    /// Constructor
-    Point() {}
-    /// Constructor
-    /// \param thePoint the point
-    Point(gp_Pnt thePoint)
-    {
-      setPoint(thePoint);
-    }
-    ~Point() {}
-
-    /// clear the initialized flag.
-    void clear() { myIsInitialized = false; }
-    /// set the point and switch on the initialized flag
-    /// \param thePoint the point
-    void setPoint(const gp_Pnt& thePoint)
-    {
-      myIsInitialized = true;
-      myPoint = thePoint;
-    }
-
-    bool myIsInitialized; /// the state whether the point is set
-    gp_Pnt myPoint; /// the point
-  };
-
-public:
-  /// Returns the operation type key
-  static std::string Type() { return "EditLine"; }
-
-public:
-  /// Constructor
-  /// \param theId the feature identifier
-  /// \param theParent the operation parent
-  /// \param theFeature the parent feature
-  PartSet_OperationEditLine(const QString& theId, QObject* theParent,
-                            FeaturePtr theFeature);
-  /// Destructor
-  virtual ~PartSet_OperationEditLine();
-
-  /// 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(FeaturePtr theFeature) const;
-
-  /// Initializes some fields accorging to the feature
-  /// \param theFeature the feature
-  /// \param theSelected the list of selected presentations
-  /// \param theHighlighted the list of highlighted presentations
-  virtual void init(FeaturePtr theFeature,
-                    const std::list<XGUI_ViewerPrs>& theSelected,
-                    const std::list<XGUI_ViewerPrs>& theHighlighted);
-
-  /// Returns the operation sketch feature
-  /// \returns the sketch instance
-  virtual FeaturePtr sketch() const;
-
-  /// 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<XGUI_ViewerPrs>& theSelected,
-                            const std::list<XGUI_ViewerPrs>& theHighlighted);
-  /// 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);
-  /// 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<XGUI_ViewerPrs>& theSelected,
-                            const std::list<XGUI_ViewerPrs>& theHighlighted);
-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
-  virtual void startOperation();
-
-  /// Virtual method called when operation stopped - committed or aborted.
-  /// Restore the multi selection state
-  virtual void stopOperation();
-
-  /// Creates an operation new feature
-  /// 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);
-
-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);
-
-  /// \brief Save the point to the line.
-  /// \param theFeature the source feature
-  /// \param theDeltaX the delta for X coordinate is moved
-  /// \param theDeltaY the delta for Y coordinate is moved
-  /// \param theAttribute the start or end attribute of the line
-  void  moveLinePoint(FeaturePtr theFeature,
-                      double theDeltaX, double theDeltaY,
-                      const std::string& theAttribute);
-  /// Sends the features
-  void sendFeatures();
-
-private:
-  FeaturePtr mySketch; ///< the sketch feature
-  std::list<XGUI_ViewerPrs> myFeatures; ///< the features to apply the edit operation
-  Point myCurPoint; ///< the current 3D point clicked or moved
-  bool myIsBlockedSelection; ///< the state of the last state of selection blocked signal
-};
-
-#endif
index 039d293b39600b053b4d4cfca45565be6a40e561..33a0a22bdd52918f51b3f50214592ef8b322371f 100644 (file)
@@ -4,7 +4,7 @@
 
 #include <PartSet_OperationSketch.h>
 
-#include <PartSet_OperationEditLine.h>
+#include <PartSet_OperationEditFeature.h>
 #include <PartSet_Tools.h>
 
 #include <SketchPlugin_Sketch.h>
@@ -90,7 +90,7 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
     if (theHighlighted.size() == 1) {
       FeaturePtr aFeature = theHighlighted.front().feature();
       if (aFeature)
-        restartOperation(PartSet_OperationEditLine::Type(), aFeature);
+        restartOperation(PartSet_OperationEditFeature::Type(), aFeature);
     }
     else
       myFeatures = theHighlighted;
@@ -139,7 +139,7 @@ void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View)
     FeaturePtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(),
                                                                 theView, feature(), myFeatures);
     if (aFeature)
-      restartOperation(PartSet_OperationEditLine::Type(), aFeature);
+      restartOperation(PartSet_OperationEditFeature::Type(), aFeature);
   }
 }