]> 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>
Wed, 25 Jun 2014 04:43:57 +0000 (08:43 +0400)
committernds <natalia.donis@opencascade.com>
Wed, 25 Jun 2014 04:43:57 +0000 (08:43 +0400)
Edit/multi edit are separated.

15 files changed:
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_Module.h
src/PartSet/PartSet_OperationEditConstraint.cpp
src/PartSet/PartSet_OperationEditFeature.cpp [deleted file]
src/PartSet/PartSet_OperationEditFeature.h [deleted file]
src/PartSet/PartSet_OperationFeatureEdit.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationFeatureEdit.h [new file with mode: 0644]
src/PartSet/PartSet_OperationFeatureEditMulti.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationFeatureEditMulti.h [new file with mode: 0644]
src/PartSet/PartSet_OperationSketch.cpp
src/PartSet/PartSet_OperationSketchBase.h
src/PartSet/PartSet_TestOCC.cpp
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Displayer.h

index c720df3298132fa8c7de980142ec45ef4a1c99a6..a429b06778343a782551c21044abb3fee95693bd 100644 (file)
@@ -19,8 +19,9 @@ SET(PROJECT_HEADERS
        PartSet_OperationCreateConstraint.h
        PartSet_OperationCreateFeature.h
        PartSet_OperationEditConstraint.h
-       PartSet_OperationEditFeature.h
        PartSet_OperationFeatureCreate.h
+       PartSet_OperationFeatureEdit.h
+       PartSet_OperationFeatureEditMulti.h
        PartSet_OperationSketchBase.h
        PartSet_OperationSketch.h
        PartSet_TestOCC.h
@@ -42,8 +43,9 @@ SET(PROJECT_SOURCES
        PartSet_OperationCreateConstraint.cpp
        PartSet_OperationCreateFeature.cpp
        PartSet_OperationEditConstraint.cpp
-       PartSet_OperationEditFeature.cpp
        PartSet_OperationFeatureCreate.cpp
+       PartSet_OperationFeatureEdit.cpp
+       PartSet_OperationFeatureEditMulti.cpp
        PartSet_OperationSketchBase.cpp
        PartSet_OperationSketch.cpp
        PartSet_TestOCC.cpp
index 409b8d7efad5eebd532a67510264a018136d4d62..bc88fa82119949b60fd018e8030c2b892843821c 100644 (file)
@@ -1,10 +1,11 @@
 #include <PartSet_Module.h>
 #include <PartSet_OperationSketch.h>
 #include <PartSet_OperationCreateFeature.h>
-#include <PartSet_OperationEditFeature.h>
 #include <PartSet_OperationEditConstraint.h>
 #include <PartSet_OperationCreateConstraint.h>
 #include <PartSet_OperationFeatureCreate.h>
+#include <PartSet_OperationFeatureEditMulti.h>
+#include <PartSet_OperationFeatureEdit.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetFactory.h>
@@ -252,8 +253,8 @@ void PartSet_Module::onLaunchOperation(std::string theName, FeaturePtr theFeatur
   {
     XGUI_Displayer* aDisplayer = myWorkshop->displayer();
     // refill the features list with avoiding of the features, obtained only by vertex shape (TODO)
-    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected(TopAbs_VERTEX);
-    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted(TopAbs_VERTEX);
+    std::list<XGUI_ViewerPrs> aSelected = aDisplayer->getSelected();
+    std::list<XGUI_ViewerPrs> aHighlighted = aDisplayer->getHighlighted();
     aPreviewOp->init(theFeature, aSelected, aHighlighted);
   } else {
     anOperation->setEditingFeature(theFeature);
@@ -268,14 +269,13 @@ void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
   aViewer->enableMultiselection(theEnabled);
 }
 
-void PartSet_Module::onStopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop)
+void PartSet_Module::onStopSelection(const QFeatureList& theFeatures, const bool isStop)
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   if (!isStop) {
-    std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
-    FeaturePtr aFeature;
+    QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
     for (; anIt != aLast; anIt++) {
-      activateFeature((*anIt).feature(), false);
+      activateFeature((*anIt), false);
     }
   }
   aDisplayer->stopSelection(theFeatures, isStop, false);
@@ -286,7 +286,7 @@ void PartSet_Module::onStopSelection(const std::list<XGUI_ViewerPrs>& theFeature
   aDisplayer->updateViewer();
 }
 
-void PartSet_Module::onSetSelection(const std::list<XGUI_ViewerPrs>& theFeatures)
+void PartSet_Module::onSetSelection(const QFeatureList& theFeatures)
 {
   XGUI_Displayer* aDisplayer = myWorkshop->displayer();
   aDisplayer->setSelected(theFeatures, false);
@@ -343,10 +343,12 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
       aSketch = aPrevOp->sketch();
     if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId))
       anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
-    else if (PartSet_OperationCreateFeature::canProcessKind(theCmdId))
+       else if (PartSet_OperationCreateFeature::canProcessKind(theCmdId))
       anOperation = new PartSet_OperationCreateFeature(theCmdId.c_str(), this, aSketch);
-    else if (theCmdId == PartSet_OperationEditFeature::Type())
-      anOperation = new PartSet_OperationEditFeature(theCmdId.c_str(), this, aSketch);
+       else if (theCmdId == PartSet_OperationFeatureEditMulti::Type())
+               anOperation = new PartSet_OperationFeatureEditMulti(theCmdId.c_str(), this, aSketch);
+    else if (theCmdId == PartSet_OperationFeatureEdit::Type())
+      anOperation = new PartSet_OperationFeatureEdit(theCmdId.c_str(), this, aSketch);
     else if (PartSet_OperationCreateConstraint::canProcessKind(theCmdId))
       anOperation = new PartSet_OperationCreateConstraint(theCmdId.c_str(), this, aSketch);
     else if (theCmdId == PartSet_OperationEditConstraint::Type())
@@ -390,10 +392,10 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
 
     connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
             this, SLOT(onMultiSelectionEnabled(bool)));
