]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #143 Focus on "selector" widget allows to select another feature to apply the...
authorsbh <sergey.belash@opencascade.com>
Tue, 23 Sep 2014 07:09:37 +0000 (11:09 +0400)
committersbh <sergey.belash@opencascade.com>
Tue, 23 Sep 2014 07:09:37 +0000 (11:09 +0400)
14 files changed:
src/ModuleBase/ModuleBase_ModelWidget.cpp
src/ModuleBase/ModuleBase_ModelWidget.h
src/ModuleBase/ModuleBase_WidgetFeature.cpp
src/ModuleBase/ModuleBase_WidgetFeature.h
src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureBase.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationFeatureBase.h [new file with mode: 0644]
src/PartSet/PartSet_OperationFeatureCreate.cpp
src/PartSet/PartSet_OperationFeatureCreate.h
src/PartSet/PartSet_OperationFeatureEdit.cpp
src/PartSet/PartSet_OperationFeatureEdit.h
src/XGUI/XGUI_PropertyPanel.cpp

index 12e0e034c54747ed71843b15c3a9591faa04f1bb..c6670f24ae1647f8b8476dd2a088077c72d9833e 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <Events_Loop.h>
 
+#include <QEvent>
 #include <QWidget>
 
 ModuleBase_ModelWidget::ModuleBase_ModelWidget(QObject* theParent, const Config_WidgetAPI* theData,
@@ -48,3 +49,22 @@ void ModuleBase_ModelWidget::updateObject(ObjectPtr theObj) const
   static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
   ModelAPI_EventCreator::get()->sendUpdated(theObj, anEvent);
 }
+
+void ModuleBase_ModelWidget::processFocus(QWidget* theWidget)
+{
+  theWidget->setFocusPolicy(Qt::StrongFocus);
+  theWidget->installEventFilter(this);
+  myFocusInWidgets.append(theWidget);
+}
+
+bool ModuleBase_ModelWidget::eventFilter(QObject* theObject, QEvent *theEvent)
+{
+  QWidget* aWidget = dynamic_cast<QWidget*>(theObject);
+  if (theEvent->type() == QEvent::FocusIn && myFocusInWidgets.contains(aWidget)) {
+    emit focusInWidget(this);
+    return true;
+  } else {
+    // pass the event on to the parent class
+    return QObject::eventFilter(theObject, theEvent);
+  }
+}
index 400a90249682c75fcab09ffdf82b420d2e363f8d..968f5960ce72bb7fc891563b8839712009d4dc83 100644 (file)
@@ -2,8 +2,8 @@
 // Created:     25 Apr 2014
 // Author:      Natalia ERMOLAEVA
 
-#ifndef ModuleBase_ModelWidget_H
-#define ModuleBase_ModelWidget_H
+#ifndef MODULEBASE_MODELWIDGET_H
+#define MODULEBASE_MODELWIDGET_H
 
 #include <ModuleBase.h>
 
@@ -72,6 +72,9 @@ Q_OBJECT
   /// \return a control list
   virtual QList<QWidget*> getControls() const = 0;
 
+  /// FocusIn events processing
+  virtual bool eventFilter(QObject* theObject, QEvent *theEvent);
+
   /// Returns the attribute name
   /// \returns the string value
   std::string attributeID() const
@@ -95,6 +98,9 @@ Q_OBJECT
     myFeature = theFeature;
   }
 
+  /// Defines if it is supposed that the widget should interact with the viewer.
+  virtual bool isViewerSelector() { return false; }
+
 signals:
   /// The signal about widget values changed
   void valuesChanged();
@@ -102,6 +108,9 @@ signals:
   /// \param theAttributeName a name of the attribute
   /// \param theEvent key release event
   void keyReleased(QKeyEvent* theEvent);
+  /// The signal about the widget is get focus
+  /// \param theWidget the model base widget
+  void focusInWidget(ModuleBase_ModelWidget* theWidget);
   /// The signal about the widget is lost focus
   /// \param theWidget the model base widget
   void focusOutWidget(ModuleBase_ModelWidget* theWidget);
@@ -116,11 +125,18 @@ signals:
 
   void updateObject(ObjectPtr theObj) const;
 
