#include "PartSet_WidgetPoint2DFlyout.h"
#include "ModuleBase_WidgetValidator.h"
+#include "ModuleBase_ViewerPrs.h"
#include <XGUI_Workshop.h>
#include <XGUI_ModuleConnector.h>
myWidgetValidator = new ModuleBase_WidgetValidator(this, myWorkshop);
}
+bool PartSet_WidgetPoint2DFlyout::setSelection(QList<ModuleBase_ViewerPrsPtr>& theValues,
+ const bool theToValidate)
+{
+ PartSet_WidgetPoint2D::setSelection(theValues, theToValidate);
+ // true value should be returned to set this control as processed the selection
+ // to move focus to the next control if it is filled by preselection
+ return true;
+}
+
bool PartSet_WidgetPoint2DFlyout::isValidSelectionCustom(
const std::shared_ptr<ModuleBase_ViewerPrs>& theValue)
{
/// Destructor
virtual ~PartSet_WidgetPoint2DFlyout() {};
+ /// Set the given wrapped value to the current widget
+ /// This value should be processed in the widget according to the needs
+ /// \param theValues the wrapped widget values
+ /// \param theToValidate a validation flag
+ virtual bool setSelection(QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues,
+ const bool theToValidate);
+
/// Checks if the selection presentation is valid in widget
/// \param theValue a selected presentation in the view
/// \return a boolean value
return isDone;
ModuleBase_ViewerPrsPtr aValue = theValues.takeFirst();
- GeomShapePtr aShape = aValue->shape();
- if (aShape.get() && !aShape->isNull()) {
- Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
- double aX, aY;
- const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
- if (getPoint2d(aView, aTDShape, aX, aY)) {
- isDone = setPoint(aX, aY);
- setConstraintToPoint(aX, aY);
+
+ if (!theToValidate || myWidgetValidator->isValidSelection(aValue)) {
+ GeomShapePtr aShape = aValue->shape();
+ if (aShape.get() && !aShape->isNull()) {
+ Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
+ double aX, aY;
+ const TopoDS_Shape& aTDShape = aShape->impl<TopoDS_Shape>();
+ if (getPoint2d(aView, aTDShape, aX, aY)) {
+ isDone = setPoint(aX, aY);
+ setConstraintToPoint(aX, aY);
+ }
}
}
return isDone;