Index: mainwindow.cpp
===================================================================
--- mainwindow.cpp (revision 1453)
+++ mainwindow.cpp (working copy)
@@ -9,7 +9,7 @@
{
Settings settings;
settings.maxMajorSteps = 10;
settings.maxMinorSteps = 8;
Index: plot.cpp
===================================================================
--- plot.cpp (revision 1453)
+++ plot.cpp (working copy)
@@ -5,6 +5,7 @@
#include "timescaledraw.h"
#include <qwt_plot_panner.h>
#include <qwt_plot_magnifier.h>
+#include <qwt_plot_scaleitem.h>
@@ -25,9 +26,53 @@
const bool on = ( i == axis );
panner->setAxisEnabled( i, on );
magnifier->setAxisEnabled( i, on );
+ _innerTicks [i] = NULL;
}
+ InnerTicks
(QwtPlot::yLeft,
true,
true);
+ InnerTicks
(QwtPlot::xBottom,
true,
true);
}
+void
+Plot::InnerTicks (int axisId, bool showMajor, bool showMinor)
+{
+ if (showMajor || showMinor) {
+ if (_innerTicks [axisId] == NULL) {
+ switch (axisId) {
+ break;
+ break;
+ break;
+ else _innerTicks
[axisId
]->setAxes
(QwtPlot::xBottom,
QwtPlot::yLeft);
+ break;
+ }
+ _innerTicks [axisId]->setAlignment (align);
+ _innerTicks [axisId]->setBorderDistance (0); // attach to border
+ }
+ if (showMajor
) _innerTicks
[axisId
]->scaleDraw
()->setTickLength
(QwtScaleDiv::MajorTick,
8);
+ else _innerTicks
[axisId
]->scaleDraw
()->setTickLength
(QwtScaleDiv::MajorTick,
0);
+ if (showMinor
) _innerTicks
[axisId
]->scaleDraw
()->setTickLength
(QwtScaleDiv::MinorTick,
4);
+ else _innerTicks
[axisId
]->scaleDraw
()->setTickLength
(QwtScaleDiv::MinorTick,
0);
+
+ _innerTicks [axisId]->setScaleDivFromAxis (true);
+ _innerTicks [axisId]->attach (this);
+ } else {
+ if (_innerTicks [axisId] != NULL) {
+ _innerTicks [axisId]->detach ();
+ }
+ }
+}
+
void Plot::applySettings( const Settings &settings )
{
Index: plot.h
===================================================================
--- plot.h (revision 1453)
+++ plot.h (working copy)
@@ -4,6 +4,7 @@
#include <qwt_plot.h>
class Settings;
{
@@ -14,6 +15,11 @@
public Q_SLOTS:
void applySettings( const Settings & );
+
+private:
+
+ void InnerTicks(int, bool, bool);
};
#endif
Index: mainwindow.cpp
===================================================================
--- mainwindow.cpp (revision 1453)
+++ mainwindow.cpp (working copy)
@@ -9,7 +9,7 @@
QMainWindow( parent )
{
Settings settings;
- settings.startDateTime = QDateTime( QDate( 2012, 3, 10 ), QTime( 0, 5, 0 ) );
+ settings.startDateTime = QDateTime( QDate( 2011, 1, 17 ), QTime( 0, 5, 0 ) );
settings.endDateTime = QDateTime( QDate( 2012, 3, 10 ), QTime( 0, 6, 0, 5 ) );
settings.maxMajorSteps = 10;
settings.maxMinorSteps = 8;
Index: plot.cpp
===================================================================
--- plot.cpp (revision 1453)
+++ plot.cpp (working copy)
@@ -5,6 +5,7 @@
#include "timescaledraw.h"
#include <qwt_plot_panner.h>
#include <qwt_plot_magnifier.h>
+#include <qwt_plot_scaleitem.h>
Plot::Plot( QWidget *parent ):
QwtPlot( parent )
@@ -25,9 +26,53 @@
const bool on = ( i == axis );
panner->setAxisEnabled( i, on );
magnifier->setAxisEnabled( i, on );
+ _innerTicks [i] = NULL;
}
+ InnerTicks (QwtPlot::yLeft, true, true);
+ InnerTicks (QwtPlot::xBottom, true, true);
}
+void
+Plot::InnerTicks (int axisId, bool showMajor, bool showMinor)
+{
+ QwtScaleDraw::Alignment align;
+ if (showMajor || showMinor) {
+ if (_innerTicks [axisId] == NULL) {
+ _innerTicks [axisId] = new QwtPlotScaleItem ();
+ switch (axisId) {
+ case QwtPlot::yLeft : align = QwtScaleDraw::RightScale;
+ _innerTicks [axisId]->setAxes (QwtPlot::xBottom, QwtPlot::yLeft);
+ break;
+ case QwtPlot::yRight : align = QwtScaleDraw::LeftScale;
+ _innerTicks [axisId]->setAxes (QwtPlot::xBottom, QwtPlot::yRight);
+ break;
+ case QwtPlot::xBottom : align = QwtScaleDraw::TopScale;
+ _innerTicks [axisId]->setAxes (QwtPlot::xBottom, QwtPlot::yLeft);
+ break;
+ case QwtPlot::xTop : align = QwtScaleDraw::BottomScale;
+ if (axisScaleDraw (axisId)->hasComponent (QwtAbstractScaleDraw::Labels))
+ _innerTicks [axisId]->setAxes (QwtPlot::xTop, QwtPlot::yLeft);
+ else _innerTicks [axisId]->setAxes (QwtPlot::xBottom, QwtPlot::yLeft);
+ break;
+ }
+ _innerTicks [axisId]->setAlignment (align);
+ _innerTicks [axisId]->setBorderDistance (0); // attach to border
+ _innerTicks [axisId]->scaleDraw ()->enableComponent (QwtAbstractScaleDraw::Labels, false);
+ }
+ if (showMajor) _innerTicks [axisId]->scaleDraw ()->setTickLength (QwtScaleDiv::MajorTick, 8);
+ else _innerTicks [axisId]->scaleDraw ()->setTickLength (QwtScaleDiv::MajorTick, 0);
+ if (showMinor) _innerTicks [axisId]->scaleDraw ()->setTickLength (QwtScaleDiv::MinorTick, 4);
+ else _innerTicks [axisId]->scaleDraw ()->setTickLength (QwtScaleDiv::MinorTick, 0);
+
+ _innerTicks [axisId]->setScaleDivFromAxis (true);
+ _innerTicks [axisId]->attach (this);
+ } else {
+ if (_innerTicks [axisId] != NULL) {
+ _innerTicks [axisId]->detach ();
+ }
+ }
+}
+
void Plot::applySettings( const Settings &settings )
{
const int axis = QwtPlot::yLeft;
Index: plot.h
===================================================================
--- plot.h (revision 1453)
+++ plot.h (working copy)
@@ -4,6 +4,7 @@
#include <qwt_plot.h>
class Settings;
+class QwtPlotScaleItem;
class Plot: public QwtPlot
{
@@ -14,6 +15,11 @@
public Q_SLOTS:
void applySettings( const Settings & );
+
+private:
+
+ void InnerTicks(int, bool, bool);
+ QwtPlotScaleItem *_innerTicks [4];
};
#endif
To copy to clipboard, switch view to plain text mode
Bookmarks