[Kst] branches/work/kst/portto4/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Sat Sep 27 18:56:48 CEST 2008
SVN commit 865467 by netterfield:
-Add dataStrings
-Add reading of strings to data sources
-Add a stringDialog to edit and create strings
-Fix some compiler warnings
M +4 -4 devel-docs/Kst2Specs/Bugs
M +29 -10 src/datasources/ascii/ascii.cpp
M +2 -2 src/datasources/ascii/ascii.h
M +11 -0 src/datasources/dirfile/dirfile.cpp
M +2 -0 src/datasources/dirfile/dirfile.h
A src/libkst/datastring.cpp [License: GPL (v2+)]
A src/libkst/datastring.h [License: GPL (v2+)]
M +2 -0 src/libkst/libkst.pro
M +3 -1 src/libkst/string_kst.h
M +11 -4 src/libkstapp/datamanager.cpp
M +1 -0 src/libkstapp/datamanager.h
M +5 -2 src/libkstapp/dialoglaunchergui.cpp
M +1 -1 src/libkstapp/dialoglaunchergui.h
M +3 -0 src/libkstapp/libkstapp.pro
A src/libkstapp/stringdialog.cpp [License: GPL (v2+)]
A src/libkstapp/stringdialog.h [License: GPL (v2+)]
A src/libkstapp/stringtab.ui
M +3 -3 src/libkstmath/csdfactory.cpp
M +2 -1 src/libkstmath/dialoglauncher.cpp
M +1 -1 src/libkstmath/dialoglauncher.h
M +2 -2 src/libkstmath/eventmonitorfactory.cpp
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Bugs #865466:865467
@@ -1,7 +1,7 @@
+Crash deleting last tab:
+start kst, and in the only tab, select rmb->close. CRASH!
+This is especially a problem since this is what TabWidget->clear() does. TabWidget->clear() is used when opening
+a file to get rid of all of the old tabs. Currently, clear() is not called, so all of the old tabs linger after opening a file.
-------------
-
-
-
--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.cpp #865466:865467
@@ -225,6 +225,7 @@
_fieldList.clear();
_scalarList.clear();
_matrixList.clear();
+ _stringList.clear();
update(); // Yuck - same problem as in the constructor presently.
@@ -296,8 +297,7 @@
// Re-update the scalar list since we have one now
_scalarList = scalarListFor(_filename, _config);
- _scalarListComplete = _scalarList.count() > 1;
-
+ _stringList = stringListFor(_filename, _config);
}
bool forceUpdate = false;
@@ -377,11 +377,6 @@
}
-bool AsciiSource::scalarListIsComplete() const {
- return _scalarListComplete;
-}
-
-
int AsciiSource::readScalar(double &S, const QString& scalar) {
if (scalar == "FRAMES") {
S = _numFrames;
@@ -391,6 +386,16 @@
}
+int AsciiSource::readString(QString &S, const QString& string) {
+ if (string == "FILE") {
+ S = _filename;
+ return 1;
+ }
+ return 0;
+}
+
+
+
int AsciiSource::readField(double *v, const QString& field, int s, int n) {
if (n < 0) {
n = 1; /* n < 0 means read one sample, not frame - irrelevent here */
@@ -556,6 +561,22 @@
}
+QStringList AsciiSource::stringListFor(const QString& filename, AsciiSource::Config *cfg) {
+ Q_UNUSED(cfg)
+ QStringList rc;
+ QFile file(filename);
+
+ if (!file.open(QIODevice::ReadOnly)) {
+ return rc;
+ }
+
+ file.close();
+
+ rc += "FILE";
+ return rc;
+
+}
+
QStringList AsciiSource::fieldListFor(const QString& filename, AsciiSource::Config *cfg) {
QStringList rc;
QFile file(filename);
@@ -949,10 +970,8 @@
AsciiSource::Config config;
config.read(cfg, filename);
- QStringList rc;// = AsciiSource::scalarListFor(filename, &config);
+ QStringList rc = AsciiSource::stringListFor(filename, &config);
- rc.append("FILENAME");
-
if (complete) {
*complete = rc.count() > 1;
}
--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.h #865466:865467
@@ -59,13 +59,14 @@
int readScalar(double &S, const QString& scalar);
- bool scalarListIsComplete() const;
+ int readString(QString &S, const QString& string);
bool reset();
class Config;
static QStringList fieldListFor(const QString& filename, Config *cfg);
static QStringList scalarListFor(const QString& filename, Config *cfg);
+ static QStringList stringListFor(const QString& filename, Config *cfg);
private:
int *_rowIndex;
@@ -78,7 +79,6 @@
uint _tmpBufSize;
bool _haveHeader;
bool _fieldListComplete;
- bool _scalarListComplete;
};
--- branches/work/kst/portto4/kst/src/datasources/dirfile/dirfile.cpp #865466:865467
@@ -99,12 +99,14 @@
_fieldList.clear();
_scalarList.clear();
_matrixList.clear();
+ _stringList.clear();
_frameCount = 0;
FormatType *ft = GetFormat(_directoryName.toLatin1(), &err);
if (err == GD_E_OK) {
_scalarList.append("FRAMES");
+ _stringList.append("FILE");
_fieldList.append("INDEX");
for (int i = 0; i < ft->n_lincom; i++) {
@@ -221,6 +223,15 @@
}
+int DirFileSource::readString(QString &S, const QString& string) {
+ if (string == "FILE") {
+ S = _filename;
+ return 1;
+ }
+ return 0;
+}
+
+
QString DirFilePlugin::pluginName() const { return "DirFile Reader"; }
QString DirFilePlugin::pluginDescription() const { return "DirFile Reader"; }
--- branches/work/kst/portto4/kst/src/datasources/dirfile/dirfile.h #865466:865467
@@ -55,6 +55,8 @@
int readScalar(double &S, const QString& scalar);
+ int readString(QString &S, const QString& string);
+
private:
QString _directoryName;
--- branches/work/kst/portto4/kst/src/libkst/libkst.pro #865466:865467
@@ -24,6 +24,7 @@
datasourcepluginfactory.cpp \
datavector.cpp \
datascalar.cpp \
+ datastring.cpp \
dateparser.cpp \
debug.cpp \
editablematrix.cpp \
@@ -67,6 +68,7 @@
datasourcepluginfactory.h \
datavector.h \
datascalar.h \
+ datastring.h \
dateparser.h \
debug.h \
editablematrix.h \
--- branches/work/kst/portto4/kst/src/libkst/string_kst.h #865466:865467
@@ -66,8 +66,10 @@
signals:
void trigger();
+ protected:
+ QString _value;
+
private:
- QString _value;
bool _orphan : 1;
bool _editable;
};
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.cpp #865466:865467
@@ -88,10 +88,10 @@
action = new DataButtonAction(tr("Scalar"));
connect(action, SIGNAL(triggered()), this, SLOT(showScalarDialog()));
_primitives->addAction(action);
-//
-// action = new DataButtonAction(tr("String"));
-// connect(action, SIGNAL(triggered()), this, SLOT(showStringDialog()));
-// _primitives->addAction(action);
+
+ action = new DataButtonAction(tr("String"));
+ connect(action, SIGNAL(triggered()), this, SLOT(showStringDialog()));
+ _primitives->addAction(action);
action = new DataButtonAction(tr("Curve"));
connect(action, SIGNAL(triggered()), this, SLOT(showCurveDialog()));
@@ -345,6 +345,13 @@
}
+void DataManager::showStringDialog() {
+ QString stringName;
+ DialogLauncher::self()->showStringDialog(stringName);
+ _doc->session()->triggerReset();
+}
+
+
void DataManager::showEventMonitorDialog() {
DialogLauncher::self()->showEventMonitorDialog();
_doc->session()->triggerReset();
--- branches/work/kst/portto4/kst/src/libkstapp/datamanager.h #865466:865467
@@ -40,6 +40,7 @@
void showVectorDialog();
void showMatrixDialog();
void showScalarDialog();
+ void showStringDialog();
void showCurveDialog();
void showCSDDialog();
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.cpp #865466:865467
@@ -17,6 +17,7 @@
#include "histogramdialog.h"
#include "vectordialog.h"
#include "scalardialog.h"
+#include "stringdialog.h"
#include "matrixdialog.h"
#include "powerspectrumdialog.h"
#include "csddialog.h"
@@ -56,8 +57,10 @@
}
-void DialogLauncherGui::showStringDialog(ObjectPtr objectPtr) {
- Q_UNUSED(objectPtr);
+void DialogLauncherGui::showStringDialog(QString &stringname, ObjectPtr objectPtr) {
+ StringDialog dialog(objectPtr, kstApp->mainWindow());
+ dialog.exec();
+ stringname = dialog.dataObjectName();
}
--- branches/work/kst/portto4/kst/src/libkstapp/dialoglaunchergui.h #865466:865467
@@ -30,7 +30,7 @@
virtual void showScalarDialog(QString &scalarname, ObjectPtr objectPtr = 0);
- virtual void showStringDialog(ObjectPtr objectPtr = 0);
+ virtual void showStringDialog(QString &stringname, ObjectPtr objectPtr = 0);
//standard objects
virtual void showCurveDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
--- branches/work/kst/portto4/kst/src/libkstapp/libkstapp.pro #865466:865467
@@ -100,6 +100,7 @@
scene.cpp \
selectionrect.cpp \
sessionmodel.cpp \
+ stringdialog.cpp \
stringmodel.cpp \
stroketab.cpp \
svgitem.cpp \
@@ -198,6 +199,7 @@
scene.h \
selectionrect.h \
sessionmodel.h \
+ stringdialog.h \
stringmodel.h \
svgitem.h \
stroketab.h \
@@ -254,6 +256,7 @@
matrixtab.ui \
powerspectrumtab.ui \
scalartab.ui \
+ stringtab.ui \
stroketab.ui \
vectoreditordialog.ui \
vectortab.ui \
--- branches/work/kst/portto4/kst/src/libkstmath/csdfactory.cpp #865466:865467
@@ -31,10 +31,10 @@
DataObjectPtr CSDFactory::generateObject(ObjectStore *store, QXmlStreamReader& xml) {
Q_ASSERT(store);
- double frequency, gaussianSigma;
- int length, windowSize, apodizeFunction, outputType;
+ double frequency=1.0, gaussianSigma=1.0;
+ int length=8, windowSize=8, apodizeFunction=0, outputType=0;
QString vectorName, vectorUnits, rateUnits, descriptiveName;
- bool average, removeMean, apodize;
+ bool average=false, removeMean=false, apodize=false;
while (!xml.atEnd()) {
const QString n = xml.name().toString();
--- branches/work/kst/portto4/kst/src/libkstmath/dialoglauncher.cpp #865466:865467
@@ -70,8 +70,9 @@
}
-void DialogLauncher::showStringDialog(ObjectPtr objectPtr) {
+void DialogLauncher::showStringDialog(QString &scalarname, ObjectPtr objectPtr) {
Q_UNUSED(objectPtr);
+ Q_UNUSED(scalarname);
}
--- branches/work/kst/portto4/kst/src/libkstmath/dialoglauncher.h #865466:865467
@@ -49,7 +49,7 @@
virtual void showScalarDialog(QString &scalarname, ObjectPtr objectPtr = 0);
- virtual void showStringDialog(ObjectPtr objectPtr = 0);
+ virtual void showStringDialog(QString &scalarname, ObjectPtr objectPtr = 0);
//standard objects
virtual void showCurveDialog(ObjectPtr objectPtr = 0, VectorPtr vector = 0);
--- branches/work/kst/portto4/kst/src/libkstmath/eventmonitorfactory.cpp #865466:865467
@@ -32,8 +32,8 @@
Q_ASSERT(store);
QString equation, description, emailRecipients, script;
- bool logDebug, logEmail, logELOG;
- int logLevel;
+ bool logDebug=false, logEmail=false, logELOG=false;
+ int logLevel=1;
while (!xml.atEnd()) {
const QString n = xml.name().toString();
More information about the Kst
mailing list