[Kst] branches/work/kst/portto4/kst/src
Peter Kümmel
syntheticpp at gmx.net
Mon Oct 22 10:11:01 UTC 2012
SVN commit 1321910 by kuemmel:
add format string defined date/time plotting
M +15 -2 libkstapp/axistab.cpp
M +4 -0 libkstapp/axistab.h
M +63 -27 libkstapp/axistab.ui
M +21 -0 libkstapp/plotaxis.cpp
M +4 -0 libkstapp/plotaxis.h
M +5 -0 libkstapp/plotitemdialog.cpp
M +2 -0 libkstmath/plotdefines.h
--- branches/work/kst/portto4/kst/src/libkstapp/axistab.cpp #1321909:1321910
@@ -77,6 +77,7 @@
connect(_scaleLog, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
connect(_scaleReverse, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
connect(_scaleDisplayType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+ connect(_scaleDisplayFormatString, SIGNAL(textChanged(QString)), this, SIGNAL(modified()));
connect(_scaleInterpretType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
connect(_timeZone, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
@@ -418,17 +419,27 @@
return AxisDisplayType(_scaleDisplayType->itemData(_scaleDisplayType->currentIndex()).toInt());
}
-
bool AxisTab::axisDisplayDirty() const {
return _scaleDisplayType->currentIndex() != -1;
}
-
void AxisTab::setAxisDisplay(AxisDisplayType display) {
_scaleDisplayType->setCurrentIndex(_scaleDisplayType->findData(QVariant(display)));
}
+QString AxisTab::axisDisplayFormatString() const {
+ return _scaleDisplayFormatString->text();
+}
+bool AxisTab::axisDisplayFormatStringDirty() const {
+ return !_scaleDisplayFormatString->text().isEmpty();
+}
+
+void AxisTab::setAxisDisplayFormatString(const QString& formatString) {
+ _scaleDisplayFormatString->setText(formatString);
+}
+
+
QString AxisTab::timezone() const {
return _timeZone->currentText();
}
@@ -530,6 +541,7 @@
_rotation->clear();
_scaleInterpretType->setCurrentIndex(-1);
_scaleDisplayType->setCurrentIndex(-1);
+ _scaleDisplayFormatString->setText("hh:mm:ss.zzz");
_timeZone->setCurrentIndex(-1);
_drawAxisMajorTicks->setCheckState(Qt::PartiallyChecked);
@@ -556,3 +568,4 @@
}
// vim: ts=2 sw=2 et
+
--- branches/work/kst/portto4/kst/src/libkstapp/axistab.h #1321909:1321910
@@ -108,6 +108,10 @@
bool axisDisplayDirty() const;
void setAxisDisplay(AxisDisplayType display);
+ QString axisDisplayFormatString() const;
+ bool axisDisplayFormatStringDirty() const;
+ void setAxisDisplayFormatString(const QString& formatString);
+
QString timezone() const;
bool timezoneDirty() const;
void setTimezone(QString timezone);
--- branches/work/kst/portto4/kst/src/libkstapp/axistab.ui #1321909:1321910
@@ -15,13 +15,13 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
- <layout class="QGridLayout" name="gridLayout_4">
+ <layout class="QGridLayout" name="gridLayout_5">
<item row="0" column="0">
<widget class="QGroupBox" name="_scaleGroup">
<property name="title">
<string>Scale</string>
</property>
- <layout class="QGridLayout" name="gridLayout_5">
+ <layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="0">
<widget class="QCheckBox" name="_scaleLog">
<property name="toolTip">
@@ -61,7 +61,7 @@
</property>
</widget>
</item>
- <item row="1" column="1" colspan="3">
+ <item row="1" column="1">
<widget class="QComboBox" name="_scaleInterpretType">
<property name="enabled">
<bool>false</bool>
@@ -138,6 +138,42 @@
</property>
</widget>
</item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="_timeFormaLabel">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>QDateTime format string:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="buddy">
+ <cstring>_scaleDisplayType</cstring>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1" colspan="2">
+ <widget class="QLineEdit" name="_scaleDisplayFormatString">
+ <property name="text">
+ <string>hh:mm.ss.zzz</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QLabel" name="label_8">
+ <property name="text">
+ <string>Date: y,M,d Time: h,m,s,z</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>
@@ -189,17 +225,20 @@
<string>Base / Offset Mode</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
- <item row="0" column="0">
- <widget class="QCheckBox" name="_scaleAutoBaseOffset">
- <property name="text">
- <string>Auto base / offset mode</string>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="_significantDigits">
+ <property name="whatsThis">
+ <string>If this many digits are required to display the tick numbers, then the axis will revert to Base/Offset mode.</string>
</property>
- <property name="checked">
- <bool>true</bool>
+ <property name="minimum">
+ <number>2</number>
</property>
- <property name="tristate">
- <bool>false</bool>
+ <property name="maximum">
+ <number>15</number>
</property>
+ <property name="value">
+ <number>9</number>
+ </property>
</widget>
</item>
<item row="5" column="0">
@@ -215,6 +254,19 @@
</property>
</widget>
</item>
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="_scaleAutoBaseOffset">
+ <property name="text">
+ <string>Auto base / offset mode</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -228,22 +280,6 @@
</property>
</widget>
</item>
- <item row="1" column="1">
- <widget class="QSpinBox" name="_significantDigits">
- <property name="whatsThis">
- <string>If this many digits are required to display the tick numbers, then the axis will revert to Base/Offset mode.</string>
- </property>
- <property name="minimum">
- <number>2</number>
- </property>
- <property name="maximum">
- <number>15</number>
- </property>
- <property name="value">
- <number>9</number>
- </property>
- </widget>
- </item>
</layout>
</widget>
</item>
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.cpp #1321909:1321910
@@ -42,6 +42,7 @@
_axisBaseOffsetOverride(false),
_axisInterpret(false),
_axisDisplay(AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS),
+ _axisDisplayFormatString("hh:mm:ss.zzz"),
_axisInterpretation(AXIS_INTERP_CTIME),
_axisMajorTickMode(TicksNormal),
_axisOverrideMajorTicks(TicksNormal),
@@ -182,6 +183,8 @@
int hour = int(dDayFraction*24.0);
int minute = int((dDayFraction*24.0 - double(hour))*60.0);
double second = ((dDayFraction*24.0 - double(hour))*60.0 - double(minute))*60.0;
+ double fullseconds;
+ double millisec = modf(second + 0.5, &fullseconds) * 1000;
if (accuracy >= 0) {
second *= pow(10.0, accuracy);
@@ -258,6 +261,10 @@
label = date.toString(Qt::LocalDate).toLatin1();
label += hourminute + seconds;
break;
+ case AXIS_DISPLAY_QTDATETIME_FORMAT:
+ label += QDateTime(QDate(year, month, day), QTime(hour, minute, second, millisec))
+ .toString(_axisDisplayFormatString);
+ break;
default:
label = QString::number(convertJDtoDisplayTime(jd), 'G', FULL_PRECISION-2);
break;
@@ -554,7 +561,11 @@
return _axisDisplay;
}
+QString PlotAxis::axisDisplayFormatString() const {
+ return _axisDisplayFormatString;
+}
+
void PlotAxis::setAxisDisplay(const AxisDisplayType display) {
if (_axisDisplay != display) {
_axisDisplay = display;
@@ -562,6 +573,12 @@
}
}
+void PlotAxis::setAxisDisplayFormatString(const QString& formatString) {
+ if (_axisDisplayFormatString != formatString) {
+ _axisDisplayFormatString = formatString;
+ _dirty = true;
+ }
+}
AxisInterpretationType PlotAxis::axisInterpretation() const {
return _axisInterpretation;
@@ -763,6 +780,7 @@
case AXIS_DISPLAY_DDMMYYHHMMSS_SS:
case AXIS_DISPLAY_QTTEXTDATEHHMMSS_SS:
case AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS:
+ case AXIS_DISPLAY_QTDATETIME_FORMAT:
return false;
default:
return true;
@@ -1103,6 +1121,7 @@
setAxisInterpret(source->axisInterpret());
setAxisInterpretation(source->axisInterpretation());
setAxisDisplay(source->axisDisplay());
+ setAxisDisplayFormatString(source->axisDisplayFormatString());
setAxisMajorTickMode(source->axisMajorTickMode());
setAxisMinorTickCount(source->axisMinorTickCount());
setAxisAutoMinorTicks(source->axisAutoMinorTicks());
@@ -1131,6 +1150,7 @@
_dialogDefaults->setValue(group+"Interpret", QVariant(axisInterpret()).toString());
_dialogDefaults->setValue(group+"Interpretation", QVariant(axisInterpretation()).toString());
_dialogDefaults->setValue(group+"Display", QVariant(axisDisplay()).toString());
+ _dialogDefaults->setValue(group+"DisplayFormatString", QVariant(axisDisplayFormatString()).toString());
_dialogDefaults->setValue(group+"Timezone", QVariant(timezoneName()));
_dialogDefaults->setValue(group+"MajorTickMode", QVariant(axisMajorTickMode()).toString());
_dialogDefaults->setValue(group+"MinorTickCount", QVariant(axisMinorTickCount()).toString());
@@ -1161,6 +1181,7 @@
xml.writeAttribute("interpret", QVariant(axisInterpret()).toString());
xml.writeAttribute("interpretation", QVariant(axisInterpretation()).toString());
xml.writeAttribute("display", QVariant(axisDisplay()).toString());
+ xml.writeAttribute("displayformatstring", QVariant(axisDisplayFormatString()).toString());
xml.writeAttribute("majortickmode", QVariant(axisMajorTickMode()).toString());
xml.writeAttribute("minortickcount", QVariant(axisMinorTickCount()).toString());
xml.writeAttribute("autominortickcount", QVariant(axisAutoMinorTicks()).toString());
--- branches/work/kst/portto4/kst/src/libkstapp/plotaxis.h #1321909:1321910
@@ -103,6 +103,9 @@
AxisDisplayType axisDisplay() const;
void setAxisDisplay(const AxisDisplayType display);
+ QString axisDisplayFormatString() const;
+ void setAxisDisplayFormatString(const QString& formatString);
+
AxisInterpretationType axisInterpretation() const;
void setAxisInterpretation(const AxisInterpretationType interpret);
@@ -175,6 +178,7 @@
bool _axisInterpret;
AxisDisplayType _axisDisplay;
+ QString _axisDisplayFormatString;
AxisInterpretationType _axisInterpretation;
KstTimeZone _timeZone;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitemdialog.cpp #1321909:1321910
@@ -292,6 +292,7 @@
_xAxisTab->setBaseOffset(_plotItem->xAxis()->axisBaseOffset());
_xAxisTab->setInterpret(_plotItem->xAxis()->axisInterpret());
_xAxisTab->setAxisDisplay(_plotItem->xAxis()->axisDisplay());
+ _xAxisTab->setAxisDisplayFormatString(_plotItem->xAxis()->axisDisplayFormatString());
_xAxisTab->setAxisInterpretation(_plotItem->xAxis()->axisInterpretation());
_xAxisTab->setTimezone(_plotItem->xAxis()->timezoneName());
_xAxisTab->setHideTopRight(_plotItem->manuallyHideTopAxisLabel());
@@ -319,6 +320,7 @@
_yAxisTab->setBaseOffset(_plotItem->yAxis()->axisBaseOffset());
_yAxisTab->setInterpret(_plotItem->yAxis()->axisInterpret());
_yAxisTab->setAxisDisplay(_plotItem->yAxis()->axisDisplay());
+ _yAxisTab->setAxisDisplayFormatString(_plotItem->yAxis()->axisDisplayFormatString());
_yAxisTab->setAxisInterpretation(_plotItem->yAxis()->axisInterpretation());
_yAxisTab->setTimezone(_plotItem->yAxis()->timezoneName());
_yAxisTab->setHideTopRight(_plotItem->manuallyHideRightAxisLabel());
@@ -756,6 +758,9 @@
if (axisTab->axisDisplayDirty()) {
axis->setAxisDisplay(axisTab->axisDisplay());
}
+ if (axisTab->axisDisplayFormatStringDirty()) {
+ axis->setAxisDisplayFormatString(axisTab->axisDisplayFormatString());
+ }
if (axisTab->axisInterpretationDirty()) {
axis->setAxisInterpretation(axisTab->axisInterpretation());
}
--- branches/work/kst/portto4/kst/src/libkstmath/plotdefines.h #1321909:1321910
@@ -34,6 +34,7 @@
AXIS_DISPLAY_DDMMYYHHMMSS_SS,
AXIS_DISPLAY_QTTEXTDATEHHMMSS_SS,
AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS,
+ AXIS_DISPLAY_QTDATETIME_FORMAT,
AXIS_DISPLAY_JD,
AXIS_DISPLAY_MJD,
AXIS_DISPLAY_RJD };
@@ -64,6 +65,7 @@
{ I18N_NOOP("DD/MM/YYYY HH:MM:SS.SS"), AXIS_DISPLAY_DDMMYYHHMMSS_SS },
{ I18N_NOOP("<Qt Text Date> HH:MM:SS.SS"), AXIS_DISPLAY_QTTEXTDATEHHMMSS_SS },
{ I18N_NOOP("<Qt Local Date> HH:MM:SS.SS"), AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS },
+ { I18N_NOOP("QDateTime format string"), AXIS_DISPLAY_QTDATETIME_FORMAT },
{ I18N_NOOP2("Julian Date", "JD"), AXIS_DISPLAY_JD },
{ I18N_NOOP2("Modified Julian Date", "MJD"), AXIS_DISPLAY_MJD },
{ I18N_NOOP2("Reduced Julian Date", "RJD"), AXIS_DISPLAY_RJD }
More information about the Kst
mailing list