[Kst] branches/work/kst/pluginify/kst/src/plugins/linefit
Adam Treat
treat at kde.org
Wed Sep 13 23:13:02 CEST 2006
SVN commit 583961 by treat:
* I think this is the right idea for locking while modifying...
M +21 -8 linefitdialog_i.cpp
M +24 -0 linefitplugin.cpp
M +7 -7 linefitplugin.h
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitdialog_i.cpp #583960:583961
@@ -105,26 +105,24 @@
lf->inputScalars().clear();
lf->inputStrings().clear();
+ lf->unlock();
+
// Save the vectors and scalars
if (!saveInputs(lf)) {
KMessageBox::sorry(this, i18n("There is an error in the input you entered."));
- lf->unlock();
return false;
}
if (!saveOutputs(lf)) {
KMessageBox::sorry(this, i18n("There is an error in the output you entered."));
- lf->unlock();
return false;
}
if (!lf->isValid()) {
KMessageBox::sorry(this, i18n("There is an error in the values you entered."));
- lf->unlock();
return false;
}
lf->setDirty();
- lf->unlock();
emit modified();
return true;
@@ -132,16 +130,31 @@
bool LineFitDialogI::saveInputs(LineFitPtr lf)
{
- Q_UNUSED(lf);
- //implement me
- return false;
+ KST::vectorList.lock().readLock();
+
+ { // leave this scope here to destroy the iterator
+ KstVectorList::Iterator it;
+ it = KST::vectorList.findTag(_w->_xArray->selectedVector());
+ if (it != KST::vectorList.end()) {
+ lf->setXArray(*it);
+ }
+
+ it = KST::vectorList.findTag(_w->_yArray->selectedVector());
+ if (it != KST::vectorList.end()) {
+ lf->setYArray(*it);
+ }
+ }
+
+ KST::vectorList.lock().unlock();
+
+ return true;
}
bool LineFitDialogI::saveOutputs(LineFitPtr lf)
{
Q_UNUSED(lf);
//implement me
- return false;
+ return true;
}
void LineFitDialogI::fillFieldsForEdit() {
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitplugin.cpp #583960:583961
@@ -278,6 +278,30 @@
return *_outputScalars.find(CHI2);
}
+void LineFit::setXArray(KstVectorPtr new_xArray) {
+ if (new_xArray) {
+ _inputVectors[X_ARRAY] = new_xArray;
+ } else {
+ _inputVectors.remove(X_ARRAY);
+ }
+ setDirty();
+}
+
+void LineFit::setYArray(KstVectorPtr new_yArray) {
+ if (new_yArray) {
+ _inputVectors[Y_ARRAY] = new_yArray;
+ } else {
+ _inputVectors.remove(Y_ARRAY);
+ }
+ setDirty();
+}
+
+// void setXInterpolated(KstVectorPtr new_xInterpolated);
+// void setYInterpolated(KstVectorPtr new_yInterpolated);
+// void setA(KstScalarPtr new_a);
+// void setB(KstScalarPtr new_b);
+// void setChi2(KstScalarPtr new_chi2);
+
QString LineFit::propertyString() const {
return "linefit";
}
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitplugin.h #583960:583961
@@ -45,13 +45,13 @@
KstScalarPtr b() const;
KstScalarPtr chi2() const;
-// void setXArray(KstVectorPtr new_xArray);
-// void setYArray(KstVectorPtr new_yArray);
-// void setXInterpolated(KstVectorPtr new_xInterpolated);
-// void setYInterpolated(KstVectorPtr new_yInterpolated);
-// void setA(KstScalarPtr new_a);
-// void setB(KstScalarPtr new_b);
-// void setChi2(KstScalarPtr new_chi2);
+ void setXArray(KstVectorPtr new_xArray);
+ void setYArray(KstVectorPtr new_yArray);
+ void setXInterpolated(KstVectorPtr new_xInterpolated);
+ void setYInterpolated(KstVectorPtr new_yInterpolated);
+ void setA(KstScalarPtr new_a);
+ void setB(KstScalarPtr new_b);
+ void setChi2(KstScalarPtr new_chi2);
//Pure virtual methods from KstDataObject
virtual KstObject::UpdateType update(int updateCounter = -1);
More information about the Kst
mailing list