]> 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>
Mon, 23 Jun 2014 17:48:57 +0000 (21:48 +0400)
committernds <natalia.donis@opencascade.com>
Mon, 23 Jun 2014 17:48:57 +0000 (21:48 +0400)
Change the feature create operation to work without a custom presentation.

14 files changed:
src/ModuleBase/CMakeLists.txt
src/ModuleBase/ModuleBase_Operation.cpp
src/ModuleBase/ModuleBase_Operation.h
src/ModuleBase/ModuleBase_WidgetPoint2D.cpp
src/ModuleBase/ModuleBase_WidgetPoint2D.h
src/PartSet/CMakeLists.txt
src/PartSet/PartSet_Module.cpp
src/PartSet/PartSet_OperationFeatureCreate.cpp [new file with mode: 0644]
src/PartSet/PartSet_OperationFeatureCreate.h [new file with mode: 0644]
src/XGUI/XGUI_OperationMgr.cpp
src/XGUI/XGUI_OperationMgr.h
src/XGUI/XGUI_PropertyPanel.cpp
src/XGUI/XGUI_PropertyPanel.h
src/XGUI/XGUI_Workshop.cpp

index b56c217912ed10bb62d52ebd8cbf69d9b73832f6..3a66ec0d57a0aa1eb1faf4198bd58e1db5d6fa3d 100644 (file)
@@ -59,6 +59,6 @@ INCLUDE_DIRECTORIES(
 
 ADD_DEFINITIONS(-DMODULEBASE_EXPORTS ${CAS_DEFINITIONS})
 ADD_LIBRARY(ModuleBase SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-TARGET_LINK_LIBRARIES(ModuleBase ${PROJECT_LIBRARIES})
+TARGET_LINK_LIBRARIES(ModuleBase GeomAPI ${PROJECT_LIBRARIES})
 
 INSTALL(TARGETS ModuleBase DESTINATION bin)
index 64fb18e77f0df0ff03ce60b555b8d5c6017a6770..f94c918ddccd3b4fffa9b90e0aa00a9e1d61b918 100644 (file)
@@ -62,6 +62,10 @@ void ModuleBase_Operation::storeCustomValue()
     aCustom->storeValue(myFeature);
 }
 
+void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
+{
+}
+
 void ModuleBase_Operation::startOperation()
 {
   if (!myIsEditing)
index 37fd95892d5afa183584deefbd68ef452baf78e4..a40d774e4e1d7ab4db1859ea5f95c7ff9a4e870e 100644 (file)
@@ -20,6 +20,7 @@
 #include <boost/shared_ptr.hpp>
 
 class ModelAPI_Document;
+class ModuleBase_ModelWidget;
 
 class QKeyEvent;
 
@@ -73,6 +74,16 @@ public:
 
   bool isEditOperation() const { return myIsEditing; }
 
+public slots:
+  /// Slots which listen the mode widget activation
+  /// \param theWidget the model widget
+  virtual void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
+
+signals:
+  /// Signals about the activating of the next widget
+  /// \param theWidget the previous active widget
+  void activateNextWidget(ModuleBase_ModelWidget* theWidget);
+
 protected:
   /// Virtual method called when operation started (see start() method for more description)
   /// Default impl calls corresponding slot and commits immediately.
index 4bfda9ed88af3056e82806e180c2b9d7b7dddcba..7903c829333acd1615e8db23da85477f6b0fec7a 100644 (file)
@@ -14,6 +14,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <GeomDataAPI_Point2D.h>
+#include <GeomAPI_Pnt2d.h>
 
 #include <QGroupBox>
 #include <QGridLayout>
@@ -70,6 +71,16 @@ ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D()
 {
 }
 
+void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
+{
+  bool isBlocked = this->blockSignals(true);
+  myXSpin->setValue(thePoint->x());
+  myYSpin->setValue(thePoint->y());
+  this->blockSignals(isBlocked);
+
+  emit valuesChanged();
+}
+
 bool ModuleBase_WidgetPoint2D::storeValue(FeaturePtr theFeature) const
 {
   boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
index bb0f7c84dbfa966a76577a623ae8bdefb43793ca..cf92afd3a020d43749965c6d497521599519ae97 100644 (file)
@@ -11,6 +11,7 @@
 #include <QObject>
 
 class ModelAPI_Feature;
+class GeomAPI_Pnt2d;
 
 class QGroupBox;
 class QDoubleSpinBox;
@@ -31,6 +32,10 @@ public:
   /// Destructor
   virtual ~ModuleBase_WidgetPoint2D();
 
+  /// Fill the widget values by given point
+  /// \param thePoint the point
+  void setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint);
+
   /// Saves the internal parameters to the given feature
   /// \param theFeature a model feature to be changed
   virtual bool storeValue(FeaturePtr theFeature) const;
index 495fe7e759a9d08b89728c009216d7a9de7dbd06..e8e2647a89fe2c35bd9e4ad2172b0e35d4cf2c4d 100644 (file)
@@ -20,6 +20,7 @@ SET(PROJECT_HEADERS
        PartSet_OperationCreateFeature.h
        PartSet_OperationEditConstraint.h
        PartSet_OperationEditFeature.h
+       PartSet_OperationFeatureCreate.h
        PartSet_OperationSketchBase.h
        PartSet_OperationSketch.h
        PartSet_Presentation.h
@@ -43,6 +44,7 @@ SET(PROJECT_SOURCES
        PartSet_OperationCreateFeature.cpp
        PartSet_OperationEditConstraint.cpp
        PartSet_OperationEditFeature.cpp
+       PartSet_OperationFeatureCreate.cpp
        PartSet_OperationSketchBase.cpp
        PartSet_OperationSketch.cpp
        PartSet_Presentation.cpp
index ab790298fc07287dc497e4b0cfb7f01a319c72f5..e0cf39292fb895386eeba5854d5128c545fb09cc 100644 (file)
@@ -4,6 +4,7 @@
 #include <PartSet_OperationEditFeature.h>
 #include <PartSet_OperationEditConstraint.h>
 #include <PartSet_OperationCreateConstraint.h>
+#include <PartSet_OperationFeatureCreate.h>
 #include <ModuleBase_Operation.h>
 #include <ModuleBase_OperationDescription.h>
 #include <ModuleBase_WidgetFactory.h>
@@ -341,7 +342,9 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI
     PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
     if (aPrevOp)
       aSketch = aPrevOp->sketch();
-    if (PartSet_OperationCreateFeature::canProcessKind(theCmdId))
+    if (PartSet_OperationFeatureCreate::canProcessKind(theCmdId))
+      anOperation = new PartSet_OperationFeatureCreate(theCmdId.c_str(), this, aSketch);
+    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);
diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp
new file mode 100644 (file)
index 0000000..6eed012
--- /dev/null
@@ -0,0 +1,314 @@
+// File:        PartSet_OperationFeatureCreate.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#include <PartSet_OperationFeatureCreate.h>
+
+#include <PartSet_Tools.h>
+#include <PartSet_OperationSketch.h>
+#include <PartSet_FeaturePointPrs.h>
+#include <PartSet_FeatureLinePrs.h>
+#include <PartSet_FeatureCirclePrs.h>
+#include <PartSet_FeatureArcPrs.h>
+
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Point.h>
+#include <SketchPlugin_Line.h>
+#include <SketchPlugin_Circle.h>
+#include <SketchPlugin_Arc.h>
+
+#include <GeomAPI_Pnt2d.h>
+
+#include <ModuleBase_OperationDescription.h>
+#include <ModuleBase_WidgetPoint2D.h>
+
+#include <XGUI_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>
+#endif
+
+#include <QMouseEvent>
+
+using namespace std;
+
+PartSet_OperationFeatureCreate::PartSet_OperationFeatureCreate(const QString& theId,
+                                                               QObject* theParent,
+                                                               FeaturePtr theFeature)
+: PartSet_OperationSketchBase(theId, theParent), mySketch(theFeature), myActiveWidget(0)
+  //myPointSelectionMode(SM_FirstPoint)
+{
+  //std::string aKind = theId.toStdString();
+  //myFeaturePrs = PartSet_Tools::createFeaturePrs(aKind, theFeature);
+}
+
+PartSet_OperationFeatureCreate::~PartSet_OperationFeatureCreate()
+{
+}
+
+bool PartSet_OperationFeatureCreate::canProcessKind(const std::string& theId)
+{
+  return theId == SKETCH_LINE_KIND;/* || theId == SKETCH_POINT_KIND || theId == SKETCH_CIRCLE_KIND ||
+         theId == SKETCH_ARC_KIND;*/
+}
+
+bool PartSet_OperationFeatureCreate::canBeCommitted() const
+{
+  return !myActiveWidget;//myPointSelectionMode == SM_DonePoint;
+}
+
+bool PartSet_OperationFeatureCreate::isGranted(ModuleBase_IOperation* theOperation) const
+{
+  return theOperation->getDescription()->operationId().toStdString() == PartSet_OperationSketch::Type();
+}
+
+std::list<int> PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theFeature) const
+{
+  std::list<int> aModes;
+  if (theFeature != feature())
+    aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature);
+  return aModes;
+}
+
+void PartSet_OperationFeatureCreate::init(FeaturePtr theFeature,
+                                       const std::list<XGUI_ViewerPrs>& /*theSelected*/,
+                                       const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+{
+  if (!theFeature || theFeature->getKind() != SKETCH_LINE_KIND)
+    return;
+  myInitFeature = theFeature;
+}
+
+FeaturePtr PartSet_OperationFeatureCreate::sketch() const
+{
+  return mySketch;
+}
+
+void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView,
+                                                const std::list<XGUI_ViewerPrs>& theSelected,
+                                                const std::list<XGUI_ViewerPrs>& /*theHighlighted*/)
+{
+  if (canBeCommitted()/*myPointSelectionMode == SM_DonePoint*/)
+  {
+    // if the point creation is finished, the next mouse release should commit the modification
+    // the next release can happens by double click in the viewer
+    commit();
+    restartOperation(feature()->getKind(), feature());
+    return;
+  }
+
+  double aX, anY;
+
+  gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+  if (theSelected.empty()) {
+    PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+  }
+  else {
+    XGUI_ViewerPrs aPrs = theSelected.front();
+    const TopoDS_Shape& aShape = aPrs.shape();
+    if (!aShape.IsNull()) // the point is selected
+    {
+      if (aShape.ShapeType() == TopAbs_VERTEX) {
+        const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape);
+        if (!aVertex.IsNull()) {
+          aPoint = BRep_Tool::Pnt(aVertex);
+          PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+
+          //myFeaturePrs->setConstraints(aX, anY, myPointSelectionMode);
+        }
+      }
+      else if (aShape.ShapeType() == TopAbs_EDGE) // the line is selected
+      {
+        PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+        // move to selected line
+        if (feature()->getKind() == SKETCH_LINE_KIND) {
+          //boost::shared_ptr<PartSet_FeatureLinePrs> aLinePrs =
+          //                       boost::dynamic_pointer_cast<PartSet_FeatureLinePrs>(myFeaturePrs);
+          //if (aLinePrs) {
+          //  FeaturePtr aFeature = aPrs.feature();
+            //aLinePrs->projectPointOnLine(aFeature, myPointSelectionMode, aPoint, theView, aX, anY);
+          //}
+        }
+      }
+    }
+  }
+
+  setWidgetPoint(aX, anY);
+  flushUpdated();
+  emit activateNextWidget(myActiveWidget);
+
+  /*switch (myPointSelectionMode)
+  {
+    case SM_FirstPoint:
+    case SM_SecondPoint:
+    case SM_ThirdPoint: {
+      if (feature()->getKind() == SKETCH_ARC_KIND) {
+        boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
+                                 boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
+        if (anArcPrs) {
+          anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
+        }
+      }
+      PartSet_SelectionMode aMode = myFeaturePrs->setPoint(aX, anY, myPointSelectionMode);
+      flushUpdated();
+      setPointSelectionMode(aMode);
+    }
+    break;
+    default:
+      break;
+  }*/
+}
+
+void PartSet_OperationFeatureCreate::mouseMoved(QMouseEvent* theEvent, Handle(V3d_View) theView)
+{
+  if (canBeCommitted()/*myPointSelectionMode == SM_DonePoint*/) {
+    commit();
+    restartOperation(feature()->getKind(), feature());
+  }
+  else {
+  /*switch (myPointSelectionMode)
+  {
+    case SM_FirstPoint:
+    case SM_SecondPoint:
+    case SM_ThirdPoint:
+    {*/
+      double aX, anY;
+      gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), theView);
+      PartSet_Tools::convertTo2D(aPoint, sketch(), theView, aX, anY);
+      /*if (myPointSelectionMode == SM_ThirdPoint) {
+        if (feature()->getKind() == SKETCH_ARC_KIND) {
+          boost::shared_ptr<PartSet_FeatureArcPrs> anArcPrs =
+                                 boost::dynamic_pointer_cast<PartSet_FeatureArcPrs>(myFeaturePrs);
+          if (anArcPrs) {
+            anArcPrs->projectPointOnFeature(feature(), sketch(), aPoint, theView, aX, anY);
+          }
+        }
+      }*/
+      //myFeaturePrs->setPoint(aX, anY, myPointSelectionMode);
+      setWidgetPoint(aX, anY);
+      flushUpdated();
+      //emit focusActivated(myFeaturePrs->getAttribute(myPointSelectionMode));
+      //emit activateNextWidget(myActiveWidget);
+    /*}
+    break;
+    case SM_DonePoint:
+    {
+      commit();
+      restartOperation(feature()->getKind(), feature());
+    }
+    default:
+      break;*/
+  }
+}
+
+void PartSet_OperationFeatureCreate::keyReleased(std::string theName, QKeyEvent* theEvent)
+{
+  int aKeyType = theEvent->key();
+  // the second point should be activated by any modification in the property panel
+  if (!theName.empty())
+  {
+    //setPointSelectionMode(myFeaturePrs->getNextMode(theName), false);
+  }
+  keyReleased(theEvent->key());
+}
+
+void PartSet_OperationFeatureCreate::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
+{
+  myActiveWidget = theWidget;
+}
+
+void PartSet_OperationFeatureCreate::keyReleased(const int theKey)
+{
+  switch (theKey) {
+    case Qt::Key_Return: {
+      if (canBeCommitted()/*myPointSelectionMode == SM_DonePoint*/)
+      {
+        commit();
+        // it start a new line creation at a free point
+        restartOperation(feature()->getKind(), FeaturePtr()/*feature()*/);
+      }
+    }
+    break;
+    case Qt::Key_Escape: {
+      if (canBeCommitted()/*myPointSelectionMode == SM_DonePoint*/)
+      {
+        commit();
+      }
+      else
+      {
+        abort();
+      }
+    }
+    default:
+    break;
+  }
+}
+
+void PartSet_OperationFeatureCreate::startOperation()
+{
+  PartSet_OperationSketchBase::startOperation();
+  //setPointSelectionMode(!myInitFeature ? SM_FirstPoint : SM_SecondPoint);
+
+  emit multiSelectionEnabled(false);
+}
+
+void PartSet_OperationFeatureCreate::abortOperation()
+{
+  emit featureConstructed(feature(), FM_Hide);
+  PartSet_OperationSketchBase::abortOperation();
+}
+
+void PartSet_OperationFeatureCreate::stopOperation()
+{
+  PartSet_OperationSketchBase::stopOperation();
+  emit multiSelectionEnabled(true);
+}
+
+void PartSet_OperationFeatureCreate::afterCommitOperation()
+{
+  PartSet_OperationSketchBase::afterCommitOperation();  
+  emit featureConstructed(feature(), FM_Deactivation);
+}
+
+FeaturePtr PartSet_OperationFeatureCreate::createFeature(const bool theFlushMessage)
+{
+  FeaturePtr aNewFeature = ModuleBase_Operation::createFeature(false);
+  if (sketch()) {
+    boost::shared_ptr<SketchPlugin_Feature> aFeature = 
+                           boost::dynamic_pointer_cast<SketchPlugin_Feature>(sketch());
+
+    aFeature->addSub(aNewFeature);
+  }
+  //myFeaturePrs->init(aNewFeature);
+  //myFeaturePrs->setFeature(myInitFeature, SM_FirstPoint);
+
+  emit featureConstructed(aNewFeature, FM_Activation);
+  if (theFlushMessage)
+    flushCreated();
+  return aNewFeature;
+}
+
+/*void PartSet_OperationFeatureCreate::setPointSelectionMode(const PartSet_SelectionMode& theMode,
+                                                           const bool isToEmitSignal)
+{
+  myPointSelectionMode = theMode;
+  if (isToEmitSignal) {
+    std::string aName = myFeaturePrs->getAttribute(theMode);
+    if (aName.empty() && theMode == SM_DonePoint) {
+      aName = XGUI::PROP_PANEL_OK;
+    }
+    emit focusActivated(aName);
+  }
+}*/
+
+void PartSet_OperationFeatureCreate::setWidgetPoint(double theX, double theY)
+{
+  ModuleBase_WidgetPoint2D* aWidget = dynamic_cast<ModuleBase_WidgetPoint2D*>(myActiveWidget);
+  aWidget->setPoint(boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(theX, theY)));
+}
\ No newline at end of file
diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h
new file mode 100644 (file)
index 0000000..519c45e
--- /dev/null
@@ -0,0 +1,137 @@
+// File:        PartSet_OperationFeatureCreate.h
+// Created:     20 Apr 2014
+// Author:      Natalia ERMOLAEVA
+
+#ifndef PartSet_OperationFeatureCreate_H
+#define PartSet_OperationFeatureCreate_H
+
+#include "PartSet.h"
+
+#include <PartSet_OperationSketchBase.h>
+#include <PartSet_Constants.h>
+
+#include <QObject>
+
+class PartSet_FeaturePrs;
+class GeomDataAPI_Point2D;
+class QMouseEvent;
+class QKeyEvent;
+
+/*!
+ \class PartSet_OperationFeatureCreate
+ * \brief The operation for the sketch feature creation
+*/
+class PARTSET_EXPORT PartSet_OperationFeatureCreate : public PartSet_OperationSketchBase
+{
+  Q_OBJECT
+
+public:
+  /// Returns true if the feature with the given kind can be created by this operation
+  /// \param theId the feature kind
+  /// \return the boolean result
+  static bool canProcessKind(const std::string& theId);
+
+public:
+  /// Constructor
+  /// \param theId the feature identifier
+  /// \param theParent the operation parent
+  /// \param theSketch the parent feature
+  PartSet_OperationFeatureCreate(const QString& theId, QObject* theParent,
+                                 FeaturePtr theSketch);
+  /// Destructor
+  virtual ~PartSet_OperationFeatureCreate();
+
+  /// 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;
+
+  /// 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 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;
+
+  /// 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<XGUI_ViewerPrs>& theSelected,
+                            const std::list<XGUI_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);
+
+  virtual void keyReleased(std::string theName, QKeyEvent* theEvent);
+
+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)
+  /// After the parent operation body perform, set sketch feature to the created line feature
+  virtual void startOperation();
+
+  /// Virtual method called when operation aborted (see abort() method for more description)
+  /// Before the feature is aborted, it should be hidden from the viewer
+  virtual void abortOperation();
+
+  /// Virtual method called when operation stopped - committed or aborted.
+  /// Restore the multi selection state
+  virtual void stopOperation();
+
+  /// Virtual method called after operation committed (see commit() method for more description)
+  virtual void afterCommitOperation();
+
+  /// Creates an operation new feature
+  /// In addition to the default realization it appends the created line feature to
+  /// the sketch feature
+  /// \param theFlushMessage the flag whether the create message should be flushed
+  /// \returns the created feature
+  virtual FeaturePtr createFeature(const bool theFlushMessage = true);
+
+protected:
+  ///< Set the point selection mode. Emit signal about focus change if necessary.
+  /// \param theMode a new selection mode
+  /// \param isToEmitSignal the neccessity to emit signal
+  //void setPointSelectionMode(const PartSet_SelectionMode& theMode,
+  //                           const bool isToEmitSignal = true);
+
+  /// Set the widget point
+  /// \param theX the horizontal coordinate
+  /// \param theY the vertical coordinate
+  void setWidgetPoint(double theX, double theY);
+
+private:
+  //boost::shared_ptr<PartSet_FeaturePrs> myFeaturePrs; ///< the feature presentation
+  FeaturePtr myInitFeature; ///< the initial feature
+  FeaturePtr mySketch; ///< the sketch of the feature
+  //PartSet_SelectionMode myPointSelectionMode; ///< point selection mode
+
+  ModuleBase_ModelWidget* myActiveWidget; ///< the active widget
+};
+
+#endif
index 514c5b2f116c1f760e975a7dbc1f86efb86bda20..320678b1440769d1fbafef96d350a02f78a6066c 100644 (file)
@@ -46,6 +46,8 @@ bool XGUI_OperationMgr::startOperation(ModuleBase_Operation* theOperation)
   connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
   connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted()));
   connect(theOperation, SIGNAL(resumed()), this, SIGNAL(operationResumed()));
