X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_WidgetPoint2D.cpp;h=8feec7a6c5e96aa9f7d7983c0d4e7af82a8b9cf7;hb=2ca8be5b9d184c33cbfd78b1259638f340eeb017;hp=cefa9284771c98de52d5b0ebf2f55af5febd0e02;hpb=db1bdf5481826c868b2c92c6cbc9afe8c5ad337c;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp index cefa92847..8feec7a6c 100644 --- a/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp +++ b/src/ModuleBase/ModuleBase_WidgetPoint2D.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -19,7 +20,6 @@ #include #include -#include #include #include #include @@ -28,14 +28,15 @@ #include ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, - const Config_WidgetAPI* theData) -: ModuleBase_ModelWidget(theParent, theData) + const Config_WidgetAPI* theData, + const std::string& theParentId) + : ModuleBase_ModelWidget(theParent, theData, theParentId) { myOptionParam = theData->getProperty(PREVIOUS_FEATURE_PARAM); myGroupBox = new QGroupBox(QString::fromStdString(theData->getProperty(CONTAINER_PAGE_NAME)), theParent); QGridLayout* aGroupLay = new QGridLayout(myGroupBox); - aGroupLay->setContentsMargins(0, 0, 0, 0); + aGroupLay->setContentsMargins(2, 0, 2, 0); aGroupLay->setColumnStretch(1, 1); { QLabel* aLabel = new QLabel(myGroupBox); @@ -43,12 +44,12 @@ ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, aLabel->setPixmap(QPixmap(":pictures/x_point.png")); aGroupLay->addWidget(aLabel, 0, 0); - myXSpin = new QDoubleSpinBox(myGroupBox); + myXSpin = new ModuleBase_DoubleSpinBox(myGroupBox); myXSpin->setMinimum(-DBL_MAX); myXSpin->setMaximum(DBL_MAX); myXSpin->setToolTip("X"); aGroupLay->addWidget(myXSpin, 0, 1); - + connect(myXSpin, SIGNAL(valueChanged(double)), this, SIGNAL(valuesChanged())); } { @@ -57,7 +58,7 @@ ModuleBase_WidgetPoint2D::ModuleBase_WidgetPoint2D(QWidget* theParent, aLabel->setPixmap(QPixmap(":pictures/y_point.png")); aGroupLay->addWidget(aLabel, 1, 0); - myYSpin = new QDoubleSpinBox(myGroupBox); + myYSpin = new ModuleBase_DoubleSpinBox(myGroupBox); myYSpin->setMinimum(-DBL_MAX); myYSpin->setMaximum(DBL_MAX); myYSpin->setToolTip("X"); @@ -77,8 +78,8 @@ bool ModuleBase_WidgetPoint2D::setValue(ModuleBase_WidgetValue* theValue) { bool isDone = false; if (theValue) { - ModuleBase_WidgetValueFeature* aFeatureValue = - dynamic_cast(theValue); + ModuleBase_WidgetValueFeature* aFeatureValue = + dynamic_cast(theValue); if (aFeatureValue) { boost::shared_ptr aPoint = aFeatureValue->point(); if (aPoint) { @@ -101,26 +102,26 @@ void ModuleBase_WidgetPoint2D::setPoint(const boost::shared_ptr& emit valuesChanged(); } -bool ModuleBase_WidgetPoint2D::storeValue(ObjectPtr theObject) const +bool ModuleBase_WidgetPoint2D::storeValue() const { - boost::shared_ptr aData = theObject->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aData = myFeature->data(); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(attributeID())); ModuleBase_WidgetPoint2D* that = (ModuleBase_WidgetPoint2D*) this; bool isBlocked = that->blockSignals(true); aPoint->setValue(myXSpin->value(), myYSpin->value()); - Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_UPDATED)); + updateObject(myFeature); that->blockSignals(isBlocked); return true; } -bool ModuleBase_WidgetPoint2D::restoreValue(ObjectPtr theObject) +bool ModuleBase_WidgetPoint2D::restoreValue() { - boost::shared_ptr aData = theObject->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(attributeID())); + boost::shared_ptr aData = myFeature->data(); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(attributeID())); bool isBlocked = this->blockSignals(true); myXSpin->setValue(aPoint->x()); @@ -143,28 +144,13 @@ QList ModuleBase_WidgetPoint2D::getControls() const return aControls; } -bool ModuleBase_WidgetPoint2D::eventFilter(QObject *theObject, QEvent *theEvent) -{ - 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); -} - bool ModuleBase_WidgetPoint2D::initFromPrevious(ObjectPtr theObject) { if (myOptionParam.length() == 0) return false; boost::shared_ptr aData = theObject->data(); - boost::shared_ptr aPoint = - boost::dynamic_pointer_cast(aData->attribute(myOptionParam)); + boost::shared_ptr aPoint = boost::dynamic_pointer_cast( + aData->attribute(myOptionParam)); if (aPoint) { bool isBlocked = this->blockSignals(true); myXSpin->setValue(aPoint->x());