+  /// Let the widget process FocusIn events
+  void processFocus(QWidget* theWidget);
+
   std::string myAttributeID;  /// the attribute name of the model feature
   std::string myParentId;    /// name of parent
   FeaturePtr myFeature;
 
   bool myIsComputedDefault;
+
+ private:
+   /// Contains a list of widgets that may accept focus
+   QList<QWidget*> myFocusInWidgets;
 };
 
 #endif
index e1f8752dc30f221e5780fe12fa259921317b5de2..22b6c316f48f1435c13d2a3a143468105f7eda11 100644 (file)
@@ -43,11 +43,11 @@ ModuleBase_WidgetFeature::ModuleBase_WidgetFeature(QWidget* theParent,
   QString anObjName = QString::fromStdString(attributeID());
   myEditor->setObjectName(anObjName);
   myEditor->setReadOnly(true);
+  processFocus(myEditor);
   aControlLay->addWidget(myEditor);
 
   QString aTTip = QString::fromStdString(theData->widgetTooltip());
   myEditor->setToolTip(aTTip);
-
   aControlLay->addWidget(myEditor);
   aControlLay->setStretch(1, 1);
 }
index 9320fb6965e2f3fb8adc6ec2f8174bbae352c271..ec74136542e54c80890f2274e86c4d5d3f7a8f30 100644 (file)
@@ -16,6 +16,7 @@ class ModelAPI_Feature;
 class QWidget;
 class QLabel;
 class QLineEdit;
