#include "ExternalAxisControl.h"
#include <guitools/Feather/ExternalAxis.h>
#include <qwt/qwt_plot_canvas.h>
ExternalAxisControl::ExternalAxisControl(QWidget* parent) :QWidget( parent ),
plot( NULL ), AXIS_SMALL_SIDE(100), MARGIN(5), MIN_START_Y(22),
FONT_SIZE(8), FONT_SIZE_AXIS_LABEL(8){
void ExternalAxisControl::setPlot( QwtPlot* plotOwner ){
int ExternalAxisControl::getStartY() const {
double ExternalAxisControl::getTickStartPixel( QwtPlot::Axis axis ){
#if QWT_VERSION >= 0x060000
QwtScaleDiv scaleDiv = plot->axisScaleDiv( axis );
double upperBound = scaleDiv.upperBound();
double lowerBound = scaleDiv.lowerBound();
double axisExtent = upperBound - lowerBound;
const QList<double> axisTicks = scaleDiv.ticks(axis);
QwtScaleDiv* scaleDiv = plot->axisScaleDiv( axis );
double upperBound = scaleDiv->upperBound();
double lowerBound = scaleDiv->lowerBound();
double axisExtent = upperBound - lowerBound;
const QList<double> axisTicks = scaleDiv->ticks(axis);
double endDistancePercentage = 0;
if ( axisTicks.size() > 0 ){
double lowerBoundDistance = qAbs(lowerBound - axisTicks[0]);
endDistancePercentage = lowerBoundDistance / axisExtent;
int canvasBound = width();
if ( axis != QwtPlot::xBottom ){
canvasBound = getCanvasHeight() - getStartY();
double startPixel = canvasBound * endDistancePercentage;
if ( axis != QwtPlot::xBottom ){
startPixel = getStartY() + startPixel;
double ExternalAxisControl::getTickDistance(QwtPlot::Axis axis ){
#if QWT_VERSION >= 0x060000
QwtScaleDiv scaleDiv = plot->axisScaleDiv( axis );
const QList<double> axisTicks = scaleDiv.ticks( axis);
double tickDistance = scaleDiv.upperBound() - scaleDiv.lowerBound();
QwtScaleDiv* scaleDiv = plot->axisScaleDiv( axis );
const QList<double> axisTicks = scaleDiv->ticks( axis);
double tickDistance = scaleDiv->upperBound() - scaleDiv->lowerBound();