From: nds Date: Wed, 14 Oct 2015 11:01:24 +0000 (+0300) Subject: The flyout widget should not accept the focus if the corresponded presentation is... X-Git-Tag: V_2.0.0_alfa1~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1924606833292eede4a943af131063199e252feb;p=modules%2Fshaper.git The flyout widget should not accept the focus if the corresponded presentation is not built on the feature attributes. Case: create a contour, select any vertex, detach it from a line. Call distance and select the equal points of detached lines. Previous result: no active control, waiting for user click. Current result: the flyout attribute is initialized with a default value, the focus is on the value control. --- diff --git a/src/GeomAPI/GeomAPI_AISObject.cpp b/src/GeomAPI/GeomAPI_AISObject.cpp index 30879add3..bd8892987 100644 --- a/src/GeomAPI/GeomAPI_AISObject.cpp +++ b/src/GeomAPI/GeomAPI_AISObject.cpp @@ -141,6 +141,21 @@ void GeomAPI_AISObject::createDistance(std::shared_ptr theStartPoin } } +bool GeomAPI_AISObject::isEmptyDistanceGeometry() +{ + bool anEmpty = false; + + Handle(AIS_InteractiveObject) anAIS = impl(); + if (!anAIS.IsNull()) { + Handle(AIS_LengthDimension) aDimAIS = Handle(AIS_LengthDimension)::DownCast(anAIS); + if (!aDimAIS.IsNull()) { + anEmpty = !aDimAIS->IsValid(); + } + } + + return anEmpty; +} + void GeomAPI_AISObject::createRadius(std::shared_ptr theCircle, std::shared_ptr theFlyoutPoint, double theRadius) diff --git a/src/GeomAPI/GeomAPI_AISObject.h b/src/GeomAPI/GeomAPI_AISObject.h index 6d0a3f2e5..a3c0c23ce 100644 --- a/src/GeomAPI/GeomAPI_AISObject.h +++ b/src/GeomAPI/GeomAPI_AISObject.h @@ -49,6 +49,14 @@ class GeomAPI_AISObject : public GeomAPI_Interface std::shared_ptr theFlyoutPoint, std::shared_ptr thePlane, double theDistance); + /** + * Returns validity of the AIS distance. It is invalid if set measured geometry is not valid, + * e.g. the distance points are equal. + * \return a boolean result + */ + GEOMAPI_EXPORT + bool isEmptyDistanceGeometry(); + /** \brief Creates AIS_RadiusDimension object * \param[in] theCircle the radius is created for this circle * \param[in] theFlyoutPoint the flyout of dimension diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 0db713356..350924e1f 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -19,6 +19,7 @@ SET(PROJECT_HEADERS PartSet_WidgetEditor.h PartSet_WidgetMultiSelector.h PartSet_WidgetPoint2dDistance.h + PartSet_WidgetPoint2DFlyout.h PartSet_WidgetShapeSelector.h PartSet_WidgetFileSelector.h PartSet_Filters.h @@ -43,6 +44,7 @@ SET(PROJECT_SOURCES PartSet_WidgetPoint2d.cpp PartSet_WidgetPoint2dAngle.cpp PartSet_WidgetPoint2dDistance.cpp + PartSet_WidgetPoint2DFlyout.cpp PartSet_WidgetShapeSelector.cpp PartSet_WidgetFileSelector.cpp PartSet_Filters.cpp diff --git a/src/PartSet/PartSet_Module.cpp b/src/PartSet/PartSet_Module.cpp index ae090a39e..a20479f8c 100755 --- a/src/PartSet/PartSet_Module.cpp +++ b/src/PartSet/PartSet_Module.cpp @@ -6,6 +6,7 @@ #include "PartSet_Tools.h" #include "PartSet_WidgetPoint2d.h" #include "PartSet_WidgetPoint2dDistance.h" +#include "PartSet_WidgetPoint2DFlyout.h" #include "PartSet_WidgetShapeSelector.h" #include "PartSet_WidgetPoint2dAngle.h" #include "PartSet_WidgetMultiSelector.h" @@ -630,6 +631,12 @@ ModuleBase_ModelWidget* PartSet_Module::createWidgetByType(const std::string& th aPointWgt->setSketch(mySketchMgr->activeSketch()); connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected())); aWgt = aPointWgt; + } else if (theType == "sketch-2dpoint_flyout_selector") { + PartSet_WidgetPoint2DFlyout* aPointWgt = new PartSet_WidgetPoint2DFlyout(theParent, aWorkshop, + theWidgetApi, theParentId); + aPointWgt->setSketch(mySketchMgr->activeSketch()); + connect(aPointWgt, SIGNAL(vertexSelected()), this, SLOT(onVertexSelected())); + aWgt = aPointWgt; } else if (theType == "point2ddistance") { PartSet_WidgetPoint2dDistance* aDistanceWgt = new PartSet_WidgetPoint2dDistance(theParent, aWorkshop, theWidgetApi, theParentId); diff --git a/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp b/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp new file mode 100755 index 000000000..61c2aba45 --- /dev/null +++ b/src/PartSet/PartSet_WidgetPoint2DFlyout.cpp @@ -0,0 +1,44 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PartSet_WidgetPoint2D.cpp +// Created: 25 Apr 2014 +// Author: Natalia ERMOLAEVA + +#include "PartSet_WidgetPoint2DFlyout.h" + +#include +#include +#include + +#include +#include + +#include + + +PartSet_WidgetPoint2DFlyout::PartSet_WidgetPoint2DFlyout(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData, + const std::string& theParentId) + : PartSet_WidgetPoint2D(theParent, theWorkshop, theData, theParentId) +{ + myIsInternal = theData->getBooleanAttribute(ATTR_INTERNAL, false); +} + +bool PartSet_WidgetPoint2DFlyout::focusTo() +{ + bool aCanAcceptFocus = true; + if (myIsInternal && isComputedDefault()) { + AISObjectPtr anObject = workshop()->displayer()->getAISObject(feature()); + aCanAcceptFocus = anObject.get() && !anObject->isEmptyDistanceGeometry(); + } + if (aCanAcceptFocus) + aCanAcceptFocus = PartSet_WidgetPoint2D::focusTo(); + return aCanAcceptFocus; +} + +XGUI_Workshop* PartSet_WidgetPoint2DFlyout::workshop() const +{ + XGUI_ModuleConnector* aConnector = dynamic_cast(myWorkshop); + return aConnector->workshop(); +} diff --git a/src/PartSet/PartSet_WidgetPoint2DFlyout.h b/src/PartSet/PartSet_WidgetPoint2DFlyout.h new file mode 100755 index 000000000..3c294d3b5 --- /dev/null +++ b/src/PartSet/PartSet_WidgetPoint2DFlyout.h @@ -0,0 +1,48 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: PartSet_WidgetPoint2dFlyout.h +// Created: 14 Oct 2015 +// Author: Natalia ERMOLAEVA + +#ifndef PartSet_WidgetPoint2DFlyout_H +#define PartSet_WidgetPoint2DFlyout_H + +#include "PartSet.h" +#include + +class XGUI_Workshop; + +/**\class PartSet_WidgetPoint2DFlyout + * \ingroup Modules + * \brief Implementation of usual point 2d widget with a condition that it can not accept the focus + * when the AIS presentation is not visualized in the viewer. + */ +class PARTSET_EXPORT PartSet_WidgetPoint2DFlyout : public PartSet_WidgetPoint2D +{ + Q_OBJECT +public: + /// Constructor + /// \param theParent the parent object + /// \param theWorkshop a current workshop + /// \param theData the widget configuation. The attribute of the model widget is obtained from + /// \param theParentId is Id of a parent of the current attribute + PartSet_WidgetPoint2DFlyout(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData, + const std::string& theParentId); + /// Destructor + virtual ~PartSet_WidgetPoint2DFlyout() {}; + + /// Activates the editor control only in case if the mouse over the OCC window, otherwise + /// set focus to the usual double value control + /// \return the state whether the widget can accept the focus + virtual bool focusTo(); + +private: + //! Returns workshop + XGUI_Workshop* workshop() const; + +private: + bool myIsInternal; /// an XML internal state +}; + +#endif diff --git a/src/PartSet/PartSet_WidgetPoint2d.h b/src/PartSet/PartSet_WidgetPoint2d.h index c85ad2082..88ae9ac2e 100644 --- a/src/PartSet/PartSet_WidgetPoint2d.h +++ b/src/PartSet/PartSet_WidgetPoint2d.h @@ -138,7 +138,10 @@ private slots: /// \theObject a result object void setConstraintWith(const ObjectPtr& theObject); +protected: ModuleBase_IWorkshop* myWorkshop; + +private: PartSet_LockApplyMgr* myLockApplyMgr; ///< a manager to lock/unlock Apply button in PP QGroupBox* myGroupBox; ///< the parent group box for all intenal widgets diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 3a926c248..381d4fb80 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -70,7 +70,7 @@ - + @@ -85,7 +85,7 @@ - + @@ -99,7 +99,7 @@ shape_types="edge"> - + @@ -118,7 +118,7 @@ - + diff --git a/src/XGUI/XGUI_PropertyPanel.cpp b/src/XGUI/XGUI_PropertyPanel.cpp index 1df3582db..637521cb7 100644 --- a/src/XGUI/XGUI_PropertyPanel.cpp +++ b/src/XGUI/XGUI_PropertyPanel.cpp @@ -177,7 +177,7 @@ void XGUI_PropertyPanel::activateNextWidget(ModuleBase_ModelWidget* theWidget) return; } } - isFoundWidget = (*anIt) == theWidget; + isFoundWidget = isFoundWidget || (*anIt) == theWidget; } activateWidget(NULL); } @@ -207,6 +207,7 @@ void XGUI_PropertyPanel::activateWidget(ModuleBase_ModelWidget* theWidget) emit widgetActivated(theWidget); } else if (!isEditingMode()) { emit noMoreWidgets(); + setFocusOnOkButton(); } }