[Kst] branches/work/kst/portto4/kst/src/libkstapp
Mike Fenton
mike at staikos.net
Mon Apr 20 19:21:11 CEST 2009
SVN commit 956812 by fenton:
Add saving of reference point and offset status.
M +28 -1 plotrenderitem.cpp
M +1 -0 plotrenderitem.h
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.cpp #956811:956812
@@ -89,6 +89,12 @@
}
+void PlotRenderItem::setReferencePoint(const QPointF& point) {
+ _referencePointMode = true;
+ _referencePoint = point;
+}
+
+
PlotRenderItem::RenderType PlotRenderItem::type() {
return _type;
}
@@ -160,6 +166,12 @@
void PlotRenderItem::saveInPlot(QXmlStreamWriter &xml) {
xml.writeAttribute("name", typeName());
xml.writeAttribute("type", QVariant(_type).toString());
+ if (_referencePointMode) {
+ xml.writeStartElement("referencepoint");
+ }
+ xml.writeAttribute("x", QVariant(_referencePoint.x()).toString());
+ xml.writeAttribute("y", QVariant(_referencePoint.y()).toString());
+ xml.writeEndElement();
foreach (RelationPtr relation, relationList()) {
xml.writeStartElement("relation");
xml.writeAttribute("tag", relation->Name());
@@ -178,7 +190,6 @@
if (!av.isNull()) {
setType((RenderType)av.toString().toInt());
}
-
QString expectedEnd;
while (!(xml.isEndElement() && (xml.name().toString() == primaryTag))) {
if (xml.isStartElement() && xml.name().toString() == "relation") {
@@ -189,6 +200,19 @@
if (relation) {
addRelation(relation);
}
+ } else if (xml.isStartElement() && xml.name().toString() == "referencepoint") {
+ expectedEnd = xml.name().toString();
+ double x = 0, y = 0;
+ attrs = xml.attributes();
+ av = attrs.value("x");
+ if (!av.isNull()) {
+ x = av.toString().toDouble();
+ }
+ av = attrs.value("y");
+ if (!av.isNull()) {
+ y = av.toString().toDouble();
+ }
+ setReferencePoint(QPointF(x, y));
} else if (xml.isEndElement()) {
if (xml.name().toString() != expectedEnd) {
validTag = false;
@@ -493,6 +517,9 @@
} else {
_highlightPointActive = false;
QString message = QString("(%1, %2)").arg(QString::number(point.x(), 'G')).arg(QString::number(point.y()));
+ if (_referencePointMode) {
+ message += QString(" [Offset: %1, %2]").arg(QString::number(point.x() - _referencePoint.x(), 'G')).arg(QString::number(point.y() - _referencePoint.y()));
+ }
kstApp->mainWindow()->statusBar()->showMessage(message);
}
}
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitem.h #956811:956812
@@ -114,6 +114,7 @@
void computeNoSpike(Qt::Orientation orientation, qreal *min, qreal *max) const;
void highlightNearestDataPoint(const QPointF& position);
+ void setReferencePoint(const QPointF& point);
private:
RenderType _type;
More information about the Kst
mailing list