void KstMatrixDialog::fillFieldsForSMatrixEdit() { KstSMatrixPtr smp; // // first hide/show the correct widgets... // _w->_readFromSource->setChecked(false); _w->_generateGradient->setChecked(true); _w->_dataSourceGroup->hide(); _w->_dataRangeGroup->hide(); _w->_gradientGroup->show(); _w->_scalingGroup->show(); smp = kst_cast<KstSMatrix>(_dp); if (smp) { smp->readLock(); _w->_gradientX->setChecked(smp->xDirection()); _w->_gradientY->setChecked(!smp->xDirection()); _w->_gradientZAtMin->setText(QString::number(smp->gradZMin())); _w->_gradientZAtMax->setText(QString::number(smp->gradZMax())); _w->_nX->setValue(smp->xNumSteps()); _w->_nY->setValue(smp->yNumSteps()); smp->unlock(); } }
bool KstMatrixDialog::editSingleSMatrix(KstSMatrixPtr smp) { double gradientZAtMin, gradientZAtMax; double xMin, yMin, xStepSize, yStepSize; bool ok1 = true, ok2 = true, ok3 = true, ok4 = true; bool xDirection, ok5 = true, ok6 = true; int nX, nY; smp->readLock(); if (_xStepDirty) { xStepSize = _w->_xStep->text().toDouble(&ok1); } else { xStepSize = smp->xStepSize(); } if (_yStepDirty) { yStepSize = _w->_yStep->text().toDouble(&ok2); } else { yStepSize = smp->yStepSize(); } if (_minXDirty) { xMin = _w->_minX->text().toDouble(&ok3); } else { xMin = smp->minX(); } if (_minYDirty) { yMin = _w->_minY->text().toDouble(&ok4); } else { yMin = smp->minY(); } if (_gradientXDirty || _gradientYDirty) { xDirection = _w->_gradientX->isChecked(); } else { xDirection = smp->xDirection(); } if (_gradientZAtMinDirty) { gradientZAtMin = _w->_gradientZAtMin->text().toDouble(&ok5); } else { gradientZAtMin = smp->gradZMin(); } if (_gradientZAtMaxDirty) { gradientZAtMax = _w->_gradientZAtMax->text().toDouble(&ok6); } else { gradientZAtMax = smp->gradZMax(); } if (_nXDirty) { nX = _w->_nX->value(); } else { nX = smp->xNumSteps(); } if (_nYDirty) { nY = _w->_nY->value(); } else { nY = smp->yNumSteps(); } smp->unlock(); if (!ok5 || !ok6) { QMessageBox::warning(this, QObject::tr("Kst"), QObject::tr("Gradient values are invalid. Ensure only decimal values are entered.")); return false; } if (!checkParameters(ok1, ok2, ok3, ok4, xStepSize, yStepSize)) { return false; } smp->writeLock(); smp->change(KstObjectTag(smp->tag().tag(), smp->tag().context()), nX, nY, xMin, yMin, xStepSize, yStepSize, gradientZAtMin, gradientZAtMax, xDirection); smp->unlock(); return true; }