qwt_polar_magnifier.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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_magnifier.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 
15 #include <qevent.h>
16 
18 {
19 public:
21  unzoomKey( Qt::Key_Home ),
22  unzoomKeyModifiers( Qt::NoModifier )
23  {
24  }
25 
26  int unzoomKey;
28 };
29 
35  QwtMagnifier( canvas )
36 {
37  d_data = new PrivateData();
38 }
39 
42 {
43  delete d_data;
44 }
45 
54 void QwtPolarMagnifier::setUnzoomKey( int key, int modifiers )
55 {
56  d_data->unzoomKey = key;
57  d_data->unzoomKeyModifiers = modifiers;
58 }
59 
67 void QwtPolarMagnifier::getUnzoomKey( int &key, int &modifiers ) const
68 {
69  key = d_data->unzoomKey;
70  modifiers = d_data->unzoomKeyModifiers;
71 }
72 
75 {
76  return qobject_cast<QwtPolarCanvas *>( parent() );
77 }
78 
81 {
82  return qobject_cast<QwtPolarCanvas *>( parent() );
83 }
84 
87 {
88  QwtPolarCanvas *c = canvas();
89  if ( c )
90  return c->plot();
91 
92  return NULL;
93 }
94 
97 {
98  const QwtPolarCanvas *c = canvas();
99  if ( c )
100  return c->plot();
101 
102  return NULL;
103 }
104 
111 {
112  const int key = event->key();
113  const int state = event->modifiers();
114 
115  if ( key == d_data->unzoomKey &&
116  state == d_data->unzoomKeyModifiers )
117  {
118  unzoom();
119  return;
120  }
121 
123 }
124 
129 void QwtPolarMagnifier::rescale( double factor )
130 {
131  factor = qAbs( factor );
132  if ( factor == 1.0 || factor == 0.0 )
133  return;
134 
135  QwtPolarPlot* plt = plot();
136  if ( plt == NULL )
137  return;
138 
139  QwtPointPolar zoomPos;
140  double newZoomFactor = plt->zoomFactor() * factor;
141 
142  if ( newZoomFactor >= 1.0 )
143  newZoomFactor = 1.0;
144  else
145  zoomPos = plt->zoomPos();
146 
147  const bool autoReplot = plt->autoReplot();
148  plt->setAutoReplot( false );
149 
150  plt->zoom( zoomPos, newZoomFactor );
151 
152  plt->setAutoReplot( autoReplot );
153  plt->replot();
154 }
155 
158 {
159  QwtPolarPlot* plt = plot();
160 
161  const bool autoReplot = plt->autoReplot();
162  plt->setAutoReplot( false );
163 
164  plt->unzoom();
165 
166  plt->setAutoReplot( autoReplot );
167  plt->replot();
168 }
169 
170 #if QWT_MOC_INCLUDE
171 #include "moc_qwt_polar_magnifier.cpp"
172 #endif
A plotting widget, displaying a polar coordinate system.
double zoomFactor() const
static heap_info state
Definition: Heap.c:58
A point in polar coordinates.
virtual void rescale(double factor) QWT_OVERRIDE
QwtPointPolar zoomPos() const
void getUnzoomKey(int &key, int &modifiers) const
QwtMagnifier provides zooming, by magnifying in steps.
Definition: qwt_magnifier.h:27
void setAutoReplot(bool tf=true)
Set or reset the autoReplot option.
virtual void widgetKeyPressEvent(QKeyEvent *) QWT_OVERRIDE
void zoom(const QwtPointPolar &, double factor)
Translate and in/decrease the zoom factor.
QwtPolarCanvas * canvas()
bool autoReplot() const
QwtPolarPlot * plot()
Canvas of a QwtPolarPlot.
void unzoom()
Unzoom the plot widget.
QwtPolarPlot * plot()
MQTTClient c
Definition: test10.c:1656
void setUnzoomKey(int key, int modifiers)
QwtPolarMagnifier(QwtPolarCanvas *)
virtual void widgetKeyPressEvent(QKeyEvent *)
virtual void replot()
Redraw the plot.
virtual ~QwtPolarMagnifier()
Destructor.


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10