📄 qwt__plot__zoomer_8cpp-source.html
字号:
<!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"><link href="tabs.css" rel="stylesheet" type="text/css"></head><body><!-- Generated by Doxygen 1.4.6 --><div class="tabs"> <ul> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="classes.html"><span>Classes</span></a></li> <li id="current"><a href="files.html"><span>Files</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> </ul></div><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><a name="l00002"></a>00002 <span class="comment"> * Qwt Widget Library</span><a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span><a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span><a name="l00005"></a>00005 <span class="comment"> *</span><a name="l00006"></a>00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span><a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span><a name="l00008"></a>00008 <span class="comment"> *****************************************************************************/</span><a name="l00009"></a>00009 <a name="l00010"></a>00010 <span class="comment">// vim: expandtab</span><a name="l00011"></a>00011 <a name="l00012"></a>00012 <span class="preprocessor">#include <math.h></span><a name="l00013"></a>00013 <span class="preprocessor">#include "qwt_plot.h"</span><a name="l00014"></a>00014 <span class="preprocessor">#include "qwt_plot_canvas.h"</span><a name="l00015"></a>00015 <span class="preprocessor">#include "qwt_plot_zoomer.h"</span><a name="l00016"></a>00016 <span class="preprocessor">#include "qwt_scale_div.h"</span><a name="l00017"></a>00017 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00018"></a>00018 <span class="preprocessor"></span><span class="keyword">typedef</span> QValueStack<QwtDoubleRect> QwtZoomStack;<a name="l00019"></a>00019 <span class="preprocessor">#else</span><a name="l00020"></a>00020 <span class="preprocessor"></span><span class="keyword">typedef</span> QStack<QwtDoubleRect> QwtZoomStack;<a name="l00021"></a>00021 <span class="preprocessor">#endif</span><a name="l00022"></a>00022 <span class="preprocessor"></span><a name="l00023"></a>00023 <span class="keyword">class </span>QwtPlotZoomer::PrivateData<a name="l00024"></a>00024 {<a name="l00025"></a>00025 <span class="keyword">public</span>:<a name="l00026"></a>00026 uint <a class="code" href="class_qwt_plot_zoomer.html#63797aa3b9e540a2c5f539fa34a05fbc">zoomRectIndex</a>;<a name="l00027"></a>00027 QwtZoomStack <a class="code" href="class_qwt_plot_zoomer.html#bbd7fe8750c177a82f80ea91611909fd">zoomStack</a>;<a name="l00028"></a>00028 <a name="l00029"></a>00029 <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_zoomer.html#c0d39d53af224cbeda37e0417d084dab">maxStackDepth</a>;<a name="l00030"></a>00030 };<a name="l00031"></a>00031 <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):<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>)<a name="l00053"></a>00053 {<a name="l00054"></a>00054 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_picker.html#402820e19bc6a9a33184264345703015">canvas</a> )<a name="l00055"></a>00055 init(RectSelection & ClickSelection, ActiveOnly, doReplot);<a name="l00056"></a>00056 }<a name="l00057"></a>00057 <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,<a name="l00076"></a>00076 <a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *canvas, <span class="keywordtype">bool</span> doReplot):<a name="l00077"></a>00077 <a class="code" href="class_qwt_plot_picker.html">QwtPlotPicker</a>(xAxis, yAxis, canvas)<a name="l00078"></a>00078 {<a name="l00079"></a>00079 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_picker.html#402820e19bc6a9a33184264345703015">canvas</a> )<a name="l00080"></a>00080 init(RectSelection & ClickSelection, ActiveOnly, doReplot);<a name="l00081"></a>00081 }<a name="l00082"></a>00082 <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,<a name="l00104"></a>00104 DisplayMode trackerMode, <a class="code" href="class_qwt_plot_canvas.html">QwtPlotCanvas</a> *canvas, <span class="keywordtype">bool</span> doReplot):<a name="l00105"></a>00105 <a class="code" href="class_qwt_plot_picker.html">QwtPlotPicker</a>(xAxis, yAxis, canvas)<a name="l00106"></a>00106 {<a name="l00107"></a>00107 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_picker.html#402820e19bc6a9a33184264345703015">canvas</a> )<a name="l00108"></a>00108 init(selectionFlags, trackerMode, doReplot);<a name="l00109"></a>00109 }<a name="l00110"></a>00110 <a name="l00112"></a>00112 <span class="keywordtype">void</span> QwtPlotZoomer::init(<span class="keywordtype">int</span> selectionFlags, <a name="l00113"></a>00113 DisplayMode trackerMode, <span class="keywordtype">bool</span> doReplot)<a name="l00114"></a>00114 {<a name="l00115"></a>00115 d_data = <span class="keyword">new</span> PrivateData;<a name="l00116"></a>00116 <a name="l00117"></a>00117 d_data->maxStackDepth = -1;<a name="l00118"></a>00118 <a name="l00119"></a>00119 <a class="code" href="class_qwt_plot_zoomer.html#c9d52dbddc9e79e7ce8ebd545e855e89">setSelectionFlags</a>(selectionFlags);<a name="l00120"></a>00120 <a class="code" href="class_qwt_picker.html#94fc60c7223cdc470ae63156f6446d6f">setTrackerMode</a>(trackerMode);<a name="l00121"></a>00121 <a class="code" href="class_qwt_picker.html#83096bad2662e02e4914a7b40241c351">setRubberBand</a>(RectRubberBand);<a name="l00122"></a>00122 <a name="l00123"></a>00123 <span class="keywordflow">if</span> ( doReplot && <a class="code" href="class_qwt_plot_picker.html#c5906d5fe7543f3db7808da44d8197a9">plot</a>() )<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>();<a name="l00125"></a>00125 <a name="l00126"></a>00126 <a class="code" href="class_qwt_plot_zoomer.html#7a1711597f441223efdb7d9931fe19b9">setZoomBase</a>(<a class="code" href="class_qwt_plot_picker.html#4bdeadb4e7a794bab248d1e2a2c76345">scaleRect</a>());<a name="l00127"></a>00127 }<a name="l00128"></a>00128 <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>()<a name="l00130"></a>00130 {<a name="l00131"></a>00131 <span class="keyword">delete</span> d_data;<a name="l00132"></a>00132 }<a name="l00133"></a>00133 <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)<a name="l00146"></a>00146 {<a name="l00147"></a>00147 d_data->maxStackDepth = depth;<a name="l00148"></a>00148 <a name="l00149"></a>00149 <span class="keywordflow">if</span> ( depth >= 0 )<a name="l00150"></a>00150 {<a name="l00151"></a>00151 <span class="comment">// unzoom if the current depth is below d_data->maxStackDepth</span><a name="l00152"></a>00152 <a name="l00153"></a>00153 <span class="keyword">const</span> <span class="keywordtype">int</span> zoomOut = <a name="l00154"></a>00154 int(d_data->zoomStack.count()) - 1 - depth; <span class="comment">// -1 for the zoom base</span><a name="l00155"></a>00155 <a name="l00156"></a>00156 <span class="keywordflow">if</span> ( zoomOut > 0 )<a name="l00157"></a>00157 {<a name="l00158"></a>00158 <a class="code" href="class_qwt_plot_zoomer.html#eeed51dfa01136f00961e679dcbb9d9d">zoom</a>(-zoomOut);<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; <a name="l00160"></a>00160 i > int(d_data->zoomRectIndex); i-- )<a name="l00161"></a>00161 {<a name="l00162"></a>00162 (<span class="keywordtype">void</span>)d_data->zoomStack.pop(); <span class="comment">// remove trailing rects</span><a name="l00163"></a>00163 }<a name="l00164"></a>00164 }<a name="l00165"></a>00165 }<a name="l00166"></a>00166 }<a name="l00167"></a>00167 <a name="l00172"></a><a class="code" href="class_qwt_plot_zoomer.html#c0d39d53af224cbeda37e0417d084dab">00172</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_zoomer.html#c0d39d53af224cbeda37e0417d084dab">QwtPlotZoomer::maxStackDepth</a>()<span class="keyword"> const</span><a name="l00173"></a>00173 <span class="keyword"></span>{<a name="l00174"></a>00174 <span class="keywordflow">return</span> d_data->maxStackDepth;<a name="l00175"></a>00175 }<a name="l00176"></a>00176 <a name="l00181"></a><a class="code" href="class_qwt_plot_zoomer.html#bbd7fe8750c177a82f80ea91611909fd">00181</a> <span class="keyword">const</span> QwtZoomStack &<a class="code" href="class_qwt_plot_zoomer.html#bbd7fe8750c177a82f80ea91611909fd">QwtPlotZoomer::zoomStack</a>()<span class="keyword"> const</span><a name="l00182"></a>00182 <span class="keyword"></span>{<a name="l00183"></a>00183 <span class="keywordflow">return</span> d_data->zoomStack;<a name="l00184"></a>00184 }<a name="l00185"></a>00185 <a name="l00190"></a><a class="code" href="class_qwt_plot_zoomer.html#ec745fbace2e6d1e69e7d9be0368bd8e">00190</a> QwtDoubleRect <a class="code" href="class_qwt_plot_zoomer.html#ec745fbace2e6d1e69e7d9be0368bd8e">QwtPlotZoomer::zoomBase</a>()<span class="keyword"> const</span><a name="l00191"></a>00191 <span class="keyword"></span>{<a name="l00192"></a>00192 <span class="keywordflow">return</span> d_data->zoomStack[0];<a name="l00193"></a>00193 }<a name="l00194"></a>00194 <a name="l00208"></a><a class="code" href="class_qwt_plot_zoomer.html#7a1711597f441223efdb7d9931fe19b9">00208</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_zoomer.html#7a1711597f441223efdb7d9931fe19b9">QwtPlotZoomer::setZoomBase</a>()<a name="l00209"></a>00209 {<a name="l00210"></a>00210 <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>();<a name="l00211"></a>00211 <span class="keywordflow">if</span> ( !plt )<a name="l00212"></a>00212 <span class="keywordflow">return</span>;<a name="l00213"></a>00213 <a name="l00214"></a>00214 d_data->zoomStack.clear();<a name="l00215"></a>00215 d_data->zoomStack.push(<a class="code" href="class_qwt_plot_picker.html#4bdeadb4e7a794bab248d1e2a2c76345">scaleRect</a>());<a name="l00216"></a>00216 d_data->zoomRectIndex = 0;<a name="l00217"></a>00217 <a name="l00218"></a>00218 <a class="code" href="class_qwt_plot_zoomer.html#0d0f90bbd5fe99d5231b3cee00fffabe">rescale</a>();<a name="l00219"></a>00219 }<a name="l00220"></a>00220
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -