From: nds Date: Mon, 23 Jun 2014 17:48:57 +0000 (+0400) Subject: refs #80 - Sketch base GUI: create/draw point, circle and arc X-Git-Tag: V_0.4.4~266^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2e6153d900999f7ddc85ba595ef5c74474fc796c;p=modules%2Fshaper.git refs #80 - Sketch base GUI: create/draw point, circle and arc Change the feature create operation to work without a custom presentation. --- diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index b56c21791..3a66ec0d5 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -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) diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index 64fb18e77..f94c918dd 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -62,6 +62,10 @@ void ModuleBase_Operation::storeCustomValue() aCustom->storeValue(myFeature); } +void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget) +{ +} + void ModuleBase_Operation::startOperation() { if (!myIsEditing) diff --git a/src/ModuleBase/ModuleBase_Operation.h b/src/ModuleBase/ModuleBase_Operation.h index 37fd95892..a40d774e4 100644 --- a/src/ModuleBase/ModuleBase_Operation.h +++ b/src/ModuleBase/ModuleBase_Operation.h @@ -20,6 +20,7 @@ #include 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. diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index 4bfda9ed8..7903c8293 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,16 @@ ModuleBase_WidgetPoint2D::~ModuleBase_WidgetPoint2D() { } +void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr& 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 aData = theFeature->data(); diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.h b/src/ModuleBase/ModuleBase_WidgetPoint2D.h index bb0f7c84d..cf92afd3a 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.h +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.h @@ -11,6 +11,7 @@ #include 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& thePoint); + /// Saves the internal parameters to the given feature /// \param theFeature a model feature to be changed virtual bool storeValue(FeaturePtr theFeature) const; diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 495fe7e75..e8e2647a8 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -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 diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ab790298f..e0cf39292 100644 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -341,7 +342,9 @@ ModuleBase_Operation* PartSet_Module::createOperation(const std::string& theCmdI PartSet_OperationSketchBase* aPrevOp = dynamic_cast(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 index 000000000..6eed01297 --- /dev/null +++ b/src/PartSet/PartSet_OperationFeatureCreate.cpp @@ -0,0 +1,314 @@ +// File: PartSet_OperationFeatureCreate.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 + +#ifdef _DEBUG +#include +#endif + +#include + +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 PartSet_OperationFeatureCreate::getSelectionModes(FeaturePtr theFeature) const +{ + std::list aModes; + if (theFeature != feature()) + aModes = PartSet_OperationSketchBase::getSelectionModes(theFeature); + return aModes; +} + +void PartSet_OperationFeatureCreate::init(FeaturePtr theFeature, + const std::list& /*theSelected*/, + const std::list& /*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& theSelected, + const std::list& /*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 aLinePrs = + // boost::dynamic_pointer_cast(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 anArcPrs = + boost::dynamic_pointer_cast(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 anArcPrs = + boost::dynamic_pointer_cast(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 aFeature = + boost::dynamic_pointer_cast(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(myActiveWidget); + aWidget->setPoint(boost::shared_ptr(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 index 000000000..519c45e2f --- /dev/null +++ b/src/PartSet/PartSet_OperationFeatureCreate.h @@ -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 +#include + +#include + +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 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& theSelected, + const std::list& 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& 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); + + 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 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 diff --git a/src/XGUI/XGUI_OperationMgr.cpp b/src/XGUI/XGUI_OperationMgr.cpp index 514c5b2f1..320678b14 100644 --- a/src/XGUI/XGUI_OperationMgr.cpp +++ b/src/XGUI/XGUI_OperationMgr.cpp @@ -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); +} diff --git a/src/XGUI/XGUI_OperationMgr.h b/src/XGUI/XGUI_OperationMgr.h index 82680fb56..f47d6aebd 100644 --- a/src/XGUI/XGUI_OperationMgr.h +++ b/src/XGUI/XGUI_OperationMgr.h @@ -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 Operations; ///< definition for a list of operations Operations myOperations; ///< a stack of started operations. The active operation is on top, diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 2d2938a96..d82244211 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -107,8 +107,9 @@ void XGUI_PropertyPanel::setModelWidgets(const QList& 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::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); +} diff --git a/src/XGUI/XGUI_PropertyPanel.h b/src/XGUI/XGUI_PropertyPanel.h index 5cc9b5faf..d156289b5 100644 --- a/src/XGUI/XGUI_PropertyPanel.h +++ b/src/XGUI/XGUI_PropertyPanel.h @@ -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; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 81f91c8ce..eb099c9b7 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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*))); } //******************************************************