-    connect(aPreviewOp, SIGNAL(stopSelection(const std::list<XGUI_ViewerPrs>&, const bool)),
-            this, SLOT(onStopSelection(const std::list<XGUI_ViewerPrs>&, const bool)));
-    connect(aPreviewOp, SIGNAL(setSelection(const std::list<XGUI_ViewerPrs>&)),
-            this, SLOT(onSetSelection(const std::list<XGUI_ViewerPrs>&)));
+    connect(aPreviewOp, SIGNAL(stopSelection(const QFeatureList&, const bool)),
+            this, SLOT(onStopSelection(const QFeatureList&, const bool)));
+    connect(aPreviewOp, SIGNAL(setSelection(const QFeatureList&)),
+            this, SLOT(onSetSelection(const QFeatureList&)));
 
      connect(aPreviewOp, SIGNAL(closeLocalContext()),
              this, SLOT(onCloseLocalContext()));
index 49fb587da76e1767f5a4384bbb2e8641983ea819..0bdcb88f03774e7ac0540d035ea927eb38e4fccb 100644 (file)
@@ -105,11 +105,11 @@ public slots:
   /// SLOT, to stop or start selection mode for the features
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
-  void onStopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop);
+  void onStopSelection(const QFeatureList& theFeatures, const bool isStop);
 
   /// SLOT, to set selection
   /// \param theFeatures a list of features to be selected
-  void onSetSelection(const std::list<XGUI_ViewerPrs>& theFeatures);
+  void onSetSelection(const QFeatureList& theFeatures);
 
   /// SLOT, to close the viewer local context
   void onCloseLocalContext();
