📄 qwt__plot__print_8cpp-source.html
字号:
<a name="l00162"></a>00162 <a name="l00163"></a>00163 <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> map[axisCnt];<a name="l00164"></a>00164 <span class="keywordflow">for</span> (axisId = 0; axisId < axisCnt; axisId++)<a name="l00165"></a>00165 {<a name="l00166"></a>00166 map[axisId].setTransformation(axisScaleEngine(axisId)->transformation());<a name="l00167"></a>00167 <a name="l00168"></a>00168 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_div.html">QwtScaleDiv</a> &scaleDiv = *axisScaleDiv(axisId);<a name="l00169"></a>00169 map[axisId].<a class="code" href="class_qwt_scale_map.html#aa33bc8e1aed7aa17d345053194e7094">setScaleInterval</a>(scaleDiv.<a class="code" href="class_qwt_scale_div.html#a3b6edf00144cdc0a59fbc91784faec3">lBound</a>(), scaleDiv.<a class="code" href="class_qwt_scale_div.html#94287d3de0b107e66beea42cfeb1caef">hBound</a>());<a name="l00170"></a>00170 <a name="l00171"></a>00171 <span class="keywordtype">double</span> from, to;<a name="l00172"></a>00172 <span class="keywordflow">if</span> ( axisEnabled(axisId) )<a name="l00173"></a>00173 {<a name="l00174"></a>00174 <span class="keyword">const</span> <span class="keywordtype">int</span> sDist = axisWidget(axisId)->startBorderDist();<a name="l00175"></a>00175 <span class="keyword">const</span> <span class="keywordtype">int</span> eDist = axisWidget(axisId)->endBorderDist();<a name="l00176"></a>00176 <span class="keyword">const</span> QRect &scaleRect = plotLayout()->scaleRect(axisId);<a name="l00177"></a>00177 <a name="l00178"></a>00178 <span class="keywordflow">if</span> ( axisId == xTop || axisId == xBottom )<a name="l00179"></a>00179 {<a name="l00180"></a>00180 from = metricsMap.layoutToDeviceX(scaleRect.left() + sDist);<a name="l00181"></a>00181 to = metricsMap.layoutToDeviceX(scaleRect.right() - eDist);<a name="l00182"></a>00182 }<a name="l00183"></a>00183 <span class="keywordflow">else</span><a name="l00184"></a>00184 {<a name="l00185"></a>00185 from = metricsMap.layoutToDeviceY(scaleRect.bottom() - eDist);<a name="l00186"></a>00186 to = metricsMap.layoutToDeviceY(scaleRect.top() + sDist);<a name="l00187"></a>00187 }<a name="l00188"></a>00188 }<a name="l00189"></a>00189 <span class="keywordflow">else</span><a name="l00190"></a>00190 {<a name="l00191"></a>00191 <span class="keyword">const</span> <span class="keywordtype">int</span> margin = plotLayout()->canvasMargin(axisId);<a name="l00192"></a>00192 <a name="l00193"></a>00193 <span class="keyword">const</span> QRect &canvasRect = plotLayout()->canvasRect();<a name="l00194"></a>00194 <span class="keywordflow">if</span> ( axisId == yLeft || axisId == yRight )<a name="l00195"></a>00195 {<a name="l00196"></a>00196 from = metricsMap.layoutToDeviceX(canvasRect.bottom() - margin);<a name="l00197"></a>00197 to = metricsMap.layoutToDeviceX(canvasRect.top() + margin);<a name="l00198"></a>00198 }<a name="l00199"></a>00199 <span class="keywordflow">else</span><a name="l00200"></a>00200 {<a name="l00201"></a>00201 from = metricsMap.layoutToDeviceY(canvasRect.left() + margin);<a name="l00202"></a>00202 to = metricsMap.layoutToDeviceY(canvasRect.right() - margin);<a name="l00203"></a>00203 }<a name="l00204"></a>00204 }<a name="l00205"></a>00205 map[axisId].<a class="code" href="class_qwt_scale_map.html#1679ba72903986ff546c4c197e4680c0">setPaintXInterval</a>(from, to);<a name="l00206"></a>00206 }<a name="l00207"></a>00207 <a name="l00208"></a>00208 <a name="l00209"></a>00209 <span class="comment">// The canvas maps are already scaled. </span><a name="l00210"></a>00210 <a class="code" href="class_qwt_painter.html#952553514abb7ab83c4a43602c899777">QwtPainter::setMetricsMap</a>(painter->device(), painter->device());<a name="l00211"></a>00211 <a name="l00212"></a>00212 printCanvas(painter, canvasRect, map, pfilter);<a name="l00213"></a>00213 <a name="l00214"></a>00214 <a class="code" href="class_qwt_painter.html#0a20214cff4c8edd4c3caa0ad3a2112f">QwtPainter::resetMetricsMap</a>();<a name="l00215"></a>00215 <a name="l00216"></a>00216 ((<a class="code" href="class_qwt_plot.html">QwtPlot</a> *)<span class="keyword">this</span>)->plotLayout()->invalidate();<a name="l00217"></a>00217 <a name="l00218"></a>00218 <span class="comment">// reset all widgets with their original attributes.</span><a name="l00219"></a>00219 <span class="keywordflow">if</span> ( !(pfilter.options() & QwtPlotPrintFilter::PrintCanvasBackground) )<a name="l00220"></a>00220 {<a name="l00221"></a>00221 <span class="comment">// restore the previous base line dists</span><a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keywordflow">for</span> (axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )<a name="l00224"></a>00224 {<a name="l00225"></a>00225 <a class="code" href="class_qwt_scale_widget.html">QwtScaleWidget</a> *scaleWidget = (<a class="code" href="class_qwt_scale_widget.html">QwtScaleWidget</a> *)axisWidget(axisId);<a name="l00226"></a>00226 <span class="keywordflow">if</span> ( scaleWidget )<a name="l00227"></a>00227 scaleWidget->setMargin(baseLineDists[axisId]);<a name="l00228"></a>00228 }<a name="l00229"></a>00229 }<a name="l00230"></a>00230 <a name="l00231"></a>00231 pfilter.reset((<a class="code" href="class_qwt_plot.html">QwtPlot</a> *)<span class="keyword">this</span>);<a name="l00232"></a>00232 <a name="l00233"></a>00233 painter->restore();<a name="l00234"></a>00234 }<a name="l00235"></a>00235 <a name="l00243"></a><a class="code" href="class_qwt_plot.html#5ec342f0b38eb646f3cc6da8457b234a">00243</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot.html#5ec342f0b38eb646f3cc6da8457b234a">QwtPlot::printTitle</a>(QPainter *painter, <span class="keyword">const</span> QRect &rect)<span class="keyword"> const</span><a name="l00244"></a>00244 <span class="keyword"></span>{<a name="l00245"></a>00245 painter->setFont(<a class="code" href="class_qwt_plot.html#c39356b86ed70ebf256a8ae964910206">titleLabel</a>()->font());<a name="l00246"></a>00246 <a name="l00247"></a>00247 <span class="keyword">const</span> QColor color = <a name="l00248"></a>00248 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00249"></a>00249 <span class="preprocessor"></span> <a class="code" href="class_qwt_plot.html#c39356b86ed70ebf256a8ae964910206">titleLabel</a>()->palette().color(<a name="l00250"></a>00250 QPalette::Active, QColorGroup::Text);<a name="l00251"></a>00251 <span class="preprocessor">#else</span><a name="l00252"></a>00252 <span class="preprocessor"></span> <a class="code" href="class_qwt_plot.html#c39356b86ed70ebf256a8ae964910206">titleLabel</a>()->palette().color(<a name="l00253"></a>00253 QPalette::Active, QPalette::Text);<a name="l00254"></a>00254 <span class="preprocessor">#endif</span><a name="l00255"></a>00255 <span class="preprocessor"></span><a name="l00256"></a>00256 painter->setPen(color);<a name="l00257"></a>00257 <a class="code" href="class_qwt_plot.html#c39356b86ed70ebf256a8ae964910206">titleLabel</a>()-><a class="code" href="class_qwt_text_label.html#6ff4f9a87e11594740f312c8522f933e">text</a>().<a class="code" href="class_qwt_text.html#3907eb112ff2259adbaad4c433178354">draw</a>(painter, rect);<a name="l00258"></a>00258 }<a name="l00259"></a>00259 <a name="l00267"></a><a class="code" href="class_qwt_plot.html#e64c9c6f3a7a84c9a988c491bc73c71f">00267</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot.html#e64c9c6f3a7a84c9a988c491bc73c71f">QwtPlot::printLegend</a>(QPainter *painter, <span class="keyword">const</span> QRect &rect)<span class="keyword"> const</span><a name="l00268"></a>00268 <span class="keyword"></span>{<a name="l00269"></a>00269 <span class="keywordflow">if</span> ( !<a class="code" href="class_qwt_plot.html#ab1f2cf0e567e09a4c4bce3181c03ba0">legend</a>() || <a class="code" href="class_qwt_plot.html#ab1f2cf0e567e09a4c4bce3181c03ba0">legend</a>()->isEmpty() )<a name="l00270"></a>00270 <span class="keywordflow">return</span>;<a name="l00271"></a>00271 <a name="l00272"></a>00272 QLayout *l = <a class="code" href="class_qwt_plot.html#ab1f2cf0e567e09a4c4bce3181c03ba0">legend</a>()-><a class="code" href="class_qwt_legend.html#a52edeceb553ae703516c984f34d7ab7">contentsWidget</a>()->layout();<a name="l00273"></a>00273 <span class="keywordflow">if</span> ( l == 0 || !l->inherits(<span class="stringliteral">"QwtDynGridLayout"</span>) )<a name="l00274"></a>00274 <span class="keywordflow">return</span>;<a name="l00275"></a>00275 <a name="l00276"></a>00276 <a class="code" href="class_qwt_dyn_grid_layout.html">QwtDynGridLayout</a> *legendLayout = (<a class="code" href="class_qwt_dyn_grid_layout.html">QwtDynGridLayout</a> *)l;<a name="l00277"></a>00277 <a name="l00278"></a>00278 uint numCols = legendLayout-><a class="code" href="class_qwt_dyn_grid_layout.html#df7cc1acc36b41086fb4815633473901">columnsForWidth</a>(rect.width());<a name="l00279"></a>00279 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00280"></a>00280 <span class="preprocessor"></span> QValueList<QRect> itemRects = <a name="l00281"></a>00281 legendLayout-><a class="code" href="class_qwt_dyn_grid_layout.html#0fe5c2a70d1086036fac2487cc982341">layoutItems</a>(rect, numCols);<a name="l00282"></a>00282 <span class="preprocessor">#else</span><a name="l00283"></a>00283 <span class="preprocessor"></span> QList<QRect> itemRects = <a name="l00284"></a>00284 legendLayout-><a class="code" href="class_qwt_dyn_grid_layout.html#0fe5c2a70d1086036fac2487cc982341">layoutItems</a>(rect, numCols);<a name="l00285"></a>00285 <span class="preprocessor">#endif</span><a name="l00286"></a>00286 <span class="preprocessor"></span><a name="l00287"></a>00287 <span class="keywordtype">int</span> index = 0;<a name="l00288"></a>00288 <a name="l00289"></a>00289 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00290"></a>00290 <span class="preprocessor"></span> QLayoutIterator layoutIterator = legendLayout->iterator();<a name="l00291"></a>00291 <span class="keywordflow">for</span> ( QLayoutItem *item = layoutIterator.current(); <a name="l00292"></a>00292 item != 0; item = ++layoutIterator)<a name="l00293"></a>00293 {<a name="l00294"></a>00294 #<span class="keywordflow">else</span><a name="l00295"></a>00295 <span class="keywordflow">for</span> ( <span class="keywordtype">int</span> i = 0; i < legendLayout-><a class="code" href="class_qwt_dyn_grid_layout.html#9a74593721ef1eba3d70275c36500ff6">count</a>(); i++ )<a name="l00296"></a>00296 {<a name="l00297"></a>00297 QLayoutItem *item = legendLayout-><a class="code" href="class_qwt_dyn_grid_layout.html#dbec8dc847c4159d0765c8f0dd80d148">itemAt</a>(i);<a name="l00298"></a>00298 <span class="preprocessor">#endif</span><a name="l00299"></a>00299 <span class="preprocessor"></span> QWidget *w = item->widget();<a name="l00300"></a>00300 <span class="keywordflow">if</span> ( w )<a name="l00301"></a>00301 {<a name="l00302"></a>00302 painter->save();<a name="l00303"></a>00303 painter->setClipping(<span class="keyword">true</span>);<a name="l00304"></a>00304 <a class="code" href="class_qwt_painter.html#7a3b7e59fd56236dd99c5b1772e1a768">QwtPainter::setClipRect</a>(painter, itemRects[index]);<a name="l00305"></a>00305 <a name="l00306"></a>00306 <a class="code" href="class_qwt_plot.html#9d8ac6339a83158a0e78def13489d0ca">printLegendItem</a>(painter, w, itemRects[index]);<a name="l00307"></a>00307 <a name="l00308"></a>00308 index++;<a name="l00309"></a>00309 painter->restore();<a name="l00310"></a>00310 }<a name="l00311"></a>00311 }<a name="l00312"></a>00312 }<a name="l00313"></a>00313 <a name="l00322"></a><a class="code" href="class_qwt_plot.html#9d8ac6339a83158a0e78def13489d0ca">00322</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot.html#9d8ac6339a83158a0e78def13489d0ca">QwtPlot::printLegendItem</a>(QPainter *painter, <a name="l00323"></a>00323 <span class="keyword">const</span> QWidget *w, <span class="keyword">const</span> QRect &rect)<span class="keyword"> const</span><a name="l00324"></a>00324 <span class="keyword"></span>{<a name="l00325"></a>00325 <span class="keywordflow">if</span> ( w->inherits(<span class="stringliteral">"QwtLegendItem"</span>) )<a name="l00326"></a>00326 {<a name="l00327"></a>00327 <a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a> *item = (<a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a> *)w;<a name="l00328"></a>00328 <a name="l00329"></a>00329 painter->setFont(item->font());<a name="l00330"></a>00330 item->drawItem(painter, rect);<a name="l00331"></a>00331 }<a name="l00332"></a>00332 }<a name="l00333"></a>00333 <a name="l00346"></a><a class="code" href="class_qwt_plot.html#cc8d22136018342a7f89a341e6fe8cd3">00346</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot.html#cc8d22136018342a7f89a341e6fe8cd3">QwtPlot::printScale</a>(QPainter *painter,<a name="l00347"></a>00347 <span class="keywordtype">int</span> axisId, <span class="keywordtype">int</span> startDist, <span class="keywordtype">int</span> endDist, <span class="keywordtype">int</span> baseDist, <a name="l00348"></a>00348 <span class="keyword">const</span> QRect &rect)<span class="keyword"> const</span><a name="l00349"></a>00349 <span class="keyword"></span>{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -