[Kst] branches/work/kst/pluginify/kst/src/plugins/linefit

Adam Treat treat at kde.org
Tue Sep 12 23:43:12 CEST 2006


SVN commit 583652 by treat:

* Hook up the fillFieldsForEdit() and ...new() in the
linefit dialog.  Add convenience functions for the tags
in the lineedit plugin and figure out how all this dialog
stuff is supposed to work.


 M  +31 -4     linefitdialog_i.cpp  
 M  +97 -13    linefitplugin.cpp  
 M  +27 -2     linefitplugin.h  


--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitdialog_i.cpp #583651:583652
@@ -54,19 +54,46 @@
 : KstDataDialog(parent, name, modal, fl) {
   _w = new LineFitDialogWidget(_contents);
   setMultiple(false);
-
-  adjustSize();
-  resize(minimumSizeHint());
-  setFixedHeight(height());
 }
 
 LineFitDialogI::~LineFitDialogI() {
 }
 
 void LineFitDialogI::fillFieldsForEdit() {
+  LineFitPtr lf = kst_cast<LineFit>(_dp);
+  if (!lf) {
+    return;
+  }
+
+  lf->readLock();
+
+  _tagName->setText(lf->tagName());
+  _legendText->setText(defaultTag); //FIXME?
+
+  _w->_xArray->setSelection( lf->xArrayTag() );
+  _w->_yArray->setSelection( lf->yArrayTag() );
+
+  _w->_xInterpolated->setText( lf->xInterpolatedTag() );
+  _w->_yInterpolated->setText( lf->yInterpolatedTag() );
+
+  _w->_a->setText( lf->aTag() );
+  _w->_b->setText( lf->bTag() );
+  _w->_chi2->setText( lf->chi2Tag() );
+
+  lf->unlock();
+
+  adjustSize();
+  resize(minimumSizeHint());
+  setFixedHeight(height());
 }
 
 void LineFitDialogI::fillFieldsForNew() {
+  _tagName->setText(defaultTag);
+  _legendText->setText(defaultTag);
+
+  adjustSize();
+  resize(minimumSizeHint());
+  setFixedHeight(height());
 }
 
 #include "linefitdialog_i.moc"
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitplugin.cpp #583651:583652
@@ -26,11 +26,11 @@
 
 #include "linefitdialog_i.h"
 
-static const QString& X_COORDINATES_IN = KGlobal::staticQString("X Array");
-static const QString& Y_COORDINATES_IN = KGlobal::staticQString("Y Array");
+static const QString& X_ARRAY = KGlobal::staticQString("X Array");
+static const QString& Y_ARRAY = KGlobal::staticQString("Y Array");
 
-static const QString& X_COORDINATES_OUT = KGlobal::staticQString("X Interpolated");
-static const QString& Y_COORDINATES_OUT = KGlobal::staticQString("Y Interpolated");
+static const QString& X_INTERPOLATED = KGlobal::staticQString("X Interpolated");
+static const QString& Y_INTERPOLATED = KGlobal::staticQString("Y Interpolated");
 
 static const QString& A = KGlobal::staticQString("a");
 static const QString& B = KGlobal::staticQString("b");
@@ -63,8 +63,8 @@
     return lastUpdateResult();
   }
 
-  KstVectorPtr xIn = *_inputVectors.find(X_COORDINATES_IN);
-  KstVectorPtr yIn = *_inputVectors.find(Y_COORDINATES_IN);
+  KstVectorPtr xIn = *_inputVectors.find(X_ARRAY);
+  KstVectorPtr yIn = *_inputVectors.find(Y_ARRAY);
 
   if (!xIn || !yIn) {
     return setLastUpdateResult(NO_CHANGE);
@@ -81,8 +81,8 @@
 
   setLastUpdateResult(UPDATE); // make sure that provider callbacks work
 
-  KstVectorPtr xOut = *_outputVectors.find(X_COORDINATES_OUT);
-  KstVectorPtr yOut = *_outputVectors.find(Y_COORDINATES_OUT);
+  KstVectorPtr xOut = *_outputVectors.find(X_INTERPOLATED);
+  KstVectorPtr yOut = *_outputVectors.find(Y_INTERPOLATED);
 
   vectorRealloced(xOut, xOut->value(), 2);
   xOut->setDirty();
@@ -110,11 +110,11 @@
   double a = 0.0, b = 0.0, sx = 0.0, sy = 0.0, sxoss = 0.0, st2 = 0.0, chi2 = 0.0;
   double xScale;
 
-  KstVectorPtr xIn = *_inputVectors.find(X_COORDINATES_IN);
-  KstVectorPtr yIn = *_inputVectors.find(Y_COORDINATES_IN);
+  KstVectorPtr xIn = *_inputVectors.find(X_ARRAY);
+  KstVectorPtr yIn = *_inputVectors.find(Y_ARRAY);
 
-  KstVectorPtr xOut = *_outputVectors.find(X_COORDINATES_OUT);
-  KstVectorPtr yOut = *_outputVectors.find(Y_COORDINATES_OUT);
+  KstVectorPtr xOut = *_outputVectors.find(X_INTERPOLATED);
+  KstVectorPtr yOut = *_outputVectors.find(Y_INTERPOLATED);
 
   KstScalarPtr _a = *_outputScalars.find(A);
   KstScalarPtr _b = *_outputScalars.find(B);
@@ -194,6 +194,90 @@
   _chi2->setValue( chi2 );
 }
 
+QString LineFit::xArrayTag() const {
+  KstVectorPtr v = xArray();
+  if (v) {
+    return v->tagName();
+  }
+  return QString::null;
+}
+
+QString LineFit::yArrayTag() const {
+  KstVectorPtr v = yArray();
+  if (v) {
+    return v->tagName();
+  }
+  return QString::null;
+}
+
+QString LineFit::xInterpolatedTag() const {
+  KstVectorPtr v = xInterpolated();
+  if (v) {
+    return v->tagName();
+  }
+  return QString::null;
+}
+
+QString LineFit::yInterpolatedTag() const {
+  KstVectorPtr v = yInterpolated();
+  if (v) {
+    return v->tagName();
+  }
+  return QString::null;
+}
+
+QString LineFit::aTag() const {
+  KstScalarPtr s = a();
+  if (s) {
+    return s->tagName();
+  }
+  return QString::null;
+}
+
+QString LineFit::bTag() const {
+  KstScalarPtr s = b();
+  if (s) {
+    return s->tagName();
+  }
+  return QString::null;
+}
+
+QString LineFit::chi2Tag() const {
+  KstScalarPtr s = chi2();
+  if (s) {
+    return s->tagName();
+  }
+  return QString::null;
+}
+
+KstVectorPtr LineFit::xArray() const {
+  return *_inputVectors.find(X_ARRAY);
+}
+
+KstVectorPtr LineFit::yArray() const {
+  return *_inputVectors.find(Y_ARRAY);
+}
+
+KstVectorPtr LineFit::xInterpolated() const {
+  return *_outputVectors.find(X_INTERPOLATED);
+}
+
+KstVectorPtr LineFit::yInterpolated() const {
+  return *_outputVectors.find(Y_INTERPOLATED);
+}
+
+KstScalarPtr LineFit::a() const {
+  return *_outputScalars.find(A);
+}
+
+KstScalarPtr LineFit::b() const {
+  return *_outputScalars.find(B);
+}
+
+KstScalarPtr LineFit::chi2() const {
+  return *_outputScalars.find(CHI2);
+}
+
 QString LineFit::propertyString() const {
   return "linefit";
 }
@@ -204,7 +288,7 @@
 
 void LineFit::_showDialog() {
   LineFitDialogI *dialog = new LineFitDialogI;
-  dialog->show();
+  dialog->showEdit(tagName());
 }
 
 void LineFit::load(const QDomElement &e) {
--- branches/work/kst/pluginify/kst/src/plugins/linefit/linefitplugin.h #583651:583652
@@ -28,8 +28,31 @@
 
   //algorithm
   void linefit();
-  void createFitScalars();
 
+  QString xArrayTag() const;
+  QString yArrayTag() const;
+  QString xInterpolatedTag() const;
+  QString yInterpolatedTag() const;
+  QString aTag() const;
+  QString bTag() const;
+  QString chi2Tag() const;
+
+  KstVectorPtr xArray() const;
+  KstVectorPtr yArray() const;
+  KstVectorPtr xInterpolated() const;
+  KstVectorPtr yInterpolated() const;
+  KstScalarPtr a() const;
+  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);
+
   //Pure virtual methods from KstDataObject
   virtual KstObject::UpdateType update(int updateCounter = -1);
   virtual QString propertyString() const;
@@ -70,7 +93,9 @@
 
 private:
   bool m_init;
-
 };
 
+typedef KstSharedPtr<LineFit> LineFitPtr;
+typedef KstObjectList<LineFitPtr> LineFitList;
+
 #endif


More information about the Kst mailing list