64 changes: 52 additions & 12 deletions src/datasources/ascii/asciiconfig.ui
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,12 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -383,7 +389,7 @@
<string>Reading is faster if each column can be assumed to have its own constant width.</string>
</property>
<property name="text">
<string>Each collumn has its own constant width</string>
<string>Each column has its own constant width</string>
</property>
</widget>
</item>
Expand All @@ -394,6 +400,12 @@
</item>
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="title">
<string>General Options</string>
</property>
Expand Down Expand Up @@ -462,19 +474,47 @@
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
<layout class="QHBoxLayout" name="horizontalLayout_17">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Empty Value:</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="_nanNull">
<property name="text">
<string>Null</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="_nanNAN">
<property name="text">
<string>NaN</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="_nanPrevious">
<property name="text">
<string>Previous</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
</layout>
<zorder>_useThreads</zorder>
<zorder>layoutWidget</zorder>
<zorder>_nanNAN</zorder>
</widget>
</item>
<item>
Expand Down
11 changes: 10 additions & 1 deletion src/datasources/ascii/asciiconfigwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ AsciiSourceConfig AsciiConfigWidgetInternal::config()
config._offsetRelative = _offsetRelative->isChecked();
config._dateTimeOffset = _dateTimeOffset->dateTime();
config._relativeOffset = _relativeOffset->value();
config._nanValue = _nanNull->isChecked()
? 0 : _nanNAN->isChecked()
? 1 : _nanPrevious->isChecked()
? 2 : 0;
return config;
}

Expand Down Expand Up @@ -225,7 +229,12 @@ void AsciiConfigWidgetInternal::setConfig(const AsciiSourceConfig& config)
_offsetRelative->setChecked(config._offsetRelative.value());
_dateTimeOffset->setDateTime(config._dateTimeOffset.value());
_relativeOffset->setValue(config._relativeOffset.value());

switch (config._nanValue.value()) {
case 0: _nanNull->setChecked(true); break;
case 1: _nanNAN->setChecked(true); break;
case 2: _nanPrevious->setChecked(true); break;
default: _nanNull->setChecked(true); break;
}
}


Expand Down
11 changes: 9 additions & 2 deletions src/datasources/ascii/asciisource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,16 @@ int AsciiSource::tryReadField(double *v, const QString& field, int s, int n)
}

// now start reading
LexicalCast::NaNMode nanMode;
switch (_config._nanValue.value()) {
case 0: nanMode = LexicalCast::NullValue; break;
case 1: nanMode = LexicalCast::NaNValue; break;
case 2: nanMode = LexicalCast::PreviousValue; break;
default:nanMode = LexicalCast::NullValue; break;
}
LexicalCast::AutoReset useDot(_config._useDot, nanMode);


LexicalCast::AutoReset useDot(_config._useDot);

if (field == _config._indexVector && _config._indexInterpretation == AsciiSourceConfig::FormattedTime) {
LexicalCast::instance().setTimeFormat(_config._timeAsciiFormatString);
}
Expand Down
17 changes: 13 additions & 4 deletions src/datasources/ascii/asciisourceconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const char AsciiSourceConfig::Key_dateTimeOffset[] = "date/time offset";
const char AsciiSourceConfig::Tag_dateTimeOffset[] = "dateTimeOffset";
const char AsciiSourceConfig::Key_relativeOffset[] = "relative offset";
const char AsciiSourceConfig::Tag_relativeOffset[] = "relativeOffset";
const char AsciiSourceConfig::Key_nanValue[] = "NaN value";
const char AsciiSourceConfig::Tag_nanValue[] = "nanValue";

AsciiSourceConfig::AsciiSourceConfig() :
_delimiters(DEFAULT_COMMENT_DELIMITERS),
Expand All @@ -96,7 +98,8 @@ AsciiSourceConfig::AsciiSourceConfig() :
_offsetFileDate(false),
_offsetRelative(true),
_dateTimeOffset(QDateTime::currentDateTime()),
_relativeOffset(0)
_relativeOffset(0),
_nanValue(0)
{
}

Expand Down Expand Up @@ -127,6 +130,7 @@ void AsciiSourceConfig::save(QSettings& cfg) const {
_offsetRelative >> cfg;
_dateTimeOffset >> cfg;
_relativeOffset >> cfg;
_nanValue >> cfg;
}


Expand Down Expand Up @@ -168,6 +172,7 @@ void AsciiSourceConfig::read(QSettings& cfg) {
_offsetRelative << cfg;
_dateTimeOffset << cfg;
_relativeOffset << cfg;
_nanValue << cfg;
}


Expand Down Expand Up @@ -216,7 +221,7 @@ void AsciiSourceConfig::save(QXmlStreamWriter& s) {
_offsetRelative >> s;
_dateTimeOffset >> s;
_relativeOffset >> s;

_nanValue >> s;
s.writeEndElement();
}

Expand Down Expand Up @@ -246,6 +251,7 @@ void AsciiSourceConfig::parseProperties(QXmlStreamAttributes& attributes) {
_offsetRelative << attributes;
_dateTimeOffset << attributes;
_relativeOffset << attributes;
_nanValue << attributes;
}


Expand Down Expand Up @@ -279,6 +285,7 @@ void AsciiSourceConfig::load(const QDomElement& e) {
_offsetRelative << elem;
_dateTimeOffset << elem;
_relativeOffset << elem;
_nanValue << elem;
}
}
n = n.nextSibling();
Expand Down Expand Up @@ -311,7 +318,8 @@ bool AsciiSourceConfig::operator==(const AsciiSourceConfig& rhs) const
_offsetFileDate == rhs._offsetFileDate &&
_offsetRelative == rhs._offsetRelative &&
_dateTimeOffset == rhs._dateTimeOffset &&
_relativeOffset == rhs._relativeOffset;
_relativeOffset == rhs._relativeOffset &&
_nanValue == rhs._nanValue;

}

Expand Down Expand Up @@ -342,7 +350,8 @@ bool AsciiSourceConfig::isUpdateNecessary(const AsciiSourceConfig& rhs) const
_offsetFileDate != rhs._offsetFileDate ||
_offsetRelative != rhs._offsetRelative ||
_dateTimeOffset != rhs._dateTimeOffset ||
_relativeOffset != rhs._relativeOffset;
_relativeOffset != rhs._relativeOffset ||
_nanValue != rhs._nanValue;
}


Expand Down
3 changes: 3 additions & 0 deletions src/datasources/ascii/asciisourceconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class AsciiSourceConfig {
static const char Tag_dateTimeOffset[];
static const char Key_relativeOffset[];
static const char Tag_relativeOffset[];
static const char Key_nanValue[];
static const char Tag_nanValue[];

public:
AsciiSourceConfig();
Expand Down Expand Up @@ -113,6 +115,7 @@ class AsciiSourceConfig {
NamedParameter<bool, Key_offsetRelative, Tag_offsetRelative> _offsetRelative;
NamedParameter<QDateTime, Key_dateTimeOffset, Tag_dateTimeOffset> _dateTimeOffset;
NamedParameter<double, Key_relativeOffset, Tag_relativeOffset> _relativeOffset;
NamedParameter<int, Key_nanValue, Tag_nanValue> _nanValue;

private:
void save(QSettings& cfg) const;
Expand Down
Loading