+class QToolButton;
 
 /**\class ModuleBase_WidgetFeature
  * \ingroup GUI
@@ -52,6 +53,8 @@ Q_OBJECT
   /// Returns list of widget controls
   /// \return a control list
   virtual QList<QWidget*> getControls() const;
+  /// Defines if it is supposed that the widget should interact with the viewer.
+  virtual bool isViewerSelector() { return true; }
 
  protected:
   /// Fill the widget values by given point
@@ -80,9 +83,11 @@ Q_OBJECT
     return myObjectKinds;
   }
 
+ protected:
   ObjectPtr myObject;  ///< the current widget feature
   QStringList myObjectKinds;  ///< the kinds of possible features
 
+ private:
   QWidget* myContainer;  /// the parent top control
   QLabel* myLabel;  /// the editor information label
   QLineEdit* myEditor;  ///< the feature editor to visualize the feature name
index 8ba8d352ce320dad5781d47b2ce3d46ce918539a..9774bd20554d99f967b80b57e6c472664f08945d 100644 (file)
@@ -40,6 +40,8 @@ Q_OBJECT
   virtual bool storeValue() const;
 
   virtual bool restoreValue();
+  /// Defines if it is supposed that the widget should interact with the viewer.
+  virtual bool isViewerSelector() { return true; }
 
  protected:
   /// Set the attribute
index 2786db20b755a74ca2504cbcdb0480b34c3a7c77..2fb4d3ec207e743bd355fb1d56b5020df6ea1700 100644 (file)
@@ -13,6 +13,7 @@ SET(PROJECT_HEADERS
        PartSet_OperationFeatureEditMulti.h
        PartSet_OperationSketchBase.h
        PartSet_OperationSketch.h
+       PartSet_OperationFeatureBase.h
        PartSet_TestOCC.h
        PartSet_Tools.h
        PartSet_WidgetSketchLabel.h
@@ -28,6 +29,7 @@ SET(PROJECT_SOURCES
        PartSet_OperationFeatureEditMulti.cpp
        PartSet_OperationSketchBase.cpp
        PartSet_OperationSketch.cpp
+       PartSet_OperationFeatureBase.cpp
        PartSet_TestOCC.cpp
        PartSet_Tools.cpp
        PartSet_WidgetSketchLabel.cpp
index 082c8cfa777ae913e113f45068a181ee2a545e61..97f253c6766468ff7f7dae10564be001c944d3e4 100644 (file)
@@ -287,14 +287,14 @@ void PartSet_Module::onRestartOperation(std::string theName, ObjectPtr theObject
 
   std::string aKind = aFeature ? aFeature->getKind() : "";
   ModuleBase_Operation* anOperation = createOperation(theName, aKind);
-  PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
-  if (aPreviewOp) {
+  PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+  if (aSketchOp) {
     XGUI_Selection* aSelection = myWorkshop->selector()->selection();
     // Initialise operation with preliminary selection
     std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
     std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
-    aPreviewOp->initFeature(aFeature);
-    aPreviewOp->initSelection(aSelected, aHighlighted);
+    aSketchOp->initFeature(aFeature);
+    aSketchOp->initSelection(aSelected, aHighlighted);
   } else if (aFeature) {
     anOperation->setEditingFeature(aFeature);
     //Deactivate result of current feature in order to avoid its selection
diff --git a/src/PartSet/PartSet_OperationFeatureBase.cpp b/src/PartSet/PartSet_OperationFeatureBase.cpp
new file mode 100644 (file)
index 0000000..0363a3e
--- /dev/null
@@ -0,0 +1,149 @@
+// File:        PartSet_OperationFeatureBase.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationFeatureBase.h>
+
+#include <PartSet_Tools.h>
+#include <PartSet_OperationSketch.h>
+
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Arc.h>
+#include <SketchPlugin_ConstraintDistance.h>
+#include <SketchPlugin_ConstraintLength.h>
+#include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_ConstraintParallel.h>
+#include <SketchPlugin_ConstraintPerpendicular.h>
+#include <SketchPlugin_ConstraintCoincidence.h>
+
+#include <GeomAPI_Pnt2d.h>
+
+#include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_WidgetPoint2D.h>
+#include <ModuleBase_WidgetValueFeature.h>
+#include <ModuleBase_ViewerPrs.h>
+
+#include <XGUI_Constants.h>
+
+#include <V3d_View.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS.hxx>
+#include <BRep_Tool.hxx>
+
+#ifdef _DEBUG
+#include <QDebug>
+#include <iostream>
+#endif
+
+#include <QMouseEvent>
+
+using namespace std;
+
+PartSet_OperationFeatureBase::PartSet_OperationFeatureBase(const QString& theId,
+                                                               QObject* theParent,
+                                                               FeaturePtr theFeature)
+    : PartSet_OperationSketchBase(theId, theParent),
+      mySketch(theFeature),
+      myActiveWidget(NULL)
+{
+}
+
+PartSet_OperationFeatureBase::~PartSet_OperationFeatureBase()
+{
+}
+
+void PartSet_OperationFeatureBase::initSelection(
+    const std::list<ModuleBase_ViewerPrs>& theSelected,
+    const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+{
+  myPreSelection = theSelected;
+}
+
+void PartSet_OperationFeatureBase::initFeature(FeaturePtr theFeature)
+{
+  myInitFeature = theFeature;
+}
+
+FeaturePtr PartSet_OperationFeatureBase::sketch() const
+{
+  return mySketch;
+}
+
+void PartSet_OperationFeatureBase::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                                 const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                 const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+{
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+  double aX = aPoint.X(), anY = aPoint.Y();
+
+  if (theSelected.empty()) {
+    PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+  } else {
+    ModuleBase_ViewerPrs aPrs = theSelected.front();
+    const TopoDS_Shape& aShape = aPrs.shape();
+    if (!aShape.IsNull()) {
+      if (aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected
+        const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
+        if (!aVertex.IsNull()) {
+          aPoint = BRep_Tool::Pnt(aVertex);
+          PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+          PartSet_Tools::setConstraints(sketch(), feature(), myActiveWidget->attributeID(), aX, anY);
+        }
+      } else if (aShape.ShapeType() == TopAbs_EDGE) { // a line is selected
+        PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+      }
+    }
+  }
+  ObjectPtr aFeature;
+  if (!theSelected.empty()) {
+    ModuleBase_ViewerPrs aPrs = theSelected.front();
+    aFeature = aPrs.object();
+  } else {
+    aFeature = feature();  // for the widget distance only
+  }
+
+  bool isApplyed = setWidgetValue(aFeature, aX, anY);
+  if (isApplyed) {
+    flushUpdated();
+    emit activateNextWidget(myActiveWidget);
+  }
+  commit();
+}
+
+void PartSet_OperationFeatureBase::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
+{
+  myActiveWidget = theWidget;
+  if ((myPreSelection.size() > 0) && myActiveWidget) {
+    const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
+    ModuleBase_WidgetValueFeature aValue;
+    aValue.setObject(aPrs.object());
+    if (myActiveWidget->setValue(&aValue)) {
+      myPreSelection.remove(aPrs);
+      emit activateNextWidget(myActiveWidget);
+    }
+  }
+  if (myInitFeature && myActiveWidget) {
+    ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
+    if (aWgt && aWgt->initFromPrevious(myInitFeature)) {
+      myInitFeature = FeaturePtr();
+      emit activateNextWidget(myActiveWidget);
+    }
+  }
+}
+
+bool PartSet_OperationFeatureBase::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
+{
+  if (!myActiveWidget)
+    return false;
+  ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
+  aValue->setObject(theFeature);
+  aValue->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
+  bool isApplyed = myActiveWidget->setValue(aValue);
+
+  delete aValue;
+  myIsModified = (myIsModified || isApplyed);
+  return isApplyed;
+}
diff --git a/src/PartSet/PartSet_OperationFeatureBase.h b/src/PartSet/PartSet_OperationFeatureBase.h
new file mode 100644 (file)
index 0000000..3454805
--- /dev/null
@@ -0,0 +1,81 @@
+// File:        PartSet_OperationFeatureBase.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PARTSET_OPERATIONFEATUREBASE_H
+#define PARTSET_OPERATIONFEATUREBASE_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <PartSet_Constants.h>
+
+#include <QObject>
+
+class GeomDataAPI_Point2D;
+class QMouseEvent;
+class QKeyEvent;
+
+/*!
+ \class PartSet_OperationFeatureBase
+ * \brief The operation for the sketch feature creation
+ */
+class PARTSET_EXPORT PartSet_OperationFeatureBase : public PartSet_OperationSketchBase
+{
+Q_OBJECT
+
+ public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  /// \param theSketch the parent feature
+  PartSet_OperationFeatureBase(const QString& theId, QObject* theParent, FeaturePtr theSketch);
+  /// Destructor
+  virtual ~PartSet_OperationFeatureBase();
+
+  /// Initialisation of operation with preliminary selection
+  /// \param theSelected the list of selected presentations
+  /// \param theHighlighted the list of highlighted presentations
+  virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
+                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+
+  /// 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;
+
+  /// Gives the current selected objects to be processed by the operation
+  /// \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 mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
+                             const std::list<ModuleBase_ViewerPrs>& theSelected,
+                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
+
+
+ public slots:
+  /// Slots which listen the mode widget activation
+  /// \param theWidget the model widget
+  virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
+
+ protected:
+  /// Set value to the active widget
+  /// \param theFeature the feature
+  /// \param theX the horizontal coordinate
+  /// \param theY the vertical coordinate
+  /// \return true if the point is set
+  bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
+
+ protected:
+  FeaturePtr myInitFeature;  ///< the initial feature
+  FeaturePtr mySketch;  ///< the sketch of the feature
+  
+  ModuleBase_ModelWidget* myActiveWidget;  ///< the active widget
+
+  std::list<ModuleBase_ViewerPrs> myPreSelection;
+};
+
+#endif
index 38768a0ca2913d934cda57575905918aa46a227a..4e5165fa5d16d9ab0e8dea361713d01afa10bfe6 100644 (file)
@@ -45,9 +45,7 @@ using namespace std;
 PartSet_OperationFeatureCreate::PartSet_OperationFeatureCreate(const QString& theId,
                                                                QObject* theParent,
                                                                FeaturePtr theFeature)
