[Kst] branches/work/kst/portto4/kst/src
Barth Netterfield
netterfield at astro.utoronto.ca
Tue Jul 9 21:23:52 UTC 2013
SVN commit 1359432 by netterfield:
Improve copy X/Y coordinates
Time fields set isTime() true
M +15 -7 libkst/datasource.cpp
M +2 -0 libkst/datasource.h
M +3 -9 libkstapp/plotitem.cpp
M +4 -0 libkstapp/plotrenderitem.cpp
M +1 -0 libkstapp/plotrenderitem.h
--- branches/work/kst/portto4/kst/src/libkst/datasource.cpp #1359431:1359432
@@ -357,10 +357,10 @@
bool DataSource::isTime(const QString& field) const {
- Q_UNUSED(field)
- return false;
+ return (_timeFields.contains(field));
}
+
double DataSource::relativeTimeForSample(int sample, bool *ok) {
Q_UNUSED(sample)
if (ok) {
@@ -485,8 +485,9 @@
return(x);
}
-QStringList &DataSource::indexFields() {
- if (_frameFields.size() == 0) {
+
+QStringList &DataSource::timeFields() {
+ if (_timeFields.size() == 0) {
// FIXME: this must be created by the UI somehow.
// or by the datasource itself. Or something
// different than this!
@@ -498,16 +499,23 @@
requestedFields.append("TEMPS");
requestedFields.append("temps");
- _frameFields.append(i18n("frames"));
-
// Make sure the requested fields actually exist.
foreach (const QString &field, requestedFields) {
if (vector().list().contains(field)) {
- _frameFields.append(field);
+ _timeFields.append(field);
}
}
}
+ return(_timeFields);
+}
+
+QStringList &DataSource::indexFields() {
+ if (_frameFields.size() == 0) {
+ _frameFields.append(i18n("frames"));
+ _frameFields.append(timeFields());
+ }
+
return(_frameFields);
}
--- branches/work/kst/portto4/kst/src/libkst/datasource.h #1359431:1359432
@@ -155,6 +155,7 @@
virtual double frameToIndex(int frame, const QString &field);
virtual double readDespikedIndex(int frame, const QString &field);
virtual double framePerIndex(const QString &field);
+ virtual QStringList &timeFields();
virtual QStringList &indexFields();
@@ -259,6 +260,7 @@
void setInterface(DataInterface<DataMatrix>*);
QStringList _frameFields;
+ QStringList _timeFields;
private:
DataSource();
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #1359431:1359432
@@ -3335,22 +3335,16 @@
}
void PlotItem::copyStatus() {
- kstApp->clipboard()->setText(kstApp->mainWindow()->statusMessage().remove('(').remove(')'));
+ kstApp->clipboard()->setText(kstApp->mainWindow()->statusMessage());
}
void PlotItem::copyXCoord() {
- QStringList args = kstApp->mainWindow()->statusMessage().remove('(').split(',');
- if (args.size()>0) {
- kstApp->clipboard()->setText(args.at(0));
+ kstApp->clipboard()->setText(QString::number(renderItem()->statusMessagePoint.x(), 'g', 12));
}
-}
void PlotItem::copyYCoord() {
- QStringList args = kstApp->mainWindow()->statusMessage().remove(')').replace('[',',').split(',');
- if (args.size()>1) {
- kstApp->clipboard()->setText(args.at(1));
+ kstApp->clipboard()->setText(QString::number(renderItem()->statusMessagePoint.y(), 'g', 12));
}
-}
QString PlotItem::descriptionTip() const {
QString contents;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #1359431:1359432
@@ -801,6 +801,7 @@
}
const QPointF point = plotItem()->mapToProjection(p);
+ statusMessagePoint = point;
if (kstApp->mainWindow()->isHighlightPoint()) {
highlightNearestDataPoint(point);
} else {
@@ -842,6 +843,7 @@
distance = fabs(position.y() - y);
if (bFirst || distance < minDistance) {
matchedPoint = QPointF(x, y);
+ statusMessagePoint = matchedPoint;
bFirst = false;
minDistance = distance;
curveName = curve->CleanedName();
@@ -869,6 +871,7 @@
_highlightPointActive = true;
_highlightPoint = QPointF(matchedPoint.x(), matchedPoint.y());
} else if (!imageName.isEmpty()) {
+ statusMessagePoint = position;
QString message = imageName + QString(" (%1, %2, %3)").
arg(plotItem()->xAxis()->statusBarString(position.x())).
arg(QString::number(position.y())).
@@ -904,6 +907,7 @@
updateCursor(event->pos());
const QPointF p = plotItem()->mapToProjection(event->pos());
+ statusMessagePoint = p;
QString message = QString("(%1, %2)").
arg(plotItem()->xAxis()->statusBarString(p.x())).
arg(QString::number(p.y()));
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #1359431:1359432
@@ -78,6 +78,7 @@
void dragYZoomMouseCursor(double y);
void dragXZoomMouseCursor(double x);
+ QPointF statusMessagePoint;
public Q_SLOTS:
virtual void edit();
virtual void raise();
More information about the Kst
mailing list