qwt_polar_panner.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * QwtPolar Widget Library
3  * Copyright (C) 2008 Uwe Rathmann
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the Qwt License, Version 1.0
7  *****************************************************************************/
8 
9 #include "qwt_polar_panner.h"
10 #include "qwt_polar_plot.h"
11 #include "qwt_polar_canvas.h"
12 #include "qwt_scale_div.h"
13 #include "qwt_point_polar.h"
14 
17  : QwtPanner( canvas )
18 {
19  connect( this, SIGNAL(panned(int,int)),
20  SLOT(movePlot(int,int)) );
21 }
22 
25 {
26 }
27 
30 {
31  return qobject_cast< QwtPolarCanvas* >( parent() );
32 }
33 
36 {
37  return qobject_cast< const QwtPolarCanvas* >( parent() );
38 }
39 
42 {
43  QwtPolarCanvas* c = canvas();
44  if ( c )
45  return c->plot();
46 
47  return NULL;
48 }
49 
52 {
53  const QwtPolarCanvas* c = canvas();
54  if ( c )
55  return c->plot();
56 
57  return NULL;
58 }
59 
68 void QwtPolarPanner::movePlot( int dx, int dy )
69 {
71  if ( plot == NULL || ( dx == 0 && dy == 0 ) )
72  return;
73 
75 
76  QwtPointPolar pos = plot->zoomPos();
77  if ( map.s1() <= map.s2() )
78  {
79  pos.setRadius(
80  map.transform( map.s1() + pos.radius() ) - map.p1() );
81  pos.setPoint( pos.toPoint() - QPointF( dx, -dy ) );
82  pos.setRadius(
83  map.invTransform( map.p1() + pos.radius() ) - map.s1() );
84  }
85  else
86  {
87  pos.setRadius(
88  map.transform( map.s1() - pos.radius() ) - map.p1() );
89  pos.setPoint( pos.toPoint() - QPointF( dx, -dy ) );
90  pos.setRadius(
91  map.s1() - map.invTransform( map.p1() + pos.radius() ) );
92  }
93 
94  const bool doAutoReplot = plot->autoReplot();
95  plot->setAutoReplot( false );
96 
97  plot->zoom( pos, plot->zoomFactor() );
98 
99  plot->setAutoReplot( doAutoReplot );
100  plot->replot();
101 }
102 
108 void QwtPolarPanner::widgetMousePressEvent( QMouseEvent* event )
109 {
111  if ( plot )
112  {
113  if ( plot->zoomFactor() < 1.0 )
115  }
116 }
117 
118 #if QWT_MOC_INCLUDE
119 #include "moc_qwt_polar_panner.cpp"
120 #endif
QwtPolarPanner::movePlot
virtual void movePlot(int dx, int dy)
Definition: qwt_polar_panner.cpp:68
QwtPolarPlot
A plotting widget, displaying a polar coordinate system.
Definition: qwt_polar_plot.h:46
QwtPolarPlot::scaleMap
QwtScaleMap scaleMap(int scaleId, double radius) const
Definition: qwt_polar_plot.cpp:730
QwtPanner
QwtPanner provides panning of a widget.
Definition: qwt_panner.h:35
QwtPolarPanner::QwtPolarPanner
QwtPolarPanner(QwtPolarCanvas *)
Create a plot panner for a polar plot canvas.
Definition: qwt_polar_panner.cpp:16
qwt_scale_div.h
QwtPolarCanvas
Canvas of a QwtPolarPlot.
Definition: qwt_polar_canvas.h:27
QwtPolarPanner::widgetMousePressEvent
virtual void widgetMousePressEvent(QMouseEvent *) QWT_OVERRIDE
Definition: qwt_polar_panner.cpp:108
QwtPanner::widgetMousePressEvent
virtual void widgetMousePressEvent(QMouseEvent *)
Definition: qwt_panner.cpp:381
qwt_polar_canvas.h
QwtPointPolar::setRadius
void setRadius(double)
Sets the radius to radius.
Definition: qwt_point_polar.h:126
QwtPolarPlot::zoom
void zoom(const QwtPointPolar &, double factor)
Translate and in/decrease the zoom factor.
Definition: qwt_polar_plot.cpp:651
QwtPointPolar
A point in polar coordinates.
Definition: qwt_point_polar.h:28
qwt_polar_panner.h
QwtPolarPanner::canvas
QwtPolarCanvas * canvas()
Definition: qwt_polar_panner.cpp:29
QwtPolarPanner::plot
QwtPolarPlot * plot()
Definition: qwt_polar_panner.cpp:41
range_format::map
@ map
QwtPointPolar::toPoint
QPointF toPoint() const
Definition: qwt_point_polar.cpp:68
QwtPolarPlot::setAutoReplot
void setAutoReplot(bool tf=true)
Set or reset the autoReplot option.
Definition: qwt_polar_plot.cpp:342
qwt_point_polar.h
QwtPolarPlot::autoReplot
bool autoReplot() const
Definition: qwt_polar_plot.cpp:348
QwtPolarCanvas::plot
QwtPolarPlot * plot()
Definition: qwt_polar_canvas.cpp:97
QwtScaleMap
A scale map.
Definition: qwt_scale_map.h:26
QwtPanner::panned
void panned(int dx, int dy)
QwtPolarPlot::replot
virtual void replot()
Redraw the plot.
Definition: qwt_polar_plot.cpp:899
QwtPointPolar::setPoint
void setPoint(const QPointF &)
Definition: qwt_point_polar.cpp:54
QwtPolarPanner::~QwtPolarPanner
virtual ~QwtPolarPanner()
Destructor.
Definition: qwt_polar_panner.cpp:24
qwt_polar_plot.h
QwtPointPolar::radius
double radius() const
Returns the radius.
Definition: qwt_point_polar.h:102
QwtPolarPlot::zoomPos
QwtPointPolar zoomPos() const
Definition: qwt_polar_plot.cpp:682
QwtPolarPlot::zoomFactor
double zoomFactor() const
Definition: qwt_polar_plot.cpp:691
QwtPolar::Radius
@ Radius
Radius.
Definition: qwt_polar.h:45


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46