index 07416339a40630a01aec9487800c7aa1a5a0577d..d7ed7d01e41740637f1d3ada9a67bc567adfc0e0 100644 (file)
@@ -233,7 +233,7 @@ void PartSet_OperationEditConstraint::blockSelection(bool isBlocked, const bool
 
   myIsBlockedSelection = isBlocked;
   if (isBlocked) {
-    emit setSelection(std::list<XGUI_ViewerPrs>());
+    emit setSelection(QFeatureList());
     //emit stopSelection(myFeatures, true);
   }
   else {
diff --git a/src/PartSet/PartSet_OperationEditFeature.cpp b/src/PartSet/PartSet_OperationEditFeature.cpp
deleted file mode 100644 (file)
index 5f53b18..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-// 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)
-{
-  setEditingFeature(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;
-
-    boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = 
-                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
-    aSketchFeature->move(aDeltaX, aDeltaY);
-
-    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;
-      aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-      aSketchFeature->move(aDeltaX, aDeltaY);
-    }
-  }
-  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()
-{
-  PartSet_OperationSketchBase::startOperation();
-  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::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
deleted file mode 100644 (file)
index c817fc1..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-// 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);
-
-  /// 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_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp
new file mode 100644 (file)
index 0000000..2626c68
--- /dev/null
@@ -0,0 +1,181 @@
+// File:        PartSet_OperationFeatureEdit.h
+// Created:     05 May 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationFeatureEdit.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_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId,
+                                                 QObject* theParent,
+                                              FeaturePtr theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false)
+{
+}
+
+PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit()
+{
+}
+
+bool PartSet_OperationFeatureEdit::isGranted(ModuleBase_IOperation* theOperation) const
+{
+  return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
+}
+
+std::list<int> PartSet_OperationFeatureEdit::getSelectionModes(FeaturePtr theFeature) const
+{
+  return PartSet_OperationSketchBase::getSelectionModes(theFeature);
+}
+
+void PartSet_OperationFeatureEdit::init(FeaturePtr theFeature,
+                                     const std::list<XGUI_ViewerPrs>& theSelected,
+                                     const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+  setEditingFeature(theFeature);
+}
+
+FeaturePtr PartSet_OperationFeatureEdit::sketch() const
+{
+  return mySketch;
+}
+
+void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                             const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                             const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+  FeaturePtr aFeature;
+  if (!theHighlighted.empty())
+    aFeature = theHighlighted.front().feature();
+
+  if (!aFeature || aFeature != feature())
+  {
+    commit();
+    emit featureConstructed(feature(), FM_Deactivation);
+
+    bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
+    if(aHasShift && !theHighlighted.empty()) {
+      QFeatureList aSelected;
+      aSelected.push_back(feature());
+      aSelected.push_back(theHighlighted.front().feature());
+      emit setSelection(aSelected);
+    }
+    else if (aFeature) {
+      restartOperation(PartSet_OperationFeatureEdit::Type(), aFeature);
+    }
+  }
+}
+
+void PartSet_OperationFeatureEdit::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;
+
+    boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = 
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+    aSketchFeature->move(aDeltaX, aDeltaY);
+  }
+  sendFeatures();
+
+  myCurPoint.setPoint(aPoint);
+}
+
+void PartSet_OperationFeatureEdit::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                              const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                              const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+{
+  blockSelection(false);
+}
+
+void PartSet_OperationFeatureEdit::startOperation()
+{
+  PartSet_OperationSketchBase::startOperation();
+  emit multiSelectionEnabled(false);
+
+  myCurPoint.clear();
+}
+
+void PartSet_OperationFeatureEdit::stopOperation()
+{
+  emit multiSelectionEnabled(true);
+
+  blockSelection(false, false);
+}
+
+void PartSet_OperationFeatureEdit::blockSelection(bool isBlocked, const bool isRestoreSelection)
+{
+  if (myIsBlockedSelection == isBlocked)
+    return;
+
+  myIsBlockedSelection = isBlocked;
+  QFeatureList aFeatureList;
+  aFeatureList.append(feature());
+
+  if (isBlocked) {
+    emit setSelection(QFeatureList());
+    emit stopSelection(aFeatureList, true);
+  }
+  else {
+    emit stopSelection(aFeatureList, false);
+    if (isRestoreSelection)
+      emit setSelection(aFeatureList);
+  }
+}
+
+FeaturePtr PartSet_OperationFeatureEdit::createFeature(const bool /*theFlushMessage*/)
+{
+  // do nothing in order to do not create a new feature
+  return FeaturePtr();
+}
+
+void PartSet_OperationFeatureEdit::sendFeatures()
+{
+  static Events_ID anEvent = Events_Loop::eventByName(EVENT_FEATURE_MOVED);
+
+  FeaturePtr aFeature = feature();
+
+  Model_FeatureUpdatedMessage aMessage(aFeature, anEvent);
+  Events_Loop::loop()->send(aMessage);
+
+  Events_Loop::loop()->flush(anEvent);
+  flushUpdated();
+}
+
diff --git a/src/PartSet/PartSet_OperationFeatureEdit.h b/src/PartSet/PartSet_OperationFeatureEdit.h
new file mode 100644 (file)
index 0000000..4659584
--- /dev/null
@@ -0,0 +1,138 @@
+// File:        PartSet_OperationFeatureEdit.h
+// Created:     05 May 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationFeatureEdit_H
+#define PartSet_OperationFeatureEdit_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <QObject>
+
+class QMouseEvent;
+
+/*!
+ \class PartSet_OperationFeatureEdit
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationFeatureEdit : 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_OperationFeatureEdit(const QString& theId, QObject* theParent,
+                            FeaturePtr 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(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);
+
+  /// Sends the features
+  void sendFeatures();
+
+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
+};
+
+#endif
diff --git a/src/PartSet/PartSet_OperationFeatureEditMulti.cpp b/src/PartSet/PartSet_OperationFeatureEditMulti.cpp
new file mode 100644 (file)
index 0000000..d719df8
--- /dev/null
@@ -0,0 +1,197 @@
+// File:        PartSet_OperationFeatureEditMulti.h
+// Created:     05 May 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationFeatureEditMulti.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_OperationFeatureEditMulti::PartSet_OperationFeatureEditMulti(const QString& theId,
+                                                 QObject* theParent,
+                                              FeaturePtr theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myIsBlockedSelection(false)
+{
+}
+
+PartSet_OperationFeatureEditMulti::~PartSet_OperationFeatureEditMulti()
+{
+}
+
+bool PartSet_OperationFeatureEditMulti::isGranted(ModuleBase_IOperation* theOperation) const
+{
+  return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
+}
+
+void PartSet_OperationFeatureEditMulti::init(FeaturePtr theFeature,
+                                     const std::list<XGUI_ViewerPrs>& theSelected,
+                                     const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+  setEditingFeature(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_OperationFeatureEditMulti::sketch() const
+{
+  return mySketch;
+}
+
+void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                             const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                             const std::list<XGUI_ViewerPrs>& theHighlighted)
+{
+}
+
+void PartSet_OperationFeatureEditMulti::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;
+
+    boost::shared_ptr<SketchPlugin_Feature> aSketchFeature = 
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(feature());
+    aSketchFeature->move(aDeltaX, aDeltaY);
+
+    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;
+      aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+      aSketchFeature->move(aDeltaX, aDeltaY);
+    }
+  }
+  sendFeatures();
+
+  myCurPoint.setPoint(aPoint);
+}
+
+void PartSet_OperationFeatureEditMulti::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;
+  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_OperationFeatureEditMulti::startOperation()
+{
+  PartSet_OperationSketchBase::startOperation();
+  emit multiSelectionEnabled(false);
+
+  blockSelection(true);
+
+  myCurPoint.clear();
+}
+
+void PartSet_OperationFeatureEditMulti::stopOperation()
+{
+  emit multiSelectionEnabled(true);
+
+  blockSelection(false, true);
+
+  myFeatures.clear();
+}
+
+void PartSet_OperationFeatureEditMulti::blockSelection(bool isBlocked, const bool isRestoreSelection)
+{
+  if (myIsBlockedSelection == isBlocked)
+    return;
+
+  myIsBlockedSelection = isBlocked;
+  QFeatureList aFeatureList;
+  std::list<XGUI_ViewerPrs>::const_iterator anIt = myFeatures.begin(),
+                                            aLast = myFeatures.end();
+  for(; anIt != aLast; anIt++)
+    aFeatureList.append((*anIt).feature());
+  if (isBlocked) {
+    emit setSelection(QFeatureList());
+    emit stopSelection(aFeatureList, true);
+  }
+  else {
+    emit stopSelection(aFeatureList, false);
+    if (isRestoreSelection) {
+      emit setSelection(aFeatureList);
+    }
+  }
+}
+
+void PartSet_OperationFeatureEditMulti::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_OperationFeatureEditMulti.h b/src/PartSet/PartSet_OperationFeatureEditMulti.h
new file mode 100644 (file)
index 0000000..f21a78a
--- /dev/null
@@ -0,0 +1,128 @@
+// File:        PartSet_OperationFeatureEditMulti.h
+// Created:     05 May 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationFeatureEditMulti_H
+#define PartSet_OperationFeatureEditMulti_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <QObject>
+
+class QMouseEvent;
+
+/*!
+ \class PartSet_OperationFeatureEditMulti
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationFeatureEditMulti : 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 "EditMulti"; }
+
+public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  /// \param theFeature the parent feature
+  PartSet_OperationFeatureEditMulti(const QString& theId, QObject* theParent,
+                            FeaturePtr theFeature);
+  /// Destructor
+  virtual ~PartSet_OperationFeatureEditMulti();
+
+  /// 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;
+
+  /// 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();
+
+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);
+
+  /// 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 dcce1c5fbe655d4b68068272086aa9accc9176aa..702f8cdb6764718f0ff1e77e6907d5403283ce11 100644 (file)
@@ -4,7 +4,8 @@
 
 #include <PartSet_OperationSketch.h>
 
-#include <PartSet_OperationEditFeature.h>
+#include <PartSet_OperationFeatureEdit.h>
+#include <PartSet_OperationFeatureEditMulti.h>
 #include <PartSet_OperationEditConstraint.h>
 #include <PartSet_Tools.h>
 
@@ -92,8 +93,12 @@ void PartSet_OperationSketch::mousePressed(QMouseEvent* theEvent, Handle_V3d_Vie
 
     if (theHighlighted.size() == 1) {
       FeaturePtr aFeature = theHighlighted.front().feature();
-      if (aFeature)
-        restartOperation(getOperationType(aFeature), aFeature);
+      if (aFeature) {
+        std::string anOperationType = getOperationType(aFeature);
+        if (theSelected.size() > 1)
+          anOperationType = PartSet_OperationFeatureEditMulti::Type();
+        restartOperation(anOperationType, aFeature);
+      }
     }
     else
       myFeatures = theHighlighted;
@@ -125,7 +130,7 @@ void PartSet_OperationSketch::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View)
     FeaturePtr aFeature = PartSet_Tools::nearestFeature(theEvent->pos(), theView, feature(),
                                                         myFeatures);
     if (aFeature)
-      restartOperation(getOperationType(aFeature), aFeature);
+               restartOperation(PartSet_OperationFeatureEditMulti::Type(), aFeature);
   }
 }
 
@@ -240,7 +245,7 @@ void PartSet_OperationSketch::setSketchPlane(const TopoDS_Shape& theShape)
 
 std::string PartSet_OperationSketch::getOperationType(FeaturePtr theFeature)
 {
-  std::string aType = PartSet_OperationEditFeature::Type();
+  std::string aType = PartSet_OperationFeatureEdit::Type();
 
   if (PartSet_Tools::isConstraintFeature(theFeature->getKind())) {
     aType = PartSet_OperationEditConstraint::Type();
index 5f4d556e07e27f1fc0203221a52f170404f1abdc..cb51f46b9ce2827a5308fb17ce0420ab7dc76a61 100644 (file)
@@ -13,6 +13,9 @@
 
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_Operation.h>
+
+#include <XGUI_Constants.h>
+
 #include <QObject>
 
 #include <map>
@@ -134,10 +137,10 @@ signals:
   /// signal to enable/disable selection in the viewer
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
-  void stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool theToStop);
+  void stopSelection(const QFeatureList& theFeatures, const bool theToStop);
   /// signal to set selection in the viewer
   /// \param theFeatures a list of features to be disabled
-  void setSelection(const std::list<XGUI_ViewerPrs>& theFeatures);
+  void setSelection(const QFeatureList& theFeatures);
 
   /// signal to close the operation local context if it is opened
   void closeLocalContext();
index 0ca4d5b6e8562ad780def95d3b2675cea95b3cf7..7e104ca34aa0e7885a96ea76eb142b5e583e0c05 100644 (file)
@@ -184,9 +184,9 @@ void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop)
     //aDisplayer->activateInLocalContext(aFeature, aModes, true);
     myTestFeature = aFeature;
 
-    std::list<XGUI_ViewerPrs> aPrs;
-    aPrs.push_back(XGUI_ViewerPrs(myTestFeature, TopoDS_Shape(), NULL));
-    aDisplayer->setSelected(aPrs, true);
+    QFeatureList aFeatureList;
+    aFeatureList.append(myTestFeature);
+    aDisplayer->setSelected(aFeatureList, true);
   }
 }
 
@@ -215,9 +215,9 @@ void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
   //aModes.push_back(TopAbs_EDGE);
   //aDisplayer->activateInLocalContext(aFeature, aModes, true);
 
-  /*std::list<XGUI_ViewerPrs> aPrs;
-  aPrs.push_back(XGUI_ViewerPrs(myTestFeature, TopoDS_Shape()));
-  theWorkshop->displayer()->setSelected(aPrs, true);*/
+  /*QFeatureList aFeatureList;
+  aFeatureList.append(myTestFeature);
+  theWorkshop->displayer()->setSelected(aFeatureList, true);*/
 
   theWorkshop->displayer()->updateViewer();
 }