+  connect(theOperation, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)),
+          this, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)));
 
   theOperation->start();
   return true;
@@ -164,3 +166,10 @@ void XGUI_OperationMgr::onKeyReleased(const std::string& theName, QKeyEvent* the
   if (anOperation)
     anOperation->keyReleased(theName, theEvent);
 }
+
+void XGUI_OperationMgr::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
+{
+  ModuleBase_Operation* anOperation = currentOperation();
+  if (anOperation)
+    anOperation->onWidgetActivated(theWidget);
+}
index 82680fb56035ab4f072be9ef0db42b82c37c15b8..f47d6aebdab54b2585b91ea89e233f0587f2f281 100644 (file)
@@ -62,6 +62,9 @@ signals:
   void operationStopped(ModuleBase_Operation* theOperation);
   /// Signal about an operation is resumed. It is emitted after the resume() of operation is done.
   void operationResumed();
+  /// Signal about the necessety of the next widget activating
+  /// \param theWidget the model widget
+  void activateNextWidget(ModuleBase_ModelWidget* theWidget);
 
 protected:
   /// Sets the current operation or NULL
@@ -93,6 +96,10 @@ protected slots:
   /// \param theEvent the mouse event
   void onKeyReleased(const std::string& theName, QKeyEvent* theEvent);
 