-    : PartSet_OperationSketchBase(theId, theParent),
-      mySketch(theFeature),
-      myActiveWidget(0)
+    : PartSet_OperationFeatureBase(theId, theParent, theFeature)
 {
 }
 
@@ -82,27 +80,34 @@ std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFe
   return aModes;
 }
 
-void PartSet_OperationFeatureCreate::initSelection(
-    const std::list<ModuleBase_ViewerPrs>& theSelected,
-    const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
-{
-  myPreSelection = theSelected;
-}
-
-void PartSet_OperationFeatureCreate::initFeature(FeaturePtr theFeature)
+void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
 {
-  myInitFeature = theFeature;
+    double aX, anY;
+    gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+    PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+    setWidgetValue(feature(), aX, anY);
+    flushUpdated();
 }
 
-FeaturePtr PartSet_OperationFeatureCreate::sketch() const
+void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
 {
-  return mySketch;
+  switch (theKey) {
+    case Qt::Key_Return:
+    case Qt::Key_Enter: {
+      if (commit()) {
+        // it start a new line creation at a free point
+        restartOperation(feature()->getKind());
+      }
+    }
+      break;
+    default:
+      break;
+  }
 }
 
-void PartSet_OperationFeatureCreate::mouseReleased(
-    QMouseEvent* theEvent, Handle(V3d_View) theView,
-    const std::list<ModuleBase_ViewerPrs>& theSelected,
-    const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                                 const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                 const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
 {
   gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
   double aX = aPoint.X(), anY = aPoint.Y();
@@ -113,8 +118,7 @@ void PartSet_OperationFeatureCreate::mouseReleased(
   } else {
     ModuleBase_ViewerPrs aPrs = theSelected.front();
     const TopoDS_Shape& aShape = aPrs.shape();
-    if (!aShape.IsNull())
-    {
+    if (!aShape.IsNull()) {
       if (aShape.ShapeType() == TopAbs_VERTEX) { // a point is selected
         const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
         if (!aVertex.IsNull()) {
@@ -125,11 +129,6 @@ void PartSet_OperationFeatureCreate::mouseReleased(
         }
       } else if (aShape.ShapeType() == TopAbs_EDGE) { // a line is selected
         PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
-        // move to selected line
-        if (feature()->getKind() == SketchPlugin_Line::ID()) {
-          //FeaturePtr aFeature = aPrs.feature();
-          //projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY);
-        }
       }
     }
   }
@@ -137,8 +136,9 @@ void PartSet_OperationFeatureCreate::mouseReleased(
   if (!theSelected.empty()) {
     ModuleBase_ViewerPrs aPrs = theSelected.front();
     aFeature = aPrs.object();
-  } else
+  } else {
     aFeature = feature();  // for the widget distance only
+  }
 
   bool isApplyed = setWidgetValue(aFeature, aX, anY);
   if (isApplyed) {
@@ -154,52 +154,6 @@ void PartSet_OperationFeatureCreate::mouseReleased(
   }
 }
 
-void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
-{
-    double aX, anY;
-    gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
-    PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
-    setWidgetValue(feature(), aX, anY);
-    flushUpdated();
-}
-
-void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
-{
-  myActiveWidget = theWidget;
-  if ((myPreSelection.size() > 0) && myActiveWidget) {
-    const ModuleBase_ViewerPrs& aPrs = myPreSelection.front();
-    ModuleBase_WidgetValueFeature aValue;
-    aValue.setObject(aPrs.object());
-    if (myActiveWidget->setValue(&aValue)) {
-      myPreSelection.remove(aPrs);
-      emit activateNextWidget(myActiveWidget);
-    }
-  }
-  if (myInitFeature && myActiveWidget) {
-    ModuleBase_WidgetPoint2D* aWgt = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
-    if (aWgt && aWgt->initFromPrevious(myInitFeature)) {
-      myInitFeature = FeaturePtr();
-      emit activateNextWidget(myActiveWidget);
-    }
-  }
-}
-
-void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
-{
-  switch (theKey) {
-    case Qt::Key_Return:
-    case Qt::Key_Enter: {
-      if (commit()) {
-        // it start a new line creation at a free point
-        restartOperation(feature()->getKind());
-      }
-    }
-      break;
-    default:
-      break;
-  }
-}
-
 void PartSet_OperationFeatureCreate::activateNextToCurrentWidget()
 {
   emit activateNextWidget(myActiveWidget);
@@ -248,17 +202,3 @@ FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMess
     flushCreated();
   return aNewFeature;
 }
-
-bool PartSet_OperationFeatureCreate::setWidgetValue(ObjectPtr theFeature, double theX, double theY)
-{
-  if (!myActiveWidget)
-    return false;
-  ModuleBase_WidgetValueFeature* aValue = new ModuleBase_WidgetValueFeature();
-  aValue->setObject(theFeature);
-  aValue->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
-  bool isApplyed = myActiveWidget->setValue(aValue);
-
-  delete aValue;
-  myIsModified = (myIsModified || isApplyed);
-  return isApplyed;
-}
index 07dd0eab52e127d07cb1d180ebd9485c1c85a75e..f254b713a0f7c21ee5ab0f5bfc6a0b2e1c680235 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "PartSet.h"
 
-#include <PartSet_OperationSketchBase.h>
+#include <PartSet_OperationFeatureBase.h>
 #include <PartSet_Constants.h>
 
 #include <QObject>
@@ -20,7 +20,7 @@ class QKeyEvent;
  \class PartSet_OperationFeatureCreate
  * \brief The operation for the sketch feature creation
  */
-class PARTSET_EXPORT PartSet_OperationFeatureCreate : public PartSet_OperationSketchBase
+class PARTSET_EXPORT PartSet_OperationFeatureCreate : public PartSet_OperationFeatureBase
 {
 Q_OBJECT
 
@@ -30,7 +30,6 @@ Q_OBJECT
   /// \return the boolean result
   static bool canProcessKind(const std::string& theId);
 
- public:
   /// Constructor
   /// \param theId the feature identifier
   /// \param theParent the operation parent
@@ -44,18 +43,10 @@ Q_OBJECT
   /// \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);
-
-  /// Initialisation of operation with preliminary selection
-  /// \param theSelected the list of selected presentations
-  /// \param theHighlighted the list of highlighted presentations
-  virtual void initSelection(const std::list<ModuleBase_ViewerPrs>& theSelected,
-                             const std::list<ModuleBase_ViewerPrs>& theHighlighted);
-
-  /// Returns the operation sketch feature
-  /// \returns the sketch instance
-  virtual FeaturePtr sketch() const;
+  /// Gives the current mouse point in the viewer
+  /// \param thePoint a point clicked in the viewer
+  /// \param theEvent the mouse event
+  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
 
   /// Gives the current selected objects to be processed by the operation
   /// \param theEvent the mouse event
@@ -65,21 +56,13 @@ Q_OBJECT
   virtual void mouseReleased(QMouseEvent* theEvent, Handle_V3d_View theView,
                              const std::list<ModuleBase_ViewerPrs>& theSelected,
                              const std::list<ModuleBase_ViewerPrs>& theHighlighted);
-  /// Gives the current mouse point in the viewer
-  /// \param thePoint a point clicked in the viewer
-  /// \param theEvent the mouse event
-  virtual void mouseMoved(QMouseEvent* theEvent, Handle_V3d_View theView);
   /// Processes the key pressed in the view
   /// \param theKey a key value
   virtual void keyReleased(const int theKey);
 
+  /// alias for activateNextWidget(myActiveWidget);
   virtual void activateNextToCurrentWidget();
 
- public slots:
-  /// Slots which listen the mode widget activation
-  /// \param theWidget the model widget
-  virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
-
  protected:
   /// \brief Virtual method called when operation is started
   /// Virtual method called when operation started (see start() method for more description)
@@ -107,22 +90,6 @@ Q_OBJECT
   /// Verifies whether this operator can be commited.
   /// \return Returns TRUE if current operation can be committed, e.g. all parameters are filled
   virtual bool canBeCommitted() const;
-
- protected:
-  /// Set value to the active widget
-  /// \param theFeature the feature
-  /// \param theX the horizontal coordinate
-  /// \param theY the vertical coordinate
-  /// \return true if the point is set
-  bool setWidgetValue(ObjectPtr theFeature, double theX, double theY);
-
- private:
-  FeaturePtr myInitFeature;  ///< the initial feature
-  FeaturePtr mySketch;  ///< the sketch of the feature
-
-  ModuleBase_ModelWidget* myActiveWidget;  ///< the active widget
-
-  std::list<ModuleBase_ViewerPrs> myPreSelection;
 };
 
 #endif
index 7a16b92405ee559a0fda5f0009e1e0970e8f6193..2036d55760d69e3bf540dd47eef848aafea8f1a8 100644 (file)
 
 using namespace std;
 
-PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId, QObject* theParent,
+PartSet_OperationFeatureEdit::PartSet_OperationFeatureEdit(const QString& theId,
+                                                           QObject* theParent,
                                                            FeaturePtr theFeature)
-    : PartSet_OperationSketchBase(theId, theParent),
-      mySketch(theFeature),
+    : PartSet_OperationFeatureBase(theId, theParent, theFeature),
       myIsBlockedSelection(false)
 {
 }
@@ -49,26 +49,20 @@ PartSet_OperationFeatureEdit::~PartSet_OperationFeatureEdit()
 {
 }
 
-std::list<int> PartSet_OperationFeatureEdit::getSelectionModes(ObjectPtr theFeature) const
-{
-  return PartSet_OperationSketchBase::getSelectionModes(theFeature);
-}
-
 void PartSet_OperationFeatureEdit::initFeature(FeaturePtr theFeature)
 {
   setEditingFeature(theFeature);
 }
 
-FeaturePtr PartSet_OperationFeatureEdit::sketch() const
-{
-  return mySketch;
-}
-
-void PartSet_OperationFeatureEdit::mousePressed(
-    QMouseEvent* theEvent, Handle(V3d_View) theView,
-    const std::list<ModuleBase_ViewerPrs>& theSelected,
-    const std::list<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                                const std::list<ModuleBase_ViewerPrs>& theSelected,
+                                                const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
+  if(myActiveWidget && myActiveWidget->isViewerSelector()) {
+    // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
+    PartSet_OperationFeatureBase::mousePressed(theEvent, theView, theSelected, theHighlighted);
+    return;
+  }
   ObjectPtr aObject;
   if (!theHighlighted.empty())
     aObject = theHighlighted.front().object();
@@ -131,10 +125,15 @@ void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, Handle(V3d_
 
 void PartSet_OperationFeatureEdit::mouseReleased(
     QMouseEvent* theEvent, Handle(V3d_View) theView,
-    const std::list<ModuleBase_ViewerPrs>& /*theSelected*/,
-    const std::list<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+    const std::list<ModuleBase_ViewerPrs>& theSelected,
+    const std::list<ModuleBase_ViewerPrs>& theHighlighted)
 {
-  blockSelection(false);
+  if(myActiveWidget && myActiveWidget->isViewerSelector()) {
+    // Almost do nothing, all stuff in on PartSet_OperationFeatureBase::mouseReleased
+    PartSet_OperationFeatureBase::mouseReleased(theEvent, theView, theSelected, theHighlighted);
+  } else {
+    blockSelection(false);
+  }
 }
 
 void PartSet_OperationFeatureEdit::mouseDoubleClick(
index 7bdb6aee29cb67eba2e24a1cc91c729a724d84bc..2082258b0257000b6c3d867f7bbf7d861ca00445 100644 (file)
@@ -7,7 +7,7 @@
 
 #include "PartSet.h"
 
-#include <PartSet_OperationSketchBase.h>
+#include <PartSet_OperationFeatureBase.h>
 #include <QObject>
 
 class QMouseEvent;
@@ -16,7 +16,7 @@ class QMouseEvent;
  \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
   /// Struct to define gp point, with the state is the point is initialized
@@ -25,6 +25,7 @@ Q_OBJECT
     /// Constructor
     Point()
     {
+      myIsInitialized = false;
     }
     /// Constructor
     /// \param thePoint the point
@@ -69,18 +70,9 @@ Q_OBJECT
   /// Destructor
   virtual ~PartSet_OperationFeatureEdit();
 
-  /// 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;
-
   /// Processes the mouse pressed in the point
   /// \param theEvent the mouse event
   /// \param theView a viewer to have the viewer the eye position
@@ -139,7 +131,6 @@ Q_OBJECT
   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
 };
index 126f87610d2c349aa3fc462663e0d34e5c75f191..9a5877369ba5a51254ba151fc696429a48688a00 100644 (file)
@@ -85,9 +85,8 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
 
     connect(*anIt, SIGNAL(focusOutWidget(ModuleBase_ModelWidget*)), this,
             SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
-
-    //connect(*anIt, SIGNAL(activated(ModuleBase_ModelWidget*)),
-    //        this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
+    connect(*anIt, SIGNAL(focusInWidget(ModuleBase_ModelWidget*)),
+            this, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)));
 
     ModuleBase_WidgetPoint2D* aPointWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(*anIt);
     if (aPointWidget)