1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
30 \brief Convert Plot2d marker type to Qwt marker type.
31 \param m Plot2d marker type
32 \return Qwt marker type
34 QwtSymbol::Style Plot2d::plot2qwtMarker( Plot2d::MarkerType m )
36 QwtSymbol::Style ms = QwtSymbol::NoSymbol;
39 ms = QwtSymbol::Ellipse; break;
40 case Plot2d::Rectangle:
41 ms = QwtSymbol::Rect; break;
43 ms = QwtSymbol::Diamond; break;
44 case Plot2d::DTriangle:
45 ms = QwtSymbol::DTriangle; break;
46 case Plot2d::UTriangle:
47 ms = QwtSymbol::UTriangle; break;
48 case Plot2d::LTriangle:
49 ms = QwtSymbol::LTriangle; break;
50 case Plot2d::RTriangle:
51 ms = QwtSymbol::RTriangle; break;
53 ms = QwtSymbol::Cross; break;
55 ms = QwtSymbol::XCross; break;
58 ms = QwtSymbol::NoSymbol; break;
64 \brief Convert Qwt marker type to Plot2d marker type.
65 \param m Qwt marker type
66 \return Plot2d marker type
68 Plot2d::MarkerType Plot2d::qwt2plotMarker( QwtSymbol::Style m )
70 Plot2d::MarkerType ms = Plot2d::None;
72 case QwtSymbol::Ellipse:
73 ms = Plot2d::Circle; break;
75 ms = Plot2d::Rectangle; break;
76 case QwtSymbol::Diamond:
77 ms = Plot2d::Diamond; break;
78 case QwtSymbol::DTriangle:
79 ms = Plot2d::DTriangle; break;
80 case QwtSymbol::UTriangle:
81 ms = Plot2d::UTriangle; break;
82 case QwtSymbol::RTriangle:
83 ms = Plot2d::RTriangle; break;
84 case QwtSymbol::LTriangle:
85 ms = Plot2d::LTriangle; break;
86 case QwtSymbol::Cross:
87 ms = Plot2d::Cross; break;
88 case QwtSymbol::XCross:
89 ms = Plot2d::XCross; break;
90 case QwtSymbol::NoSymbol:
92 ms = Plot2d::None; break;
98 \brief Convert Plot2d line type to Qt/Qwt line type.
99 \param p Plot2d line type
100 \return Qt/Qwt line type
102 Qt::PenStyle Plot2d::plot2qwtLine( Plot2d::LineType p )
104 Qt::PenStyle ps = Qt::NoPen;
107 ps = Qt::SolidLine; break;
109 ps = Qt::DashLine; break;
111 ps = Qt::DotLine; break;
112 case Plot2d::DashDot:
113 ps = Qt::DashDotLine; break;
114 case Plot2d::DashDotDot:
115 ps = Qt::DashDotDotLine; break;
118 ps = Qt::NoPen; break;
124 \brief Convert Qt/Qwt line type to Plot2d line type.
125 \param p Qt/Qwt line type
126 \return Plot2d line type
128 Plot2d::LineType Plot2d::qwt2plotLine( Qt::PenStyle p )
130 Plot2d::LineType ps = Plot2d::NoPen;
133 ps = Plot2d::Solid; break;
135 ps = Plot2d::Dash; break;
137 ps = Plot2d::Dot; break;
138 case Qt::DashDotLine:
139 ps = Plot2d::DashDot; break;
140 case Qt::DashDotDotLine:
141 ps = Plot2d::DashDotDot; break;
144 ps = Plot2d::NoPen; break;
151 \param painter painter
152 \param p1 starting point
153 \param p2 ending point
154 \param type line type
155 \param color line color
156 \param width line width
158 void Plot2d::drawLine( QPainter* painter, const QPoint& p1, const QPoint& p2,
159 Qt::PenStyle type, const QColor& color, int width )
163 pen.setColor( color );
164 pen.setWidth( width );
165 painter->setPen( pen );
166 painter->drawLine( p1, p2 );
172 \param painter painter
173 \param p1 starting point
174 \param p2 ending point
175 \param type line type
176 \param color line color
177 \param width line width
179 void Plot2d::drawLine( QPainter* painter, const QPoint& p1, const QPoint& p2,
180 Plot2d::LineType type, const QColor& color, int width )
182 drawLine( painter, p1, p2, plot2qwtLine( type ), color, width );
187 \param painter painter
188 \param x1 X coordinate of the starting point
189 \param y1 Y coordinate of the starting point
190 \param x2 X coordinate of the ending point
191 \param y2 Y coordinate of the ending point
192 \param type line type
193 \param color line color
194 \param width line width
196 void Plot2d::drawLine( QPainter* painter, int x1, int y1, int x2, int y2,
197 Qt::PenStyle type, const QColor& color, int width )
199 drawLine( painter, QPoint( x1, y1 ), QPoint( x2, y2 ), type, color, width );
204 \param painter painter
205 \param x1 X coordinate of the starting point
206 \param y1 Y coordinate of the starting point
207 \param x2 X coordinate of the ending point
208 \param y2 Y coordinate of the ending point
209 \param type line type
210 \param color line color
211 \param width line width
213 void Plot2d::drawLine( QPainter* painter, int x1, int y1, int x2, int y2,
214 Plot2d::LineType type, const QColor& color, int width )
216 drawLine( painter, QPoint( x1, y1 ), QPoint( x2, y2 ),
217 plot2qwtLine( type), color, width );
222 \param painter painter
223 \param p central point
224 \param r marker rectangle
225 \param type marker type
226 \param color marker color
228 void Plot2d::drawMarker( QPainter* painter, const QPoint& p, const QRect& r,
229 QwtSymbol::Style type, const QColor& color )
232 painter->setPen( color );
233 painter->setBrush( color );
237 const int w2 = ar.width() / 2;
238 const int h2 = ar.height() / 2;
241 case QwtSymbol::Ellipse:
242 painter->drawEllipse( ar );
244 case QwtSymbol::Rect:
245 painter->drawRect( ar );
246 painter->fillRect( ar, QBrush( color ) );
248 case QwtSymbol::Diamond:
251 polygon << QPoint( ar.x() + w2, ar.y() );
252 polygon << QPoint( ar.right(), ar.y() + h2 );
253 polygon << QPoint( ar.x() + w2, ar.bottom() );
254 polygon << QPoint( ar.x(), ar.y() + h2 );
255 painter->drawPolygon( polygon );
258 case QwtSymbol::Cross:
259 painter->drawLine( ar.left() + w2, ar.top(), ar.left() + w2, ar.bottom() );
260 painter->drawLine( ar.left(), ar.top() + h2, ar.right(), ar.top() + h2 );
262 case QwtSymbol::XCross:
263 painter->drawLine( ar.left(), ar.top(), ar.right(), ar.bottom() );
264 painter->drawLine( ar.left(), ar.bottom(), ar.right(), ar.top() );
266 case QwtSymbol::UTriangle:
269 polygon << QPoint( ar.left() + w2, ar.top() );
270 polygon << QPoint( ar.right(), ar.bottom() );
271 polygon << QPoint( ar.left(), ar.bottom() );
272 painter->drawPolygon( polygon );
275 case QwtSymbol::DTriangle:
278 polygon << QPoint( ar.left() + w2, ar.bottom() );
279 polygon << QPoint( ar.right(), ar.top() );
280 polygon << QPoint( ar.left(), ar.top() );
281 painter->drawPolygon( polygon );
284 case QwtSymbol::RTriangle:
287 polygon << QPoint( ar.left(), ar.top() );
288 polygon << QPoint( ar.right(), ar.top() + h2 );
289 polygon << QPoint( ar.left(), ar.bottom() );
290 painter->drawPolygon( polygon );
293 case QwtSymbol::LTriangle:
296 polygon << QPoint( ar.left(), ar.top() + h2 );
297 polygon << QPoint( ar.right(), ar.top() );
298 polygon << QPoint( ar.right(), ar.bottom() );
299 painter->drawPolygon( polygon );
310 \param painter painter
311 \param p central point
312 \param r marker rectangle
313 \param type marker type
314 \param color marker color
316 void Plot2d::drawMarker( QPainter* painter, const QPoint& p, const QRect& r,
317 Plot2d::MarkerType type, const QColor& color )
319 drawMarker( painter, p, r, plot2qwtMarker( type ), color );
324 \param painter painter
325 \param x X coordinate of the central point
326 \param y Y coordinate of the central point
327 \param w marker rectangle width
328 \param h marker rectangle height
329 \param type marker type
330 \param color marker color
332 void Plot2d::drawMarker( QPainter* painter, int x, int y, int w, int h,
333 QwtSymbol::Style type, const QColor& color )
335 drawMarker( painter, QPoint( x, y ), QRect( 0, 0, w, h ), type, color );
340 \param painter painter
341 \param x X coordinate of the central point
342 \param y Y coordinate of the central point
343 \param w marker rectangle width
344 \param h marker rectangle height
345 \param type marker type
346 \param color marker color
348 void Plot2d::drawMarker( QPainter* painter, int x, int y, int w, int h,
349 Plot2d::MarkerType type, const QColor& color )
351 drawMarker( painter, QPoint( x, y ), QRect( 0, 0, w, h ), plot2qwtMarker( type ), color );