1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>Qwt User's Guide: qwt_plot_zoomer.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.8 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>qwt_plot_zoomer.cpp</h1><pre class="fragment"><div>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
00002 <span class="comment"> * Qwt Widget Library</span>
00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span>
00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span>
00005 <span class="comment"> *</span>
00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
00008 <span class="comment"> *****************************************************************************/</span>
00009
00010 <span class="comment">// vim: expandtab</span>
00011
00012 <span class="preprocessor">#include <math.h></span>
00013 <span class="preprocessor">#include "qwt_plot.h"</span>
00014 <span class="preprocessor">#include "qwt_plot_canvas.h"</span>
00015 <span class="preprocessor">#include "qwt_plot_zoomer.h"</span>
00016
<a name="l00040"></a><a class="code" href="class_qwt_plot_zoomer.html#a0">00040</a> <a class="code" href="class_qwt_plot_zoomer.html#a0">QwtPlotZoomer::QwtPlotZoomer</a>(<a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *canvas, <span class="keyword">const</span> <span class="keywordtype">char</span> *name):
00041 <a class="code" href="class_qwt_plot_picker.html">QwtPlotPicker</a>(canvas, name)
00042 {
00043 <span class="keywordflow">if</span> ( canvas )
00044 init();
00045 }
00046
<a name="l00068"></a><a class="code" href="class_qwt_plot_zoomer.html#a1">00068</a> <a class="code" href="class_qwt_plot_zoomer.html#a0">QwtPlotZoomer::QwtPlotZoomer</a>(<span class="keywordtype">int</span> xAxis, <span class="keywordtype">int</span> yAxis,
00069 <a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *canvas, <span class="keyword">const</span> <span class="keywordtype">char</span> *name):
00070 <a class="code" href="class_qwt_plot_picker.html">QwtPlotPicker</a>(xAxis, yAxis, canvas, name)
00071 {
00072 <span class="keywordflow">if</span> ( canvas )
00073 {
00074 init();
00075 }
00076 }
00077
<a name="l00102"></a><a class="code" href="class_qwt_plot_zoomer.html#a2">00102</a> <a class="code" href="class_qwt_plot_zoomer.html#a0">QwtPlotZoomer::QwtPlotZoomer</a>(<span class="keywordtype">int</span> xAxis, <span class="keywordtype">int</span> yAxis, <span class="keywordtype">int</span> selectionFlags,
00103 DisplayMode cursorLabelMode, <a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *canvas, <span class="keyword">const</span> <span class="keywordtype">char</span> *name):
00104 <a class="code" href="class_qwt_plot_picker.html">QwtPlotPicker</a>(xAxis, yAxis,canvas, name)
00105 {
00106 <span class="keywordflow">if</span> ( canvas )
00107 {
00108 init(selectionFlags, cursorLabelMode);
00109 }
00110 }
00111
00113 <span class="keywordtype">void</span> QwtPlotZoomer::init(<span class="keywordtype">int</span> selectionFlags, DisplayMode cursorLabelMode)
00114 {
00115 d_maxStackDepth = -1;
00116
00117 <a class="code" href="class_qwt_plot_zoomer.html#a12">setSelectionFlags</a>(selectionFlags);
00118 <a class="code" href="class_qwt_picker.html#a7">setCursorLabelMode</a>(cursorLabelMode);
00119 <a class="code" href="class_qwt_picker.html#a5">setRubberBand</a>(RectRubberBand);
00120
00121 <a class="code" href="class_qwt_plot_zoomer.html#a3">setZoomBase</a>(<a class="code" href="class_qwt_plot_picker.html#b0">scaleRect</a>());
00122 }
00123
<a name="l00135"></a><a class="code" href="class_qwt_plot_zoomer.html#a8">00135</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a8">QwtPlotZoomer::setMaxStackDepth</a>(<span class="keywordtype">int</span> depth)
00136 {
00137 d_maxStackDepth = depth;
00138
00139 <span class="keywordflow">if</span> ( depth >= 0 )
00140 {
00141 <span class="comment">// unzoom if the current depth is below d_maxStackDepth</span>
00142
00143 <span class="keyword">const</span> <span class="keywordtype">int</span> zoomOut =
00144 d_zoomStack.count() - 1 - depth; <span class="comment">// -1 for the zoom base</span>
00145
00146 <span class="keywordflow">if</span> ( zoomOut > 0 )
00147 {
00148 <a class="code" href="class_qwt_plot_zoomer.html#i2">zoom</a>(-zoomOut);
00149 <span class="keywordflow">for</span> ( uint i = d_zoomStack.count() - 1; i > d_zoomRectIndex; i-- )
00150 (<span class="keywordtype">void</span>)d_zoomStack.pop(); <span class="comment">// remove trailing rects</span>
00151 }
00152 }
00153 }
00154
<a name="l00159"></a><a class="code" href="class_qwt_plot_zoomer.html#a9">00159</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_zoomer.html#a9">QwtPlotZoomer::maxStackDepth</a>()<span class="keyword"> const</span>
00160 <span class="keyword"></span>{
00161 <span class="keywordflow">return</span> d_maxStackDepth;
00162 }
00163
<a name="l00168"></a><a class="code" href="class_qwt_plot_zoomer.html#a10">00168</a> <span class="keyword">const</span> QValueStack<QwtDoubleRect> &<a class="code" href="class_qwt_plot_zoomer.html#a10">QwtPlotZoomer::zoomStack</a>()<span class="keyword"> const</span>
00169 <span class="keyword"></span>{
00170 <span class="keywordflow">return</span> d_zoomStack;
00171 }
00172
<a name="l00177"></a><a class="code" href="class_qwt_plot_zoomer.html#b0">00177</a> QValueStack<QwtDoubleRect> &<a class="code" href="class_qwt_plot_zoomer.html#a10">QwtPlotZoomer::zoomStack</a>()
00178 {
00179 <span class="keywordflow">return</span> d_zoomStack;
00180 }
00181
<a name="l00186"></a><a class="code" href="class_qwt_plot_zoomer.html#a5">00186</a> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> <a class="code" href="class_qwt_plot_zoomer.html#a5">QwtPlotZoomer::zoomBase</a>()<span class="keyword"> const</span>
00187 <span class="keyword"></span>{
00188 <span class="keywordflow">return</span> d_zoomStack[0];
00189 }
00190
<a name="l00204"></a><a class="code" href="class_qwt_plot_zoomer.html#a3">00204</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a3">QwtPlotZoomer::setZoomBase</a>()
00205 {
00206 <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#a6">plot</a>();
00207 <span class="keywordflow">if</span> ( !plt )
00208 <span class="keywordflow">return</span>;
00209
00210 d_zoomStack.clear();
00211 d_zoomStack.push(<a class="code" href="class_qwt_plot_picker.html#b0">scaleRect</a>());
00212 d_zoomRectIndex = 0;
00213
00214 <a class="code" href="class_qwt_plot_zoomer.html#b1">rescale</a>();
00215 }
00216
<a name="l00227"></a><a class="code" href="class_qwt_plot_zoomer.html#a4">00227</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a3">QwtPlotZoomer::setZoomBase</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> &base)
00228 {
00229 <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#a6">plot</a>();
00230 <span class="keywordflow">if</span> ( !plt )
00231 <span class="keywordflow">return</span>;
00232
00233 <span class="keyword">const</span> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> sRect = <a class="code" href="class_qwt_plot_picker.html#b0">scaleRect</a>();
00234 <span class="keyword">const</span> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> bRect = base | sRect;
00235
00236 d_zoomStack.clear();
00237 d_zoomStack.push(bRect);
00238 d_zoomRectIndex = 0;
00239
00240 <span class="keywordflow">if</span> ( base != sRect )
00241 {
00242 d_zoomStack.push(sRect);
00243 d_zoomRectIndex++;
00244 }
00245
00246 <a class="code" href="class_qwt_plot_zoomer.html#b1">rescale</a>();
00247 }
00248
<a name="l00254"></a><a class="code" href="class_qwt_plot_zoomer.html#a6">00254</a> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> <a class="code" href="class_qwt_plot_zoomer.html#a6">QwtPlotZoomer::zoomRect</a>()<span class="keyword"> const</span>
00255 <span class="keyword"></span>{
00256 <span class="keywordflow">return</span> d_zoomStack[d_zoomRectIndex];
00257 }
00258
<a name="l00262"></a><a class="code" href="class_qwt_plot_zoomer.html#a11">00262</a> uint <a class="code" href="class_qwt_plot_zoomer.html#a11">QwtPlotZoomer::zoomRectIndex</a>()<span class="keyword"> const</span>
00263 <span class="keyword"></span>{
00264 <span class="keywordflow">return</span> d_zoomRectIndex;
00265 }
00266
<a name="l00277"></a><a class="code" href="class_qwt_plot_zoomer.html#i2">00277</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#i2">QwtPlotZoomer::zoom</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> &rect)
00278 {
00279 <span class="keywordflow">if</span> ( d_maxStackDepth >= 0 && int(d_zoomRectIndex) >= d_maxStackDepth )
00280 <span class="keywordflow">return</span>;
00281
00282 <span class="keyword">const</span> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> <a class="code" href="class_qwt_plot_zoomer.html#a6">zoomRect</a> = d_zoomStack[0] & rect.<a class="code" href="class_qwt_double_rect.html#a6">normalize</a>();
00283 <span class="keywordflow">if</span> ( zoomRect != d_zoomStack[d_zoomRectIndex] )
00284 {
00285 <span class="keywordflow">for</span> ( uint i = d_zoomStack.count() - 1; i > d_zoomRectIndex; i-- )
00286 (<span class="keywordtype">void</span>)d_zoomStack.pop();
00287
00288 d_zoomStack.push(zoomRect);
00289 d_zoomRectIndex++;
00290
00291 <a class="code" href="class_qwt_plot_zoomer.html#b1">rescale</a>();
00292 }
00293 }
00294
<a name="l00305"></a><a class="code" href="class_qwt_plot_zoomer.html#i3">00305</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#i2">QwtPlotZoomer::zoom</a>(<span class="keywordtype">int</span> offset)
00306 {
00307 <span class="keywordflow">if</span> ( offset == 0 )
00308 d_zoomRectIndex = 0;
00309 <span class="keywordflow">else</span>
00310 {
00311 <span class="keywordtype">int</span> newIndex = d_zoomRectIndex + offset;
00312 newIndex = QMAX(0, newIndex);
00313 newIndex = QMIN(<span class="keywordtype">int</span>(d_zoomStack.count() - 1), newIndex);
00314
00315 d_zoomRectIndex = uint(newIndex);
00316 }
00317
00318 <a class="code" href="class_qwt_plot_zoomer.html#b1">rescale</a>();
00319 }
00320
<a name="l00327"></a><a class="code" href="class_qwt_plot_zoomer.html#b1">00327</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#b1">QwtPlotZoomer::rescale</a>()
00328 {
00329 <a class="code" href="class_qwt_plot.html">QwtPlot</a> *plt = <a class="code" href="class_qwt_plot_picker.html#a6">plot</a>();
00330 <span class="keywordflow">if</span> ( !plt )
00331 <span class="keywordflow">return</span>;
00332
00333 <span class="keyword">const</span> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> &rect = d_zoomStack[d_zoomRectIndex];
00334 <span class="keywordflow">if</span> ( rect != <a class="code" href="class_qwt_plot_picker.html#b0">scaleRect</a>() )
00335 {
00336 plt-><a class="code" href="class_qwt_plot.html#a105">setAxisScale</a>(<a class="code" href="class_qwt_plot_picker.html#a4">xAxis</a>(), rect.<a class="code" href="class_qwt_double_rect.html#a7">x1</a>(), rect.<a class="code" href="class_qwt_double_rect.html#a8">x2</a>());
00337 plt-><a class="code" href="class_qwt_plot.html#a105">setAxisScale</a>(<a class="code" href="class_qwt_plot_picker.html#a5">yAxis</a>(), rect.<a class="code" href="class_qwt_double_rect.html#a9">y1</a>(), rect.<a class="code" href="class_qwt_double_rect.html#a10">y2</a>());
00338
00339 plt-><a class="code" href="class_qwt_plot.html#i5">replot</a>();
00340 }
00341 }
00342
<a name="l00350"></a><a class="code" href="class_qwt_plot_zoomer.html#a7">00350</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a7">QwtPlotZoomer::setAxis</a>(<span class="keywordtype">int</span> xAxis, <span class="keywordtype">int</span> yAxis)
00351 {
00352 <span class="keywordflow">if</span> ( xAxis != <a class="code" href="class_qwt_plot_picker.html#a4">QwtPlotPicker::xAxis</a>() || yAxis != <a class="code" href="class_qwt_plot_picker.html#a5">QwtPlotPicker::yAxis</a>() )
00353 {
00354 <a class="code" href="class_qwt_plot_picker.html#a3">QwtPlotPicker::setAxis</a>(xAxis, yAxis);
00355 <a class="code" href="class_qwt_plot_zoomer.html#a3">setZoomBase</a>(<a class="code" href="class_qwt_plot_picker.html#b0">scaleRect</a>());
00356 }
00357 }
00358
<a name="l00369"></a><a class="code" href="class_qwt_plot_zoomer.html#b3">00369</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#b3">QwtPlotZoomer::widgetMouseReleaseEvent</a>(QMouseEvent *me)
00370 {
00371 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#a12">mouseMatch</a>(MouseSelect2, me) )
00372 <a class="code" href="class_qwt_plot_zoomer.html#i2">zoom</a>(0);
00373 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#a12">mouseMatch</a>(MouseSelect3, me) )
00374 <a class="code" href="class_qwt_plot_zoomer.html#i2">zoom</a>(-1);
00375 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#a12">mouseMatch</a>(MouseSelect6, me) )
00376 <a class="code" href="class_qwt_plot_zoomer.html#i2">zoom</a>(+1);
00377 <span class="keywordflow">else</span>
00378 <a class="code" href="class_qwt_picker.html#b7">QwtPlotPicker::widgetMouseReleaseEvent</a>(me);
00379 }
00380
<a name="l00392"></a><a class="code" href="class_qwt_plot_zoomer.html#b4">00392</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#b4">QwtPlotZoomer::widgetKeyPressEvent</a>(QKeyEvent *ke)
00393 {
00394 <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_picker.html#a19">isActive</a>() )
00395 {
00396 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#a13">keyMatch</a>(KeyUndo, ke) )
00397 <a class="code" href="class_qwt_plot_zoomer.html#i2">zoom</a>(-1);
00398 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#a13">keyMatch</a>(KeyRedo, ke) )
00399 <a class="code" href="class_qwt_plot_zoomer.html#i2">zoom</a>(+1);
00400 <span class="keywordflow">else</span> <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_event_pattern.html#a13">keyMatch</a>(KeyHome, ke) )
00401 <a class="code" href="class_qwt_plot_zoomer.html#i2">zoom</a>(0);
00402 }
00403
00404 <a class="code" href="class_qwt_picker.html#b11">QwtPlotPicker::widgetKeyPressEvent</a>(ke);
00405 }
00406
<a name="l00415"></a><a class="code" href="class_qwt_plot_zoomer.html#i0">00415</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#i0">QwtPlotZoomer::moveBy</a>(<span class="keywordtype">double</span> dx, <span class="keywordtype">double</span> dy)
00416 {
00417 <span class="keyword">const</span> <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> &rect = d_zoomStack[d_zoomRectIndex];
00418 <a class="code" href="class_qwt_plot_zoomer.html#i1">move</a>(rect.<a class="code" href="class_qwt_double_rect.html#a7">x1</a>() + dx, rect.<a class="code" href="class_qwt_double_rect.html#a9">y1</a>() + dy);
00419 }
00420
<a name="l00430"></a><a class="code" href="class_qwt_plot_zoomer.html#i1">00430</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#i1">QwtPlotZoomer::move</a>(<span class="keywordtype">double</span> x, <span class="keywordtype">double</span> y)
00431 {
00432 x = QMAX(x, <a class="code" href="class_qwt_plot_zoomer.html#a5">zoomBase</a>().x1());
00433 x = QMIN(x, <a class="code" href="class_qwt_plot_zoomer.html#a5">zoomBase</a>().x2() - <a class="code" href="class_qwt_plot_zoomer.html#a6">zoomRect</a>().width());
00434
00435 y = QMAX(y, <a class="code" href="class_qwt_plot_zoomer.html#a5">zoomBase</a>().y1());
00436 y = QMIN(y, <a class="code" href="class_qwt_plot_zoomer.html#a5">zoomBase</a>().y2() - <a class="code" href="class_qwt_plot_zoomer.html#a6">zoomRect</a>().height());
00437
00438 <span class="keywordflow">if</span> ( x != <a class="code" href="class_qwt_plot_zoomer.html#a6">zoomRect</a>().<a class="code" href="class_qwt_double_rect.html#a7">x1</a>() || y != <a class="code" href="class_qwt_plot_zoomer.html#a6">zoomRect</a>().<a class="code" href="class_qwt_double_rect.html#a9">y1</a>() )
00439 {
00440 d_zoomStack[d_zoomRectIndex].move(x, y);
00441 <a class="code" href="class_qwt_plot_zoomer.html#b1">rescale</a>();
00442 }
00443 }
00444
<a name="l00456"></a><a class="code" href="class_qwt_plot_zoomer.html#b7">00456</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_zoomer.html#b7">QwtPlotZoomer::accept</a>(QPointArray &pa)<span class="keyword"> const</span>
00457 <span class="keyword"></span>{
00458 <span class="keywordflow">if</span> ( pa.count() < 2 )
00459 <span class="keywordflow">return</span> FALSE;
00460
00461 QRect rect = QRect(pa[0], pa[<span class="keywordtype">int</span>(pa.count() - 1)]).normalize();
00462
00463 <span class="keyword">const</span> <span class="keywordtype">int</span> minSize = 2;
00464 <span class="keywordflow">if</span> (rect.width() < minSize && rect.height() < minSize )
00465 <span class="keywordflow">return</span> FALSE;
00466
00467 <span class="keyword">const</span> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_zoomer.html#b2">minZoomSize</a> = 11;
00468
00469 <span class="keyword">const</span> QPoint center = rect.center();
00470 rect.setSize(rect.size().expandedTo(QSize(minZoomSize, minZoomSize)));
00471 rect.moveCenter(center);
00472
00473 pa.resize(2);
00474 pa[0] = rect.topLeft();
00475 pa[1] = rect.bottomRight();
00476
00477 <span class="keywordflow">return</span> TRUE;
00478 }
00479
<a name="l00488"></a><a class="code" href="class_qwt_plot_zoomer.html#b2">00488</a> <a class="code" href="class_qwt_double_size.html">QwtDoubleSize</a> <a class="code" href="class_qwt_plot_zoomer.html#b2">QwtPlotZoomer::minZoomSize</a>()<span class="keyword"> const</span>
00489 <span class="keyword"></span>{
00490 <span class="keywordtype">char</span> f;
00491 <span class="keywordtype">int</span> fw, xprecision, yprecision;
00492
00493 <a class="code" href="class_qwt_plot_picker.html#a6">plot</a>()-><a class="code" href="class_qwt_plot.html#a111">axisLabelFormat</a>(<a class="code" href="class_qwt_plot_picker.html#a4">xAxis</a>(), f, xprecision, fw);
00494 <a class="code" href="class_qwt_plot_picker.html#a6">plot</a>()-><a class="code" href="class_qwt_plot.html#a111">axisLabelFormat</a>(<a class="code" href="class_qwt_plot_picker.html#a5">yAxis</a>(), f, yprecision, fw);
00495
00496 <span class="keywordflow">return</span> <a class="code" href="class_qwt_double_size.html">QwtDoubleSize</a>(
00497 d_zoomStack[0].width() / pow(10.0, xprecision - 1),
00498 d_zoomStack[0].height() / pow(10.0, yprecision - 1)
00499 );
00500 }
00501
<a name="l00508"></a><a class="code" href="class_qwt_plot_zoomer.html#b5">00508</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#b5">QwtPlotZoomer::begin</a>()
00509 {
00510 <span class="keywordflow">if</span> ( d_maxStackDepth >= 0 )
00511 {
00512 <span class="keywordflow">if</span> ( d_zoomRectIndex >= uint(d_maxStackDepth) )
00513 <span class="keywordflow">return</span>;
00514 }
00515
00516 <span class="keyword">const</span> <a class="code" href="class_qwt_double_size.html">QwtDoubleSize</a> minSize = <a class="code" href="class_qwt_plot_zoomer.html#b2">minZoomSize</a>();
00517 <span class="keywordflow">if</span> ( minSize.<a class="code" href="class_qwt_double_size.html#a5">isValid</a>() )
00518 {
00519 <span class="keyword">const</span> <a class="code" href="class_qwt_double_size.html">QwtDoubleSize</a> sz =
00520 d_zoomStack[d_zoomRectIndex].size() * 0.9999;
00521
00522 <span class="keywordflow">if</span> ( minSize.<a class="code" href="class_qwt_double_size.html#a6">width</a>() >= sz.<a class="code" href="class_qwt_double_size.html#a6">width</a>() &&
00523 minSize.<a class="code" href="class_qwt_double_size.html#a7">height</a>() >= sz.<a class="code" href="class_qwt_double_size.html#a7">height</a>() )
00524 {
00525 <span class="keywordflow">return</span>;
00526 }
00527 }
00528
00529 <a class="code" href="class_qwt_picker.html#b2">QwtPlotPicker::begin</a>();
00530 }
00531
<a name="l00539"></a><a class="code" href="class_qwt_plot_zoomer.html#b6">00539</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_zoomer.html#b6">QwtPlotZoomer::end</a>(<span class="keywordtype">bool</span> ok)
00540 {
00541 ok = <a class="code" href="class_qwt_plot_picker.html#b9">QwtPlotPicker::end</a>(ok);
00542 <span class="keywordflow">if</span> (!ok)
00543 <span class="keywordflow">return</span> FALSE;
00544
00545 <a class="code" href="class_qwt_plot.html">QwtPlot</a> *plot = <a class="code" href="class_qwt_plot_picker.html#a6">QwtPlotZoomer::plot</a>();
00546 <span class="keywordflow">if</span> ( !plot )
00547 <span class="keywordflow">return</span> FALSE;
00548
00549 <span class="keyword">const</span> QPointArray &pa = <a class="code" href="class_qwt_picker.html#a24">selection</a>();
00550 <span class="keywordflow">if</span> ( pa.count() < 2 )
00551 <span class="keywordflow">return</span> FALSE;
00552
00553 QRect rect = QRect(pa[0], pa[<span class="keywordtype">int</span>(pa.count() - 1)]).normalize();
00554
00555 <a class="code" href="class_qwt_double_rect.html">QwtDoubleRect</a> <a class="code" href="class_qwt_plot_zoomer.html#a6">zoomRect</a> = <a class="code" href="class_qwt_plot_picker.html#b1">invTransform</a>(rect).<a class="code" href="class_qwt_double_rect.html#a6">normalize</a>();
00556
00557 <span class="keyword">const</span> <a class="code" href="class_qwt_double_point.html">QwtDoublePoint</a> center = zoomRect.<a class="code" href="class_qwt_double_rect.html#a19">center</a>();
00558 zoomRect.<a class="code" href="class_qwt_double_rect.html#a32">setSize</a>(zoomRect.<a class="code" href="class_qwt_double_rect.html#a29">size</a>().<a class="code" href="class_qwt_double_size.html#a11">expandedTo</a>(<a class="code" href="class_qwt_plot_zoomer.html#b2">minZoomSize</a>()));
00559 zoomRect.<a class="code" href="class_qwt_double_rect.html#a24">moveCenter</a>(center);
00560
00561 <a class="code" href="class_qwt_plot_zoomer.html#i2">zoom</a>(zoomRect);
00562 emit <a class="code" href="class_qwt_plot_zoomer.html#l0">zoomed</a>(zoomRect);
00563
00564 <span class="keywordflow">return</span> TRUE;
00565 }
00566
<a name="l00578"></a><a class="code" href="class_qwt_plot_zoomer.html#a12">00578</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#a12">QwtPlotZoomer::setSelectionFlags</a>(<span class="keywordtype">int</span> flags)
00579 {
00580 <span class="comment">// we accept only rects</span>
00581 flags &= ~(PointSelection | PolygonSelection);
00582 flags |= RectSelection;
00583
00584 <a class="code" href="class_qwt_picker.html#a3">QwtPlotPicker::setSelectionFlags</a>(flags);
00585 }
00586
00587 <span class="comment">// Local Variables:</span>
00588 <span class="comment">// mode: C++</span>
00589 <span class="comment">// c-file-style: "stroustrup"</span>
00590 <span class="comment">// indent-tabs-mode: nil</span>
00591 <span class="comment">// End:</span>
00592
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 16 21:12:21 2004 for Qwt User's Guide by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>
|