+  /// SLOT, that reacts to the widget activation
+  /// \param theWidget an activated widget
+  void onWidgetActivated(ModuleBase_ModelWidget* theWidget);
+
 private:
   typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
   Operations myOperations; ///< a stack of started operations. The active operation is on top,
index 2d2938a96ab7348cc9b986ab2a16d9744d91b35a..d82244211d37b9134bcd0fe8da212552e87ac5b8 100644 (file)
@@ -107,8 +107,9 @@ void XGUI_PropertyPanel::setModelWidgets(const QList<ModuleBase_ModelWidget*>& t
       }
     }
     ModuleBase_ModelWidget* aWidget = theWidgets.first();
-    if (aWidget)
-      aWidget->focusTo();
+    if (aWidget) {
+      activateWidget(aWidget);
+    }
   }
 }
 
@@ -162,3 +163,28 @@ void XGUI_PropertyPanel::onFocusActivated(const std::string& theAttributeName)
     }
   }
 }
+
+void XGUI_PropertyPanel::onActivateNextWidget(ModuleBase_ModelWidget* theWidget)
+{
+  ModuleBase_ModelWidget* aNextWidget = 0;
+
+  QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(),
+                                                 aLast = myWidgets.end();
+  for (;anIt != aLast; anIt++)
+  {
+    if ((*anIt) == theWidget) {
+      anIt++;
+      if (anIt != aLast)
+        aNextWidget = *anIt;
+      break;
+    }
+  }
+  activateWidget(aNextWidget);
+}
+
+void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget)
+{
+  if (theWidget)
+    theWidget->focusTo();
+  emit widgetActivated(theWidget);
+}
index 5cc9b5faf9b5882e17b71b9c5b7699765d9549e0..d156289b56ee88ffd7ff72f302ca8890377b67c3 100644 (file)
@@ -38,12 +38,24 @@ public slots:
   /// slot to set the focus to the widget visualized an attribute with the given name
   /// \param theAttributteName
   void onFocusActivated(const std::string& theAttributeName);
