Loading...
Searching...
No Matches
qwt_polar_panner.cpp
/******************************************************************************
* QwtPolar Widget Library
* Copyright (C) 2008 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#include "qwt_polar_panner.h"
#include "qwt_polar_plot.h"
#include "qwt_polar_canvas.h"
#include "qwt_scale_div.h"
#include "qwt_point_polar.h"
QwtPolarPanner::QwtPolarPanner( QwtPolarCanvas* canvas )
: QwtPanner( canvas )
{
connect( this, SIGNAL(panned(int,int)),
SLOT(movePlot(int,int)) );
}
QwtPolarPanner::~QwtPolarPanner()
{
}
QwtPolarCanvas* QwtPolarPanner::canvas()
{
return qobject_cast< QwtPolarCanvas* >( parent() );
}
const QwtPolarCanvas* QwtPolarPanner::canvas() const
{
return qobject_cast< const QwtPolarCanvas* >( parent() );
}
QwtPolarPlot* QwtPolarPanner::plot()
{
QwtPolarCanvas* c = canvas();
if ( c )
return c->plot();
return NULL;
}
const QwtPolarPlot* QwtPolarPanner::plot() const
{
const QwtPolarCanvas* c = canvas();
if ( c )
return c->plot();
return NULL;
}
void QwtPolarPanner::movePlot( int dx, int dy )
{
QwtPolarPlot* plot = QwtPolarPanner::plot();
if ( plot == NULL || ( dx == 0 && dy == 0 ) )
return;
const QwtScaleMap map = plot->scaleMap( QwtPolar::Radius );
QwtPointPolar pos = plot->zoomPos();
if ( map.s1() <= map.s2() )
{
pos.setRadius(
map.transform( map.s1() + pos.radius() ) - map.p1() );
pos.setPoint( pos.toPoint() - QPointF( dx, -dy ) );
pos.setRadius(
map.invTransform( map.p1() + pos.radius() ) - map.s1() );
}
else
{
pos.setRadius(
map.transform( map.s1() - pos.radius() ) - map.p1() );
pos.setPoint( pos.toPoint() - QPointF( dx, -dy ) );
pos.setRadius(
map.s1() - map.invTransform( map.p1() + pos.radius() ) );
}
const bool doAutoReplot = plot->autoReplot();
plot->setAutoReplot( false );
plot->zoom( pos, plot->zoomFactor() );
plot->setAutoReplot( doAutoReplot );
plot->replot();
}
void QwtPolarPanner::widgetMousePressEvent( QMouseEvent* event )
{
const QwtPolarPlot* plot = QwtPolarPanner::plot();
if ( plot )
{
if ( plot->zoomFactor() < 1.0 )
QwtPanner::widgetMousePressEvent( event );
}
}
#include "moc_qwt_polar_panner.cpp"
QwtPanner
QwtPanner provides panning of a widget.
Definition qwt_panner.h:36
QwtPanner::widgetMousePressEvent
virtual void widgetMousePressEvent(QMouseEvent *)
Definition qwt_panner.cpp:381
QwtPanner::panned
void panned(int dx, int dy)
QwtPointPolar
A point in polar coordinates.
Definition qwt_point_polar.h:29
QwtPointPolar::radius
double radius() const
Returns the radius.
Definition qwt_point_polar.h:102
QwtPointPolar::setRadius
void setRadius(double)
Sets the radius to radius.
Definition qwt_point_polar.h:126
QwtPointPolar::toPoint
QPointF toPoint() const
Definition qwt_point_polar.cpp:68
QwtPointPolar::setPoint
void setPoint(const QPointF &)
Definition qwt_point_polar.cpp:54
QwtPolarCanvas
Canvas of a QwtPolarPlot.
Definition qwt_polar_canvas.h:28
QwtPolarCanvas::plot
QwtPolarPlot * plot()
Definition qwt_polar_canvas.cpp:97
QwtPolarPanner::canvas
QwtPolarCanvas * canvas()
Definition qwt_polar_panner.cpp:29
QwtPolarPanner::~QwtPolarPanner
virtual ~QwtPolarPanner()
Destructor.
Definition qwt_polar_panner.cpp:24
QwtPolarPanner::widgetMousePressEvent
virtual void widgetMousePressEvent(QMouseEvent *) override
Definition qwt_polar_panner.cpp:108
QwtPolarPanner::QwtPolarPanner
QwtPolarPanner(QwtPolarCanvas *)
Create a plot panner for a polar plot canvas.
Definition qwt_polar_panner.cpp:16
QwtPolarPanner::movePlot
virtual void movePlot(int dx, int dy)
Definition qwt_polar_panner.cpp:68
QwtPolarPanner::plot
QwtPolarPlot * plot()
Definition qwt_polar_panner.cpp:41
QwtPolarPlot
A plotting widget, displaying a polar coordinate system.
Definition qwt_polar_plot.h:47
QwtPolarPlot::scaleMap
QwtScaleMap scaleMap(int scaleId, double radius) const
Definition qwt_polar_plot.cpp:730
QwtPolarPlot::zoomPos
QwtPointPolar zoomPos() const
Definition qwt_polar_plot.cpp:682
QwtPolarPlot::replot
virtual void replot()
Redraw the plot.
Definition qwt_polar_plot.cpp:899
QwtPolarPlot::zoom
void zoom(const QwtPointPolar &, double factor)
Translate and in/decrease the zoom factor.
Definition qwt_polar_plot.cpp:651
QwtPolarPlot::zoomFactor
double zoomFactor() const
Definition qwt_polar_plot.cpp:691
QwtPolarPlot::autoReplot
bool autoReplot() const
Definition qwt_polar_plot.cpp:348
QwtPolarPlot::setAutoReplot
void setAutoReplot(bool tf=true)
Set or reset the autoReplot option.
Definition qwt_polar_plot.cpp:342
QwtScaleMap
A scale map.
Definition qwt_scale_map.h:27
QwtScaleMap::p1
double p1() const
Definition qwt_scale_map.h:99
QwtScaleMap::transform
double transform(double s) const
Definition qwt_scale_map.h:137
QwtScaleMap::s1
double s1() const
Definition qwt_scale_map.h:83
QwtScaleMap::s2
double s2() const
Definition qwt_scale_map.h:91
QwtScaleMap::invTransform
double invTransform(double p) const
Definition qwt_scale_map.h:154