1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
3
<title>Qwt User's Guide: qwt_plot_item.cpp Source File</title>
4
<link href="doxygen.css" rel="stylesheet" type="text/css">
5
<link href="tabs.css" rel="stylesheet" type="text/css">
7
<!-- Generated by Doxygen 1.4.6 -->
10
<li><a href="index.html"><span>Main Page</span></a></li>
11
<li><a href="classes.html"><span>Classes</span></a></li>
12
<li id="current"><a href="files.html"><span>Files</span></a></li>
13
<li><a href="pages.html"><span>Related Pages</span></a></li>
15
<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>
16
<a name="l00002"></a>00002 <span class="comment"> * Qwt Widget Library</span>
17
<a name="l00003"></a>00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span>
18
<a name="l00004"></a>00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span>
19
<a name="l00005"></a>00005 <span class="comment"> * </span>
20
<a name="l00006"></a>00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
21
<a name="l00007"></a>00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
22
<a name="l00008"></a>00008 <span class="comment"> *****************************************************************************/</span>
23
<a name="l00009"></a>00009
24
<a name="l00010"></a>00010 <span class="preprocessor">#include "qwt_text.h"</span>
25
<a name="l00011"></a>00011 <span class="preprocessor">#include "qwt_plot.h"</span>
26
<a name="l00012"></a>00012 <span class="preprocessor">#include "qwt_legend.h"</span>
27
<a name="l00013"></a>00013 <span class="preprocessor">#include "qwt_legend_item.h"</span>
28
<a name="l00014"></a>00014 <span class="preprocessor">#include "qwt_plot_item.h"</span>
29
<a name="l00015"></a>00015
30
<a name="l00016"></a>00016 <span class="keyword">class </span>QwtPlotItem::PrivateData
31
<a name="l00017"></a>00017 {
32
<a name="l00018"></a>00018 <span class="keyword">public</span>:
33
<a name="l00019"></a>00019 PrivateData():
34
<a name="l00020"></a>00020 <a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a>(NULL),
35
<a name="l00021"></a>00021 <a class="code" href="class_qwt_plot_item.html#eaf8eeb5f080017e181a5d7be798d789">isVisible</a>(true),
36
<a name="l00022"></a>00022 attributes(0),
37
<a name="l00023"></a>00023 #if QT_VERSION >= 0x040000
38
<a name="l00024"></a>00024 renderHints(0),
39
<a name="l00025"></a>00025 #endif
40
<a name="l00026"></a>00026 <a class="code" href="class_qwt_plot_item.html#4c58d814336643190b9f2918f80c30df">z</a>(0.0),
41
<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),
42
<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)
43
<a name="l00029"></a>00029 {
44
<a name="l00030"></a>00030 }
45
<a name="l00031"></a>00031
46
<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>;
47
<a name="l00033"></a>00033
48
<a name="l00034"></a>00034 <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_item.html#eaf8eeb5f080017e181a5d7be798d789">isVisible</a>;
49
<a name="l00035"></a>00035 <span class="keywordtype">int</span> attributes;
50
<a name="l00036"></a>00036 <span class="preprocessor">#if QT_VERSION >= 0x040000</span>
51
<a name="l00037"></a>00037 <span class="preprocessor"></span> <span class="keywordtype">int</span> renderHints;
52
<a name="l00038"></a>00038 <span class="preprocessor">#endif</span>
53
<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>;
54
<a name="l00040"></a>00040
55
<a name="l00041"></a>00041 <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_item.html#7af360bf6d5a5b6257ce6b0dd99b7525">xAxis</a>;
56
<a name="l00042"></a>00042 <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_item.html#c7714ffa278a10e0cf45972e487b63ff">yAxis</a>;
57
<a name="l00043"></a>00043
58
<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>;
59
<a name="l00045"></a>00045 };
60
<a name="l00046"></a>00046
61
<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> &<a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>)
62
<a name="l00049"></a>00049 {
63
<a name="l00050"></a>00050 d_data = <span class="keyword">new</span> PrivateData;
64
<a name="l00051"></a>00051 d_data->title = <a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>;
65
<a name="l00052"></a>00052 }
66
<a name="l00053"></a>00053
67
<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>()
68
<a name="l00056"></a>00056 {
69
<a name="l00057"></a>00057 <a class="code" href="class_qwt_plot_item.html#eb2f676533ccae3436bf578824e2165e">attach</a>(NULL);
70
<a name="l00058"></a>00058 <span class="keyword">delete</span> d_data;
71
<a name="l00059"></a>00059 }
72
<a name="l00060"></a>00060
73
<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)
74
<a name="l00065"></a>00065 {
75
<a name="l00066"></a>00066 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_item.html#4c99653a14a49ad94d466168d06e97b9">plot</a> == d_data->plot )
76
<a name="l00067"></a>00067 <span class="keywordflow">return</span>;
77
<a name="l00068"></a>00068
78
<a name="l00069"></a>00069 <span class="comment">// remove the item from the previous plot</span>
79
<a name="l00070"></a>00070
80
<a name="l00071"></a>00071 <span class="keywordflow">if</span> ( d_data->plot )
81
<a name="l00072"></a>00072 {
82
<a name="l00073"></a>00073 <span class="keywordflow">if</span> ( d_data->plot->legend() )
83
<a name="l00074"></a>00074 {
84
<a name="l00075"></a>00075 QWidget *<a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a> = d_data->plot->legend()->find(<span class="keyword">this</span>);
85
<a name="l00076"></a>00076 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a> )
86
<a name="l00077"></a>00077 <span class="keyword">delete</span> <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>;
87
<a name="l00078"></a>00078 }
88
<a name="l00079"></a>00079
89
<a name="l00080"></a>00080 d_data->plot->attachItem(<span class="keyword">this</span>, <span class="keyword">false</span>);
90
<a name="l00081"></a>00081
91
<a name="l00082"></a>00082 <span class="keywordflow">if</span> ( d_data->plot->autoReplot() )
92
<a name="l00083"></a>00083 d_data->plot->update();
93
<a name="l00084"></a>00084 }
94
<a name="l00085"></a>00085
95
<a name="l00086"></a>00086 d_data->plot = plot;
96
<a name="l00087"></a>00087
97
<a name="l00088"></a>00088 <span class="keywordflow">if</span> ( d_data->plot )
98
<a name="l00089"></a>00089 {
99
<a name="l00090"></a>00090 <span class="comment">// insert the item into the current plot</span>
100
<a name="l00091"></a>00091
101
<a name="l00092"></a>00092 d_data->plot->attachItem(<span class="keyword">this</span>, <span class="keyword">true</span>);
102
<a name="l00093"></a>00093 itemChanged();
103
<a name="l00094"></a>00094 }
104
<a name="l00095"></a>00095 }
105
<a name="l00096"></a>00096
106
<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>
107
<a name="l00098"></a>00098 <span class="keyword"></span>{
108
<a name="l00099"></a>00099 <span class="keywordflow">return</span> Rtti_PlotItem;
109
<a name="l00100"></a>00100 }
110
<a name="l00101"></a>00101
111
<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>
112
<a name="l00104"></a>00104 <span class="keyword"></span>{
113
<a name="l00105"></a>00105 <span class="keywordflow">return</span> d_data->plot;
114
<a name="l00106"></a>00106 }
115
<a name="l00107"></a>00107
116
<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>
117
<a name="l00114"></a>00114 <span class="keyword"></span>{
118
<a name="l00115"></a>00115 <span class="keywordflow">return</span> d_data->z;
119
<a name="l00116"></a>00116 }
120
<a name="l00117"></a>00117
121
<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)
122
<a name="l00127"></a>00127 {
123
<a name="l00128"></a>00128 <span class="keywordflow">if</span> ( d_data->z != z )
124
<a name="l00129"></a>00129 {
125
<a name="l00130"></a>00130 d_data->z = z;
126
<a name="l00131"></a>00131 <span class="keywordflow">if</span> ( d_data->plot )
127
<a name="l00132"></a>00132 {
128
<a name="l00133"></a>00133 <span class="comment">// update the z order</span>
129
<a name="l00134"></a>00134 d_data->plot->attachItem(<span class="keyword">this</span>, <span class="keyword">false</span>);
130
<a name="l00135"></a>00135 d_data->plot->attachItem(<span class="keyword">this</span>, <span class="keyword">true</span>);
131
<a name="l00136"></a>00136 }
132
<a name="l00137"></a>00137 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
133
<a name="l00138"></a>00138 }
134
<a name="l00139"></a>00139 }
135
<a name="l00140"></a>00140
136
<a name="l00147"></a><a class="code" href="class_qwt_plot_item.html#1b74686181ab6dd5033917123c7db30f">00147</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#1b74686181ab6dd5033917123c7db30f">QwtPlotItem::setTitle</a>(<span class="keyword">const</span> QString &title)
137
<a name="l00148"></a>00148 {
138
<a name="l00149"></a>00149 <a class="code" href="class_qwt_plot_item.html#1b74686181ab6dd5033917123c7db30f">setTitle</a>(<a class="code" href="class_qwt_text.html">QwtText</a>(title));
139
<a name="l00150"></a>00150 }
140
<a name="l00151"></a>00151
141
<a name="l00158"></a><a class="code" href="class_qwt_plot_item.html#2db3214b23b78274fa6f8c0321a76839">00158</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#1b74686181ab6dd5033917123c7db30f">QwtPlotItem::setTitle</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_text.html">QwtText</a> &title)
142
<a name="l00159"></a>00159 {
143
<a name="l00160"></a>00160 <span class="keywordflow">if</span> ( d_data->title != <a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a> )
144
<a name="l00161"></a>00161 {
145
<a name="l00162"></a>00162 d_data->title = <a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">title</a>;
146
<a name="l00163"></a>00163 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
147
<a name="l00164"></a>00164 }
148
<a name="l00165"></a>00165 }
149
<a name="l00166"></a>00166
150
<a name="l00171"></a><a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">00171</a> <span class="keyword">const</span> <a class="code" href="class_qwt_text.html">QwtText</a> &<a class="code" href="class_qwt_plot_item.html#3859d011b670b5f89e45d1ccef9206f7">QwtPlotItem::title</a>()<span class="keyword"> const</span>
151
<a name="l00172"></a>00172 <span class="keyword"></span>{
152
<a name="l00173"></a>00173 <span class="keywordflow">return</span> d_data->title;
153
<a name="l00174"></a>00174 }
154
<a name="l00175"></a>00175
155
<a name="l00184"></a><a class="code" href="class_qwt_plot_item.html#5a335be8ff488809a2cf7f4b734ad1b6">00184</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#5a335be8ff488809a2cf7f4b734ad1b6">QwtPlotItem::setItemAttribute</a>(<a class="code" href="class_qwt_plot_item.html#e0fabcdd35f4818ce5bbe019b0eed062">ItemAttribute</a> attribute, <span class="keywordtype">bool</span> on)
156
<a name="l00185"></a>00185 {
157
<a name="l00186"></a>00186 <span class="keywordflow">if</span> ( <span class="keywordtype">bool</span>(d_data->attributes & attribute) != on )
158
<a name="l00187"></a>00187 {
159
<a name="l00188"></a>00188 <span class="keywordflow">if</span> ( on )
160
<a name="l00189"></a>00189 d_data->attributes |= attribute;
161
<a name="l00190"></a>00190 <span class="keywordflow">else</span>
162
<a name="l00191"></a>00191 d_data->attributes &= ~attribute;
163
<a name="l00192"></a>00192
164
<a name="l00193"></a>00193 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
165
<a name="l00194"></a>00194 }
166
<a name="l00195"></a>00195 }
167
<a name="l00196"></a>00196
168
<a name="l00204"></a><a class="code" href="class_qwt_plot_item.html#ef70936d34ef661876692e6a06d4a464">00204</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_item.html#ef70936d34ef661876692e6a06d4a464">QwtPlotItem::testItemAttribute</a>(<a class="code" href="class_qwt_plot_item.html#e0fabcdd35f4818ce5bbe019b0eed062">ItemAttribute</a> attribute)<span class="keyword"> const</span>
169
<a name="l00205"></a>00205 <span class="keyword"></span>{
170
<a name="l00206"></a>00206 <span class="keywordflow">return</span> d_data->attributes & attribute;
171
<a name="l00207"></a>00207 }
172
<a name="l00208"></a>00208
173
<a name="l00209"></a>00209 <span class="preprocessor">#if QT_VERSION >= 0x040000</span>
174
<a name="l00210"></a>00210 <span class="preprocessor"></span>
175
<a name="l00219"></a><a class="code" href="class_qwt_plot_item.html#cd023c40f659c304ded324942865edc8">00219</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#cd023c40f659c304ded324942865edc8">QwtPlotItem::setRenderHint</a>(<a class="code" href="class_qwt_plot_item.html#be0e8a39aceef9a600b73e02550a9704">RenderHint</a> hint, <span class="keywordtype">bool</span> on)
176
<a name="l00220"></a>00220 {
177
<a name="l00221"></a>00221 <span class="keywordflow">if</span> ( ((d_data->renderHints & hint) != 0) != on )
178
<a name="l00222"></a>00222 {
179
<a name="l00223"></a>00223 <span class="keywordflow">if</span> ( on )
180
<a name="l00224"></a>00224 d_data->renderHints |= hint;
181
<a name="l00225"></a>00225 <span class="keywordflow">else</span>
182
<a name="l00226"></a>00226 d_data->renderHints &= ~hint;
183
<a name="l00227"></a>00227
184
<a name="l00228"></a>00228 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
185
<a name="l00229"></a>00229 }
186
<a name="l00230"></a>00230 }
187
<a name="l00231"></a>00231
188
<a name="l00239"></a><a class="code" href="class_qwt_plot_item.html#d4009381d6a26359125549e1cf874b69">00239</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_item.html#d4009381d6a26359125549e1cf874b69">QwtPlotItem::testRenderHint</a>(<a class="code" href="class_qwt_plot_item.html#be0e8a39aceef9a600b73e02550a9704">RenderHint</a> hint)<span class="keyword"> const</span>
189
<a name="l00240"></a>00240 <span class="keyword"></span>{
190
<a name="l00241"></a>00241 <span class="keywordflow">return</span> (d_data->renderHints & hint);
191
<a name="l00242"></a>00242 }
192
<a name="l00243"></a>00243
193
<a name="l00244"></a>00244 <span class="preprocessor">#endif</span>
194
<a name="l00245"></a>00245 <span class="preprocessor"></span>
195
<a name="l00246"></a><a class="code" href="class_qwt_plot_item.html#93a50fb9c86bc66617e28315e02281c3">00246</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#93a50fb9c86bc66617e28315e02281c3">QwtPlotItem::show</a>()
196
<a name="l00247"></a>00247 {
197
<a name="l00248"></a>00248 <a class="code" href="class_qwt_plot_item.html#5f0eeb2b72207fd8d33a95b0565657a1">setVisible</a>(<span class="keyword">true</span>);
198
<a name="l00249"></a>00249 }
199
<a name="l00250"></a>00250
200
<a name="l00251"></a><a class="code" href="class_qwt_plot_item.html#1faea017baa2492416a13e6bc3c144aa">00251</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#1faea017baa2492416a13e6bc3c144aa">QwtPlotItem::hide</a>()
201
<a name="l00252"></a>00252 {
202
<a name="l00253"></a>00253 <a class="code" href="class_qwt_plot_item.html#5f0eeb2b72207fd8d33a95b0565657a1">setVisible</a>(<span class="keyword">false</span>);
203
<a name="l00254"></a>00254 }
204
<a name="l00255"></a>00255
205
<a name="l00262"></a><a class="code" href="class_qwt_plot_item.html#5f0eeb2b72207fd8d33a95b0565657a1">00262</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#5f0eeb2b72207fd8d33a95b0565657a1">QwtPlotItem::setVisible</a>(<span class="keywordtype">bool</span> on)
206
<a name="l00263"></a>00263 {
207
<a name="l00264"></a>00264 <span class="keywordflow">if</span> ( on != d_data->isVisible )
208
<a name="l00265"></a>00265 {
209
<a name="l00266"></a>00266 d_data->isVisible = on;
210
<a name="l00267"></a>00267 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
211
<a name="l00268"></a>00268 }
212
<a name="l00269"></a>00269 }
213
<a name="l00270"></a>00270
214
<a name="l00275"></a><a class="code" href="class_qwt_plot_item.html#eaf8eeb5f080017e181a5d7be798d789">00275</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_plot_item.html#eaf8eeb5f080017e181a5d7be798d789">QwtPlotItem::isVisible</a>()<span class="keyword"> const</span>
215
<a name="l00276"></a>00276 <span class="keyword"></span>{
216
<a name="l00277"></a>00277 <span class="keywordflow">return</span> d_data->isVisible;
217
<a name="l00278"></a>00278 }
218
<a name="l00279"></a>00279
219
<a name="l00286"></a><a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">00286</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">QwtPlotItem::itemChanged</a>()
220
<a name="l00287"></a>00287 {
221
<a name="l00288"></a>00288 <span class="keywordflow">if</span> ( d_data->plot )
222
<a name="l00289"></a>00289 {
223
<a name="l00290"></a>00290 <span class="keywordflow">if</span> ( d_data->plot->legend() )
224
<a name="l00291"></a>00291 <a class="code" href="class_qwt_plot_item.html#193770cd20609a368c5130de59cb782e">updateLegend</a>(d_data->plot->legend());
225
<a name="l00292"></a>00292
226
<a name="l00293"></a>00293 d_data->plot->autoRefresh();
227
<a name="l00294"></a>00294 }
228
<a name="l00295"></a>00295 }
229
<a name="l00296"></a>00296
230
<a name="l00307"></a><a class="code" href="class_qwt_plot_item.html#aef9628d6194ae7bb53ac85a5950635a">00307</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#aef9628d6194ae7bb53ac85a5950635a">QwtPlotItem::setAxis</a>(<span class="keywordtype">int</span> xAxis, <span class="keywordtype">int</span> yAxis)
231
<a name="l00308"></a>00308 {
232
<a name="l00309"></a>00309 <span class="keywordflow">if</span> (xAxis == QwtPlot::xBottom || xAxis == QwtPlot::xTop )
233
<a name="l00310"></a>00310 d_data->xAxis = xAxis;
234
<a name="l00311"></a>00311
235
<a name="l00312"></a>00312 <span class="keywordflow">if</span> (yAxis == QwtPlot::yLeft || yAxis == QwtPlot::yRight )
236
<a name="l00313"></a>00313 d_data->yAxis = yAxis;
237
<a name="l00314"></a>00314
238
<a name="l00315"></a>00315 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
239
<a name="l00316"></a>00316 }
240
<a name="l00317"></a>00317
241
<a name="l00326"></a><a class="code" href="class_qwt_plot_item.html#81d3dd7feaadda4b0dbb8c13642046cf">00326</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#81d3dd7feaadda4b0dbb8c13642046cf">QwtPlotItem::setXAxis</a>(<span class="keywordtype">int</span> axis)
242
<a name="l00327"></a>00327 {
243
<a name="l00328"></a>00328 <span class="keywordflow">if</span> (axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
244
<a name="l00329"></a>00329 {
245
<a name="l00330"></a>00330 d_data->xAxis = axis;
246
<a name="l00331"></a>00331 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
247
<a name="l00332"></a>00332 }
248
<a name="l00333"></a>00333 }
249
<a name="l00334"></a>00334
250
<a name="l00343"></a><a class="code" href="class_qwt_plot_item.html#a92dad876d76ce136925d5ae8f01db9a">00343</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#a92dad876d76ce136925d5ae8f01db9a">QwtPlotItem::setYAxis</a>(<span class="keywordtype">int</span> axis)
251
<a name="l00344"></a>00344 {
252
<a name="l00345"></a>00345 <span class="keywordflow">if</span> (axis == QwtPlot::yLeft || axis == QwtPlot::yRight )
253
<a name="l00346"></a>00346 {
254
<a name="l00347"></a>00347 d_data->yAxis = axis;
255
<a name="l00348"></a>00348 <a class="code" href="class_qwt_plot_item.html#d956fdbce5b0721abccce6d09fe4d5ce">itemChanged</a>();
256
<a name="l00349"></a>00349 }
257
<a name="l00350"></a>00350 }
258
<a name="l00351"></a>00351
259
<a name="l00353"></a><a class="code" href="class_qwt_plot_item.html#7af360bf6d5a5b6257ce6b0dd99b7525">00353</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_item.html#7af360bf6d5a5b6257ce6b0dd99b7525">QwtPlotItem::xAxis</a>()<span class="keyword"> const </span>
260
<a name="l00354"></a>00354 <span class="keyword"></span>{
261
<a name="l00355"></a>00355 <span class="keywordflow">return</span> d_data->xAxis;
262
<a name="l00356"></a>00356 }
263
<a name="l00357"></a>00357
264
<a name="l00359"></a><a class="code" href="class_qwt_plot_item.html#c7714ffa278a10e0cf45972e487b63ff">00359</a> <span class="keywordtype">int</span> <a class="code" href="class_qwt_plot_item.html#c7714ffa278a10e0cf45972e487b63ff">QwtPlotItem::yAxis</a>()<span class="keyword"> const </span>
265
<a name="l00360"></a>00360 <span class="keyword"></span>{
266
<a name="l00361"></a>00361 <span class="keywordflow">return</span> d_data->yAxis;
267
<a name="l00362"></a>00362 }
268
<a name="l00363"></a>00363
269
<a name="l00367"></a><a class="code" href="class_qwt_plot_item.html#4c2c1c77421229383b3c43cb777e3bfe">00367</a> QwtDoubleRect <a class="code" href="class_qwt_plot_item.html#4c2c1c77421229383b3c43cb777e3bfe">QwtPlotItem::boundingRect</a>()<span class="keyword"> const</span>
270
<a name="l00368"></a>00368 <span class="keyword"></span>{
271
<a name="l00369"></a>00369 <span class="keywordflow">return</span> QwtDoubleRect(1.0, 1.0, -2.0, -2.0); <span class="comment">// invalid</span>
272
<a name="l00370"></a>00370 }
273
<a name="l00371"></a>00371
274
<a name="l00382"></a><a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">00382</a> QWidget *<a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">QwtPlotItem::legendItem</a>()<span class="keyword"> const</span>
275
<a name="l00383"></a>00383 <span class="keyword"></span>{
276
<a name="l00384"></a>00384 <span class="keywordflow">return</span> <span class="keyword">new</span> <a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a>;
277
<a name="l00385"></a>00385 }
278
<a name="l00386"></a>00386
279
<a name="l00399"></a><a class="code" href="class_qwt_plot_item.html#193770cd20609a368c5130de59cb782e">00399</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#193770cd20609a368c5130de59cb782e">QwtPlotItem::updateLegend</a>(<a class="code" href="class_qwt_legend.html">QwtLegend</a> *legend)<span class="keyword"> const</span>
280
<a name="l00400"></a>00400 <span class="keyword"></span>{
281
<a name="l00401"></a>00401 <span class="keywordflow">if</span> ( !legend )
282
<a name="l00402"></a>00402 <span class="keywordflow">return</span>;
283
<a name="l00403"></a>00403
284
<a name="l00404"></a>00404 QWidget *lgdItem = legend-><a class="code" href="class_qwt_legend.html#ae136e8199d5a3caf86a7767c1de186c">find</a>(<span class="keyword">this</span>);
285
<a name="l00405"></a>00405 <span class="keywordflow">if</span> ( <a class="code" href="class_qwt_plot_item.html#ef70936d34ef661876692e6a06d4a464">testItemAttribute</a>(QwtPlotItem::Legend) )
286
<a name="l00406"></a>00406 {
287
<a name="l00407"></a>00407 <span class="keywordflow">if</span> ( lgdItem == NULL )
288
<a name="l00408"></a>00408 {
289
<a name="l00409"></a>00409 lgdItem = <a class="code" href="class_qwt_plot_item.html#09824eda5e564a853e6586bc387a3b4b">legendItem</a>();
290
<a name="l00410"></a>00410 <span class="keywordflow">if</span> ( lgdItem )
291
<a name="l00411"></a>00411 {
292
<a name="l00412"></a>00412 <span class="keywordflow">if</span> ( lgdItem->inherits(<span class="stringliteral">"QwtLegendItem"</span>) )
293
<a name="l00413"></a>00413 {
294
<a name="l00414"></a>00414 <a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a> *label = (<a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a> *)lgdItem;
295
<a name="l00415"></a>00415 label->setItemMode(legend-><a class="code" href="class_qwt_legend.html#463c5542c6547c04050c912a5e500155">itemMode</a>());
296
<a name="l00416"></a>00416
297
<a name="l00417"></a>00417 <span class="keywordflow">if</span> ( d_data->plot )
298
<a name="l00418"></a>00418 {
299
<a name="l00419"></a>00419 QObject::connect(label, SIGNAL(clicked()),
300
<a name="l00420"></a>00420 d_data->plot, SLOT(legendItemClicked()));
301
<a name="l00421"></a>00421 QObject::connect(label, SIGNAL(checked(<span class="keywordtype">bool</span>)),
302
<a name="l00422"></a>00422 d_data->plot, SLOT(legendItemChecked(<span class="keywordtype">bool</span>)));
303
<a name="l00423"></a>00423 }
304
<a name="l00424"></a>00424 }
305
<a name="l00425"></a>00425 legend-><a class="code" href="class_qwt_legend.html#54456bf97e80da5bfb4cca91367b8e15">insert</a>(<span class="keyword">this</span>, lgdItem);
306
<a name="l00426"></a>00426 }
307
<a name="l00427"></a>00427 }
308
<a name="l00428"></a>00428 <span class="keywordflow">if</span> ( lgdItem && lgdItem->inherits(<span class="stringliteral">"QwtLegendItem"</span>) )
309
<a name="l00429"></a>00429 {
310
<a name="l00430"></a>00430 <a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a>* label = (<a class="code" href="class_qwt_legend_item.html">QwtLegendItem</a>*)lgdItem;
311
<a name="l00431"></a>00431 <span class="keywordflow">if</span> ( label )
312
<a name="l00432"></a>00432 label->setText(d_data->title);
313
<a name="l00433"></a>00433 }
314
<a name="l00434"></a>00434 }
315
<a name="l00435"></a>00435 <span class="keywordflow">else</span>
316
<a name="l00436"></a>00436 {
317
<a name="l00437"></a>00437 <span class="keyword">delete</span> lgdItem;
318
<a name="l00438"></a>00438 }
319
<a name="l00439"></a>00439 }
320
<a name="l00440"></a>00440
321
<a name="l00454"></a><a class="code" href="class_qwt_plot_item.html#bf6a70847d3db952161ca4d4a952eea0">00454</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_plot_item.html#bf6a70847d3db952161ca4d4a952eea0">QwtPlotItem::updateScaleDiv</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_scale_div.html">QwtScaleDiv</a> &,
322
<a name="l00455"></a>00455 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_div.html">QwtScaleDiv</a> &)
323
<a name="l00456"></a>00456 {
324
<a name="l00457"></a>00457 }
325
<a name="l00458"></a>00458
326
<a name="l00467"></a><a class="code" href="class_qwt_plot_item.html#0a0181bc26a041b4e58f2810e55866bb">00467</a> QwtDoubleRect <a class="code" href="class_qwt_plot_item.html#0a0181bc26a041b4e58f2810e55866bb">QwtPlotItem::scaleRect</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap,
327
<a name="l00468"></a>00468 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap)<span class="keyword"> const</span>
328
<a name="l00469"></a>00469 <span class="keyword"></span>{
329
<a name="l00470"></a>00470 <span class="keywordflow">return</span> QwtDoubleRect(xMap.<a class="code" href="class_qwt_scale_map.html#38b6a7040cd15a427f7631afa20cbad8">s1</a>(), yMap.<a class="code" href="class_qwt_scale_map.html#38b6a7040cd15a427f7631afa20cbad8">s1</a>(),
330
<a name="l00471"></a>00471 xMap.<a class="code" href="class_qwt_scale_map.html#df621246cfa7313280a35a44063972f3">sDist</a>(), yMap.<a class="code" href="class_qwt_scale_map.html#df621246cfa7313280a35a44063972f3">sDist</a>() );
331
<a name="l00472"></a>00472 }
332
<a name="l00473"></a>00473
333
<a name="l00482"></a><a class="code" href="class_qwt_plot_item.html#97559cef0e65e59c48ca9bd3e7953b04">00482</a> QRect <a class="code" href="class_qwt_plot_item.html#97559cef0e65e59c48ca9bd3e7953b04">QwtPlotItem::paintRect</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap,
334
<a name="l00483"></a>00483 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap)<span class="keyword"> const</span>
335
<a name="l00484"></a>00484 <span class="keyword"></span>{
336
<a name="l00485"></a>00485 <span class="keyword">const</span> QRect rect( qRound(xMap.<a class="code" href="class_qwt_scale_map.html#c1ca2f9b4643d27fde693cc98bca0cd7">p1</a>()), qRound(yMap.<a class="code" href="class_qwt_scale_map.html#c1ca2f9b4643d27fde693cc98bca0cd7">p1</a>()),
337
<a name="l00486"></a>00486 qRound(xMap.<a class="code" href="class_qwt_scale_map.html#f364d4fa10db6f5dbc93d6ce763e603f">pDist</a>()), qRound(yMap.<a class="code" href="class_qwt_scale_map.html#f364d4fa10db6f5dbc93d6ce763e603f">pDist</a>()) );
338
<a name="l00487"></a>00487
339
<a name="l00488"></a>00488 <span class="keywordflow">return</span> rect;
340
<a name="l00489"></a>00489 }
341
<a name="l00490"></a>00490
342
<a name="l00501"></a><a class="code" href="class_qwt_plot_item.html#ce79adb7c901ef5d729dba35265096c2">00501</a> QRect <a class="code" href="class_qwt_plot_item.html#ce79adb7c901ef5d729dba35265096c2">QwtPlotItem::transform</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap,
343
<a name="l00502"></a>00502 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap, <span class="keyword">const</span> QwtDoubleRect& rect)<span class="keyword"> const</span>
344
<a name="l00503"></a>00503 <span class="keyword"></span>{
345
<a name="l00504"></a>00504 <span class="keywordtype">int</span> x1 = qRound(xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(rect.left()));
346
<a name="l00505"></a>00505 <span class="keywordtype">int</span> x2 = qRound(xMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(rect.right()));
347
<a name="l00506"></a>00506 <span class="keywordtype">int</span> y1 = qRound(yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(rect.top()));
348
<a name="l00507"></a>00507 <span class="keywordtype">int</span> y2 = qRound(yMap.<a class="code" href="class_qwt_scale_map.html#1ddda39f41e137560e625a8c66c1d2e1">transform</a>(rect.bottom()));
349
<a name="l00508"></a>00508
350
<a name="l00509"></a>00509 <span class="keywordflow">if</span> ( x2 < x1 )
351
<a name="l00510"></a>00510 qSwap(x1, x2);
352
<a name="l00511"></a>00511 <span class="keywordflow">if</span> ( y2 < y1 )
353
<a name="l00512"></a>00512 qSwap(y1, y2);
354
<a name="l00513"></a>00513
355
<a name="l00514"></a>00514 <span class="keywordflow">return</span> QRect(x1, y1, x2 - x1 - 1, y2 - y1 - 1);
356
<a name="l00515"></a>00515 }
357
<a name="l00516"></a>00516
358
<a name="l00526"></a><a class="code" href="class_qwt_plot_item.html#913adffa4cb6914f3248b7157b9bbf33">00526</a> QwtDoubleRect <a class="code" href="class_qwt_plot_item.html#913adffa4cb6914f3248b7157b9bbf33">QwtPlotItem::invTransform</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &xMap,
359
<a name="l00527"></a>00527 <span class="keyword">const</span> <a class="code" href="class_qwt_scale_map.html">QwtScaleMap</a> &yMap, <span class="keyword">const</span> QRect& rect)<span class="keyword"> const</span>
360
<a name="l00528"></a>00528 <span class="keyword"></span>{
361
<a name="l00529"></a>00529 <span class="keyword">const</span> <span class="keywordtype">double</span> x1 = xMap.<a class="code" href="class_qwt_scale_map.html#0df4d78da09fa88d1063554542c7fb03">invTransform</a>(rect.x());
362
<a name="l00530"></a>00530 <span class="keyword">const</span> <span class="keywordtype">double</span> x2 = xMap.<a class="code" href="class_qwt_scale_map.html#0df4d78da09fa88d1063554542c7fb03">invTransform</a>(rect.x() + rect.width() + 1);
363
<a name="l00531"></a>00531 <span class="keyword">const</span> <span class="keywordtype">double</span> y1 = yMap.<a class="code" href="class_qwt_scale_map.html#0df4d78da09fa88d1063554542c7fb03">invTransform</a>(rect.y());
364
<a name="l00532"></a>00532 <span class="keyword">const</span> <span class="keywordtype">double</span> y2 = yMap.<a class="code" href="class_qwt_scale_map.html#0df4d78da09fa88d1063554542c7fb03">invTransform</a>(rect.y() + rect.height() + 1);
365
<a name="l00533"></a>00533
366
<a name="l00534"></a>00534 <span class="keyword">const</span> QwtDoubleRect r(x1, y1, x2 - x1, y2 - y1);
367
<a name="l00535"></a>00535
368
<a name="l00536"></a>00536 <span class="keywordflow">return</span> r.normalized();
369
<a name="l00537"></a>00537 }
370
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Mon Feb 26 21:22:37 2007 for Qwt User's Guide by
371
<a href="http://www.doxygen.org/index.html">
372
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.6 </small></address>