+  /// slot to activate the next widget in the property panel
+  /// \param theWidget a widget. The next widget should be activated
+  void onActivateNextWidget(ModuleBase_ModelWidget* theWidget);
 
 signals:
   /// The signal about key release on the control, that corresponds to the attribute
   /// \param theAttributeName a name of the attribute
   /// \param theEvent key release event
   void keyReleased(const std::string& theAttributeName, QKeyEvent* theEvent);
+  /// The signal about the widget activation
+  /// \param theWidget the activated widget
+  void widgetActivated(ModuleBase_ModelWidget* theWidget);
+
+protected:
+  /// Activate the widget, which means the focus on the widget.
+  /// The signal about the widget activation is emitted
+  /// \param theWidget
+  void activateWidget(ModuleBase_ModelWidget* theWidget);
 
 private:
   QWidget* myCustomWidget;
index 81f91c8ce33007d891ff4faeff8b60141fb5f05b..eb099c9b76254b7b9d4ed31ad5e973547a5cc1c0 100644 (file)
@@ -726,6 +726,11 @@ void XGUI_Workshop::createDockWidgets()
 
   connect(myPropertyPanel, SIGNAL(keyReleased(const std::string&, QKeyEvent*)),
           myOperationMgr, SLOT(onKeyReleased(const std::string&, QKeyEvent*)));
+
+  connect(myPropertyPanel, SIGNAL(widgetActivated(ModuleBase_ModelWidget*)),
+          myOperationMgr, SLOT(onWidgetActivated(ModuleBase_ModelWidget*)));
+  connect(myOperationMgr, SIGNAL(activateNextWidget(ModuleBase_ModelWidget*)),
+          myPropertyPanel, SLOT(onActivateNextWidget(ModuleBase_ModelWidget*)));
 }
 
 //******************************************************