// Author: Natalia ERMOLAEVA
#include <ModuleBase_WidgetPoint2D.h>
+#include <ModuleBase_WidgetValueFeature.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
{
}
+bool ModuleBase_WidgetPoint2D::setValue(ModuleBase_WidgetValue* theValue)
+{
+ bool isDone = false;
+ if (theValue) {
+ ModuleBase_WidgetValueFeature* aFeatureValue =
+ dynamic_cast<ModuleBase_WidgetValueFeature*>(theValue);
+ if (aFeatureValue) {
+ boost::shared_ptr<GeomAPI_Pnt2d> aPoint = aFeatureValue->point();
+ if (aPoint) {
+ setPoint(aPoint);
+ isDone = true;
+ }
+ }
+ }
+ return isDone;
+}
+
void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr<GeomAPI_Pnt2d>& thePoint)
{
{
if (theObject == myXSpin || theObject == myYSpin) {
if (theEvent->type() == QEvent::KeyRelease) {
+ QKeyEvent* aKeyEvent = (QKeyEvent*)theEvent;
+ if (aKeyEvent && aKeyEvent->key() == Qt::Key_Return) {
+ emit focusOutWidget(this);
+ }
emit keyReleased(attributeID(), (QKeyEvent*) theEvent);
return true;
}
return ModuleBase_ModelWidget::eventFilter(theObject, theEvent);
}
-void ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
+bool ModuleBase_WidgetPoint2D::initFromPrevious(FeaturePtr theFeature)
{
if (myOptionParam.length() == 0)
- return;
+ return false;
boost::shared_ptr<ModelAPI_Data> aData = theFeature->data();
boost::shared_ptr<GeomDataAPI_Point2D> aPoint =
boost::dynamic_pointer_cast<GeomDataAPI_Point2D>(aData->attribute(myOptionParam));
if (aPoint) {
bool isBlocked = this->blockSignals(true);
myXSpin->setValue(aPoint->x());
- this->blockSignals(isBlocked);
myYSpin->setValue(aPoint->y());
+ this->blockSignals(isBlocked);
+
+ emit valuesChanged();
+ emit storedPoint2D(theFeature, myOptionParam);
+ return true;
}
+ return false;
}