1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
|
<!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_symbol.cpp Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.3.8 -->
<div class="qindex"><a class="qindex" href="index.html">Main Page</a> | <a class="qindex" href="hierarchy.html">Class Hierarchy</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="functions.html">Class Members</a> | <a class="qindex" href="globals.html">File Members</a> | <a class="qindex" href="pages.html">Related Pages</a></div>
<h1>qwt_symbol.cpp</h1><pre class="fragment"><div>00001 <span class="comment">/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************</span>
00002 <span class="comment"> * Qwt Widget Library</span>
00003 <span class="comment"> * Copyright (C) 1997 Josef Wilgen</span>
00004 <span class="comment"> * Copyright (C) 2002 Uwe Rathmann</span>
00005 <span class="comment"> * </span>
00006 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
00007 <span class="comment"> * modify it under the terms of the Qwt License, Version 1.0</span>
00008 <span class="comment"> *****************************************************************************/</span>
00009
00010 <span class="preprocessor">#include <qpainter.h></span>
00011 <span class="preprocessor">#include <qpaintdevicemetrics.h></span>
00012 <span class="preprocessor">#include <qapplication.h></span>
00013 <span class="preprocessor">#include "qwt_painter.h"</span>
00014 <span class="preprocessor">#include "qwt_symbol.h"</span>
00015
<a name="l00022"></a><a class="code" href="class_qwt_symbol.html#a0">00022</a> <a class="code" href="class_qwt_symbol.html#a0">QwtSymbol::QwtSymbol</a>():
00023 d_brush(Qt::gray),
00024 d_pen(Qt::black),
00025 d_size(0,0),
00026 d_style(<a class="code" href="class_qwt_symbol.html">QwtSymbol</a>::None)
00027 {
00028 }
00029
<a name="l00037"></a><a class="code" href="class_qwt_symbol.html#a1">00037</a> <a class="code" href="class_qwt_symbol.html#a0">QwtSymbol::QwtSymbol</a>(QwtSymbol::Style style, <span class="keyword">const</span> QBrush &brush,
00038 <span class="keyword">const</span> QPen &pen, <span class="keyword">const</span> QSize &size):
00039 d_brush(brush),
00040 d_pen(pen),
00041 d_size(size),
00042 d_style(style)
00043 {
00044 }
00045
<a name="l00047"></a><a class="code" href="class_qwt_symbol.html#a2">00047</a> <a class="code" href="class_qwt_symbol.html#a2">QwtSymbol::~QwtSymbol</a>()
00048 {
00049 }
00050
<a name="l00060"></a><a class="code" href="class_qwt_symbol.html#a6">00060</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_symbol.html#a5">QwtSymbol::setSize</a>(<span class="keywordtype">int</span> w, <span class="keywordtype">int</span> h)
00061 {
00062 <span class="keywordflow">if</span> ((w >= 0) && (h < 0))
00063 h = w;
00064 d_size = QSize(w,h);
00065 }
00066
<a name="l00068"></a><a class="code" href="class_qwt_symbol.html#a5">00068</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_symbol.html#a5">QwtSymbol::setSize</a>(<span class="keyword">const</span> QSize &s)
00069 {
00070 <span class="keywordflow">if</span> (s.isValid())
00071 d_size = s;
00072 }
00073
<a name="l00080"></a><a class="code" href="class_qwt_symbol.html#a7">00080</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_symbol.html#a7">QwtSymbol::setBrush</a>(<span class="keyword">const</span> QBrush &br)
00081 {
00082 d_brush = br;
00083 }
00084
<a name="l00092"></a><a class="code" href="class_qwt_symbol.html#a8">00092</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_symbol.html#a8">QwtSymbol::setPen</a>(<span class="keyword">const</span> QPen &pn)
00093 {
00094 d_pen = pn;
00095 }
00096
<a name="l00100"></a><a class="code" href="class_qwt_symbol.html#a15">00100</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_symbol.html#a14">QwtSymbol::draw</a>(QPainter *painter, <span class="keywordtype">int</span> x, <span class="keywordtype">int</span> y)<span class="keyword"> const</span>
00101 <span class="keyword"></span>{
00102 <a class="code" href="class_qwt_symbol.html#a14">draw</a>(painter, QPoint(x, y));
00103 }
00104
00105
<a name="l00116"></a><a class="code" href="class_qwt_symbol.html#a16">00116</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_symbol.html#a14">QwtSymbol::draw</a>(QPainter *painter, <span class="keyword">const</span> QRect& r)<span class="keyword"> const</span>
00117 <span class="keyword"></span>{
00118 <span class="keyword">const</span> <span class="keywordtype">int</span> w2 = r.width() / 2;
00119 <span class="keyword">const</span> <span class="keywordtype">int</span> h2 = r.height() / 2;
00120
00121 <span class="keywordflow">switch</span>(d_style)
00122 {
00123 <span class="keywordflow">case</span> QwtSymbol::Ellipse:
00124 <a class="code" href="class_qwt_painter.html#e15">QwtPainter::drawEllipse</a>(painter, r);
00125 <span class="keywordflow">break</span>;
00126 <span class="keywordflow">case</span> QwtSymbol::Rect:
00127 <a class="code" href="class_qwt_painter.html#e12">QwtPainter::drawRect</a>(painter, r);
00128 <span class="keywordflow">break</span>;
00129 <span class="keywordflow">case</span> QwtSymbol::Diamond:
00130 {
00131 QPointArray pa(4);
00132 pa.setPoint(0, r.x() + w2, r.y());
00133 pa.setPoint(1, r.right(), r.y() + h2);
00134 pa.setPoint(2, r.x() + w2, r.bottom());
00135 pa.setPoint(3, r.x(), r.y() + h2);
00136 <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, pa);
00137 <span class="keywordflow">break</span>;
00138 }
00139 <span class="keywordflow">case</span> QwtSymbol::Cross:
00140 <a class="code" href="class_qwt_painter.html#e16">QwtPainter::drawLine</a>(painter, r.x() + w2, r.y(),
00141 r.x() + w2, r.bottom());
00142 <a class="code" href="class_qwt_painter.html#e16">QwtPainter::drawLine</a>(painter, r.x(), r.y() + h2,
00143 r.right(), r.y() + h2);
00144 <span class="keywordflow">break</span>;
00145 <span class="keywordflow">case</span> QwtSymbol::XCross:
00146 <a class="code" href="class_qwt_painter.html#e16">QwtPainter::drawLine</a>(painter, r.left(), r.top(),
00147 r.right(), r.bottom());
00148 <a class="code" href="class_qwt_painter.html#e16">QwtPainter::drawLine</a>(painter, r.left(), r.bottom(),
00149 r.right(), r.top());
00150 <span class="keywordflow">break</span>;
00151 <span class="keywordflow">case</span> QwtSymbol::Triangle:
00152 <span class="keywordflow">case</span> QwtSymbol::UTriangle:
00153 {
00154 QPointArray pa(3);
00155 pa.setPoint(0, r.x() + w2, r.y());
00156 pa.setPoint(1, r.right(), r.bottom());
00157 pa.setPoint(2, r.x(), r.bottom());
00158 <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, pa);
00159 <span class="keywordflow">break</span>;
00160 }
00161 <span class="keywordflow">case</span> QwtSymbol::DTriangle:
00162 {
00163 QPointArray pa(3);
00164 pa.setPoint(0, r.x(), r.y());
00165 pa.setPoint(1, r.right(), r.y());
00166 pa.setPoint(2, r.x() + w2, r.bottom());
00167 <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, pa);
00168 <span class="keywordflow">break</span>;
00169 }
00170 <span class="keywordflow">case</span> QwtSymbol::RTriangle:
00171 {
00172 QPointArray pa(3);
00173 pa.setPoint(0, r.x(), r.y());
00174 pa.setPoint(1, r.right(), r.y() + h2);
00175 pa.setPoint(2, r.x(), r.bottom());
00176 <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, pa);
00177 <span class="keywordflow">break</span>;
00178 }
00179 <span class="keywordflow">case</span> QwtSymbol::LTriangle:
00180 {
00181 QPointArray pa(3);
00182 pa.setPoint(0, r.right(), r.y());
00183 pa.setPoint(1, r.x(), r.y() + h2);
00184 pa.setPoint(2, r.right(), r.bottom());
00185 <a class="code" href="class_qwt_painter.html#e18">QwtPainter::drawPolygon</a>(painter, pa);
00186 <span class="keywordflow">break</span>;
00187 }
00188 <span class="keywordflow">default</span>:;
00189 }
00190 }
00191
<a name="l00198"></a><a class="code" href="class_qwt_symbol.html#a14">00198</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_symbol.html#a14">QwtSymbol::draw</a>(QPainter *painter, <span class="keyword">const</span> QPoint &pos)<span class="keyword"> const</span>
00199 <span class="keyword"></span>{
00200 QRect rect;
00201 rect.setSize(QwtPainter::metricsMap().screenToLayout(d_size));
00202 rect.moveCenter(pos);
00203
00204 painter->setBrush(d_brush);
00205 painter->setPen(d_pen);
00206
00207 <a class="code" href="class_qwt_symbol.html#a14">draw</a>(painter, rect);
00208 }
00209
<a name="l00227"></a><a class="code" href="class_qwt_symbol.html#a9">00227</a> <span class="keywordtype">void</span> <a class="code" href="class_qwt_symbol.html#a9">QwtSymbol::setStyle</a>(QwtSymbol::Style s)
00228 {
00229 d_style = s;
00230 }
00231
<a name="l00233"></a><a class="code" href="class_qwt_symbol.html#a4">00233</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_symbol.html#a4">QwtSymbol::operator==</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &other)<span class="keyword"> const</span>
00234 <span class="keyword"></span>{
00235 <span class="keywordflow">return</span> <a class="code" href="class_qwt_symbol.html#a10">brush</a>() == other.<a class="code" href="class_qwt_symbol.html#a10">brush</a>() && <a class="code" href="class_qwt_symbol.html#a11">pen</a>() == other.<a class="code" href="class_qwt_symbol.html#a11">pen</a>()
00236 && <a class="code" href="class_qwt_symbol.html#a13">style</a>() == other.<a class="code" href="class_qwt_symbol.html#a13">style</a>() && <a class="code" href="class_qwt_symbol.html#a12">size</a>() == other.<a class="code" href="class_qwt_symbol.html#a12">size</a>();
00237 }
00238
<a name="l00240"></a><a class="code" href="class_qwt_symbol.html#a3">00240</a> <span class="keywordtype">bool</span> <a class="code" href="class_qwt_symbol.html#a3">QwtSymbol::operator!=</a>(<span class="keyword">const</span> <a class="code" href="class_qwt_symbol.html">QwtSymbol</a> &other)<span class="keyword"> const</span>
00241 <span class="keyword"></span>{
00242 <span class="keywordflow">return</span> !(*<span class="keyword">this</span> == other);
00243 }
</div></pre><hr size="1"><address style="align: right;"><small>Generated on Tue Nov 16 21:12:21 2004 for Qwt User's Guide by
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.8 </small></address>
</body>
</html>
|