1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3
<title>Qwt User's Guide: qwt_plot_zoomer.cpp Source File</title>
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
5
<link href="tabs.css" rel="stylesheet" type="text/css">
7
<!-- Generated by Doxygen 1.5.0 -->
10
<li><a href="index.html"><span>Main Page</span></a></li>
11
<li><a href="classes.html"><span>Classes</span></a></li>
12
<li id="current"><a href="files.html"><span>Files</span></a></li>
13
<li><a href="pages.html"><span>Related Pages</span></a></li>
17
<li><a href="files.html"><span>File List</span></a></li>
18
<li><a href="globals.html"><span>File Members</span></a></li>
20
<h1>qwt_plot_zoomer.cpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
21
<a name="l00002"></a>00002 <span class="comment"> * Qwt Widget Library</span>
22
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span>
23
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span>
24
<a name="l00005"></a>00005 <span class="comment"> *</span>
25
<a name="l00006"></a>00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
26
<a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
27
<a name="l00008"></a>00008 <span class="comment"> *****************************************************************************/</span>
28
<a name="l00009"></a>00009
29
<a name="l00010"></a>00010 <span class="comment">// vim: expandtab</span>
30
<a name="l00011"></a>00011
31
<a name="l00012"></a>00012 <span class="preprocessor">#include <math.h></span>
32
<a name="l00013"></a>00013 <span class="preprocessor">#include "qwt_plot.h"</span>
33
<a name="l00014"></a>00014 <span class="preprocessor">#include "qwt_plot_canvas.h"</span>
34
<a name="l00015"></a>00015 <span class="preprocessor">#include "qwt_plot_zoomer.h"</span>
35
<a name="l00016"></a>00016 <span class="preprocessor">#include "qwt_scale_div.h"</span>
36
<a name="l00017"></a>00017 <span class="preprocessor">#if QT_VERSION < 0x040000</span>
37
<a name="l00018"></a>00018 <span class="preprocessor"></span><span class="keyword">typedef</span> QValueStack<QwtDoubleRect> QwtZoomStack;
38
<a name="l00019"></a>00019 <span class="preprocessor">#else</span>
39
<a name="l00020"></a>00020 <span class="preprocessor"></span><span class="keyword">typedef</span> QStack<QwtDoubleRect> QwtZoomStack;
40
<a name="l00021"></a>00021 <span class="preprocessor">#endif</span>
41
<a name="l00022"></a>00022 <span class="preprocessor"></span>
42
<a name="l00023"></a>00023 <span class="keyword">class </span>QwtPlotZoomer::PrivateData
43
<a name="l00024"></a>00024 {
44
<a name="l00025"></a>00025 <span class="keyword">public</span>:
45
<a name="l00026"></a>00026 uint <a class="code" href="class_qwt_plot_zoomer.html#b2a8af282a7052976e9c18b2d0c59db9">zoomRectIndex</a>;
46
<a name="l00027"></a>00027 QwtZoomStack <a class="code" href="class_qwt_plot_zoomer.html#0befad8b95d8cb651e993e85d51acb06">zoomStack</a>;
47
<a name="l00028"></a>00028
48
<a name="l00029"></a>00029 <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_zoomer.html#b541148fa7d57b8102d3d70ab9daccc4">maxStackDepth</a>;
49
<a name="l00030"></a>00030 };
50
<a name="l00031"></a>00031
51
<a name="l00051"></a><a class="code" href="class_qwt_plot_zoomer.html#07f5135e421d2aab3f06542ff1320ece">00051</a> <a class="code" href="class_qwt_plot_zoomer.html#07f5135e421d2aab3f06542ff1320ece">QwtPlotZoomer::QwtPlotZoomer</a>(<a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *<a class="code" href="class_qwt_plot_picker.html#402820e19bc6a9a33184264345703015">canvas</a>, <span class="keywordtype">bool</span> doReplot):
52
<a name="l00052"></a>00052 <a class="code" href="class_qwt_plot_picker.html">QwtPlotPicker</a>(<a class="code" href="class_qwt_plot_picker.html#402820e19bc6a9a33184264345703015">canvas</a>)
53
<a name="l00053"></a>00053 {
54
<a name="l00054"></a>00054 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_picker.html#402820e19bc6a9a33184264345703015">canvas</a> )
55
<a name="l00055"></a>00055 init(RectSelection & ClickSelection, ActiveOnly, doReplot);
56
<a name="l00056"></a>00056 }
57
<a name="l00057"></a>00057
58
<a name="l00075"></a><a class="code" href="class_qwt_plot_zoomer.html#b64adf928b11ec8f441098a551e437b4">00075</a> <a class="code" href="class_qwt_plot_zoomer.html#07f5135e421d2aab3f06542ff1320ece">QwtPlotZoomer::QwtPlotZoomer</a>(<span class="keywordtype">int</span> xAxis, <span class="keywordtype">int</span> yAxis,
59
<a name="l00076"></a>00076 <a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *canvas, <span class="keywordtype">bool</span> doReplot):
60
<a name="l00077"></a>00077 <a class="code" href="class_qwt_plot_picker.html">QwtPlotPicker</a>(xAxis, yAxis, canvas)
61
<a name="l00078"></a>00078 {
62
<a name="l00079"></a>00079 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_picker.html#402820e19bc6a9a33184264345703015">canvas</a> )
63
<a name="l00080"></a>00080 init(RectSelection & ClickSelection, ActiveOnly, doReplot);
64
<a name="l00081"></a>00081 }
65
<a name="l00082"></a>00082
66
<a name="l00103"></a><a class="code" href="class_qwt_plot_zoomer.html#c94a73ec32fcfee08edf14d1a3021cd5">00103</a> <a class="code" href="class_qwt_plot_zoomer.html#07f5135e421d2aab3f06542ff1320ece">QwtPlotZoomer::QwtPlotZoomer</a>(<span class="keywordtype">int</span> xAxis, <span class="keywordtype">int</span> yAxis, <span class="keywordtype">int</span> selectionFlags,
67
<a name="l00104"></a>00104 <a class="code" href="class_qwt_picker.html#01be4d404ffc3a7b238b0d0aaeb66b93">DisplayMode</a> trackerMode, <a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *canvas, <span class="keywordtype">bool</span> doReplot):
68
<a name="l00105"></a>00105 <a class="code" href="class_qwt_plot_picker.html">QwtPlotPicker</a>(xAxis, yAxis, canvas)
69
<a name="l00106"></a>00106 {
70
<a name="l00107"></a>00107 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_picker.html#402820e19bc6a9a33184264345703015">canvas</a> )
71
<a name="l00108"></a>00108 init(selectionFlags, trackerMode, doReplot);
72
<a name="l00109"></a>00109 }
73
<a name="l00110"></a>00110
74
<a name="l00112"></a>00112 <span class="keywordtype">void</span> QwtPlotZoomer::init(<span class="keywordtype">int</span> selectionFlags,
75
<a name="l00113"></a>00113 DisplayMode trackerMode, <span class="keywordtype">bool</span> doReplot)
76
<a name="l00114"></a>00114 {
77
<a name="l00115"></a>00115 d_data = <span class="keyword">new</span> PrivateData;
78
<a name="l00116"></a>00116
79
<a name="l00117"></a>00117 d_data->maxStackDepth = -1;
80
<a name="l00118"></a>00118
81
<a name="l00119"></a>00119 <a class="code" href="class_qwt_plot_zoomer.html#c9d52dbddc9e79e7ce8ebd545e855e89">setSelectionFlags</a>(selectionFlags);
82
<a name="l00120"></a>00120 <a class="code" href="class_qwt_picker.html#94fc60c7223cdc470ae63156f6446d6f">setTrackerMode</a>(trackerMode);
83
<a name="l00121"></a>00121 <a class="code" href="class_qwt_picker.html#83096bad2662e02e4914a7b40241c351">setRubberBand</a>(RectRubberBand);
84
<a name="l00122"></a>00122
85
<a name="l00123"></a>00123 <span class="keywordflow">if</span> ( doReplot && <a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a>() )
86
<a name="l00124"></a>00124 <a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a>()-><a class="code" href="class_qwt_plot.html#7b094e29b8e92b00e36517d0d7633c4b">replot</a>();
87
<a name="l00125"></a>00125
88
<a name="l00126"></a>00126 <a class="code" href="class_qwt_plot_zoomer.html#7ee4f2a0606df6e85258c52f0b5c7bc2">setZoomBase</a>(<a class="code" href="class_qwt_plot_picker.html#96e73f28d02d49cb80ff2d3b607fccc5">scaleRect</a>());
89
<a name="l00127"></a>00127 }
90
<a name="l00128"></a>00128
91
<a name="l00129"></a><a class="code" href="class_qwt_plot_zoomer.html#3af28fe93e0098ce8d09222a7976f254">00129</a> <a class="code" href="class_qwt_plot_zoomer.html#3af28fe93e0098ce8d09222a7976f254">QwtPlotZoomer::~QwtPlotZoomer</a>()
92
<a name="l00130"></a>00130 {
93
<a name="l00131"></a>00131 <span class="keyword">delete</span> d_data;
94
<a name="l00132"></a>00132 }
95
<a name="l00133"></a>00133
96
<a name="l00145"></a><a class="code" href="class_qwt_plot_zoomer.html#3965591944793790407ba91d6de3a882">00145</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#3965591944793790407ba91d6de3a882">QwtPlotZoomer::setMaxStackDepth</a>(<span class="keywordtype">int</span> depth)
97
<a name="l00146"></a>00146 {
98
<a name="l00147"></a>00147 d_data->maxStackDepth = depth;
99
<a name="l00148"></a>00148
100
<a name="l00149"></a>00149 <span class="keywordflow">if</span> ( depth >= 0 )
101
<a name="l00150"></a>00150 {
102
<a name="l00151"></a>00151 <span class="comment">// unzoom if the current depth is below d_data->maxStackDepth</span>
103
<a name="l00152"></a>00152
104
<a name="l00153"></a>00153 <span class="keyword">const</span> <span class="keywordtype">int</span> zoomOut =
105
<a name="l00154"></a>00154 int(d_data->zoomStack.count()) - 1 - depth; <span class="comment">// -1 for the zoom base</span>
106
<a name="l00155"></a>00155
107
<a name="l00156"></a>00156 <span class="keywordflow">if</span> ( zoomOut > 0 )
108
<a name="l00157"></a>00157 {
109
<a name="l00158"></a>00158 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(-zoomOut);
110
<a name="l00159"></a>00159 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = <span class="keywordtype">int</span>(d_data->zoomStack.count()) - 1;
111
<a name="l00160"></a>00160 i > int(d_data->zoomRectIndex); i-- )
112
<a name="l00161"></a>00161 {
113
<a name="l00162"></a>00162 (<span class="keywordtype">void</span>)d_data->zoomStack.pop(); <span class="comment">// remove trailing rects</span>
114
<a name="l00163"></a>00163 }
115
<a name="l00164"></a>00164 }
116
<a name="l00165"></a>00165 }
117
<a name="l00166"></a>00166 }
118
<a name="l00167"></a>00167
119
<a name="l00172"></a><a class="code" href="class_qwt_plot_zoomer.html#b541148fa7d57b8102d3d70ab9daccc4">00172</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_zoomer.html#b541148fa7d57b8102d3d70ab9daccc4">QwtPlotZoomer::maxStackDepth</a>()<span class="keyword"> const</span>
120
<a name="l00173"></a>00173 <span class="keyword"></span>{
121
<a name="l00174"></a>00174 <span class="keywordflow">return</span> d_data->maxStackDepth;
122
<a name="l00175"></a>00175 }
123
<a name="l00176"></a>00176
124
<a name="l00183"></a><a class="code" href="class_qwt_plot_zoomer.html#0befad8b95d8cb651e993e85d51acb06">00183</a> <span class="keyword">const</span> QwtZoomStack &<a class="code" href="class_qwt_plot_zoomer.html#0befad8b95d8cb651e993e85d51acb06">QwtPlotZoomer::zoomStack</a>()<span class="keyword"> const</span>
125
<a name="l00184"></a>00184 <span class="keyword"></span>{
126
<a name="l00185"></a>00185 <span class="keywordflow">return</span> d_data->zoomStack;
127
<a name="l00186"></a>00186 }
128
<a name="l00187"></a>00187
129
<a name="l00192"></a><a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">00192</a> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">QwtPlotZoomer::zoomBase</a>()<span class="keyword"> const</span>
130
<a name="l00193"></a>00193 <span class="keyword"></span>{
131
<a name="l00194"></a>00194 <span class="keywordflow">return</span> d_data->zoomStack[0];
132
<a name="l00195"></a>00195 }
133
<a name="l00196"></a>00196
134
<a name="l00206"></a><a class="code" href="class_qwt_plot_zoomer.html#7ee4f2a0606df6e85258c52f0b5c7bc2">00206</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#7ee4f2a0606df6e85258c52f0b5c7bc2">QwtPlotZoomer::setZoomBase</a>(<span class="keywordtype">bool</span> doReplot)
135
<a name="l00207"></a>00207 {
136
<a name="l00208"></a>00208 <a class="code" href="class_qwt_plot.html">QwtPlot</a> *plt = <a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a>();
137
<a name="l00209"></a>00209 <span class="keywordflow">if</span> ( plt == NULL )
138
<a name="l00210"></a>00210 <span class="keywordflow">return</span>;
139
<a name="l00211"></a>00211
140
<a name="l00212"></a>00212 <span class="keywordflow">if</span> ( doReplot )
141
<a name="l00213"></a>00213 plt-><a class="code" href="class_qwt_plot.html#7b094e29b8e92b00e36517d0d7633c4b">replot</a>();
142
<a name="l00214"></a>00214
143
<a name="l00215"></a>00215 d_data->zoomStack.clear();
144
<a name="l00216"></a>00216 d_data->zoomStack.push(<a class="code" href="class_qwt_plot_picker.html#96e73f28d02d49cb80ff2d3b607fccc5">scaleRect</a>());
145
<a name="l00217"></a>00217 d_data->zoomRectIndex = 0;
146
<a name="l00218"></a>00218
147
<a name="l00219"></a>00219 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();
148
<a name="l00220"></a>00220 }
149
<a name="l00221"></a>00221
150
<a name="l00232"></a><a class="code" href="class_qwt_plot_zoomer.html#80e1f91cf51b88aa11f2d976f01b4a3f">00232</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#7ee4f2a0606df6e85258c52f0b5c7bc2">QwtPlotZoomer::setZoomBase</a>(<span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> &base)
151
<a name="l00233"></a>00233 {
152
<a name="l00234"></a>00234 <span class="keyword">const</span> <a class="code" href="class_qwt_plot.html">QwtPlot</a> *plt = <a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a>();
153
<a name="l00235"></a>00235 <span class="keywordflow">if</span> ( !plt )
154
<a name="l00236"></a>00236 <span class="keywordflow">return</span>;
155
<a name="l00237"></a>00237
156
<a name="l00238"></a>00238 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> sRect = <a class="code" href="class_qwt_plot_picker.html#96e73f28d02d49cb80ff2d3b607fccc5">scaleRect</a>();
157
<a name="l00239"></a>00239 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> bRect = base | sRect;
158
<a name="l00240"></a>00240
159
<a name="l00241"></a>00241 d_data->zoomStack.clear();
160
<a name="l00242"></a>00242 d_data->zoomStack.push(bRect);
161
<a name="l00243"></a>00243 d_data->zoomRectIndex = 0;
162
<a name="l00244"></a>00244
163
<a name="l00245"></a>00245 <span class="keywordflow">if</span> ( base != sRect )
164
<a name="l00246"></a>00246 {
165
<a name="l00247"></a>00247 d_data->zoomStack.push(sRect);
166
<a name="l00248"></a>00248 d_data->zoomRectIndex++;
167
<a name="l00249"></a>00249 }
168
<a name="l00250"></a>00250
169
<a name="l00251"></a>00251 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();
170
<a name="l00252"></a>00252 }
171
<a name="l00253"></a>00253
172
<a name="l00259"></a><a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">00259</a> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">QwtPlotZoomer::zoomRect</a>()<span class="keyword"> const</span>
173
<a name="l00260"></a>00260 <span class="keyword"></span>{
174
<a name="l00261"></a>00261 <span class="keywordflow">return</span> d_data->zoomStack[d_data->zoomRectIndex];
175
<a name="l00262"></a>00262 }
176
<a name="l00263"></a>00263
177
<a name="l00267"></a><a class="code" href="class_qwt_plot_zoomer.html#b2a8af282a7052976e9c18b2d0c59db9">00267</a> uint <a class="code" href="class_qwt_plot_zoomer.html#b2a8af282a7052976e9c18b2d0c59db9">QwtPlotZoomer::zoomRectIndex</a>()<span class="keyword"> const</span>
178
<a name="l00268"></a>00268 <span class="keyword"></span>{
179
<a name="l00269"></a>00269 <span class="keywordflow">return</span> d_data->zoomRectIndex;
180
<a name="l00270"></a>00270 }
181
<a name="l00271"></a>00271
182
<a name="l00283"></a><a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">00283</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">QwtPlotZoomer::zoom</a>(<span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> &rect)
183
<a name="l00284"></a>00284 {
184
<a name="l00285"></a>00285 <span class="keywordflow">if</span> ( d_data->maxStackDepth >= 0 &&
185
<a name="l00286"></a>00286 <span class="keywordtype">int</span>(d_data->zoomRectIndex) >= d_data->maxStackDepth )
186
<a name="l00287"></a>00287 {
187
<a name="l00288"></a>00288 <span class="keywordflow">return</span>;
188
<a name="l00289"></a>00289 }
189
<a name="l00290"></a>00290
190
<a name="l00291"></a>00291 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a> = d_data->zoomStack[0] & rect.normalized();
191
<a name="l00292"></a>00292 <span class="keywordflow">if</span> ( zoomRect != d_data->zoomStack[d_data->zoomRectIndex] )
192
<a name="l00293"></a>00293 {
193
<a name="l00294"></a>00294 <span class="keywordflow">for</span> ( uint i = <span class="keywordtype">int</span>(d_data->zoomStack.count()) - 1;
194
<a name="l00295"></a>00295 i > d_data->zoomRectIndex; i-- )
195
<a name="l00296"></a>00296 {
196
<a name="l00297"></a>00297 (<span class="keywordtype">void</span>)d_data->zoomStack.pop();
197
<a name="l00298"></a>00298 }
198
<a name="l00299"></a>00299
199
<a name="l00300"></a>00300 d_data->zoomStack.push(zoomRect);
200
<a name="l00301"></a>00301 d_data->zoomRectIndex++;
201
<a name="l00302"></a>00302
202
<a name="l00303"></a>00303 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();
203
<a name="l00304"></a>00304
204
<a name="l00305"></a>00305 emit <a class="code" href="class_qwt_plot_zoomer.html#e4e9b90ccfb97f4eae54c667f79644ff">zoomed</a>(zoomRect);
205
<a name="l00306"></a>00306 }
206
<a name="l00307"></a>00307 }
207
<a name="l00308"></a>00308
208
<a name="l00320"></a><a class="code" href="class_qwt_plot_zoomer.html#0cee73f15c5791553cb52c4e7b3e881e">00320</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">QwtPlotZoomer::zoom</a>(<span class="keywordtype">int</span> offset)
209
<a name="l00321"></a>00321 {
210
<a name="l00322"></a>00322 <span class="keywordflow">if</span> ( offset == 0 )
211
<a name="l00323"></a>00323 d_data->zoomRectIndex = 0;
212
<a name="l00324"></a>00324 <span class="keywordflow">else</span>
213
<a name="l00325"></a>00325 {
214
<a name="l00326"></a>00326 <span class="keywordtype">int</span> newIndex = d_data->zoomRectIndex + offset;
215
<a name="l00327"></a>00327 newIndex = qwtMax(0, newIndex);
216
<a name="l00328"></a>00328 newIndex = qwtMin(<span class="keywordtype">int</span>(d_data->zoomStack.count()) - 1, newIndex);
217
<a name="l00329"></a>00329
218
<a name="l00330"></a>00330 d_data->zoomRectIndex = uint(newIndex);
219
<a name="l00331"></a>00331 }
220
<a name="l00332"></a>00332
221
<a name="l00333"></a>00333 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();
222
<a name="l00334"></a>00334
223
<a name="l00335"></a>00335 emit <a class="code" href="class_qwt_plot_zoomer.html#e4e9b90ccfb97f4eae54c667f79644ff">zoomed</a>(<a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>());
224
<a name="l00336"></a>00336 }
225
<a name="l00337"></a>00337
226
<a name="l00352"></a>00352 <span class="keywordtype">void</span> QwtPlotZoomer::setZoomStack(
227
<a name="l00353"></a>00353 <span class="keyword">const</span> QwtZoomStack &zoomStack, <span class="keywordtype">int</span> zoomRectIndex)
228
<a name="l00354"></a>00354 {
229
<a name="l00355"></a>00355 <span class="keywordflow">if</span> ( zoomStack.isEmpty() || int(zoomStack.count()) > d_data->maxStackDepth )
230
<a name="l00356"></a>00356 <span class="keywordflow">return</span>;
231
<a name="l00357"></a>00357
232
<a name="l00358"></a>00358 <span class="keywordflow">if</span> ( zoomRectIndex < 0 || zoomRectIndex > <span class="keywordtype">int</span>(zoomStack.count()) )
233
<a name="l00359"></a>00359 zoomRectIndex = zoomStack.count() - 1;
234
<a name="l00360"></a>00360
235
<a name="l00361"></a>00361 <span class="keyword">const</span> <span class="keywordtype">bool</span> doRescale = zoomStack[zoomRectIndex] != <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>();
236
<a name="l00362"></a>00362
237
<a name="l00363"></a>00363 d_data->zoomStack = zoomStack;
238
<a name="l00364"></a>00364 d_data->zoomRectIndex = uint(zoomRectIndex);
239
<a name="l00365"></a>00365
240
<a name="l00366"></a>00366 <span class="keywordflow">if</span> ( doRescale )
241
<a name="l00367"></a>00367 {
242
<a name="l00368"></a>00368 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();
243
<a name="l00369"></a>00369 emit <a class="code" href="class_qwt_plot_zoomer.html#e4e9b90ccfb97f4eae54c667f79644ff">zoomed</a>(<a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>());
244
<a name="l00370"></a>00370 }
245
<a name="l00371"></a>00371 }
246
<a name="l00372"></a>00372
247
<a name="l00379"></a><a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">00379</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">QwtPlotZoomer::rescale</a>()
248
<a name="l00380"></a>00380 {
249
<a name="l00381"></a>00381 <a class="code" href="class_qwt_plot.html">QwtPlot</a> *plt = <a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a>();
250
<a name="l00382"></a>00382 <span class="keywordflow">if</span> ( !plt )
251
<a name="l00383"></a>00383 <span class="keywordflow">return</span>;
252
<a name="l00384"></a>00384
253
<a name="l00385"></a>00385 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> &rect = d_data->zoomStack[d_data->zoomRectIndex];
254
<a name="l00386"></a>00386 <span class="keywordflow">if</span> ( rect != <a class="code" href="class_qwt_plot_picker.html#96e73f28d02d49cb80ff2d3b607fccc5">scaleRect</a>() )
255
<a name="l00387"></a>00387 {
256
<a name="l00388"></a>00388 <span class="keyword">const</span> <span class="keywordtype">bool</span> doReplot = plt-><a class="code" href="class_qwt_plot.html#3a639850b65bc4dbf22b3f3170d61804">autoReplot</a>();
257
<a name="l00389"></a>00389 plt-><a class="code" href="class_qwt_plot.html#654934ec2ad167101dacb5174f5172d6">setAutoReplot</a>(<span class="keyword">false</span>);
258
<a name="l00390"></a>00390
259
<a name="l00391"></a>00391 <span class="keywordtype">double</span> x1 = rect.left();
260
<a name="l00392"></a>00392 <span class="keywordtype">double</span> x2 = rect.right();
261
<a name="l00393"></a>00393 <span class="keywordflow">if</span> ( plt-><a class="code" href="class_qwt_plot.html#029086e7b26fcfeff5430d25a4df4f3e">axisScaleDiv</a>(<a class="code" href="class_qwt_plot_picker.html#721b1d74143839034c730556d0691c1e">xAxis</a>())-><a class="code" href="class_qwt_scale_div.html#df5e9211cd42a3efc1a3cdf836dc741a">lBound</a>() >
262
<a name="l00394"></a>00394 plt-><a class="code" href="class_qwt_plot.html#029086e7b26fcfeff5430d25a4df4f3e">axisScaleDiv</a>(<a class="code" href="class_qwt_plot_picker.html#721b1d74143839034c730556d0691c1e">xAxis</a>())-><a class="code" href="class_qwt_scale_div.html#8c6238cf9e8f406e9633fcede305e33c">hBound</a>() )
263
<a name="l00395"></a>00395 {
264
<a name="l00396"></a>00396 qSwap(x1, x2);
265
<a name="l00397"></a>00397 }
266
<a name="l00398"></a>00398
267
<a name="l00399"></a>00399 plt-><a class="code" href="class_qwt_plot.html#cef5ea818944b93b8695d0c16924eed6">setAxisScale</a>(<a class="code" href="class_qwt_plot_picker.html#721b1d74143839034c730556d0691c1e">xAxis</a>(), x1, x2);
268
<a name="l00400"></a>00400
269
<a name="l00401"></a>00401 <span class="keywordtype">double</span> y1 = rect.top();
270
<a name="l00402"></a>00402 <span class="keywordtype">double</span> y2 = rect.bottom();
271
<a name="l00403"></a>00403 <span class="keywordflow">if</span> ( plt-><a class="code" href="class_qwt_plot.html#029086e7b26fcfeff5430d25a4df4f3e">axisScaleDiv</a>(<a class="code" href="class_qwt_plot_picker.html#3f2919671ab530b182a6b7ebd0c20f6f">yAxis</a>())-><a class="code" href="class_qwt_scale_div.html#df5e9211cd42a3efc1a3cdf836dc741a">lBound</a>() >
272
<a name="l00404"></a>00404 plt-><a class="code" href="class_qwt_plot.html#029086e7b26fcfeff5430d25a4df4f3e">axisScaleDiv</a>(<a class="code" href="class_qwt_plot_picker.html#3f2919671ab530b182a6b7ebd0c20f6f">yAxis</a>())-><a class="code" href="class_qwt_scale_div.html#8c6238cf9e8f406e9633fcede305e33c">hBound</a>() )
273
<a name="l00405"></a>00405 {
274
<a name="l00406"></a>00406 qSwap(y1, y2);
275
<a name="l00407"></a>00407 }
276
<a name="l00408"></a>00408 plt-><a class="code" href="class_qwt_plot.html#cef5ea818944b93b8695d0c16924eed6">setAxisScale</a>(<a class="code" href="class_qwt_plot_picker.html#3f2919671ab530b182a6b7ebd0c20f6f">yAxis</a>(), y1, y2);
277
<a name="l00409"></a>00409
278
<a name="l00410"></a>00410 plt-><a class="code" href="class_qwt_plot.html#654934ec2ad167101dacb5174f5172d6">setAutoReplot</a>(doReplot);
279
<a name="l00411"></a>00411
280
<a name="l00412"></a>00412 plt-><a class="code" href="class_qwt_plot.html#7b094e29b8e92b00e36517d0d7633c4b">replot</a>();
281
<a name="l00413"></a>00413 }
282
<a name="l00414"></a>00414 }
283
<a name="l00415"></a>00415
284
<a name="l00423"></a><a class="code" href="class_qwt_plot_zoomer.html#6cb755e06b83e50e8353dd706f7fb6f0">00423</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#6cb755e06b83e50e8353dd706f7fb6f0">QwtPlotZoomer::setAxis</a>(<span class="keywordtype">int</span> xAxis, <span class="keywordtype">int</span> yAxis)
285
<a name="l00424"></a>00424 {
286
<a name="l00425"></a>00425 <span class="keywordflow">if</span> ( xAxis != <a class="code" href="class_qwt_plot_picker.html#721b1d74143839034c730556d0691c1e">QwtPlotPicker::xAxis</a>() || yAxis != <a class="code" href="class_qwt_plot_picker.html#3f2919671ab530b182a6b7ebd0c20f6f">QwtPlotPicker::yAxis</a>() )
287
<a name="l00426"></a>00426 {
288
<a name="l00427"></a>00427 <a class="code" href="class_qwt_plot_picker.html#a901c86543585c7056133a5cb6652e3d">QwtPlotPicker::setAxis</a>(xAxis, yAxis);
289
<a name="l00428"></a>00428 <a class="code" href="class_qwt_plot_zoomer.html#7ee4f2a0606df6e85258c52f0b5c7bc2">setZoomBase</a>(<a class="code" href="class_qwt_plot_picker.html#96e73f28d02d49cb80ff2d3b607fccc5">scaleRect</a>());
290
<a name="l00429"></a>00429 }
291
<a name="l00430"></a>00430 }
292
<a name="l00431"></a>00431
293
<a name="l00442"></a><a class="code" href="class_qwt_plot_zoomer.html#abded662ecb3555b3a29cf3daacf79de">00442</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#abded662ecb3555b3a29cf3daacf79de">QwtPlotZoomer::widgetMouseReleaseEvent</a>(QMouseEvent *me)
294
<a name="l00443"></a>00443 {
295
<a name="l00444"></a>00444 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#d03614cbb9812890e0b3486dafff8bd9">mouseMatch</a>(MouseSelect2, me) )
296
<a name="l00445"></a>00445 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(0);
297
<a name="l00446"></a>00446 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#d03614cbb9812890e0b3486dafff8bd9">mouseMatch</a>(MouseSelect3, me) )
298
<a name="l00447"></a>00447 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(-1);
299
<a name="l00448"></a>00448 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#d03614cbb9812890e0b3486dafff8bd9">mouseMatch</a>(MouseSelect6, me) )
300
<a name="l00449"></a>00449 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(+1);
301
<a name="l00450"></a>00450 <span class="keywordflow">else</span>
302
<a name="l00451"></a>00451 <a class="code" href="class_qwt_picker.html#c009633e005b6290e07b902f2a58e45e">QwtPlotPicker::widgetMouseReleaseEvent</a>(me);
303
<a name="l00452"></a>00452 }
304
<a name="l00453"></a>00453
305
<a name="l00465"></a><a class="code" href="class_qwt_plot_zoomer.html#a44e42dcf37547a6b93d04a593f140c6">00465</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a44e42dcf37547a6b93d04a593f140c6">QwtPlotZoomer::widgetKeyPressEvent</a>(QKeyEvent *ke)
306
<a name="l00466"></a>00466 {
307
<a name="l00467"></a>00467 <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_picker.html#9ee030f985edfa20d0f896534b9b611b">isActive</a>() )
308
<a name="l00468"></a>00468 {
309
<a name="l00469"></a>00469 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#5c7cb6016d605bbac56b9c47c698be8a">keyMatch</a>(KeyUndo, ke) )
310
<a name="l00470"></a>00470 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(-1);
311
<a name="l00471"></a>00471 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#5c7cb6016d605bbac56b9c47c698be8a">keyMatch</a>(KeyRedo, ke) )
312
<a name="l00472"></a>00472 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(+1);
313
<a name="l00473"></a>00473 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#5c7cb6016d605bbac56b9c47c698be8a">keyMatch</a>(KeyHome, ke) )
314
<a name="l00474"></a>00474 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(0);
315
<a name="l00475"></a>00475 }
316
<a name="l00476"></a>00476
317
<a name="l00477"></a>00477 <a class="code" href="class_qwt_picker.html#f5bc441b2fc143363563922a3b3c70ae">QwtPlotPicker::widgetKeyPressEvent</a>(ke);
318
<a name="l00478"></a>00478 }
319
<a name="l00479"></a>00479
320
<a name="l00488"></a><a class="code" href="class_qwt_plot_zoomer.html#c66b3eac03db212812198637f4e233ca">00488</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#c66b3eac03db212812198637f4e233ca">QwtPlotZoomer::moveBy</a>(<span class="keywordtype">double</span> dx, <span class="keywordtype">double</span> dy)
321
<a name="l00489"></a>00489 {
322
<a name="l00490"></a>00490 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> &rect = d_data->zoomStack[d_data->zoomRectIndex];
323
<a name="l00491"></a>00491 <a class="code" href="class_qwt_plot_zoomer.html#6bfbb67129b1220df65685858c9d882c">move</a>(rect.left() + dx, rect.top() + dy);
324
<a name="l00492"></a>00492 }
325
<a name="l00493"></a>00493
326
<a name="l00503"></a><a class="code" href="class_qwt_plot_zoomer.html#6bfbb67129b1220df65685858c9d882c">00503</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#6bfbb67129b1220df65685858c9d882c">QwtPlotZoomer::move</a>(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y)
327
<a name="l00504"></a>00504 {
328
<a name="l00505"></a>00505 <span class="keywordflow">if</span> ( x < <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().left() )
329
<a name="l00506"></a>00506 x = <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().left();
330
<a name="l00507"></a>00507 <span class="keywordflow">if</span> ( x > <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().right() - <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>().width() )
331
<a name="l00508"></a>00508 x = <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().right() - <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>().width();
332
<a name="l00509"></a>00509
333
<a name="l00510"></a>00510 <span class="keywordflow">if</span> ( y < <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().top() )
334
<a name="l00511"></a>00511 y = <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().top();
335
<a name="l00512"></a>00512 <span class="keywordflow">if</span> ( y > <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().bottom() - <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>().height() )
336
<a name="l00513"></a>00513 y = <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().bottom() - <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>().height();
337
<a name="l00514"></a>00514
338
<a name="l00515"></a>00515 <span class="keywordflow">if</span> ( x != <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>().left() || y != <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a>().top() )
339
<a name="l00516"></a>00516 {
340
<a name="l00517"></a>00517 d_data->zoomStack[d_data->zoomRectIndex].moveTo(x, y);
341
<a name="l00518"></a>00518 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();
342
<a name="l00519"></a>00519 }
343
<a name="l00520"></a>00520 }
344
<a name="l00521"></a>00521
345
<a name="l00533"></a><a class="code" href="class_qwt_plot_zoomer.html#86898c6696ee0706a3ac6b61018a112e">00533</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_zoomer.html#86898c6696ee0706a3ac6b61018a112e">QwtPlotZoomer::accept</a>(QwtPolygon &pa)<span class="keyword"> const</span>
346
<a name="l00534"></a>00534 <span class="keyword"></span>{
347
<a name="l00535"></a>00535 <span class="keywordflow">if</span> ( pa.count() < 2 )
348
<a name="l00536"></a>00536 <span class="keywordflow">return</span> <span class="keyword">false</span>;
349
<a name="l00537"></a>00537
350
<a name="l00538"></a>00538 QRect rect = QRect(pa[0], pa[<span class="keywordtype">int</span>(pa.count()) - 1]);
351
<a name="l00539"></a>00539 <span class="preprocessor">#if QT_VERSION < 0x040000</span>
352
<a name="l00540"></a>00540 <span class="preprocessor"></span> rect = rect.normalize();
353
<a name="l00541"></a>00541 <span class="preprocessor">#else</span>
354
<a name="l00542"></a>00542 <span class="preprocessor"></span> rect = rect.normalized();
355
<a name="l00543"></a>00543 <span class="preprocessor">#endif</span>
356
<a name="l00544"></a>00544 <span class="preprocessor"></span>
357
<a name="l00545"></a>00545 <span class="keyword">const</span> <span class="keywordtype">int</span> minSize = 2;
358
<a name="l00546"></a>00546 <span class="keywordflow">if</span> (rect.width() < minSize && rect.height() < minSize )
359
<a name="l00547"></a>00547 <span class="keywordflow">return</span> <span class="keyword">false</span>;
360
<a name="l00548"></a>00548
361
<a name="l00549"></a>00549 <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_zoomer.html#27bb8d7911ef686f2a66bbc88df7e8d1">minZoomSize</a> = 11;
362
<a name="l00550"></a>00550
363
<a name="l00551"></a>00551 <span class="keyword">const</span> QPoint center = rect.center();
364
<a name="l00552"></a>00552 rect.setSize(rect.size().expandedTo(QSize(minZoomSize, minZoomSize)));
365
<a name="l00553"></a>00553 rect.moveCenter(center);
366
<a name="l00554"></a>00554
367
<a name="l00555"></a>00555 pa.resize(2);
368
<a name="l00556"></a>00556 pa[0] = rect.topLeft();
369
<a name="l00557"></a>00557 pa[1] = rect.bottomRight();
370
<a name="l00558"></a>00558
371
<a name="l00559"></a>00559 <span class="keywordflow">return</span> <span class="keyword">true</span>;
372
<a name="l00560"></a>00560 }
373
<a name="l00561"></a>00561
374
<a name="l00567"></a><a class="code" href="class_qwt_plot_zoomer.html#27bb8d7911ef686f2a66bbc88df7e8d1">00567</a> <a class="code" href="qwt__double__rect_8h.html#b86c0b8b4728646331f12743013c5b43">QwtDoubleSize</a> <a class="code" href="class_qwt_plot_zoomer.html#27bb8d7911ef686f2a66bbc88df7e8d1">QwtPlotZoomer::minZoomSize</a>()<span class="keyword"> const</span>
375
<a name="l00568"></a>00568 <span class="keyword"></span>{
376
<a name="l00569"></a>00569 <span class="keywordflow">return</span> <a class="code" href="qwt__double__rect_8h.html#b86c0b8b4728646331f12743013c5b43">QwtDoubleSize</a>(
377
<a name="l00570"></a>00570 d_data->zoomStack[0].width() / 10e4,
378
<a name="l00571"></a>00571 d_data->zoomStack[0].height() / 10e4
379
<a name="l00572"></a>00572 );
380
<a name="l00573"></a>00573 }
381
<a name="l00574"></a>00574
382
<a name="l00581"></a><a class="code" href="class_qwt_plot_zoomer.html#a54bb05797c0468c0f8de4217dce24dd">00581</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a54bb05797c0468c0f8de4217dce24dd">QwtPlotZoomer::begin</a>()
383
<a name="l00582"></a>00582 {
384
<a name="l00583"></a>00583 <span class="keywordflow">if</span> ( d_data->maxStackDepth >= 0 )
385
<a name="l00584"></a>00584 {
386
<a name="l00585"></a>00585 <span class="keywordflow">if</span> ( d_data->zoomRectIndex >= uint(d_data->maxStackDepth) )
387
<a name="l00586"></a>00586 <span class="keywordflow">return</span>;
388
<a name="l00587"></a>00587 }
389
<a name="l00588"></a>00588
390
<a name="l00589"></a>00589 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#b86c0b8b4728646331f12743013c5b43">QwtDoubleSize</a> minSize = <a class="code" href="class_qwt_plot_zoomer.html#27bb8d7911ef686f2a66bbc88df7e8d1">minZoomSize</a>();
391
<a name="l00590"></a>00590 <span class="keywordflow">if</span> ( minSize.isValid() )
392
<a name="l00591"></a>00591 {
393
<a name="l00592"></a>00592 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#b86c0b8b4728646331f12743013c5b43">QwtDoubleSize</a> sz =
394
<a name="l00593"></a>00593 d_data->zoomStack[d_data->zoomRectIndex].size() * 0.9999;
395
<a name="l00594"></a>00594
396
<a name="l00595"></a>00595 <span class="keywordflow">if</span> ( minSize.width() >= sz.width() &&
397
<a name="l00596"></a>00596 minSize.height() >= sz.height() )
398
<a name="l00597"></a>00597 {
399
<a name="l00598"></a>00598 <span class="keywordflow">return</span>;
400
<a name="l00599"></a>00599 }
401
<a name="l00600"></a>00600 }
402
<a name="l00601"></a>00601
403
<a name="l00602"></a>00602 <a class="code" href="class_qwt_picker.html#49cb19aea451e275c5d376235e5a1d83">QwtPlotPicker::begin</a>();
404
<a name="l00603"></a>00603 }
405
<a name="l00604"></a>00604
406
<a name="l00611"></a><a class="code" href="class_qwt_plot_zoomer.html#c7d10eb27858ccfebebecab5d69ecbb3">00611</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_zoomer.html#c7d10eb27858ccfebebecab5d69ecbb3">QwtPlotZoomer::end</a>(<span class="keywordtype">bool</span> ok)
407
<a name="l00612"></a>00612 {
408
<a name="l00613"></a>00613 ok = <a class="code" href="class_qwt_plot_picker.html#9fceb663542b6f9b0a358e9419406423">QwtPlotPicker::end</a>(ok);
409
<a name="l00614"></a>00614 <span class="keywordflow">if</span> (!ok)
410
<a name="l00615"></a>00615 <span class="keywordflow">return</span> <span class="keyword">false</span>;
411
<a name="l00616"></a>00616
412
<a name="l00617"></a>00617 <a class="code" href="class_qwt_plot.html">QwtPlot</a> *<a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a> = <a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">QwtPlotZoomer::plot</a>();
413
<a name="l00618"></a>00618 <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a> )
414
<a name="l00619"></a>00619 <span class="keywordflow">return</span> <span class="keyword">false</span>;
415
<a name="l00620"></a>00620
416
<a name="l00621"></a>00621 <span class="keyword">const</span> QwtPolygon &pa = <a class="code" href="class_qwt_picker.html#ffd1873073e70397661bb23ad8f43457">selection</a>();
417
<a name="l00622"></a>00622 <span class="keywordflow">if</span> ( pa.count() < 2 )
418
<a name="l00623"></a>00623 <span class="keywordflow">return</span> <span class="keyword">false</span>;
419
<a name="l00624"></a>00624
420
<a name="l00625"></a>00625 QRect rect = QRect(pa[0], pa[<span class="keywordtype">int</span>(pa.count() - 1)]);
421
<a name="l00626"></a>00626 <span class="preprocessor">#if QT_VERSION < 0x040000</span>
422
<a name="l00627"></a>00627 <span class="preprocessor"></span> rect = rect.normalize();
423
<a name="l00628"></a>00628 <span class="preprocessor">#else</span>
424
<a name="l00629"></a>00629 <span class="preprocessor"></span> rect = rect.normalized();
425
<a name="l00630"></a>00630 <span class="preprocessor">#endif</span>
426
<a name="l00631"></a>00631 <span class="preprocessor"></span>
427
<a name="l00632"></a>00632
428
<a name="l00633"></a>00633 <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> <a class="code" href="class_qwt_plot_zoomer.html#261d13f67af6e02ba48a64b36f7b5aef">zoomRect</a> = <a class="code" href="class_qwt_plot_picker.html#fed4c21c2c9d7a3bf1d7a722b78b6264">invTransform</a>(rect).normalized();
429
<a name="l00634"></a>00634
430
<a name="l00635"></a>00635 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#5fdf5abc59b6e6cee5c11d355906927a">QwtDoublePoint</a> center = zoomRect.center();
431
<a name="l00636"></a>00636 zoomRect.setSize(zoomRect.size().expandedTo(<a class="code" href="class_qwt_plot_zoomer.html#27bb8d7911ef686f2a66bbc88df7e8d1">minZoomSize</a>()));
432
<a name="l00637"></a>00637 zoomRect.moveCenter(center);
433
<a name="l00638"></a>00638
434
<a name="l00639"></a>00639 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(zoomRect);
435
<a name="l00640"></a>00640
436
<a name="l00641"></a>00641 <span class="keywordflow">return</span> <span class="keyword">true</span>;
437
<a name="l00642"></a>00642 }
438
<a name="l00643"></a>00643
439
<a name="l00655"></a><a class="code" href="class_qwt_plot_zoomer.html#c9d52dbddc9e79e7ce8ebd545e855e89">00655</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#c9d52dbddc9e79e7ce8ebd545e855e89">QwtPlotZoomer::setSelectionFlags</a>(<span class="keywordtype">int</span> flags)
440
<a name="l00656"></a>00656 {
441
<a name="l00657"></a>00657 <span class="comment">// we accept only rects</span>
442
<a name="l00658"></a>00658 flags &= ~(PointSelection | PolygonSelection);
443
<a name="l00659"></a>00659 flags |= RectSelection;
444
<a name="l00660"></a>00660
445
<a name="l00661"></a>00661 <a class="code" href="class_qwt_picker.html#e93fe995c8c581ac33a9f3445ea5e7b9">QwtPlotPicker::setSelectionFlags</a>(flags);
446
<a name="l00662"></a>00662 }
447
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sat May 24 18:47:40 2008 for Qwt User's Guide by
448
<a href="http://www.doxygen.org/index.html">
449
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.0 </small></address>