index f2ee9a1965a1acea4b47f392f098181331b7dcd4..3da77af534343c163e538677df8afae6c4514fa5 100644 (file)
@@ -217,16 +217,16 @@ void XGUI_Displayer::activateInLocalContext(FeaturePtr theFeature,
     updateViewer();
 }
 
-void XGUI_Displayer::stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
+void XGUI_Displayer::stopSelection(const QFeatureList& theFeatures, const bool isStop,
                                    const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
 
   Handle(AIS_Shape) anAIS;
-  std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
+  QFeatureList::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
   FeaturePtr aFeature;
   for (; anIt != aLast; anIt++) {
-    aFeature = (*anIt).feature();
+    aFeature = *anIt;
     if (isVisible(aFeature))
       anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]);
     if (anAIS.IsNull())
@@ -247,38 +247,15 @@ void XGUI_Displayer::stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures,
     updateViewer();
 }
 
-void XGUI_Displayer::setSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer)
+void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isUpdateViewer)
 {
   Handle(AIS_InteractiveContext) aContext = AISContext();
-
-  std::list<XGUI_ViewerPrs>::const_iterator anIt = theFeatures.begin(), aLast = theFeatures.end();
-  FeaturePtr aFeature;
-
-  Handle(AIS_Shape) anAIS;
   // we need to unhighligth objects manually in the current local context
   // in couple with the selection clear (TODO)
   Handle(AIS_LocalContext) aLocalContext = aContext->LocalContext();
   if (!aLocalContext.IsNull())
     aLocalContext->UnhilightLastDetected(myWorkshop->viewer()->activeView());
-  aContext->ClearSelected(false);
 
-  for (; anIt != aLast; anIt++) {
-    aFeature = (*anIt).feature();
-    if (isVisible(aFeature))
-      anAIS = Handle(AIS_Shape)::DownCast(myFeature2AISObjectMap[aFeature]);
-    if (anAIS.IsNull())
-      continue;
-    aContext->AddOrRemoveSelected(anAIS, false);
-  }
-  if (isUpdateViewer)
-    updateViewer();
-}
-
-
-void XGUI_Displayer::setSelected(const QFeatureList& theFeatures, const bool isUpdateViewer)
-{
-  Handle(AIS_InteractiveContext) aContext = AISContext();
   aContext->ClearSelected();
   foreach(FeaturePtr aFeature, theFeatures) {
     FeaturePtr aRFeature = XGUI_Tools::realFeature(aFeature);
index d16b36279839a685d8a3f6e41df7e992e721ee9e..f5402c3519fdf70b242dde9141de052331288851 100644 (file)
@@ -106,14 +106,9 @@ public:
   /// \param theFeatures a list of features to be disabled
   /// \param theToStop the boolean state whether it it stopped or non stopped
   /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void stopSelection(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isStop,
+  void stopSelection(const QFeatureList& theFeatures, const bool isStop,
                      const bool isUpdateViewer);
 
-  /// Set the features are selected
-  /// \param theFeatures a list of features to be selected
-  /// \param isUpdateViewer the parameter whether the viewer should be update immediatelly
-  void setSelected(const std::list<XGUI_ViewerPrs>& theFeatures, const bool isUpdateViewer);
-
   /**
   * Add presentations which corresponds to the given features to current selection
   * \param theFeatures a list of features to be selected