[Kst] branches/work/kst/portto4/kst
Barth Netterfield
netterfield at astro.utoronto.ca
Tue Nov 11 22:58:59 CET 2008
SVN commit 883021 by netterfield:
Update bug list
Improve command line option logic
typeString should return something useful. Fixed for ascii and dirfilesource.
Fewer magic strings in ascii.
M +0 -7 devel-docs/Kst2Specs/Bugs
M +6 -0 devel-docs/Kst2Specs/FixedBugs
M +22 -11 src/datasources/ascii/ascii.cpp
M +2 -0 src/datasources/ascii/ascii.h
M +16 -11 src/datasources/dirfilesource/dirfilesource.cpp
M +6 -0 src/datasources/dirfilesource/dirfilesource.h
M +16 -9 src/libkstapp/commandlineparser.cpp
M +1 -1 src/libkstapp/commandlineparser.h
M +1 -0 src/widgets/scalarselector.cpp
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/Bugs #883020:883021
@@ -42,10 +42,3 @@
already a scalar of that name. This is particularly important for plugin entries. It can be created when
the scalar that the selector has selected is asked for.
---------
-Only dirfiles can be chosen from the data wizard.
- ascii files can't find any fields
-
---------
-Problems reading files from the command line
- ascii files can't find any fields from the command line
--- branches/work/kst/portto4/kst/devel-docs/Kst2Specs/FixedBugs #883020:883021
@@ -70,4 +70,10 @@
Cur files no longer work.
Select a cur file from dirfile_maker. It thinks its a ascii file.
+--------
+Problems reading files from the command line
+ ascii files can't find any fields from the command line
+--------
+Only dirfiles can be chosen from the data wizard.
+ ascii files can't find any fields
--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.cpp #883020:883021
@@ -37,10 +37,16 @@
#include <math_kst.h>
#include "ascii.h"
#include "ui_asciiconfig.h"
+#include "kst_i18n.h"
#define DEFAULT_DELIMITERS "#/c!;"
#define DEFAULT_COLUMN_WIDTH 16
+static const QString asciiTypeString = I18N_NOOP("ASCII file");
+
+//const QString AsciiSource::staticTypeString = I18N_NOOP("Ascii Source");
+//const QString AsciiSource::staticTypeTag = I18N_NOOP("source");
+
class AsciiSource::Config {
public:
Config() {
@@ -55,7 +61,7 @@
}
void read(QSettings *cfg, const QString& fileName = QString::null) {
- cfg->beginGroup("ASCII General");
+ cfg->beginGroup(asciiTypeString);
_fileNamePattern = cfg->value("Filename Pattern").toString();
_delimiters = cfg->value("Comment Delimiters", "#/c!;").toString().toLatin1();
_indexInterpretation = (Interpretation)cfg->value("Default INDEX Interpretation", (int)Unknown).toInt();
@@ -174,8 +180,8 @@
_valid = false;
_haveHeader = false;
_fieldListComplete = false;
- _source = "ASCII File Reader";
- if (!type.isEmpty() && type != "ASCII") {
+ _source = asciiTypeString;
+ if (!type.isEmpty() && type != asciiTypeString) {
return;
}
_config = new AsciiSource::Config;
@@ -537,7 +543,7 @@
QString AsciiSource::fileType() const {
- return "ASCII";
+ return asciiTypeString;
}
@@ -725,6 +731,11 @@
}
+const QString& AsciiSource::typeString() const {
+ return asciiTypeString;
+}
+
+
int AsciiSource::sampleForTime(const QDateTime& time, bool *ok) {
switch (_config->_indexInterpretation) {
case AsciiSource::Config::Seconds:
@@ -767,7 +778,7 @@
}
void load() {
- _cfg->beginGroup("ASCII General");
+ _cfg->beginGroup(asciiTypeString);
_ac->_delimiters->setText(_cfg->value("Comment Delimiters", DEFAULT_DELIMITERS).toString());
_ac->_fileNamePattern->setText(_cfg->value("Filename Pattern").toString());
_ac->_columnDelimiter->setText(_cfg->value("Column Delimiter").toString());
@@ -825,7 +836,7 @@
void save() {
assert(_cfg);
- _cfg->beginGroup("ASCII General");
+ _cfg->beginGroup(asciiTypeString);
_cfg->setValue("Filename Pattern", _ac->_fileNamePattern->text());
// If we have an instance, save settings for that instance only
Kst::SharedPtr<AsciiSource> src = Kst::kst_cast<AsciiSource>(_instance);
@@ -878,7 +889,7 @@
if (typeSuggestion) {
- *typeSuggestion = "ASCII";
+ *typeSuggestion = asciiTypeString;
}
if ((!type.isEmpty() && !provides().contains(type)) ||
0 == understands(cfg, filename)) {
@@ -905,7 +916,7 @@
}
if (typeSuggestion) {
- *typeSuggestion = "ASCII";
+ *typeSuggestion = asciiTypeString;
}
AsciiSource::Config config;
@@ -935,7 +946,7 @@
}
if (typeSuggestion) {
- *typeSuggestion = "ASCII";
+ *typeSuggestion = asciiTypeString;
}
AsciiSource::Config config;
@@ -965,7 +976,7 @@
}
if (typeSuggestion) {
- *typeSuggestion = "ASCII";
+ *typeSuggestion = asciiTypeString;
}
AsciiSource::Config config;
@@ -1055,7 +1066,7 @@
QStringList AsciiPlugin::provides() const {
QStringList rc;
- rc += "ASCII";
+ rc += asciiTypeString;
return rc;
}
--- branches/work/kst/portto4/kst/src/datasources/ascii/ascii.h #883020:883021
@@ -63,6 +63,8 @@
bool reset();
+ virtual const QString& typeString() const;
+
class Config;
static QStringList fieldListFor(const QString& filename, Config *cfg);
static QStringList scalarListFor(const QString& filename, Config *cfg);
--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.cpp #883020:883021
@@ -22,8 +22,7 @@
#include <QFileSystemWatcher>
#include <QDir>
-static const QString staticTypeString = I18N_NOOP("Directory of Binary Files");
-//#define staticTypeString "Directory of Binary Files"
+static const QString dirfileTypeString = I18N_NOOP("Directory of Binary Files");
class DirFileSource::Config {
public:
@@ -32,7 +31,7 @@
void read(QSettings *cfg, const QString& fileName = QString::null) {
Q_UNUSED(fileName);
- cfg->beginGroup(staticTypeString);
+ cfg->beginGroup(dirfileTypeString);
cfg->endGroup();
}
@@ -49,10 +48,10 @@
DirFileSource::DirFileSource(Kst::ObjectStore *store, QSettings *cfg, const QString& filename, const QString& type, const QDomElement& e)
: Kst::DataSource(store, cfg, filename, type, None), _config(0L) {
_valid = false;
- if (!type.isEmpty() && type != staticTypeString) {
+ if (!type.isEmpty() && type != dirfileTypeString) {
return;
}
-
+
_config = new DirFileSource::Config;
_config->read(cfg, filename);
if (!e.isNull()) {
@@ -185,7 +184,7 @@
QString DirFileSource::fileType() const {
- return "Directory of Binary Files";
+ return dirfileTypeString;
}
@@ -301,7 +300,7 @@
if (typeSuggestion) {
- *typeSuggestion = staticTypeString;
+ *typeSuggestion = dirfileTypeString;
}
if ((!type.isEmpty() && !provides().contains(type)) ||
0 == understands(cfg, filename)) {
@@ -313,6 +312,12 @@
return QStringList();
}
+const QString& DirFileSource::typeString() const {
+ return dirfileTypeString;
+}
+
+
+
QStringList DirFilePlugin::scalarList(QSettings *cfg,
const QString& filename,
const QString& type,
@@ -338,7 +343,7 @@
}
if (typeSuggestion) {
- *typeSuggestion = staticTypeString;
+ *typeSuggestion = dirfileTypeString;
}
return scalarList;
@@ -369,7 +374,7 @@
}
if (typeSuggestion) {
- *typeSuggestion = staticTypeString;
+ *typeSuggestion = dirfileTypeString;
}
return stringList;
@@ -400,7 +405,7 @@
}
if (typeSuggestion) {
- *typeSuggestion = staticTypeString;
+ *typeSuggestion = dirfileTypeString;
}
return fieldList;
@@ -451,7 +456,7 @@
QStringList DirFilePlugin::provides() const {
QStringList rc;
- rc += staticTypeString;
+ rc += dirfileTypeString;
return rc;
}
--- branches/work/kst/portto4/kst/src/datasources/dirfilesource/dirfilesource.h #883020:883021
@@ -66,6 +66,12 @@
virtual int readFieldStrings(QStringList &v, const QString& field, bool init);
+ virtual const QString& typeString() const;
+ //static const QString staticTypeString;
+ //static const QString staticTypeTag;
+
+
+
private:
QString _directoryName;
Dirfile *_dirfile;
--- branches/work/kst/portto4/kst/src/libkstapp/commandlineparser.cpp #883020:883021
@@ -27,7 +27,7 @@
CommandLineParser::CommandLineParser(Document *doc):
_doAve(false), _doSkip(false), _doConsecutivePlots(true), _useBargraph(false),
_useLines(true), _usePoints(false), _overrideStyle(false), _sampleRate(1.0),
- _numFrames(-1), _startFrame(0),
+ _numFrames(-1), _startFrame(-1),
_skip(0), _plotName(), _errorField(), _fileName(), _xField(QString("INDEX")) {
Q_ASSERT(QCoreApplication::instance());
@@ -64,8 +64,8 @@
"\n"
"OPTIONS are read and interpreted in order. Except for data object options, all are applied to all future data objects, unless later overridden.\n"
"File Options:\n"
-" -f <startframe> default: 0. 'end' counts from end.\n"
-" -n <numframes> default: to end of file ('eof')\n"
+" -f <startframe> default: 'end' counts from end.\n"
+" -n <numframes> default: 'end' reads to end of file\n"
" -s <frames per sample> default: 0 (read every sample)\n"
" -a apply averaging filter: requires -s\n"
"Position:\n"
@@ -116,13 +116,17 @@
exit(0);
}
-void CommandLineParser::_setIntArg(int *arg, QString Message) {
+void CommandLineParser::_setIntArg(int *arg, QString Message, bool accept_end) {
QString param;
bool ok = true;
-
+
if (_arguments.count()> 0) {
param = _arguments.takeFirst();
- *arg = param.toInt(&ok);
+ if ((param==i18n("end") || (param=="end")) && (accept_end)) {
+ *arg = -1;
+ } else {
+ *arg = param.toInt(&ok);
+ }
} else {
ok=false;
}
@@ -159,6 +163,10 @@
DataVectorPtr xv;
bool found = false;
+ if ((_startFrame==-1) && (_numFrames==-1)) { // count from end and read to end
+ _startFrame = 0;
+ }
+
// check to see if an identical vector already exists. If so, use it.
for (int i=0; i<_vectors.count(); i++) {
xv = _vectors.at(i);
@@ -280,9 +288,9 @@
if ((arg == "--help")||(arg == "-help")) {
usage();
} else if (arg == "-f") {
- _setIntArg(&_startFrame, i18n("Usage: -f <startframe>\n"));
+ _setIntArg(&_startFrame, i18n("Usage: -f <startframe>\n"), true);
} else if (arg == "-n") {
- _setIntArg(&_numFrames, i18n("Usage: -f <numframes>\n"));
+ _setIntArg(&_numFrames, i18n("Usage: -f <numframes>\n"), true);
} else if (arg == "-s") {
_setIntArg(&_skip, i18n("Usage: -s <frames per sample>\n"));
} else if (arg == "-a") {
@@ -330,7 +338,6 @@
usage(i18n("file %1 does not exist\n").arg(file));
DataSourcePtr ds = DataSource::findOrLoadSource(_document->objectStore(), file);
-
DataVectorPtr xv = createOrFindDataVector(_xField, ds);
DataVectorPtr yv = createOrFindDataVector(field, ds);
--- branches/work/kst/portto4/kst/src/libkstapp/commandlineparser.h #883020:883021
@@ -56,7 +56,7 @@
Document *_document;
- void _setIntArg(int *arg, QString Message);
+ void _setIntArg(int *arg, QString Message, bool accept_end=false);
void _setDoubleArg(double *arg, QString Message);
void _setStringArg(QString &arg, QString Message);
void usage(QString Message = "");
--- branches/work/kst/portto4/kst/src/widgets/scalarselector.cpp #883020:883021
@@ -67,6 +67,7 @@
ScalarPtr ScalarSelector::selectedScalar() const {
+ //qDebug() << "xxx text: " << _scalar->currentText();
return qVariantValue<Scalar*>(_scalar->itemData(_scalar->currentIndex()));
}
More information about the Kst
mailing list