[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Fri Oct 7 23:23:28 CEST 2005


SVN commit 468373 by staikos:

load X, Y, Top labels from kst files


 M  +17 -3     kst2dplot.cpp  
 M  +42 -0     kstplotlabel.cpp  
 M  +2 -0      kstplotlabel.h  


--- trunk/extragear/graphics/kst/kst/kst2dplot.cpp #468372:468373
@@ -206,6 +206,8 @@
   _xScaleModeDefault = AUTO;
   _yScaleModeDefault = AUTOBORDER;
 
+  QDomElement xLabelNode, yLabelNode, topLabelNode;
+
   QDomNode n = e.firstChild();
   while (!n.isNull()) {
     QDomElement el = n.toElement(); // try to convert the node to an element.
@@ -235,11 +237,11 @@
       } else if (el.tagName() == "ymax") {
         ymax_in = el.text().toDouble();
       } else if (el.tagName() == "toplabel") {
-        // FIXME
+        topLabelNode = el;
       } else if (el.tagName() == "xlabel") {
-        // FIXME
+        xLabelNode = el;
       } else if (el.tagName() == "ylabel") {
-        // FIXME
+        yLabelNode = el;
       } else if (el.tagName() == "ticklabel") {
         // FIXME
       } else if (el.tagName() == "xticklabel") {
@@ -382,6 +384,18 @@
   commonConstructor(tagName(), yscale_in, xscale_in, xmin_in, ymin_in,
                     xmax_in, ymax_in, x_log, y_log);
 
+  if (!topLabelNode.isNull()) {
+    _topLabel->load(topLabelNode);
+  }
+
+  if (!yLabelNode.isNull()) {
+    _yLabel->load(yLabelNode);
+  }
+
+  if (!xLabelNode.isNull()) {
+    _xLabel->load(xLabelNode);
+  }
+
   KstBaseCurveList l = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
   for (unsigned i = 0; i < ctaglist.count(); i++) {
     KstBaseCurveList::Iterator it = l.findTag(ctaglist[i]);
--- trunk/extragear/graphics/kst/kst/kstplotlabel.cpp #468372:468373
@@ -23,6 +23,8 @@
 #include "kstsettings.h"
 #include "labelrenderer.h"
 
+#include <qdom.h>
+
 #include <kdebug.h>
 #include <kglobal.h>
 #include <klocale.h>
@@ -189,4 +191,44 @@
   _lineSpacing = QFontMetrics(QFont(_fontName, _absFontSize)).lineSpacing();
 }
 
+
+void KstPlotLabel::load(const QDomElement& e) {
+  bool upLS = false;
+  QDomNode n = e.firstChild();
+  while (!n.isNull()) {
+    QDomElement e = n.toElement(); // try to convert the node to an element.
+    if (!e.isNull()) { // the node was really an element.
+      if (e.tagName() == "text") {
+        setText(e.text());
+      } else if  (e.tagName() == "justify") {
+        // FIXME: do a proper type conversion
+        // _justify = KstLJustifyType(e.text().toInt());
+      } else if  (e.tagName() == "rotation") {
+        _rotation = e.text().toFloat();
+      } else if  (e.tagName() == "interpret") {
+        _interpret = true;
+      } else if (e.tagName() == "fontfamily") {
+        _fontName = e.text();
+        upLS = true;
+      } else if (e.tagName() == "symbolfontfamily") {
+        _symbolFontName = e.text();
+      } else if (e.tagName() == "fontsize") {
+        _fontSize = e.text().toInt() - KstSettings::globalSettings()->plotFontSize;
+        _absFontSize = e.text().toInt();
+        upLS = true;
+      } else if (e.tagName() == "useusercolor") {
+        // Unsupported
+      } else if (e.tagName() == "color") {
+        // Unsupported
+      }
+    }
+    n = n.nextSibling();
+  }
+
+  if (upLS) {
+    updateLineSpacing();
+  }
+}
+
+
 // vim: ts=2 sw=2 et
--- trunk/extragear/graphics/kst/kst/kstplotlabel.h #468372:468373
@@ -55,6 +55,8 @@
 
     QSize size() const;
 
+    void load(const QDomElement& e);
+
   private:
     void commonConstructor(const QString& txt, const QString& font, int fontSize, KstLJustifyType justify, float rotation);
     void drawToPainter(Label::Parsed *lp, QPainter& p);


More information about the Kst mailing list