📄 qwt__thermo_8cpp-source.html
字号:
<a name="l00149"></a>00149 <a name="l00150"></a><a class="code" href="class_qwt_thermo.html#8b5ab653b893e41116200570632ad1c3">00150</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#8b5ab653b893e41116200570632ad1c3">QwtThermo::setScaleDraw</a>(<a class="code" href="class_qwt_scale_draw.html">QwtScaleDraw</a> *scaleDraw)<a name="l00151"></a>00151 {<a name="l00152"></a>00152 <a class="code" href="class_qwt_abstract_scale.html#950c5bf521dc704b78f76c7951346288">setAbstractScaleDraw</a>(<a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>);<a name="l00153"></a>00153 }<a name="l00154"></a>00154 <a name="l00155"></a><a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">00155</a> <span class="keyword">const</span> <a class="code" href="class_qwt_scale_draw.html">QwtScaleDraw</a> *<a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">QwtThermo::scaleDraw</a>()<span class="keyword"> const</span><a name="l00156"></a>00156 <span class="keyword"></span>{<a name="l00157"></a>00157 <span class="keywordflow">return</span> (<a class="code" href="class_qwt_scale_draw.html">QwtScaleDraw</a> *)<a class="code" href="class_qwt_abstract_scale.html#b3c5f30892792e5ca3d84f4409ef6216">abstractScaleDraw</a>();<a name="l00158"></a>00158 }<a name="l00159"></a>00159 <a name="l00160"></a><a class="code" href="class_qwt_thermo.html#7d0f262032c034c5da703ec2f2d120b7">00160</a> <a class="code" href="class_qwt_scale_draw.html">QwtScaleDraw</a> *<a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">QwtThermo::scaleDraw</a>() <a name="l00161"></a>00161 {<a name="l00162"></a>00162 <span class="keywordflow">return</span> (<a class="code" href="class_qwt_scale_draw.html">QwtScaleDraw</a> *)<a class="code" href="class_qwt_abstract_scale.html#b3c5f30892792e5ca3d84f4409ef6216">abstractScaleDraw</a>();<a name="l00163"></a>00163 }<a name="l00164"></a>00164 <a name="l00166"></a><a class="code" href="class_qwt_thermo.html#f7d628cb5c8a7f3e62f1696007299bd1">00166</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#f7d628cb5c8a7f3e62f1696007299bd1">QwtThermo::paintEvent</a>(QPaintEvent *e)<a name="l00167"></a>00167 {<a name="l00168"></a>00168 <span class="comment">// Use double-buffering</span><a name="l00169"></a>00169 <span class="keyword">const</span> QRect &ur = e->rect();<a name="l00170"></a>00170 <span class="keywordflow">if</span> ( ur.isValid() )<a name="l00171"></a>00171 {<a name="l00172"></a>00172 #<span class="keywordflow">if</span> QT_VERSION < 0x040000<a name="l00173"></a>00173 QwtPaintBuffer paintBuffer(<span class="keyword">this</span>, ur);<a name="l00174"></a>00174 <a class="code" href="class_qwt_thermo.html#d976ad3862954c8d5ce65b3c5903bd61">draw</a>(paintBuffer.painter(), ur);<a name="l00175"></a>00175 <span class="preprocessor">#else</span><a name="l00176"></a>00176 <span class="preprocessor"></span> QPainter painter(<span class="keyword">this</span>);<a name="l00177"></a>00177 <a class="code" href="class_qwt_thermo.html#d976ad3862954c8d5ce65b3c5903bd61">draw</a>(&painter, ur);<a name="l00178"></a>00178 <span class="preprocessor">#endif</span><a name="l00179"></a>00179 <span class="preprocessor"></span> }<a name="l00180"></a>00180 }<a name="l00181"></a>00181 <a name="l00183"></a><a class="code" href="class_qwt_thermo.html#d976ad3862954c8d5ce65b3c5903bd61">00183</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#d976ad3862954c8d5ce65b3c5903bd61">QwtThermo::draw</a>(QPainter *p, <span class="keyword">const</span> QRect& ur)<a name="l00184"></a>00184 {<a name="l00185"></a>00185 <span class="keywordflow">if</span> ( !d_data->thermoRect.contains(ur) )<a name="l00186"></a>00186 {<a name="l00187"></a>00187 <span class="keywordflow">if</span> (d_data->scalePos != NoScale)<a name="l00188"></a>00188 {<a name="l00189"></a>00189 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00190"></a>00190 <span class="preprocessor"></span> <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_abstract_scale_draw.html#ca3c3a7499112f52616d0ee8518fa5a6">draw</a>(p, colorGroup());<a name="l00191"></a>00191 <span class="preprocessor">#else</span><a name="l00192"></a>00192 <span class="preprocessor"></span> <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_abstract_scale_draw.html#ca3c3a7499112f52616d0ee8518fa5a6">draw</a>(p, palette());<a name="l00193"></a>00193 <span class="preprocessor">#endif</span><a name="l00194"></a>00194 <span class="preprocessor"></span> }<a name="l00195"></a>00195 <a name="l00196"></a>00196 qDrawShadePanel(p,<a name="l00197"></a>00197 d_data->thermoRect.x() - d_data->borderWidth,<a name="l00198"></a>00198 d_data->thermoRect.y() - d_data->borderWidth,<a name="l00199"></a>00199 d_data->thermoRect.width() + 2*d_data->borderWidth,<a name="l00200"></a>00200 d_data->thermoRect.height() + 2*d_data->borderWidth,<a name="l00201"></a>00201 <span class="preprocessor">#if QT_VERSION < 0x040000</span><a name="l00202"></a>00202 <span class="preprocessor"></span> colorGroup(), <a name="l00203"></a>00203 <span class="preprocessor">#else</span><a name="l00204"></a>00204 <span class="preprocessor"></span> palette(), <a name="l00205"></a>00205 <span class="preprocessor">#endif</span><a name="l00206"></a>00206 <span class="preprocessor"></span> <span class="keyword">true</span>, d_data->borderWidth,0);<a name="l00207"></a>00207 }<a name="l00208"></a>00208 drawThermo(p);<a name="l00209"></a>00209 }<a name="l00210"></a>00210 <a name="l00212"></a><a class="code" href="class_qwt_thermo.html#c28bbfadd5d69841ac93ec9524d5f2be">00212</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#c28bbfadd5d69841ac93ec9524d5f2be">QwtThermo::resizeEvent</a>(QResizeEvent *)<a name="l00213"></a>00213 {<a name="l00214"></a>00214 <a class="code" href="class_qwt_thermo.html#29ce009b8b0546b7ce04936d27fb8364">layoutThermo</a>( <span class="keyword">false</span> );<a name="l00215"></a>00215 }<a name="l00216"></a>00216 <a name="l00223"></a><a class="code" href="class_qwt_thermo.html#29ce009b8b0546b7ce04936d27fb8364">00223</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_thermo.html#29ce009b8b0546b7ce04936d27fb8364">QwtThermo::layoutThermo</a>( <span class="keywordtype">bool</span> update_geometry )<a name="l00224"></a>00224 {<a name="l00225"></a>00225 QRect r = rect();<a name="l00226"></a>00226 <span class="keywordtype">int</span> mbd = 0;<a name="l00227"></a>00227 <span class="keywordflow">if</span> ( d_data->scalePos != NoScale )<a name="l00228"></a>00228 {<a name="l00229"></a>00229 <span class="keywordtype">int</span> d1, d2;<a name="l00230"></a>00230 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#b6c5d65a109b63b2dd62984d38a4df0e">getBorderDistHint</a>(font(), d1, d2);<a name="l00231"></a>00231 mbd = qwtMax(d1, d2);<a name="l00232"></a>00232 }<a name="l00233"></a>00233 <a name="l00234"></a>00234 <span class="keywordflow">if</span> ( d_data->orientation == Qt::Horizontal )<a name="l00235"></a>00235 {<a name="l00236"></a>00236 <span class="keywordflow">switch</span> ( d_data->scalePos )<a name="l00237"></a>00237 {<a name="l00238"></a>00238 <span class="keywordflow">case</span> TopScale:<a name="l00239"></a>00239 {<a name="l00240"></a>00240 d_data->thermoRect.setRect(<a name="l00241"></a>00241 r.x() + mbd + d_data->borderWidth,<a name="l00242"></a>00242 r.y() + r.height()<a name="l00243"></a>00243 - d_data->thermoWidth - 2*d_data->borderWidth,<a name="l00244"></a>00244 r.width() - 2*(d_data->borderWidth + mbd),<a name="l00245"></a>00245 d_data->thermoWidth);<a name="l00246"></a>00246 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#7a4de0055dc1358e55c3357366a54091">setAlignment</a>(QwtScaleDraw::TopScale);<a name="l00247"></a>00247 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#d301aed0c797c10f0104976d1a62ff69">move</a>( d_data->thermoRect.x(),<a name="l00248"></a>00248 d_data->thermoRect.y() - d_data->borderWidth <a name="l00249"></a>00249 - d_data->scaleDist);<a name="l00250"></a>00250 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#2094e09579671d0a8e4b14a636eba6ef">setLength</a>(d_data->thermoRect.width());<a name="l00251"></a>00251 <span class="keywordflow">break</span>;<a name="l00252"></a>00252 }<a name="l00253"></a>00253 <a name="l00254"></a>00254 <span class="keywordflow">case</span> BottomScale:<a name="l00255"></a>00255 <span class="keywordflow">case</span> NoScale: <span class="comment">// like Bottom but without scale</span><a name="l00256"></a>00256 <span class="keywordflow">default</span>: <span class="comment">// inconsistent orientation and scale position</span><a name="l00257"></a>00257 <span class="comment">// Mapping between values and pixels requires</span><a name="l00258"></a>00258 <span class="comment">// initialization of the scale geometry</span><a name="l00259"></a>00259 {<a name="l00260"></a>00260 d_data->thermoRect.setRect(<a name="l00261"></a>00261 r.x() + mbd + d_data->borderWidth,<a name="l00262"></a>00262 r.y() + d_data->borderWidth,<a name="l00263"></a>00263 r.width() - 2*(d_data->borderWidth + mbd),<a name="l00264"></a>00264 d_data->thermoWidth);<a name="l00265"></a>00265 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#7a4de0055dc1358e55c3357366a54091">setAlignment</a>(QwtScaleDraw::BottomScale);<a name="l00266"></a>00266 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#d301aed0c797c10f0104976d1a62ff69">move</a>(<a name="l00267"></a>00267 d_data->thermoRect.x(),<a name="l00268"></a>00268 d_data->thermoRect.y() + d_data->thermoRect.height()<a name="l00269"></a>00269 + d_data->borderWidth + d_data->scaleDist );<a name="l00270"></a>00270 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#2094e09579671d0a8e4b14a636eba6ef">setLength</a>(d_data->thermoRect.width());<a name="l00271"></a>00271 <span class="keywordflow">break</span>;<a name="l00272"></a>00272 }<a name="l00273"></a>00273 }<a name="l00274"></a>00274 d_data->map.setPaintInterval(d_data->thermoRect.x(),<a name="l00275"></a>00275 d_data->thermoRect.x() + d_data->thermoRect.width() - 1);<a name="l00276"></a>00276 }<a name="l00277"></a>00277 <span class="keywordflow">else</span> <span class="comment">// Qt::Vertical</span><a name="l00278"></a>00278 {<a name="l00279"></a>00279 <span class="keywordflow">switch</span> ( d_data->scalePos )<a name="l00280"></a>00280 {<a name="l00281"></a>00281 <span class="keywordflow">case</span> RightScale:<a name="l00282"></a>00282 {<a name="l00283"></a>00283 d_data->thermoRect.setRect(<a name="l00284"></a>00284 r.x() + d_data->borderWidth,<a name="l00285"></a>00285 r.y() + mbd + d_data->borderWidth,<a name="l00286"></a>00286 d_data->thermoWidth,<a name="l00287"></a>00287 r.height() - 2*(d_data->borderWidth + mbd));<a name="l00288"></a>00288 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#7a4de0055dc1358e55c3357366a54091">setAlignment</a>(QwtScaleDraw::RightScale);<a name="l00289"></a>00289 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#d301aed0c797c10f0104976d1a62ff69">move</a>(<a name="l00290"></a>00290 d_data->thermoRect.x() + d_data->thermoRect.width()<a name="l00291"></a>00291 + d_data->borderWidth + d_data->scaleDist,<a name="l00292"></a>00292 d_data->thermoRect.y());<a name="l00293"></a>00293 <a class="code" href="class_qwt_thermo.html#aacb94a49eb05c91a3896d202f79ec46">scaleDraw</a>()-><a class="code" href="class_qwt_scale_draw.html#2094e09579671d0a8e4b14a636eba6ef">setLength</a>(d_data->thermoRect.height());<a name="l00294"></a>00294 <span class="keywordflow">break</span>;<a name="l00295"></a>00295 }<a name="l00296"></a>00296 <a name="l00297"></a>00297 <span class="keywordflow">case</span> LeftScale:<a name="l00298"></a>00298 <span class="keywordflow">case</span> NoScale: <span class="comment">// like Left but without scale</span><a name="l00299"></a>00299 <span class="keywordflow">default</span>: <span class="comment">// inconsistent orientation and scale position</span><a name="l00300"></a>00300 <span class="comment">// Mapping between values and pixels requires</span><a name="l00301"></a>00301 <span class="comment">// initialization of the scale geometry</span><a name="l00302"></a>00302 {<a name="l00303"></a>00303 d_data->thermoRect.setRect(<a name="l00304"></a>00304 r.x() + r.width() - 2*d_data->borderWidth - d_data->thermoWidth,
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -