From 5886d3bb6adb74533e2dbac1bcb0addcad68014a Mon Sep 17 00:00:00 2001 From: sbh Date: Tue, 23 Sep 2014 11:09:37 +0400 Subject: [PATCH] Issue #143 Focus on "selector" widget allows to select another feature to apply the constraint --- src/ModuleBase/ModuleBase_ModelWidget.cpp | 20 +++ src/ModuleBase/ModuleBase_ModelWidget.h | 20 ++- src/ModuleBase/ModuleBase_WidgetFeature.cpp | 2 +- src/ModuleBase/ModuleBase_WidgetFeature.h | 5 + .../ModuleBase_WidgetFeatureOrAttribute.h | 2 + src/PartSet/CMakeLists.txt | 2 + src/PartSet/PartSet_Module.cpp | 8 +- src/PartSet/PartSet_OperationFeatureBase.cpp | 149 ++++++++++++++++++ src/PartSet/PartSet_OperationFeatureBase.h | 81 ++++++++++ .../PartSet_OperationFeatureCreate.cpp | 112 +++---------- src/PartSet/PartSet_OperationFeatureCreate.h | 47 +----- src/PartSet/PartSet_OperationFeatureEdit.cpp | 39 +++-- src/PartSet/PartSet_OperationFeatureEdit.h | 15 +- src/XGUI/XGUI_PropertyPanel.cpp | 5 +- 14 files changed, 339 insertions(+), 168 deletions(-) create mode 100644 src/PartSet/PartSet_OperationFeatureBase.cpp create mode 100644 src/PartSet/PartSet_OperationFeatureBase.h diff --git a/src/ModuleBase/ModuleBase_ModelWidget.cpp b/src/ModuleBase/ModuleBase_ModelWidget.cpp index 12e0e034c..c6670f24a 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.cpp +++ b/src/ModuleBase/ModuleBase_ModelWidget.cpp @@ -12,6 +12,7 @@ #include +#include #include 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(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); + } +} diff --git a/src/ModuleBase/ModuleBase_ModelWidget.h b/src/ModuleBase/ModuleBase_ModelWidget.h index 400a90249..968f5960c 100644 --- a/src/ModuleBase/ModuleBase_ModelWidget.h +++ b/src/ModuleBase/ModuleBase_ModelWidget.h @@ -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 @@ -72,6 +72,9 @@ Q_OBJECT /// \return a control list virtual QList 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 myFocusInWidgets; }; #endif diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.cpp b/src/ModuleBase/ModuleBase_WidgetFeature.cpp index e1f8752dc..22b6c316f 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFeature.cpp @@ -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); } diff --git a/src/ModuleBase/ModuleBase_WidgetFeature.h b/src/ModuleBase/ModuleBase_WidgetFeature.h index 9320fb696..ec7413654 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeature.h +++ b/src/ModuleBase/ModuleBase_WidgetFeature.h @@ -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 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 diff --git a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h index 8ba8d352c..9774bd205 100644 --- a/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h +++ b/src/ModuleBase/ModuleBase_WidgetFeatureOrAttribute.h @@ -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 diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 2786db20b..2fb4d3ec2 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -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 diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index 082c8cfa7..97f253c67 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -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(anOperation); - if (aPreviewOp) { + PartSet_OperationSketchBase* aSketchOp = dynamic_cast(anOperation); + if (aSketchOp) { XGUI_Selection* aSelection = myWorkshop->selector()->selection(); // Initialise operation with preliminary selection std::list aSelected = aSelection->getSelected(); std::list 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 index 000000000..0363a3eae --- /dev/null +++ b/src/PartSet/PartSet_OperationFeatureBase.cpp @@ -0,0 +1,149 @@ +// File: PartSet_OperationFeatureBase.h +// Created: 20 Apr 2014 +// Author: Natalia ERMOLAEVA + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +#ifdef _DEBUG +#include +#include +#endif + +#include + +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& theSelected, + const std::list& /*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& theSelected, + const std::list& /*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(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(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 index 000000000..34548056b --- /dev/null +++ b/src/PartSet/PartSet_OperationFeatureBase.h @@ -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 +#include + +#include + +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& theSelected, + const std::list& 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& theSelected, + const std::list& 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 myPreSelection; +}; + +#endif diff --git a/src/PartSet/PartSet_OperationFeatureCreate.cpp b/src/PartSet/PartSet_OperationFeatureCreate.cpp index 38768a0ca..4e5165fa5 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.cpp +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -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 PartSet_OperationFeatureCreate::getSelectionModes(ObjectPtr theFe return aModes; } -void PartSet_OperationFeatureCreate::initSelection( - const std::list& theSelected, - const std::list& /*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& theSelected, - const std::list& /*theHighlighted*/) +void PartSet_OperationFeatureCreate::mouseReleased(QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& theSelected, + const std::list& /*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(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(new GeomAPI_Pnt2d(theX, theY))); - bool isApplyed = myActiveWidget->setValue(aValue); - - delete aValue; - myIsModified = (myIsModified || isApplyed); - return isApplyed; -} diff --git a/src/PartSet/PartSet_OperationFeatureCreate.h b/src/PartSet/PartSet_OperationFeatureCreate.h index 07dd0eab5..f254b713a 100644 --- a/src/PartSet/PartSet_OperationFeatureCreate.h +++ b/src/PartSet/PartSet_OperationFeatureCreate.h @@ -7,7 +7,7 @@ #include "PartSet.h" -#include +#include #include #include @@ -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 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& theSelected, - const std::list& 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& theSelected, const std::list& 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 myPreSelection; }; #endif diff --git a/src/PartSet/PartSet_OperationFeatureEdit.cpp b/src/PartSet/PartSet_OperationFeatureEdit.cpp index 7a16b9240..2036d5576 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.cpp +++ b/src/PartSet/PartSet_OperationFeatureEdit.cpp @@ -37,10 +37,10 @@ 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 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& theSelected, - const std::list& theHighlighted) +void PartSet_OperationFeatureEdit::mousePressed(QMouseEvent* theEvent, Handle(V3d_View) theView, + const std::list& theSelected, + const std::list& 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& /*theSelected*/, - const std::list& /*theHighlighted*/) + const std::list& theSelected, + const std::list& 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( diff --git a/src/PartSet/PartSet_OperationFeatureEdit.h b/src/PartSet/PartSet_OperationFeatureEdit.h index 7bdb6aee2..2082258b0 100644 --- a/src/PartSet/PartSet_OperationFeatureEdit.h +++ b/src/PartSet/PartSet_OperationFeatureEdit.h @@ -7,7 +7,7 @@ #include "PartSet.h" -#include +#include #include 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 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 }; diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 126f87610..9a5877369 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -85,9 +85,8 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& 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(*anIt); if (aPointWidget) -- 2.39.2