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() )
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> ( d_data->maxStackDepth >= 0 &&
233
<a name="l00359"></a>00359 <span class="keywordtype">int</span>(zoomStack.count()) > d_data->maxStackDepth )
234
<a name="l00360"></a>00360 {
235
<a name="l00361"></a>00361 <span class="keywordflow">return</span>;
236
<a name="l00362"></a>00362 }
237
<a name="l00363"></a>00363
238
<a name="l00364"></a>00364 <span class="keywordflow">if</span> ( zoomRectIndex < 0 || zoomRectIndex > <span class="keywordtype">int</span>(zoomStack.count()) )
239
<a name="l00365"></a>00365 zoomRectIndex = zoomStack.count() - 1;
240
<a name="l00366"></a>00366
241
<a name="l00367"></a>00367 <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>();
242
<a name="l00368"></a>00368
243
<a name="l00369"></a>00369 d_data->zoomStack = zoomStack;
244
<a name="l00370"></a>00370 d_data->zoomRectIndex = uint(zoomRectIndex);
245
<a name="l00371"></a>00371
246
<a name="l00372"></a>00372 <span class="keywordflow">if</span> ( doRescale )
247
<a name="l00373"></a>00373 {
248
<a name="l00374"></a>00374 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();
249
<a name="l00375"></a>00375 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>());
250
<a name="l00376"></a>00376 }
251
<a name="l00377"></a>00377 }
252
<a name="l00378"></a>00378
253
<a name="l00385"></a><a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">00385</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">QwtPlotZoomer::rescale</a>()
254
<a name="l00386"></a>00386 {
255
<a name="l00387"></a>00387 <a class="code" href="class_qwt_plot.html">QwtPlot</a> *plt = <a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a>();
256
<a name="l00388"></a>00388 <span class="keywordflow">if</span> ( !plt )
257
<a name="l00389"></a>00389 <span class="keywordflow">return</span>;
258
<a name="l00390"></a>00390
259
<a name="l00391"></a>00391 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> &rect = d_data->zoomStack[d_data->zoomRectIndex];
260
<a name="l00392"></a>00392 <span class="keywordflow">if</span> ( rect != <a class="code" href="class_qwt_plot_picker.html#96e73f28d02d49cb80ff2d3b607fccc5">scaleRect</a>() )
261
<a name="l00393"></a>00393 {
262
<a name="l00394"></a>00394 <span class="keyword">const</span> <span class="keywordtype">bool</span> doReplot = plt-><a class="code" href="class_qwt_plot.html#3a639850b65bc4dbf22b3f3170d61804">autoReplot</a>();
263
<a name="l00395"></a>00395 plt-><a class="code" href="class_qwt_plot.html#654934ec2ad167101dacb5174f5172d6">setAutoReplot</a>(<span class="keyword">false</span>);
264
<a name="l00396"></a>00396
265
<a name="l00397"></a>00397 <span class="keywordtype">double</span> x1 = rect.left();
266
<a name="l00398"></a>00398 <span class="keywordtype">double</span> x2 = rect.right();
267
<a name="l00399"></a>00399 <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>() >
268
<a name="l00400"></a>00400 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>() )
269
<a name="l00401"></a>00401 {
270
<a name="l00402"></a>00402 qSwap(x1, x2);
271
<a name="l00403"></a>00403 }
272
<a name="l00404"></a>00404
273
<a name="l00405"></a>00405 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);
274
<a name="l00406"></a>00406
275
<a name="l00407"></a>00407 <span class="keywordtype">double</span> y1 = rect.top();
276
<a name="l00408"></a>00408 <span class="keywordtype">double</span> y2 = rect.bottom();
277
<a name="l00409"></a>00409 <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>() >
278
<a name="l00410"></a>00410 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>() )
279
<a name="l00411"></a>00411 {
280
<a name="l00412"></a>00412 qSwap(y1, y2);
281
<a name="l00413"></a>00413 }
282
<a name="l00414"></a>00414 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);
283
<a name="l00415"></a>00415
284
<a name="l00416"></a>00416 plt-><a class="code" href="class_qwt_plot.html#654934ec2ad167101dacb5174f5172d6">setAutoReplot</a>(doReplot);
285
<a name="l00417"></a>00417
286
<a name="l00418"></a>00418 plt-><a class="code" href="class_qwt_plot.html#7b094e29b8e92b00e36517d0d7633c4b">replot</a>();
287
<a name="l00419"></a>00419 }
288
<a name="l00420"></a>00420 }
289
<a name="l00421"></a>00421
290
<a name="l00429"></a><a class="code" href="class_qwt_plot_zoomer.html#6cb755e06b83e50e8353dd706f7fb6f0">00429</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)
291
<a name="l00430"></a>00430 {
292
<a name="l00431"></a>00431 <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>() )
293
<a name="l00432"></a>00432 {
294
<a name="l00433"></a>00433 <a class="code" href="class_qwt_plot_picker.html#a901c86543585c7056133a5cb6652e3d">QwtPlotPicker::setAxis</a>(xAxis, yAxis);
295
<a name="l00434"></a>00434 <a class="code" href="class_qwt_plot_zoomer.html#7ee4f2a0606df6e85258c52f0b5c7bc2">setZoomBase</a>(<a class="code" href="class_qwt_plot_picker.html#96e73f28d02d49cb80ff2d3b607fccc5">scaleRect</a>());
296
<a name="l00435"></a>00435 }
297
<a name="l00436"></a>00436 }
298
<a name="l00437"></a>00437
299
<a name="l00448"></a><a class="code" href="class_qwt_plot_zoomer.html#abded662ecb3555b3a29cf3daacf79de">00448</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#abded662ecb3555b3a29cf3daacf79de">QwtPlotZoomer::widgetMouseReleaseEvent</a>(QMouseEvent *me)
300
<a name="l00449"></a>00449 {
301
<a name="l00450"></a>00450 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#d03614cbb9812890e0b3486dafff8bd9">mouseMatch</a>(MouseSelect2, me) )
302
<a name="l00451"></a>00451 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(0);
303
<a name="l00452"></a>00452 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#d03614cbb9812890e0b3486dafff8bd9">mouseMatch</a>(MouseSelect3, me) )
304
<a name="l00453"></a>00453 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(-1);
305
<a name="l00454"></a>00454 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#d03614cbb9812890e0b3486dafff8bd9">mouseMatch</a>(MouseSelect6, me) )
306
<a name="l00455"></a>00455 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(+1);
307
<a name="l00456"></a>00456 <span class="keywordflow">else</span>
308
<a name="l00457"></a>00457 <a class="code" href="class_qwt_picker.html#c009633e005b6290e07b902f2a58e45e">QwtPlotPicker::widgetMouseReleaseEvent</a>(me);
309
<a name="l00458"></a>00458 }
310
<a name="l00459"></a>00459
311
<a name="l00471"></a><a class="code" href="class_qwt_plot_zoomer.html#a44e42dcf37547a6b93d04a593f140c6">00471</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a44e42dcf37547a6b93d04a593f140c6">QwtPlotZoomer::widgetKeyPressEvent</a>(QKeyEvent *ke)
312
<a name="l00472"></a>00472 {
313
<a name="l00473"></a>00473 <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_picker.html#9ee030f985edfa20d0f896534b9b611b">isActive</a>() )
314
<a name="l00474"></a>00474 {
315
<a name="l00475"></a>00475 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#5c7cb6016d605bbac56b9c47c698be8a">keyMatch</a>(KeyUndo, ke) )
316
<a name="l00476"></a>00476 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(-1);
317
<a name="l00477"></a>00477 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#5c7cb6016d605bbac56b9c47c698be8a">keyMatch</a>(KeyRedo, ke) )
318
<a name="l00478"></a>00478 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(+1);
319
<a name="l00479"></a>00479 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#5c7cb6016d605bbac56b9c47c698be8a">keyMatch</a>(KeyHome, ke) )
320
<a name="l00480"></a>00480 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(0);
321
<a name="l00481"></a>00481 }
322
<a name="l00482"></a>00482
323
<a name="l00483"></a>00483 <a class="code" href="class_qwt_picker.html#f5bc441b2fc143363563922a3b3c70ae">QwtPlotPicker::widgetKeyPressEvent</a>(ke);
324
<a name="l00484"></a>00484 }
325
<a name="l00485"></a>00485
326
<a name="l00494"></a><a class="code" href="class_qwt_plot_zoomer.html#c66b3eac03db212812198637f4e233ca">00494</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)
327
<a name="l00495"></a>00495 {
328
<a name="l00496"></a>00496 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#0c0dc4d33592fac4ad94734d8e9c4152">QwtDoubleRect</a> &rect = d_data->zoomStack[d_data->zoomRectIndex];
329
<a name="l00497"></a>00497 <a class="code" href="class_qwt_plot_zoomer.html#6bfbb67129b1220df65685858c9d882c">move</a>(rect.left() + dx, rect.top() + dy);
330
<a name="l00498"></a>00498 }
331
<a name="l00499"></a>00499
332
<a name="l00509"></a><a class="code" href="class_qwt_plot_zoomer.html#6bfbb67129b1220df65685858c9d882c">00509</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)
333
<a name="l00510"></a>00510 {
334
<a name="l00511"></a>00511 <span class="keywordflow">if</span> ( x < <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().left() )
335
<a name="l00512"></a>00512 x = <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().left();
336
<a name="l00513"></a>00513 <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() )
337
<a name="l00514"></a>00514 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();
338
<a name="l00515"></a>00515
339
<a name="l00516"></a>00516 <span class="keywordflow">if</span> ( y < <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().top() )
340
<a name="l00517"></a>00517 y = <a class="code" href="class_qwt_plot_zoomer.html#dee8a101b06a37ec778038c789518e28">zoomBase</a>().top();
341
<a name="l00518"></a>00518 <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() )
342
<a name="l00519"></a>00519 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();
343
<a name="l00520"></a>00520
344
<a name="l00521"></a>00521 <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() )
345
<a name="l00522"></a>00522 {
346
<a name="l00523"></a>00523 d_data->zoomStack[d_data->zoomRectIndex].moveTo(x, y);
347
<a name="l00524"></a>00524 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();
348
<a name="l00525"></a>00525 }
349
<a name="l00526"></a>00526 }
350
<a name="l00527"></a>00527
351
<a name="l00539"></a><a class="code" href="class_qwt_plot_zoomer.html#86898c6696ee0706a3ac6b61018a112e">00539</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>
352
<a name="l00540"></a>00540 <span class="keyword"></span>{
353
<a name="l00541"></a>00541 <span class="keywordflow">if</span> ( pa.count() < 2 )
354
<a name="l00542"></a>00542 <span class="keywordflow">return</span> <span class="keyword">false</span>;
355
<a name="l00543"></a>00543
356
<a name="l00544"></a>00544 QRect rect = QRect(pa[0], pa[<span class="keywordtype">int</span>(pa.count()) - 1]);
357
<a name="l00545"></a>00545 <span class="preprocessor">#if QT_VERSION < 0x040000</span>
358
<a name="l00546"></a>00546 <span class="preprocessor"></span> rect = rect.normalize();
359
<a name="l00547"></a>00547 <span class="preprocessor">#else</span>
360
<a name="l00548"></a>00548 <span class="preprocessor"></span> rect = rect.normalized();
361
<a name="l00549"></a>00549 <span class="preprocessor">#endif</span>
362
<a name="l00550"></a>00550 <span class="preprocessor"></span>
363
<a name="l00551"></a>00551 <span class="keyword">const</span> <span class="keywordtype">int</span> minSize = 2;
364
<a name="l00552"></a>00552 <span class="keywordflow">if</span> (rect.width() < minSize && rect.height() < minSize )
365
<a name="l00553"></a>00553 <span class="keywordflow">return</span> <span class="keyword">false</span>;
366
<a name="l00554"></a>00554
367
<a name="l00555"></a>00555 <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_zoomer.html#27bb8d7911ef686f2a66bbc88df7e8d1">minZoomSize</a> = 11;
368
<a name="l00556"></a>00556
369
<a name="l00557"></a>00557 <span class="keyword">const</span> QPoint center = rect.center();
370
<a name="l00558"></a>00558 rect.setSize(rect.size().expandedTo(QSize(minZoomSize, minZoomSize)));
371
<a name="l00559"></a>00559 rect.moveCenter(center);
372
<a name="l00560"></a>00560
373
<a name="l00561"></a>00561 pa.resize(2);
374
<a name="l00562"></a>00562 pa[0] = rect.topLeft();
375
<a name="l00563"></a>00563 pa[1] = rect.bottomRight();
376
<a name="l00564"></a>00564
377
<a name="l00565"></a>00565 <span class="keywordflow">return</span> <span class="keyword">true</span>;
378
<a name="l00566"></a>00566 }
379
<a name="l00567"></a>00567
380
<a name="l00573"></a><a class="code" href="class_qwt_plot_zoomer.html#27bb8d7911ef686f2a66bbc88df7e8d1">00573</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>
381
<a name="l00574"></a>00574 <span class="keyword"></span>{
382
<a name="l00575"></a>00575 <span class="keywordflow">return</span> <a class="code" href="qwt__double__rect_8h.html#b86c0b8b4728646331f12743013c5b43">QwtDoubleSize</a>(
383
<a name="l00576"></a>00576 d_data->zoomStack[0].width() / 10e4,
384
<a name="l00577"></a>00577 d_data->zoomStack[0].height() / 10e4
385
<a name="l00578"></a>00578 );
386
<a name="l00579"></a>00579 }
387
<a name="l00580"></a>00580
388
<a name="l00587"></a><a class="code" href="class_qwt_plot_zoomer.html#a54bb05797c0468c0f8de4217dce24dd">00587</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a54bb05797c0468c0f8de4217dce24dd">QwtPlotZoomer::begin</a>()
389
<a name="l00588"></a>00588 {
390
<a name="l00589"></a>00589 <span class="keywordflow">if</span> ( d_data->maxStackDepth >= 0 )
391
<a name="l00590"></a>00590 {
392
<a name="l00591"></a>00591 <span class="keywordflow">if</span> ( d_data->zoomRectIndex >= uint(d_data->maxStackDepth) )
393
<a name="l00592"></a>00592 <span class="keywordflow">return</span>;
394
<a name="l00593"></a>00593 }
395
<a name="l00594"></a>00594
396
<a name="l00595"></a>00595 <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>();
397
<a name="l00596"></a>00596 <span class="keywordflow">if</span> ( minSize.isValid() )
398
<a name="l00597"></a>00597 {
399
<a name="l00598"></a>00598 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#b86c0b8b4728646331f12743013c5b43">QwtDoubleSize</a> sz =
400
<a name="l00599"></a>00599 d_data->zoomStack[d_data->zoomRectIndex].size() * 0.9999;
401
<a name="l00600"></a>00600
402
<a name="l00601"></a>00601 <span class="keywordflow">if</span> ( minSize.width() >= sz.width() &&
403
<a name="l00602"></a>00602 minSize.height() >= sz.height() )
404
<a name="l00603"></a>00603 {
405
<a name="l00604"></a>00604 <span class="keywordflow">return</span>;
406
<a name="l00605"></a>00605 }
407
<a name="l00606"></a>00606 }
408
<a name="l00607"></a>00607
409
<a name="l00608"></a>00608 <a class="code" href="class_qwt_picker.html#49cb19aea451e275c5d376235e5a1d83">QwtPlotPicker::begin</a>();
410
<a name="l00609"></a>00609 }
411
<a name="l00610"></a>00610
412
<a name="l00617"></a><a class="code" href="class_qwt_plot_zoomer.html#c7d10eb27858ccfebebecab5d69ecbb3">00617</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)
413
<a name="l00618"></a>00618 {
414
<a name="l00619"></a>00619 ok = <a class="code" href="class_qwt_plot_picker.html#9fceb663542b6f9b0a358e9419406423">QwtPlotPicker::end</a>(ok);
415
<a name="l00620"></a>00620 <span class="keywordflow">if</span> (!ok)
416
<a name="l00621"></a>00621 <span class="keywordflow">return</span> <span class="keyword">false</span>;
417
<a name="l00622"></a>00622
418
<a name="l00623"></a>00623 <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>();
419
<a name="l00624"></a>00624 <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a> )
420
<a name="l00625"></a>00625 <span class="keywordflow">return</span> <span class="keyword">false</span>;
421
<a name="l00626"></a>00626
422
<a name="l00627"></a>00627 <span class="keyword">const</span> QwtPolygon &pa = <a class="code" href="class_qwt_picker.html#ffd1873073e70397661bb23ad8f43457">selection</a>();
423
<a name="l00628"></a>00628 <span class="keywordflow">if</span> ( pa.count() < 2 )
424
<a name="l00629"></a>00629 <span class="keywordflow">return</span> <span class="keyword">false</span>;
425
<a name="l00630"></a>00630
426
<a name="l00631"></a>00631 QRect rect = QRect(pa[0], pa[<span class="keywordtype">int</span>(pa.count() - 1)]);
427
<a name="l00632"></a>00632 <span class="preprocessor">#if QT_VERSION < 0x040000</span>
428
<a name="l00633"></a>00633 <span class="preprocessor"></span> rect = rect.normalize();
429
<a name="l00634"></a>00634 <span class="preprocessor">#else</span>
430
<a name="l00635"></a>00635 <span class="preprocessor"></span> rect = rect.normalized();
431
<a name="l00636"></a>00636 <span class="preprocessor">#endif</span>
432
<a name="l00637"></a>00637 <span class="preprocessor"></span>
433
<a name="l00638"></a>00638
434
<a name="l00639"></a>00639 <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();
435
<a name="l00640"></a>00640
436
<a name="l00641"></a>00641 <span class="keyword">const</span> <a class="code" href="qwt__double__rect_8h.html#5fdf5abc59b6e6cee5c11d355906927a">QwtDoublePoint</a> center = zoomRect.center();
437
<a name="l00642"></a>00642 zoomRect.setSize(zoomRect.size().expandedTo(<a class="code" href="class_qwt_plot_zoomer.html#27bb8d7911ef686f2a66bbc88df7e8d1">minZoomSize</a>()));
438
<a name="l00643"></a>00643 zoomRect.moveCenter(center);
439
<a name="l00644"></a>00644
440
<a name="l00645"></a>00645 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(zoomRect);
441
<a name="l00646"></a>00646
442
<a name="l00647"></a>00647 <span class="keywordflow">return</span> <span class="keyword">true</span>;
443
<a name="l00648"></a>00648 }
444
<a name="l00649"></a>00649
445
<a name="l00661"></a><a class="code" href="class_qwt_plot_zoomer.html#c9d52dbddc9e79e7ce8ebd545e855e89">00661</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)
446
<a name="l00662"></a>00662 {
447
<a name="l00663"></a>00663 <span class="comment">// we accept only rects</span>
448
<a name="l00664"></a>00664 flags &= ~(PointSelection | PolygonSelection);
449
<a name="l00665"></a>00665 flags |= RectSelection;
450
<a name="l00666"></a>00666
451
<a name="l00667"></a>00667 <a class="code" href="class_qwt_picker.html#e93fe995c8c581ac33a9f3445ea5e7b9">QwtPlotPicker::setSelectionFlags</a>(flags);
452
<a name="l00668"></a>00668 }
453
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Sun Mar 22 16:54:08 2009 for Qwt User's Guide by
454
<a href="http://www.doxygen.org/index.html">
455
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.0 </small></address>