qwt__plot__item_8cpp-source.html

来自「QWT5.01用于Qt开发的二维图形库程序」· HTML 代码 · 共 375 行 · 第 1/3 页

HTML
375
字号
<!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&apos;s Guide: qwt_plot_item.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&nbsp;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&nbsp;Pages</span></a></li>  </ul></div><h1>qwt_plot_item.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="preprocessor">#include "qwt_text.h"</span><a name="l00011"></a>00011 <span class="preprocessor">#include "qwt_plot.h"</span><a name="l00012"></a>00012 <span class="preprocessor">#include "qwt_legend.h"</span><a name="l00013"></a>00013 <span class="preprocessor">#include "qwt_legend_item.h"</span><a name="l00014"></a>00014 <span class="preprocessor">#include "qwt_plot_item.h"</span><a name="l00015"></a>00015 <a name="l00016"></a>00016 <span class="keyword">class </span>QwtPlotItem::PrivateData<a name="l00017"></a>00017 {<a name="l00018"></a>00018 <span class="keyword">public</span>:<a name="l00019"></a>00019     PrivateData():<a name="l00020"></a>00020         <a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a>(NULL),<a name="l00021"></a>00021         <a class="code" href="class_qwt_plot_item.html#eaf8eeb5f080017e181a5d7be798d789">isVisible</a>(true),<a name="l00022"></a>00022         attributes(0),<a name="l00023"></a>00023 #if QT_VERSION &gt;= 0x040000<a name="l00024"></a>00024         renderHints(0),<a name="l00025"></a>00025 #endif<a name="l00026"></a>00026         <a class="code" href="class_qwt_plot_item.html#4c58d814336643190b9f2918f80c30df">z</a>(0.0),<a name="l00027"></a>00027         <a class="code" href="class_qwt_plot_item.html#7af360bf6d5a5b6257ce6b0dd99b7525">xAxis</a>(<a class="code" href="class_qwt_plot.html">QwtPlot</a>::xBottom),<a name="l00028"></a>00028         <a class="code" href="class_qwt_plot_item.html#c7714ffa278a10e0cf45972e487b63ff">yAxis</a>(<a class="code" href="class_qwt_plot.html">QwtPlot</a>::yLeft)<a name="l00029"></a>00029     {<a name="l00030"></a>00030     }<a name="l00031"></a>00031 <a name="l00032"></a>00032     <span class="keyword">mutable</span> <a class="code" href="class_qwt_plot.html">QwtPlot</a> *<a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a>;<a name="l00033"></a>00033 <a name="l00034"></a>00034     <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_item.html#eaf8eeb5f080017e181a5d7be798d789">isVisible</a>;<a name="l00035"></a>00035     <span class="keywordtype">int</span> attributes;<a name="l00036"></a>00036 <span class="preprocessor">#if QT_VERSION &gt;= 0x040000</span><a name="l00037"></a>00037 <span class="preprocessor"></span>    <span class="keywordtype">int</span> renderHints;<a name="l00038"></a>00038 <span class="preprocessor">#endif</span><a name="l00039"></a>00039 <span class="preprocessor"></span>    <span class="keywordtype">double</span> <a class="code" href="class_qwt_plot_item.html#4c58d814336643190b9f2918f80c30df">z</a>;<a name="l00040"></a>00040 <a name="l00041"></a>00041     <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_item.html#7af360bf6d5a5b6257ce6b0dd99b7525">xAxis</a>;<a name="l00042"></a>00042     <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_item.html#c7714ffa278a10e0cf45972e487b63ff">yAxis</a>;<a name="l00043"></a>00043 <a name="l00044"></a>00044     <a class="code" href="class_qwt_text.html">QwtText</a> <a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>;<a name="l00045"></a>00045 };<a name="l00046"></a>00046 <a name="l00048"></a><a class="code" href="class_qwt_plot_item.html#5d892ac856fb9176515c5f2d806161dc">00048</a> <a class="code" href="class_qwt_plot_item.html#5d892ac856fb9176515c5f2d806161dc">QwtPlotItem::QwtPlotItem</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_text.html">QwtText</a> &amp;<a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>)<a name="l00049"></a>00049 {<a name="l00050"></a>00050     d_data = <span class="keyword">new</span> PrivateData;<a name="l00051"></a>00051     d_data-&gt;title = <a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>;<a name="l00052"></a>00052 }<a name="l00053"></a>00053 <a name="l00055"></a><a class="code" href="class_qwt_plot_item.html#282a1d0424a06737f80e1fe83ccf7a0c">00055</a> <a class="code" href="class_qwt_plot_item.html#282a1d0424a06737f80e1fe83ccf7a0c">QwtPlotItem::~QwtPlotItem</a>()<a name="l00056"></a>00056 {<a name="l00057"></a>00057     <a class="code" href="class_qwt_plot_item.html#eb2f676533ccae3436bf578824e2165e">attach</a>(NULL);<a name="l00058"></a>00058     <span class="keyword">delete</span> d_data;<a name="l00059"></a>00059 }<a name="l00060"></a>00060 <a name="l00064"></a><a class="code" href="class_qwt_plot_item.html#eb2f676533ccae3436bf578824e2165e">00064</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#eb2f676533ccae3436bf578824e2165e">QwtPlotItem::attach</a>(<a class="code" href="class_qwt_plot.html">QwtPlot</a> *plot)<a name="l00065"></a>00065 {<a name="l00066"></a>00066     <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a> == d_data-&gt;plot )<a name="l00067"></a>00067         <span class="keywordflow">return</span>;<a name="l00068"></a>00068 <a name="l00069"></a>00069     <span class="comment">// remove the item from the previous plot</span><a name="l00070"></a>00070 <a name="l00071"></a>00071     <span class="keywordflow">if</span> ( d_data-&gt;plot )<a name="l00072"></a>00072     {<a name="l00073"></a>00073         <span class="keywordflow">if</span> ( d_data-&gt;plot-&gt;legend() )<a name="l00074"></a>00074         {<a name="l00075"></a>00075             QWidget *<a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a> = d_data-&gt;plot-&gt;legend()-&gt;find(<span class="keyword">this</span>);<a name="l00076"></a>00076             <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a> )<a name="l00077"></a>00077                 <span class="keyword">delete</span> <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>; <a name="l00078"></a>00078         }<a name="l00079"></a>00079 <a name="l00080"></a>00080         d_data-&gt;plot-&gt;attachItem(<span class="keyword">this</span>, <span class="keyword">false</span>);<a name="l00081"></a>00081 <a name="l00082"></a>00082         <span class="keywordflow">if</span> ( d_data-&gt;plot-&gt;autoReplot() )<a name="l00083"></a>00083             d_data-&gt;plot-&gt;update();<a name="l00084"></a>00084     }<a name="l00085"></a>00085 <a name="l00086"></a>00086     d_data-&gt;plot = plot;<a name="l00087"></a>00087 <a name="l00088"></a>00088     <span class="keywordflow">if</span> ( d_data-&gt;plot )<a name="l00089"></a>00089     {<a name="l00090"></a>00090         <span class="comment">// insert the item into the current plot</span><a name="l00091"></a>00091 <a name="l00092"></a>00092         d_data-&gt;plot-&gt;attachItem(<span class="keyword">this</span>, <span class="keyword">true</span>);<a name="l00093"></a>00093         itemChanged();<a name="l00094"></a>00094     }<a name="l00095"></a>00095 }<a name="l00096"></a>00096 <a name="l00097"></a><a class="code" href="class_qwt_plot_item.html#f153b5a40a60ac626f1c58e69fc4ecad">00097</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_item.html#f153b5a40a60ac626f1c58e69fc4ecad">QwtPlotItem::rtti</a>()<span class="keyword"> const</span><a name="l00098"></a>00098 <span class="keyword"></span>{<a name="l00099"></a>00099     <span class="keywordflow">return</span> Rtti_PlotItem;<a name="l00100"></a>00100 }<a name="l00101"></a>00101 <a name="l00103"></a><a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">00103</a> <a class="code" href="class_qwt_plot.html">QwtPlot</a> *<a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">QwtPlotItem::plot</a>()<span class="keyword"> const </span><a name="l00104"></a>00104 <span class="keyword"></span>{ <a name="l00105"></a>00105     <span class="keywordflow">return</span> d_data-&gt;plot; <a name="l00106"></a>00106 }<a name="l00107"></a>00107 <a name="l00113"></a><a class="code" href="class_qwt_plot_item.html#4c58d814336643190b9f2918f80c30df">00113</a> <span class="keywordtype">double</span> <a class="code" href="class_qwt_plot_item.html#4c58d814336643190b9f2918f80c30df">QwtPlotItem::z</a>()<span class="keyword"> const </span><a name="l00114"></a>00114 <span class="keyword"></span>{ <a name="l00115"></a>00115     <span class="keywordflow">return</span> d_data-&gt;z; <a name="l00116"></a>00116 }<a name="l00117"></a>00117 <a name="l00126"></a><a class="code" href="class_qwt_plot_item.html#57d90e4146133b59d589c71b3a643e82">00126</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#57d90e4146133b59d589c71b3a643e82">QwtPlotItem::setZ</a>(<span class="keywordtype">double</span> z) <a name="l00127"></a>00127 { <a name="l00128"></a>00128     <span class="keywordflow">if</span> ( d_data-&gt;z != z )<a name="l00129"></a>00129     {<a name="l00130"></a>00130         d_data-&gt;z = z; 

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?