[Kst] kdeextragear-2/kst/kst
George Staikos
staikos at kde.org
Wed Jan 5 21:09:32 CET 2005
CVS commit by staikos:
interpolation support for saving vectors
M +22 -8 kstdatacollection-gui.cpp 1.16
M +4 -3 vectorsavedialog.ui.h 1.5
--- kdeextragear-2/kst/kst/vectorsavedialog.ui.h #1.4:1.5
@@ -27,10 +27,13 @@ void VectorSaveDialog::save()
KURL url = KFileDialog::getSaveURL(QString::null, QString::null, this, i18n("Save Vector As"));
if (!url.isEmpty()) {
+ bool interpolate = true;
switch (_multiOptions->currentItem()) {
case 0:
+ interpolate = false;
+ case 1:
{
KTempFile tf(locateLocal("tmp", "kstvectors"), "txt");
tf.setAutoDelete(true);
- if (0 != KST::vectorsToFile(toSave, tf.file())) {
+ if (0 != KST::vectorsToFile(toSave, tf.file(), interpolate)) {
KMessageBox::sorry(this, i18n("Error saving vector to %1.").arg(url.prettyURL()), i18n("Kst"));
return;
@@ -46,6 +49,4 @@ void VectorSaveDialog::save()
}
break;
- case 1:
- break;
case 2:
{
--- kdeextragear-2/kst/kst/kstdatacollection-gui.cpp #1.15:1.16
@@ -121,9 +121,16 @@ int KST::vectorToFile(KstVectorPtr v, QF
-int KST::vectorsToFile(const KstVectorList& vl, QFile *f) {
+int KST::vectorsToFile(const KstVectorList& vl, QFile *f, bool interpolate) {
KstApp *app = KstApp::inst();
int vcnt = vl.count();
int maxlen = -1;
+ if (interpolate) { // code duplication is faster
+ maxlen = 0;
+ for (KstVectorList::ConstIterator v = vl.begin(); v != vl.end(); ++v) {
+ (*v)->readLock();
+ maxlen = KMAX(maxlen, (*v)->length());
+ }
+ } else {
for (KstVectorList::ConstIterator v = vl.begin(); v != vl.end(); ++v) {
(*v)->readLock();
@@ -134,4 +141,5 @@ int KST::vectorsToFile(const KstVectorLi
}
}
+ }
QString saving = i18n("Saving vectors...");
@@ -163,5 +171,11 @@ int KST::vectorsToFile(const KstVectorLi
first = false;
}
- ltxt += QString::number((*v)->value()[line], 'g', 15);
+ double val;
+ if (interpolate) { // might be faster to put this outside the for loops
+ val = (*v)->interpolate(line, maxlen);
+ } else {
+ val = (*v)->value()[line];
+ }
+ ltxt += QString::number(val, 'g', 15);
}
ltxt += "\n";
More information about the Kst
mailing list