[Kst] branches/work/kst/portto4/kst/src/libkstapp

Mike Fenton mike at staikos.net
Thu Feb 7 21:59:28 CET 2008


SVN commit 772124 by fenton:

Add Reverse drawing of Plot Axis Labels.
Add interface for drawing base offset / interpretted Axis.


 M  +69 -2     axistab.cpp  
 M  +19 -0     axistab.h  
 M  +127 -4    plotitem.cpp  
 M  +42 -0     plotitem.h  
 M  +26 -0     plotrenderitemdialog.cpp  


--- branches/work/kst/portto4/kst/src/libkstapp/axistab.cpp #772123:772124
@@ -45,11 +45,11 @@
   setAxisMajorGridLineColor(Qt::gray);
   setAxisMinorGridLineColor(Qt::gray);
 
-  for (int i = 0; i < numAxisDisplays; i++) {
+  for (uint i = 0; i < numAxisDisplays; i++) {
     _scaleDisplayType->addItem(AxisDisplays[i].label, QVariant(AxisDisplays[i].type));
   }
 
-  for (int i = 0; i < numAxisInterpretations; i++) {
+  for (uint i = 0; i < numAxisInterpretations; i++) {
     _scaleInterpretType->addItem(AxisInterpretations[i].label, QVariant(AxisInterpretations[i].type));
   }
 
@@ -68,6 +68,13 @@
   connect(_axisMajorLineColor, SIGNAL(changed(const QColor &)), this, SIGNAL(modified()));
   connect(_axisMinorLineColor, SIGNAL(changed(const QColor &)), this, SIGNAL(modified()));
 
+  connect(_scaleInterpret, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
+  connect(_scaleLog, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
+  connect(_scaleBaseOffset, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
+  connect(_scaleReverse, SIGNAL(stateChanged(int)), this, SIGNAL(modified()));
+  connect(_scaleDisplayType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+  connect(_scaleInterpretType, SIGNAL(currentIndexChanged(int)), this, SIGNAL(modified()));
+
   connect(_axisMinorTickCount, SIGNAL(valueChanged(int)), this, SIGNAL(modified()));
 
 }
@@ -193,6 +200,66 @@
   _axisMinorTickCount->setValue(count);
 }
 
+
+bool AxisTab::isLog() const {
+  return _scaleLog->isChecked();
 }
 
+
+void AxisTab::setLog(const bool enabled) {
+  _scaleLog->setChecked(enabled);
+}
+
+
+bool AxisTab::isBaseOffset() const {
+  return _scaleBaseOffset->isChecked();
+}
+
+
+void AxisTab::setBaseOffset(const bool enabled) {
+  _scaleBaseOffset->setChecked(enabled);
+}
+
+
+bool AxisTab::isReversed() const {
+  return _scaleReverse->isChecked();
+}
+
+
+void AxisTab::setReversed(const bool enabled) {
+  _scaleReverse->setChecked(enabled);
+}
+
+
+bool AxisTab::isInterpret() const {
+  return _scaleInterpret->isChecked();
+}
+
+
+void AxisTab::setInterpret(const bool enabled) {
+  _scaleInterpret->setChecked(enabled);
+}
+
+
+KstAxisDisplay AxisTab::axisDisplay() const {
+  return KstAxisDisplay(_scaleDisplayType->itemData(_scaleDisplayType->currentIndex()).toInt());
+}
+
+
+void AxisTab::setAxisDisplay(KstAxisDisplay display) {
+  _scaleDisplayType->setCurrentIndex(_scaleDisplayType->findData(QVariant(display)));
+}
+
+
+KstAxisInterpretation AxisTab::axisInterpretation() const {
+  return KstAxisInterpretation(_scaleInterpretType->itemData(_scaleInterpretType->currentIndex()).toInt());
+}
+
+
+void AxisTab::setAxisInterpretation(KstAxisInterpretation interpret) {
+  _scaleInterpretType->setCurrentIndex(_scaleInterpretType->findData(QVariant(interpret)));
+}
+
+}
+
 // vim: ts=2 sw=2 et
--- branches/work/kst/portto4/kst/src/libkstapp/axistab.h #772123:772124
@@ -14,6 +14,7 @@
 
 #include "dialogtab.h"
 #include "plotitem.h"
+#include "plotdefines.h"
 #include "ui_axistab.h"
 
 #include "kst_export.h"
@@ -56,6 +57,24 @@
     int axisMinorTickCount() const;
     void setAxisMinorTickCount(const int count);
 
+    bool isLog() const;
+    void setLog(const bool enabled);
+
+    bool isBaseOffset() const;
+    void setBaseOffset(const bool enabled);
+
+    bool isReversed() const;
+    void setReversed(const bool enabled);
+
+    bool isInterpret() const;
+    void setInterpret(const bool enabled);
+
+    KstAxisDisplay axisDisplay() const;
+    void setAxisDisplay(KstAxisDisplay display);
+
+    KstAxisInterpretation axisInterpretation() const;
+    void setAxisInterpretation(KstAxisInterpretation interpretation);
+
   public Q_SLOTS:
     void update();
 };
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.cpp #772123:772124
@@ -45,6 +45,16 @@
   _calculatedLabelMarginHeight(0.0),
   _calculatedAxisMarginWidth(0.0),
   _calculatedAxisMarginHeight(0.0),
+  _xAxisReversed(false),
+  _yAxisReversed(false),
+  _xAxisBaseOffset(false),
+  _yAxisBaseOffset(false),
+  _xAxisInterpret(false),
+  _yAxisInterpret(false),
+  _xAxisDisplay(AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS),
+  _yAxisDisplay(AXIS_DISPLAY_QTLOCALDATEHHMMSS_SS),
+  _xAxisInterpretation(AXIS_INTERP_CTIME),
+  _yAxisInterpretation(AXIS_INTERP_CTIME),
   _xAxisMajorTickMode(Normal),
   _yAxisMajorTickMode(Normal),
   _xAxisMinorTickCount(4),
@@ -342,9 +352,15 @@
                                     const QList<qreal> &yMajorTicks) {
 
   QRectF yLabelRect;
-  foreach (qreal y, yMajorTicks) {
+  for (int i = 0; i < yMajorTicks.count(); i++) {
+    qreal y = yMajorTicks[i];
     int flags = Qt::TextSingleLine | Qt::AlignVCenter;
-    QString label = QString::number(y);
+    QString label;
+    if (_yAxisReversed) {
+      label = QString::number(yMajorTicks[(yMajorTicks.count() - 1) - i]);
+    } else {
+      label = QString::number(y);
+    }
 
     QRectF bound = painter->boundingRect(QRectF(), flags, label);
     QPointF p = mapToPlotFromProjection(QPointF(projectionRect().left(), y));
@@ -361,9 +377,15 @@
   }
 
   QRectF xLabelRect;
-  foreach (qreal x, xMajorTicks) {
+  for (int i = 0; i < xMajorTicks.count(); i++) {
+    qreal x = xMajorTicks[i];
     int flags = Qt::TextSingleLine | Qt::AlignVCenter;
-    QString label = QString::number(x);
+    QString label;
+    if (_xAxisReversed) {
+      label = QString::number(xMajorTicks[(xMajorTicks.count() - 1) - i]);
+    } else {
+      label = QString::number(x);
+    }
 
     QRectF bound = painter->boundingRect(QRectF(), flags, label);
     QPointF p = mapToPlotFromProjection(QPointF(x, projectionRect().top()));
@@ -977,6 +999,106 @@
 }
 
 
+bool PlotItem::xAxisReversed() const {
+  return _xAxisReversed;
+}
+
+
+void PlotItem::setXAxisReversed(const bool enabled) {
+  _xAxisReversed = enabled;
+}
+
+
+bool PlotItem::yAxisReversed() const {
+  return _yAxisReversed;
+}
+
+
+void PlotItem::setYAxisReversed(const bool enabled) {
+  _yAxisReversed = enabled;
+}
+
+
+bool PlotItem::xAxisBaseOffset() const {
+  return _xAxisBaseOffset;
+}
+
+
+void PlotItem::setXAxisBaseOffset(const bool enabled) {
+  _xAxisBaseOffset = enabled;
+}
+
+
+bool PlotItem::yAxisBaseOffset() const {
+  return _yAxisBaseOffset;
+}
+
+
+void PlotItem::setYAxisBaseOffset(const bool enabled) {
+  _yAxisBaseOffset = enabled;
+}
+
+
+bool PlotItem::xAxisInterpret() const {
+  return _xAxisInterpret;
+}
+
+
+void PlotItem::setXAxisInterpret(const bool enabled) {
+  _xAxisInterpret = enabled;
+}
+
+
+bool PlotItem::yAxisInterpret() const {
+  return _yAxisInterpret;
+}
+
+
+void PlotItem::setYAxisInterpret(const bool enabled) {
+  _yAxisInterpret = enabled;
+}
+
+
+KstAxisDisplay PlotItem::xAxisDisplay() const {
+  return _xAxisDisplay;
+}
+
+
+void PlotItem::setXAxisDisplay(const KstAxisDisplay display) {
+  _xAxisDisplay = display;
+}
+
+
+KstAxisDisplay PlotItem::yAxisDisplay() const {
+  return _yAxisDisplay;
+}
+
+
+void PlotItem::setYAxisDisplay(const KstAxisDisplay display) {
+  _yAxisDisplay = display;
+}
+
+
+KstAxisInterpretation PlotItem::xAxisInterpretation() const {
+  return _xAxisInterpretation;
+}
+
+
+void PlotItem::setXAxisInterpretation(const KstAxisInterpretation display) {
+  _xAxisInterpretation = display;
+}
+
+
+KstAxisInterpretation PlotItem::yAxisInterpretation() const {
+  return _yAxisInterpretation;
+}
+
+
+void PlotItem::setYAxisInterpretation(const KstAxisInterpretation display) {
+  _yAxisInterpretation = display;
+}
+
+
 qreal PlotItem::calculatedLabelMarginWidth() const {
   qreal m = qMax(MARGIN_WIDTH, _calculatedLabelMarginWidth);
 
@@ -1209,6 +1331,7 @@
   qreal yMajorTickSpacing = computedMajorTickSpacing(Qt::Vertical);
 
   QList<qreal> xTicks;
+
   qreal firstXTick = ceil(projectionRect().left() / xMajorTickSpacing) * xMajorTickSpacing;
 
   int ix = 0;
--- branches/work/kst/portto4/kst/src/libkstapp/plotitem.h #772123:772124
@@ -20,6 +20,7 @@
 #include "relation.h"
 #include "plotrenderitem.h"
 #include "plotiteminterface.h"
+#include "plotdefines.h"
 
 namespace Kst {
 
@@ -173,6 +174,36 @@
     QFont bottomLabelFont() const;
     void setBottomLabelFont(const QFont &font);
 
+    bool xAxisReversed() const;
+    void setXAxisReversed(const bool enabled);
+
+    bool yAxisReversed() const;
+    void setYAxisReversed(const bool enabled);
+
+    bool xAxisBaseOffset() const;
+    void setXAxisBaseOffset(const bool enabled);
+
+    bool yAxisBaseOffset() const;
+    void setYAxisBaseOffset(const bool enabled);
+
+    bool xAxisInterpret() const;
+    void setXAxisInterpret(const bool enabled);
+
+    bool yAxisInterpret() const;
+    void setYAxisInterpret(const bool enabled);
+
+    KstAxisDisplay xAxisDisplay() const;
+    void setXAxisDisplay(const KstAxisDisplay display);
+
+    KstAxisDisplay yAxisDisplay() const;
+    void setYAxisDisplay(const KstAxisDisplay display);
+
+    KstAxisInterpretation xAxisInterpretation() const;
+    void setXAxisInterpretation(const KstAxisInterpretation interpret);
+
+    KstAxisInterpretation yAxisInterpretation() const;
+    void setYAxisInterpretation(const KstAxisInterpretation interpret);
+
     QPointF mapFromAxisToProjection(const QPointF &point) const;
     QPointF mapToAxisFromProjection(const QPointF &point) const;
     QRectF mapFromAxisToProjection(const QRectF &rect) const;
@@ -281,6 +312,17 @@
     QFont _topLabelFont;
     QFont _rightLabelFont;
 
+    bool _xAxisReversed;
+    bool _yAxisReversed;
+    bool _xAxisBaseOffset;
+    bool _yAxisBaseOffset;
+    bool _xAxisInterpret;
+    bool _yAxisInterpret;
+    KstAxisDisplay _xAxisDisplay;
+    KstAxisDisplay _yAxisDisplay;
+    KstAxisInterpretation _xAxisInterpretation;
+    KstAxisInterpretation _yAxisInterpretation;
+
     MajorTickMode _xAxisMajorTickMode;
     MajorTickMode _yAxisMajorTickMode;
     int _xAxisMinorTickCount;
--- branches/work/kst/portto4/kst/src/libkstapp/plotrenderitemdialog.cpp #772123:772124
@@ -102,6 +102,12 @@
   _xAxisTab->setAxisMinorGridLineColor(_plotItem->plotItem()->xAxisMinorGridLineColor());
   _xAxisTab->setAxisMajorGridLineStyle(_plotItem->plotItem()->xAxisMajorGridLineStyle());
   _xAxisTab->setAxisMinorGridLineStyle(_plotItem->plotItem()->xAxisMinorGridLineStyle());
+  _xAxisTab->setLog(_plotItem->isXAxisLog());
+  _xAxisTab->setReversed(_plotItem->plotItem()->xAxisReversed());
+  _xAxisTab->setBaseOffset(_plotItem->plotItem()->xAxisBaseOffset());
+  _xAxisTab->setInterpret(_plotItem->plotItem()->xAxisInterpret());
+  _xAxisTab->setAxisDisplay(_plotItem->plotItem()->xAxisDisplay());
+  _xAxisTab->setAxisInterpretation(_plotItem->plotItem()->xAxisInterpretation());
 
   _yAxisTab->setAxisMajorTickSpacing(_plotItem->plotItem()->yAxisMajorTickMode());
   _yAxisTab->setDrawAxisMajorTicks(_plotItem->plotItem()->drawYAxisMajorTicks());
@@ -112,6 +118,13 @@
   _yAxisTab->setAxisMinorGridLineColor(_plotItem->plotItem()->yAxisMinorGridLineColor());
   _yAxisTab->setAxisMajorGridLineStyle(_plotItem->plotItem()->yAxisMajorGridLineStyle());
   _yAxisTab->setAxisMinorGridLineStyle(_plotItem->plotItem()->yAxisMinorGridLineStyle());
+  _yAxisTab->setLog(_plotItem->isYAxisLog());
+  _yAxisTab->setReversed(_plotItem->plotItem()->yAxisReversed());
+  _yAxisTab->setBaseOffset(_plotItem->plotItem()->yAxisBaseOffset());
+  _yAxisTab->setInterpret(_plotItem->plotItem()->yAxisInterpret());
+  _yAxisTab->setAxisDisplay(_plotItem->plotItem()->yAxisDisplay());
+  _yAxisTab->setAxisInterpretation(_plotItem->plotItem()->yAxisInterpretation());
+
 }
 
 void PlotRenderItemDialog::setupContent() {
@@ -328,6 +341,13 @@
   _plotItem->plotItem()->setXAxisMinorGridLineColor(_xAxisTab->axisMinorGridLineColor());
   _plotItem->plotItem()->setXAxisMajorGridLineStyle(_xAxisTab->axisMajorGridLineStyle());
   _plotItem->plotItem()->setXAxisMinorGridLineStyle(_xAxisTab->axisMinorGridLineStyle());
+  _plotItem->setXAxisLog(_xAxisTab->isLog());
+  _plotItem->plotItem()->setXAxisReversed(_xAxisTab->isReversed());
+  _plotItem->plotItem()->setXAxisInterpret(_xAxisTab->isInterpret());
+  _plotItem->plotItem()->setXAxisDisplay(_xAxisTab->axisDisplay());
+  _plotItem->plotItem()->setXAxisInterpretation(_xAxisTab->axisInterpretation());
+  _plotItem->plotItem()->setXAxisBaseOffset(_xAxisTab->isBaseOffset());
+
 }
 
 
@@ -343,6 +363,12 @@
   _plotItem->plotItem()->setYAxisMinorGridLineColor(_yAxisTab->axisMinorGridLineColor());
   _plotItem->plotItem()->setYAxisMajorGridLineStyle(_yAxisTab->axisMajorGridLineStyle());
   _plotItem->plotItem()->setYAxisMinorGridLineStyle(_yAxisTab->axisMinorGridLineStyle());
+  _plotItem->setYAxisLog(_yAxisTab->isLog());
+  _plotItem->plotItem()->setYAxisReversed(_yAxisTab->isReversed());
+  _plotItem->plotItem()->setYAxisInterpret(_yAxisTab->isInterpret());
+  _plotItem->plotItem()->setYAxisDisplay(_yAxisTab->axisDisplay());
+  _plotItem->plotItem()->setYAxisInterpretation(_yAxisTab->axisInterpretation());
+  _plotItem->plotItem()->setYAxisBaseOffset(_yAxisTab->isBaseOffset());
 }
 
 


More information about the Kst mailing list