qwt_symbol.cpp
Go to the documentation of this file.
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
2  * Qwt Widget Library
3  * Copyright (C) 1997 Josef Wilgen
4  * Copyright (C) 2002 Uwe Rathmann
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the Qwt License, Version 1.0
8  *****************************************************************************/
9 
10 #include "qwt_symbol.h"
11 #include "qwt_painter.h"
12 #include "qwt_graphic.h"
13 #include <qapplication.h>
14 #include <qpainter.h>
15 #include <qpainterpath.h>
16 #include <qpixmap.h>
17 #include <qpaintengine.h>
18 #include <qmath.h>
19 #ifndef QWT_NO_SVG
20 #include <qsvgrenderer.h>
21 #endif
22 
23 namespace QwtTriangle
24 {
25  enum Type
26  {
29  Up,
31  };
32 }
33 
34 static QwtGraphic qwtPathGraphic( const QPainterPath &path,
35  const QPen &pen, const QBrush& brush )
36 {
37  QwtGraphic graphic;
39 
40  QPainter painter( &graphic );
41  painter.setPen( pen );
42  painter.setBrush( brush );
43  painter.drawPath( path );
44  painter.end();
45 
46  return graphic;
47 }
48 
49 static inline QRectF qwtScaledBoundingRect(
50  const QwtGraphic &graphic, const QSizeF size )
51 {
52  QSizeF scaledSize = size;
53  if ( scaledSize.isEmpty() )
54  scaledSize = graphic.defaultSize();
55 
56  const QSizeF sz = graphic.controlPointRect().size();
57 
58  double sx = 1.0;
59  if ( sz.width() > 0.0 )
60  sx = scaledSize.width() / sz.width();
61 
62  double sy = 1.0;
63  if ( sz.height() > 0.0 )
64  sy = scaledSize.height() / sz.height();
65 
66  return graphic.scaledBoundingRect( sx, sy );
67 }
68 
69 static inline void qwtDrawPixmapSymbols( QPainter *painter,
70  const QPointF *points, int numPoints, const QwtSymbol &symbol )
71 {
72  QSize size = symbol.size();
73  if ( size.isEmpty() )
74  size = symbol.pixmap().size();
75 
76  const QTransform transform = painter->transform();
77  if ( transform.isScaling() )
78  {
79  const QRect r( 0, 0, size.width(), size.height() );
80  size = transform.mapRect( r ).size();
81  }
82 
83  QPixmap pm = symbol.pixmap();
84  if ( pm.size() != size )
85  pm = pm.scaled( size );
86 
87  QPointF pinPoint( 0.5 * size.width(), 0.5 * size.height() );
88  if ( symbol.isPinPointEnabled() )
89  pinPoint = symbol.pinPoint();
90 
91  painter->resetTransform();
92 
93  for ( int i = 0; i < numPoints; i++ )
94  {
95  const QPointF pos = transform.map( points[i] ) - pinPoint;
96 
97  QwtPainter::drawPixmap( painter,
98  QRect( pos.toPoint(), pm.size() ), pm );
99  }
100 }
101 
102 #ifndef QWT_NO_SVG
103 
104 static inline void qwtDrawSvgSymbols( QPainter *painter,
105  const QPointF *points, int numPoints,
106  QSvgRenderer *renderer, const QwtSymbol &symbol )
107 {
108  if ( renderer == NULL || !renderer->isValid() )
109  return;
110 
111  const QRectF viewBox = renderer->viewBoxF();
112  if ( viewBox.isEmpty() )
113  return;
114 
115  QSizeF sz = symbol.size();
116  if ( !sz.isValid() )
117  sz = viewBox.size();
118 
119  const double sx = sz.width() / viewBox.width();
120  const double sy = sz.height() / viewBox.height();
121 
122  QPointF pinPoint = viewBox.center();
123  if ( symbol.isPinPointEnabled() )
124  pinPoint = symbol.pinPoint();
125 
126  const double dx = sx * ( pinPoint.x() - viewBox.left() );
127  const double dy = sy * ( pinPoint.y() - viewBox.top() );
128 
129  for ( int i = 0; i < numPoints; i++ )
130  {
131  const double x = points[i].x() - dx;
132  const double y = points[i].y() - dy;
133 
134  renderer->render( painter,
135  QRectF( x, y, sz.width(), sz.height() ) );
136  }
137 }
138 
139 #endif
140 
141 static inline void qwtDrawGraphicSymbols( QPainter *painter,
142  const QPointF *points, int numPoints, const QwtGraphic &graphic,
143  const QwtSymbol &symbol )
144 {
145  const QRectF pointRect = graphic.controlPointRect();
146  if ( pointRect.isEmpty() )
147  return;
148 
149  double sx = 1.0;
150  double sy = 1.0;
151 
152  const QSize sz = symbol.size();
153  if ( sz.isValid() )
154  {
155  sx = sz.width() / pointRect.width();
156  sy = sz.height() / pointRect.height();
157  }
158 
159  QPointF pinPoint = pointRect.center();
160  if ( symbol.isPinPointEnabled() )
161  pinPoint = symbol.pinPoint();
162 
163  const QTransform transform = painter->transform();
164 
165  for ( int i = 0; i < numPoints; i++ )
166  {
167  QTransform tr = transform;
168  tr.translate( points[i].x(), points[i].y() );
169  tr.scale( sx, sy );
170  tr.translate( -pinPoint.x(), -pinPoint.y() );
171 
172  painter->setTransform( tr );
173 
174  graphic.render( painter );
175  }
176 
177  painter->setTransform( transform );
178 }
179 
180 static inline void qwtDrawEllipseSymbols( QPainter *painter,
181  const QPointF *points, int numPoints, const QwtSymbol &symbol )
182 {
183  painter->setBrush( symbol.brush() );
184  painter->setPen( symbol.pen() );
185 
186  const QSize size = symbol.size();
187 
188  if ( QwtPainter::roundingAlignment( painter ) )
189  {
190  const int sw = size.width();
191  const int sh = size.height();
192  const int sw2 = size.width() / 2;
193  const int sh2 = size.height() / 2;
194 
195  for ( int i = 0; i < numPoints; i++ )
196  {
197  const int x = qRound( points[i].x() );
198  const int y = qRound( points[i].y() );
199 
200  const QRectF r( x - sw2, y - sh2, sw, sh );
201  QwtPainter::drawEllipse( painter, r );
202  }
203  }
204  else
205  {
206  const double sw = size.width();
207  const double sh = size.height();
208  const double sw2 = 0.5 * size.width();
209  const double sh2 = 0.5 * size.height();
210 
211  for ( int i = 0; i < numPoints; i++ )
212  {
213  const double x = points[i].x();
214  const double y = points[i].y();
215 
216  const QRectF r( x - sw2, y - sh2, sw, sh );
217  QwtPainter::drawEllipse( painter, r );
218  }
219  }
220 }
221 
222 static inline void qwtDrawRectSymbols( QPainter *painter,
223  const QPointF *points, int numPoints, const QwtSymbol &symbol )
224 {
225  const QSize size = symbol.size();
226 
227  QPen pen = symbol.pen();
228  pen.setJoinStyle( Qt::MiterJoin );
229  painter->setPen( pen );
230  painter->setBrush( symbol.brush() );
231  painter->setRenderHint( QPainter::Antialiasing, false );
232 
233  if ( QwtPainter::roundingAlignment( painter ) )
234  {
235  const int sw = size.width();
236  const int sh = size.height();
237  const int sw2 = size.width() / 2;
238  const int sh2 = size.height() / 2;
239 
240  for ( int i = 0; i < numPoints; i++ )
241  {
242  const int x = qRound( points[i].x() );
243  const int y = qRound( points[i].y() );
244 
245  const QRect r( x - sw2, y - sh2, sw, sh );
246  QwtPainter::drawRect( painter, r );
247  }
248  }
249  else
250  {
251  const double sw = size.width();
252  const double sh = size.height();
253  const double sw2 = 0.5 * size.width();
254  const double sh2 = 0.5 * size.height();
255 
256  for ( int i = 0; i < numPoints; i++ )
257  {
258  const double x = points[i].x();
259  const double y = points[i].y();
260 
261  const QRectF r( x - sw2, y - sh2, sw, sh );
262  QwtPainter::drawRect( painter, r );
263  }
264  }
265 }
266 
267 static inline void qwtDrawDiamondSymbols( QPainter *painter,
268  const QPointF *points, int numPoints, const QwtSymbol &symbol )
269 {
270  const QSize size = symbol.size();
271 
272  QPen pen = symbol.pen();
273  pen.setJoinStyle( Qt::MiterJoin );
274  painter->setPen( pen );
275  painter->setBrush( symbol.brush() );
276 
277  if ( QwtPainter::roundingAlignment( painter ) )
278  {
279  for ( int i = 0; i < numPoints; i++ )
280  {
281  const int x = qRound( points[i].x() );
282  const int y = qRound( points[i].y() );
283 
284  const int x1 = x - size.width() / 2;
285  const int y1 = y - size.height() / 2;
286  const int x2 = x1 + size.width();
287  const int y2 = y1 + size.height();
288 
289  QPolygonF polygon;
290  polygon += QPointF( x, y1 );
291  polygon += QPointF( x1, y );
292  polygon += QPointF( x, y2 );
293  polygon += QPointF( x2, y );
294 
295  QwtPainter::drawPolygon( painter, polygon );
296  }
297  }
298  else
299  {
300  for ( int i = 0; i < numPoints; i++ )
301  {
302  const QPointF &pos = points[i];
303 
304  const double x1 = pos.x() - 0.5 * size.width();
305  const double y1 = pos.y() - 0.5 * size.height();
306  const double x2 = x1 + size.width();
307  const double y2 = y1 + size.height();
308 
309  QPolygonF polygon;
310  polygon += QPointF( pos.x(), y1 );
311  polygon += QPointF( x2, pos.y() );
312  polygon += QPointF( pos.x(), y2 );
313  polygon += QPointF( x1, pos.y() );
314 
315  QwtPainter::drawPolygon( painter, polygon );
316  }
317  }
318 }
319 
320 static inline void qwtDrawTriangleSymbols(
321  QPainter *painter, QwtTriangle::Type type,
322  const QPointF *points, int numPoints,
323  const QwtSymbol &symbol )
324 {
325  const QSize size = symbol.size();
326 
327  QPen pen = symbol.pen();
328  pen.setJoinStyle( Qt::MiterJoin );
329  painter->setPen( pen );
330 
331  painter->setBrush( symbol.brush() );
332 
333  const bool doAlign = QwtPainter::roundingAlignment( painter );
334 
335  double sw2 = 0.5 * size.width();
336  double sh2 = 0.5 * size.height();
337 
338  if ( doAlign )
339  {
340  sw2 = qFloor( sw2 );
341  sh2 = qFloor( sh2 );
342  }
343 
344  QPolygonF triangle( 3 );
345  QPointF *trianglePoints = triangle.data();
346 
347  for ( int i = 0; i < numPoints; i++ )
348  {
349  const QPointF &pos = points[i];
350 
351  double x = pos.x();
352  double y = pos.y();
353 
354  if ( doAlign )
355  {
356  x = qRound( x );
357  y = qRound( y );
358  }
359 
360  const double x1 = x - sw2;
361  const double x2 = x1 + size.width();
362  const double y1 = y - sh2;
363  const double y2 = y1 + size.height();
364 
365  switch ( type )
366  {
367  case QwtTriangle::Left:
368  {
369  trianglePoints[0].rx() = x2;
370  trianglePoints[0].ry() = y1;
371 
372  trianglePoints[1].rx() = x1;
373  trianglePoints[1].ry() = y;
374 
375  trianglePoints[2].rx() = x2;
376  trianglePoints[2].ry() = y2;
377 
378  break;
379  }
380  case QwtTriangle::Right:
381  {
382  trianglePoints[0].rx() = x1;
383  trianglePoints[0].ry() = y1;
384 
385  trianglePoints[1].rx() = x2;
386  trianglePoints[1].ry() = y;
387 
388  trianglePoints[2].rx() = x1;
389  trianglePoints[2].ry() = y2;
390 
391  break;
392  }
393  case QwtTriangle::Up:
394  {
395  trianglePoints[0].rx() = x1;
396  trianglePoints[0].ry() = y2;
397 
398  trianglePoints[1].rx() = x;
399  trianglePoints[1].ry() = y1;
400 
401  trianglePoints[2].rx() = x2;
402  trianglePoints[2].ry() = y2;
403 
404  break;
405  }
406  case QwtTriangle::Down:
407  {
408  trianglePoints[0].rx() = x1;
409  trianglePoints[0].ry() = y1;
410 
411  trianglePoints[1].rx() = x;
412  trianglePoints[1].ry() = y2;
413 
414  trianglePoints[2].rx() = x2;
415  trianglePoints[2].ry() = y1;
416 
417  break;
418  }
419  }
420  QwtPainter::drawPolygon( painter, triangle );
421  }
422 }
423 
424 static inline void qwtDrawLineSymbols(
425  QPainter *painter, int orientations,
426  const QPointF *points, int numPoints, const QwtSymbol &symbol )
427 {
428  const QSize size = symbol.size();
429 
430  int off = 0;
431 
432  QPen pen = symbol.pen();
433  if ( pen.width() > 1 )
434  {
435  pen.setCapStyle( Qt::FlatCap );
436  off = 1;
437  }
438 
439  painter->setPen( pen );
440  painter->setRenderHint( QPainter::Antialiasing, false );
441 
442  if ( QwtPainter::roundingAlignment( painter ) )
443  {
444  const int sw = qFloor( size.width() );
445  const int sh = qFloor( size.height() );
446  const int sw2 = size.width() / 2;
447  const int sh2 = size.height() / 2;
448 
449  for ( int i = 0; i < numPoints; i++ )
450  {
451  if ( orientations & Qt::Horizontal )
452  {
453  const int x = qRound( points[i].x() ) - sw2;
454  const int y = qRound( points[i].y() );
455 
456  QwtPainter::drawLine( painter, x, y, x + sw + off, y );
457  }
458  if ( orientations & Qt::Vertical )
459  {
460  const int x = qRound( points[i].x() );
461  const int y = qRound( points[i].y() ) - sh2;
462 
463  QwtPainter::drawLine( painter, x, y, x, y + sh + off );
464  }
465  }
466  }
467  else
468  {
469  const double sw = size.width();
470  const double sh = size.height();
471  const double sw2 = 0.5 * size.width();
472  const double sh2 = 0.5 * size.height();
473 
474  for ( int i = 0; i < numPoints; i++ )
475  {
476  if ( orientations & Qt::Horizontal )
477  {
478  const double x = points[i].x() - sw2;
479  const double y = points[i].y();
480 
481  QwtPainter::drawLine( painter, x, y, x + sw, y );
482  }
483  if ( orientations & Qt::Vertical )
484  {
485  const double y = points[i].y() - sh2;
486  const double x = points[i].x();
487 
488  QwtPainter::drawLine( painter, x, y, x, y + sh );
489  }
490  }
491  }
492 }
493 
494 static inline void qwtDrawXCrossSymbols( QPainter *painter,
495  const QPointF *points, int numPoints, const QwtSymbol &symbol )
496 {
497  const QSize size = symbol.size();
498  int off = 0;
499 
500  QPen pen = symbol.pen();
501  if ( pen.width() > 1 )
502  {
503  pen.setCapStyle( Qt::FlatCap );
504  off = 1;
505  }
506  painter->setPen( pen );
507 
508 
509  if ( QwtPainter::roundingAlignment( painter ) )
510  {
511  const int sw = size.width();
512  const int sh = size.height();
513  const int sw2 = size.width() / 2;
514  const int sh2 = size.height() / 2;
515 
516  for ( int i = 0; i < numPoints; i++ )
517  {
518  const QPointF &pos = points[i];
519 
520  const int x = qRound( pos.x() );
521  const int y = qRound( pos.y() );
522 
523  const int x1 = x - sw2;
524  const int x2 = x1 + sw + off;
525  const int y1 = y - sh2;
526  const int y2 = y1 + sh + off;
527 
528  QwtPainter::drawLine( painter, x1, y1, x2, y2 );
529  QwtPainter::drawLine( painter, x2, y1, x1, y2 );
530  }
531  }
532  else
533  {
534  const double sw = size.width();
535  const double sh = size.height();
536  const double sw2 = 0.5 * size.width();
537  const double sh2 = 0.5 * size.height();
538 
539  for ( int i = 0; i < numPoints; i++ )
540  {
541  const QPointF &pos = points[i];
542 
543  const double x1 = pos.x() - sw2;
544  const double x2 = x1 + sw;
545  const double y1 = pos.y() - sh2;
546  const double y2 = y1 + sh;
547 
548  QwtPainter::drawLine( painter, x1, y1, x2, y2 );
549  QwtPainter::drawLine( painter, x1, y2, x2, y1 );
550  }
551  }
552 }
553 
554 static inline void qwtDrawStar1Symbols( QPainter *painter,
555  const QPointF *points, int numPoints, const QwtSymbol &symbol )
556 {
557  const QSize size = symbol.size();
558  painter->setPen( symbol.pen() );
559 
560  if ( QwtPainter::roundingAlignment( painter ) )
561  {
562  QRect r( 0, 0, size.width(), size.height() );
563 
564  for ( int i = 0; i < numPoints; i++ )
565  {
566  r.moveCenter( points[i].toPoint() );
567 
568  const double sqrt1_2 = 0.70710678118654752440; /* 1/sqrt(2) */
569 
570  const double d1 = r.width() / 2.0 * ( 1.0 - sqrt1_2 );
571 
572  QwtPainter::drawLine( painter,
573  qRound( r.left() + d1 ), qRound( r.top() + d1 ),
574  qRound( r.right() - d1 ), qRound( r.bottom() - d1 ) );
575  QwtPainter::drawLine( painter,
576  qRound( r.left() + d1 ), qRound( r.bottom() - d1 ),
577  qRound( r .right() - d1), qRound( r.top() + d1 ) );
578 
579  const QPoint c = r.center();
580 
581  QwtPainter::drawLine( painter,
582  c.x(), r.top(), c.x(), r.bottom() );
583  QwtPainter::drawLine( painter,
584  r.left(), c.y(), r.right(), c.y() );
585  }
586  }
587  else
588  {
589  QRectF r( 0, 0, size.width(), size.height() );
590 
591  for ( int i = 0; i < numPoints; i++ )
592  {
593  r.moveCenter( points[i] );
594 
595  const double sqrt1_2 = 0.70710678118654752440; /* 1/sqrt(2) */
596 
597  const QPointF c = r.center();
598  const double d1 = r.width() / 2.0 * ( 1.0 - sqrt1_2 );
599 
600  QwtPainter::drawLine( painter,
601  r.left() + d1, r.top() + d1,
602  r.right() - d1, r.bottom() - d1 );
603  QwtPainter::drawLine( painter,
604  r.left() + d1, r.bottom() - d1,
605  r.right() - d1, r.top() + d1 );
606  QwtPainter::drawLine( painter,
607  c.x(), r.top(),
608  c.x(), r.bottom() );
609  QwtPainter::drawLine( painter,
610  r.left(), c.y(),
611  r.right(), c.y() );
612  }
613  }
614 }
615 
616 static inline void qwtDrawStar2Symbols( QPainter *painter,
617  const QPointF *points, int numPoints, const QwtSymbol &symbol )
618 {
619  QPen pen = symbol.pen();
620  if ( pen.width() > 1 )
621  pen.setCapStyle( Qt::FlatCap );
622  pen.setJoinStyle( Qt::MiterJoin );
623  painter->setPen( pen );
624 
625  painter->setBrush( symbol.brush() );
626 
627  const double cos30 = 0.866025; // cos(30°)
628 
629  const double dy = 0.25 * symbol.size().height();
630  const double dx = 0.5 * symbol.size().width() * cos30 / 3.0;
631 
632  QPolygonF star( 12 );
633  QPointF *starPoints = star.data();
634 
635  const bool doAlign = QwtPainter::roundingAlignment( painter );
636 
637  for ( int i = 0; i < numPoints; i++ )
638  {
639  double x = points[i].x();
640  double y = points[i].y();
641  if ( doAlign )
642  {
643  x = qRound( x );
644  y = qRound( y );
645  }
646 
647  double x1 = x - 3 * dx;
648  double y1 = y - 2 * dy;
649  if ( doAlign )
650  {
651  x1 = qRound( x - 3 * dx );
652  y1 = qRound( y - 2 * dy );
653  }
654 
655  const double x2 = x1 + 1 * dx;
656  const double x3 = x1 + 2 * dx;
657  const double x4 = x1 + 3 * dx;
658  const double x5 = x1 + 4 * dx;
659  const double x6 = x1 + 5 * dx;
660  const double x7 = x1 + 6 * dx;
661 
662  const double y2 = y1 + 1 * dy;
663  const double y3 = y1 + 2 * dy;
664  const double y4 = y1 + 3 * dy;
665  const double y5 = y1 + 4 * dy;
666 
667  starPoints[0].rx() = x4;
668  starPoints[0].ry() = y1;
669 
670  starPoints[1].rx() = x5;
671  starPoints[1].ry() = y2;
672 
673  starPoints[2].rx() = x7;
674  starPoints[2].ry() = y2;
675 
676  starPoints[3].rx() = x6;
677  starPoints[3].ry() = y3;
678 
679  starPoints[4].rx() = x7;
680  starPoints[4].ry() = y4;
681 
682  starPoints[5].rx() = x5;
683  starPoints[5].ry() = y4;
684 
685  starPoints[6].rx() = x4;
686  starPoints[6].ry() = y5;
687 
688  starPoints[7].rx() = x3;
689  starPoints[7].ry() = y4;
690 
691  starPoints[8].rx() = x1;
692  starPoints[8].ry() = y4;
693 
694  starPoints[9].rx() = x2;
695  starPoints[9].ry() = y3;
696 
697  starPoints[10].rx() = x1;
698  starPoints[10].ry() = y2;
699 
700  starPoints[11].rx() = x3;
701  starPoints[11].ry() = y2;
702 
703  QwtPainter::drawPolygon( painter, star );
704  }
705 }
706 
707 static inline void qwtDrawHexagonSymbols( QPainter *painter,
708  const QPointF *points, int numPoints, const QwtSymbol &symbol )
709 {
710  painter->setBrush( symbol.brush() );
711  painter->setPen( symbol.pen() );
712 
713  const double cos30 = 0.866025; // cos(30°)
714  const double dx = 0.5 * ( symbol.size().width() - cos30 );
715 
716  const double dy = 0.25 * symbol.size().height();
717 
718  QPolygonF hexaPolygon( 6 );
719  QPointF *hexaPoints = hexaPolygon.data();
720 
721  const bool doAlign = QwtPainter::roundingAlignment( painter );
722 
723  for ( int i = 0; i < numPoints; i++ )
724  {
725  double x = points[i].x();
726  double y = points[i].y();
727  if ( doAlign )
728  {
729  x = qRound( x );
730  y = qRound( y );
731  }
732 
733  double x1 = x - dx;
734  double y1 = y - 2 * dy;
735  if ( doAlign )
736  {
737  x1 = qCeil( x1 );
738  y1 = qCeil( y1 );
739  }
740 
741  const double x2 = x1 + 1 * dx;
742  const double x3 = x1 + 2 * dx;
743 
744  const double y2 = y1 + 1 * dy;
745  const double y3 = y1 + 3 * dy;
746  const double y4 = y1 + 4 * dy;
747 
748  hexaPoints[0].rx() = x2;
749  hexaPoints[0].ry() = y1;
750 
751  hexaPoints[1].rx() = x3;
752  hexaPoints[1].ry() = y2;
753 
754  hexaPoints[2].rx() = x3;
755  hexaPoints[2].ry() = y3;
756 
757  hexaPoints[3].rx() = x2;
758  hexaPoints[3].ry() = y4;
759 
760  hexaPoints[4].rx() = x1;
761  hexaPoints[4].ry() = y3;
762 
763  hexaPoints[5].rx() = x1;
764  hexaPoints[5].ry() = y2;
765 
766  QwtPainter::drawPolygon( painter, hexaPolygon );
767  }
768 }
769 
771 {
772 public:
773  PrivateData( QwtSymbol::Style st, const QBrush &br,
774  const QPen &pn, const QSize &sz ):
775  style( st ),
776  size( sz ),
777  brush( br ),
778  pen( pn ),
779  isPinPointEnabled( false )
780  {
781  cache.policy = QwtSymbol::AutoCache;
782 #ifndef QWT_NO_SVG
783  svg.renderer = NULL;
784 #endif
785  }
786 
788  {
789 #ifndef QWT_NO_SVG
790  delete svg.renderer;
791 #endif
792  }
793 
795  QSize size;
796  QBrush brush;
797  QPen pen;
798 
800  QPointF pinPoint;
801 
802  struct Path
803  {
804  QPainterPath path;
806 
807  } path;
808 
809  struct Pixmap
810  {
811  QPixmap pixmap;
812 
813  } pixmap;
814 
815  struct Graphic
816  {
818 
819  } graphic;
820 
821 #ifndef QWT_NO_SVG
822  struct SVG
823  {
824  QSvgRenderer *renderer;
825  } svg;
826 #endif
827 
828  struct PaintCache
829  {
831  QPixmap pixmap;
832 
833  } cache;
834 };
835 
844 {
845  d_data = new PrivateData( style, QBrush( Qt::gray ),
846  QPen( Qt::black, 0 ), QSize() );
847 }
848 
858 QwtSymbol::QwtSymbol( QwtSymbol::Style style, const QBrush &brush,
859  const QPen &pen, const QSize &size )
860 {
861  d_data = new PrivateData( style, brush, pen, size );
862 }
863 
878 QwtSymbol::QwtSymbol( const QPainterPath &path,
879  const QBrush &brush, const QPen &pen )
880 {
881  d_data = new PrivateData( QwtSymbol::Path, brush, pen, QSize() );
882  setPath( path );
883 }
884 
887 {
888  delete d_data;
889 }
890 
900  QwtSymbol::CachePolicy policy )
901 {
902  if ( d_data->cache.policy != policy )
903  {
904  d_data->cache.policy = policy;
905  invalidateCache();
906  }
907 }
908 
914 {
915  return d_data->cache.policy;
916 }
917 
965 void QwtSymbol::setPath( const QPainterPath &path )
966 {
967  d_data->style = QwtSymbol::Path;
968  d_data->path.path = path;
969  d_data->path.graphic.reset();
970 }
971 
976 const QPainterPath &QwtSymbol::path() const
977 {
978  return d_data->path.path;
979 }
980 
991 void QwtSymbol::setPixmap( const QPixmap &pixmap )
992 {
993  d_data->style = QwtSymbol::Pixmap;
994  d_data->pixmap.pixmap = pixmap;
995 }
996 
1001 const QPixmap &QwtSymbol::pixmap() const
1002 {
1003  return d_data->pixmap.pixmap;
1004 }
1005 
1016 void QwtSymbol::setGraphic( const QwtGraphic &graphic )
1017 {
1018  d_data->style = QwtSymbol::Graphic;
1019  d_data->graphic.graphic = graphic;
1020 }
1021 
1027 {
1028  return d_data->graphic.graphic;
1029 }
1030 
1031 #ifndef QWT_NO_SVG
1032 
1043 void QwtSymbol::setSvgDocument( const QByteArray &svgDocument )
1044 {
1045  d_data->style = QwtSymbol::SvgDocument;
1046  if ( d_data->svg.renderer == NULL )
1047  d_data->svg.renderer = new QSvgRenderer();
1048 
1049  d_data->svg.renderer->load( svgDocument );
1050 }
1051 
1052 #endif
1053 
1066 void QwtSymbol::setSize( int width, int height )
1067 {
1068  if ( ( width >= 0 ) && ( height < 0 ) )
1069  height = width;
1070 
1071  setSize( QSize( width, height ) );
1072 }
1073 
1080 void QwtSymbol::setSize( const QSize &size )
1081 {
1082  if ( size.isValid() && size != d_data->size )
1083  {
1084  d_data->size = size;
1085  invalidateCache();
1086  }
1087 }
1088 
1093 const QSize& QwtSymbol::size() const
1094 {
1095  return d_data->size;
1096 }
1097 
1106 void QwtSymbol::setBrush( const QBrush &brush )
1107 {
1108  if ( brush != d_data->brush )
1109  {
1110  d_data->brush = brush;
1111  invalidateCache();
1112 
1113  if ( d_data->style == QwtSymbol::Path )
1114  d_data->path.graphic.reset();
1115  }
1116 }
1117 
1122 const QBrush& QwtSymbol::brush() const
1123 {
1124  return d_data->brush;
1125 }
1126 
1140 void QwtSymbol::setPen( const QColor &color,
1141  qreal width, Qt::PenStyle style )
1142 {
1143  setPen( QPen( color, width, style ) );
1144 }
1145 
1154 void QwtSymbol::setPen( const QPen &pen )
1155 {
1156  if ( pen != d_data->pen )
1157  {
1158  d_data->pen = pen;
1159  invalidateCache();
1160 
1161  if ( d_data->style == QwtSymbol::Path )
1162  d_data->path.graphic.reset();
1163  }
1164 }
1165 
1170 const QPen& QwtSymbol::pen() const
1171 {
1172  return d_data->pen;
1173 }
1174 
1185 void QwtSymbol::setColor( const QColor &color )
1186 {
1187  switch ( d_data->style )
1188  {
1189  case QwtSymbol::Ellipse:
1190  case QwtSymbol::Rect:
1191  case QwtSymbol::Diamond:
1192  case QwtSymbol::Triangle:
1193  case QwtSymbol::UTriangle:
1194  case QwtSymbol::DTriangle:
1195  case QwtSymbol::RTriangle:
1196  case QwtSymbol::LTriangle:
1197  case QwtSymbol::Star2:
1198  case QwtSymbol::Hexagon:
1199  {
1200  if ( d_data->brush.color() != color )
1201  {
1202  d_data->brush.setColor( color );
1203  invalidateCache();
1204  }
1205  break;
1206  }
1207  case QwtSymbol::Cross:
1208  case QwtSymbol::XCross:
1209  case QwtSymbol::HLine:
1210  case QwtSymbol::VLine:
1211  case QwtSymbol::Star1:
1212  {
1213  if ( d_data->pen.color() != color )
1214  {
1215  d_data->pen.setColor( color );
1216  invalidateCache();
1217  }
1218  break;
1219  }
1220  default:
1221  {
1222  if ( d_data->brush.color() != color ||
1223  d_data->pen.color() != color )
1224  {
1225  invalidateCache();
1226  }
1227 
1228  d_data->brush.setColor( color );
1229  d_data->pen.setColor( color );
1230  }
1231  }
1232 }
1233 
1248 void QwtSymbol::setPinPoint( const QPointF &pos, bool enable )
1249 {
1250  if ( d_data->pinPoint != pos )
1251  {
1252  d_data->pinPoint = pos;
1253  if ( d_data->isPinPointEnabled )
1254  {
1255  invalidateCache();
1256  }
1257  }
1258 
1259  setPinPointEnabled( enable );
1260 }
1261 
1266 QPointF QwtSymbol::pinPoint() const
1267 {
1268  return d_data->pinPoint;
1269 }
1270 
1278 {
1279  if ( d_data->isPinPointEnabled != on )
1280  {
1281  d_data->isPinPointEnabled = on;
1282  invalidateCache();
1283  }
1284 }
1285 
1291 {
1292  return d_data->isPinPointEnabled;
1293 }
1294 
1306 void QwtSymbol::drawSymbols( QPainter *painter,
1307  const QPointF *points, int numPoints ) const
1308 {
1309  if ( numPoints <= 0 )
1310  return;
1311 
1312  bool useCache = false;
1313 
1314  // Don't use the pixmap, when the paint device
1315  // could generate scalable vectors
1316 
1317  if ( QwtPainter::roundingAlignment( painter ) &&
1318  !painter->transform().isScaling() )
1319  {
1320  if ( d_data->cache.policy == QwtSymbol::Cache )
1321  {
1322  useCache = true;
1323  }
1324  else if ( d_data->cache.policy == QwtSymbol::AutoCache )
1325  {
1326  switch( painter->paintEngine()->type() )
1327  {
1328  case QPaintEngine::OpenGL:
1329 #if QT_VERSION >= 0x040600
1330  case QPaintEngine::OpenGL2:
1331 #endif
1332  {
1333  // using a FBO as cache ?
1334  useCache = false;
1335  break;
1336  }
1337 #if QT_VERSION >= 0x040500
1338  case QPaintEngine::OpenVG:
1339 #endif
1340  case QPaintEngine::SVG:
1341  case QPaintEngine::Pdf:
1342  case QPaintEngine::Picture:
1343  {
1344  // vector graphics
1345  useCache = false;
1346  break;
1347  }
1348  case QPaintEngine::X11:
1349  {
1350  switch( d_data->style )
1351  {
1352  case QwtSymbol::XCross:
1353  case QwtSymbol::HLine:
1354  case QwtSymbol::VLine:
1355  case QwtSymbol::Cross:
1356  {
1357  // for the very simple shapes using vector graphics is
1358  // usually faster.
1359 
1360  useCache = false;
1361  break;
1362  }
1363 
1364  case QwtSymbol::Pixmap:
1365  {
1366  if ( d_data->size.isEmpty() ||
1367  d_data->size == d_data->pixmap.pixmap.size() )
1368  {
1369  // no need to have a pixmap cache for a pixmap
1370  // of the same size
1371 
1372  useCache = false;
1373  }
1374  break;
1375  }
1376  default:
1377  break;
1378  }
1379  break;
1380  }
1381  default:
1382  {
1383  useCache = true;
1384  }
1385  }
1386  }
1387  }
1388 
1389  if ( useCache )
1390  {
1391  const QRect br = boundingRect();
1392 
1393  if ( d_data->cache.pixmap.isNull() )
1394  {
1395  d_data->cache.pixmap = QwtPainter::backingStore( NULL, br.size() );
1396  d_data->cache.pixmap.fill( Qt::transparent );
1397 
1398  QPainter p( &d_data->cache.pixmap );
1399  p.setRenderHints( painter->renderHints() );
1400  p.translate( -br.topLeft() );
1401 
1402  const QPointF pos( 0.0, 0.0 );
1403  renderSymbols( &p, &pos, 1 );
1404  }
1405 
1406  const int dx = br.left();
1407  const int dy = br.top();
1408 
1409  for ( int i = 0; i < numPoints; i++ )
1410  {
1411  const int left = qRound( points[i].x() ) + dx;
1412  const int top = qRound( points[i].y() ) + dy;
1413 
1414  painter->drawPixmap( left, top, d_data->cache.pixmap );
1415  }
1416  }
1417  else
1418  {
1419  painter->save();
1420  renderSymbols( painter, points, numPoints );
1421  painter->restore();
1422  }
1423 }
1424 
1437 void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const
1438 {
1439  if ( d_data->style == QwtSymbol::NoSymbol )
1440  return;
1441 
1442  if ( d_data->style == QwtSymbol::Graphic )
1443  {
1444  d_data->graphic.graphic.render(
1445  painter, rect, Qt::KeepAspectRatio );
1446  }
1447  else if ( d_data->style == QwtSymbol::Path )
1448  {
1449  if ( d_data->path.graphic.isNull() )
1450  {
1451  d_data->path.graphic = qwtPathGraphic(
1452  d_data->path.path, d_data->pen, d_data->brush );
1453  }
1454 
1455  d_data->path.graphic.render(
1456  painter, rect, Qt::KeepAspectRatio );
1457  return;
1458  }
1459  else if ( d_data->style == QwtSymbol::SvgDocument )
1460  {
1461 #ifndef QWT_NO_SVG
1462  if ( d_data->svg.renderer )
1463  {
1464  QRectF scaledRect;
1465 
1466  QSizeF sz = d_data->svg.renderer->viewBoxF().size();
1467  if ( !sz.isEmpty() )
1468  {
1469  sz.scale( rect.size(), Qt::KeepAspectRatio );
1470  scaledRect.setSize( sz );
1471  scaledRect.moveCenter( rect.center() );
1472  }
1473  else
1474  {
1475  scaledRect = rect;
1476  }
1477 
1478  d_data->svg.renderer->render(
1479  painter, scaledRect );
1480  }
1481 #endif
1482  }
1483  else
1484  {
1485  const QRect br = boundingRect();
1486 
1487  // scale the symbol size to fit into rect.
1488 
1489  const double ratio = qMin( rect.width() / br.width(),
1490  rect.height() / br.height() );
1491 
1492  painter->save();
1493 
1494  painter->translate( rect.center() );
1495  painter->scale( ratio, ratio );
1496 
1497  const bool isPinPointEnabled = d_data->isPinPointEnabled;
1498  d_data->isPinPointEnabled = false;
1499 
1500  const QPointF pos;
1501  renderSymbols( painter, &pos, 1 );
1502 
1503  d_data->isPinPointEnabled = isPinPointEnabled;
1504 
1505  painter->restore();
1506  }
1507 }
1508 
1516 void QwtSymbol::renderSymbols( QPainter *painter,
1517  const QPointF *points, int numPoints ) const
1518 {
1519  switch ( d_data->style )
1520  {
1521  case QwtSymbol::Ellipse:
1522  {
1523  qwtDrawEllipseSymbols( painter, points, numPoints, *this );
1524  break;
1525  }
1526  case QwtSymbol::Rect:
1527  {
1528  qwtDrawRectSymbols( painter, points, numPoints, *this );
1529  break;
1530  }
1531  case QwtSymbol::Diamond:
1532  {
1533  qwtDrawDiamondSymbols( painter, points, numPoints, *this );
1534  break;
1535  }
1536  case QwtSymbol::Cross:
1537  {
1538  qwtDrawLineSymbols( painter, Qt::Horizontal | Qt::Vertical,
1539  points, numPoints, *this );
1540  break;
1541  }
1542  case QwtSymbol::XCross:
1543  {
1544  qwtDrawXCrossSymbols( painter, points, numPoints, *this );
1545  break;
1546  }
1547  case QwtSymbol::Triangle:
1548  case QwtSymbol::UTriangle:
1549  {
1551  points, numPoints, *this );
1552  break;
1553  }
1554  case QwtSymbol::DTriangle:
1555  {
1557  points, numPoints, *this );
1558  break;
1559  }
1560  case QwtSymbol::RTriangle:
1561  {
1563  points, numPoints, *this );
1564  break;
1565  }
1566  case QwtSymbol::LTriangle:
1567  {
1569  points, numPoints, *this );
1570  break;
1571  }
1572  case QwtSymbol::HLine:
1573  {
1574  qwtDrawLineSymbols( painter, Qt::Horizontal,
1575  points, numPoints, *this );
1576  break;
1577  }
1578  case QwtSymbol::VLine:
1579  {
1580  qwtDrawLineSymbols( painter, Qt::Vertical,
1581  points, numPoints, *this );
1582  break;
1583  }
1584  case QwtSymbol::Star1:
1585  {
1586  qwtDrawStar1Symbols( painter, points, numPoints, *this );
1587  break;
1588  }
1589  case QwtSymbol::Star2:
1590  {
1591  qwtDrawStar2Symbols( painter, points, numPoints, *this );
1592  break;
1593  }
1594  case QwtSymbol::Hexagon:
1595  {
1596  qwtDrawHexagonSymbols( painter, points, numPoints, *this );
1597  break;
1598  }
1599  case QwtSymbol::Path:
1600  {
1601  if ( d_data->path.graphic.isNull() )
1602  {
1603  d_data->path.graphic = qwtPathGraphic( d_data->path.path,
1604  d_data->pen, d_data->brush );
1605  }
1606 
1607  qwtDrawGraphicSymbols( painter, points, numPoints,
1608  d_data->path.graphic, *this );
1609  break;
1610  }
1611  case QwtSymbol::Pixmap:
1612  {
1613  qwtDrawPixmapSymbols( painter, points, numPoints, *this );
1614  break;
1615  }
1616  case QwtSymbol::Graphic:
1617  {
1618  qwtDrawGraphicSymbols( painter, points, numPoints,
1619  d_data->graphic.graphic, *this );
1620  break;
1621  }
1623  {
1624 #ifndef QWT_NO_SVG
1625  qwtDrawSvgSymbols( painter, points, numPoints,
1626  d_data->svg.renderer, *this );
1627 #endif
1628  break;
1629  }
1630  default:;
1631  }
1632 }
1633 
1641 {
1642  QRectF rect;
1643 
1644  bool pinPointTranslation = false;
1645 
1646  switch ( d_data->style )
1647  {
1648  case QwtSymbol::Ellipse:
1649  case QwtSymbol::Rect:
1650  case QwtSymbol::Hexagon:
1651  {
1652  qreal pw = 0.0;
1653  if ( d_data->pen.style() != Qt::NoPen )
1654  pw = qMax( d_data->pen.widthF(), qreal( 1.0 ) );
1655 
1656  rect.setSize( d_data->size + QSizeF( pw, pw ) );
1657  rect.moveCenter( QPointF( 0.0, 0.0 ) );
1658 
1659  break;
1660  }
1661  case QwtSymbol::XCross:
1662  case QwtSymbol::Diamond:
1663  case QwtSymbol::Triangle:
1664  case QwtSymbol::UTriangle:
1665  case QwtSymbol::DTriangle:
1666  case QwtSymbol::RTriangle:
1667  case QwtSymbol::LTriangle:
1668  case QwtSymbol::Star1:
1669  case QwtSymbol::Star2:
1670  {
1671  qreal pw = 0.0;
1672  if ( d_data->pen.style() != Qt::NoPen )
1673  pw = qMax( d_data->pen.widthF(), qreal( 1.0 ) );
1674 
1675  rect.setSize( d_data->size + QSizeF( 2 * pw, 2 * pw ) );
1676  rect.moveCenter( QPointF( 0.0, 0.0 ) );
1677  break;
1678  }
1679  case QwtSymbol::Path:
1680  {
1681  if ( d_data->path.graphic.isNull() )
1682  {
1683  d_data->path.graphic = qwtPathGraphic(
1684  d_data->path.path, d_data->pen, d_data->brush );
1685  }
1686 
1687  rect = qwtScaledBoundingRect(
1688  d_data->path.graphic, d_data->size );
1689  pinPointTranslation = true;
1690 
1691  break;
1692  }
1693  case QwtSymbol::Pixmap:
1694  {
1695  if ( d_data->size.isEmpty() )
1696  rect.setSize( d_data->pixmap.pixmap.size() );
1697  else
1698  rect.setSize( d_data->size );
1699 
1700  pinPointTranslation = true;
1701 
1702  break;
1703  }
1704  case QwtSymbol::Graphic:
1705  {
1706  rect = qwtScaledBoundingRect(
1707  d_data->graphic.graphic, d_data->size );
1708  pinPointTranslation = true;
1709 
1710  break;
1711  }
1712 #ifndef QWT_NO_SVG
1714  {
1715  if ( d_data->svg.renderer )
1716  rect = d_data->svg.renderer->viewBoxF();
1717 
1718  if ( d_data->size.isValid() && !rect.isEmpty() )
1719  {
1720  QSizeF sz = rect.size();
1721 
1722  const double sx = d_data->size.width() / sz.width();
1723  const double sy = d_data->size.height() / sz.height();
1724 
1725  QTransform transform;
1726  transform.scale( sx, sy );
1727 
1728  rect = transform.mapRect( rect );
1729  }
1730  pinPointTranslation = true;
1731  break;
1732  }
1733 #endif
1734  default:
1735  {
1736  rect.setSize( d_data->size );
1737  rect.moveCenter( QPointF( 0.0, 0.0 ) );
1738  }
1739  }
1740 
1741  if ( pinPointTranslation )
1742  {
1743  QPointF pinPoint( 0.0, 0.0 );
1744  if ( d_data->isPinPointEnabled )
1745  pinPoint = rect.center() - d_data->pinPoint;
1746 
1747  rect.moveCenter( pinPoint );
1748  }
1749 
1750  QRect r;
1751  r.setLeft( qFloor( rect.left() ) );
1752  r.setTop( qFloor( rect.top() ) );
1753  r.setRight( qCeil( rect.right() ) );
1754  r.setBottom( qCeil( rect.bottom() ) );
1755 
1756  if ( d_data->style != QwtSymbol::Pixmap )
1757  r.adjust( -1, -1, 1, 1 ); // for antialiasing
1758 
1759  return r;
1760 }
1761 
1774 {
1775  if ( !d_data->cache.pixmap.isNull() )
1776  d_data->cache.pixmap = QPixmap();
1777 }
1778 
1786 {
1787  if ( d_data->style != style )
1788  {
1789  d_data->style = style;
1790  invalidateCache();
1791  }
1792 }
1793 
1799 {
1800  return d_data->style;
1801 }
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
virtual QRect boundingRect() const
Style style() const
Six-pointed star.
Definition: qwt_symbol.h:82
static void qwtDrawPixmapSymbols(QPainter *painter, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:69
QwtSymbol::CachePolicy policy
Definition: qwt_symbol.cpp:830
static void drawLine(QPainter *, double x1, double y1, double x2, double y2)
Wrapper for QPainter::drawLine()
Definition: qwt_painter.h:147
void render(QPainter *) const
Replay all recorded painter commands.
static void qwtDrawTriangleSymbols(QPainter *painter, QwtTriangle::Type type, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:320
static void qwtDrawRectSymbols(QPainter *painter, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:222
static void qwtDrawStar2Symbols(QPainter *painter, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:616
QwtSymbol(Style=NoSymbol)
Definition: qwt_symbol.cpp:843
virtual void renderSymbols(QPainter *, const QPointF *, int numPoints) const
void invalidateCache()
const QPixmap & pixmap() const
static void drawPixmap(QPainter *, const QRectF &, const QPixmap &)
Wrapper for QPainter::drawPixmap()
void setGraphic(const QwtGraphic &)
QSizeF defaultSize() const
Default size.
const QwtGraphic & graphic() const
A class for drawing symbols.
Definition: qwt_symbol.h:30
static void qwtDrawSvgSymbols(QPainter *painter, const QPointF *points, int numPoints, QSvgRenderer *renderer, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:104
Horizontal line.
Definition: qwt_symbol.h:73
TFSIMD_FORCE_INLINE const tfScalar & y() const
Cross (+)
Definition: qwt_symbol.h:67
void setRenderHint(RenderHint, bool on=true)
void setSvgDocument(const QByteArray &)
QRectF controlPointRect() const
Diagonal cross (X)
Definition: qwt_symbol.h:70
const QSize & size() const
static void qwtDrawDiamondSymbols(QPainter *painter, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:267
static void drawPolygon(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolygon()
static void qwtDrawEllipseSymbols(QPainter *painter, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:180
QPointF pinPoint() const
GraphId path[kMaxDeadlockPathLen]
static void drawRect(QPainter *, double x, double y, double w, double h)
Wrapper for QPainter::drawRect()
Rectangle.
Definition: qwt_symbol.h:46
static void qwtDrawHexagonSymbols(QPainter *painter, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:707
PrivateData(QwtSymbol::Style st, const QBrush &br, const QPen &pn, const QSize &sz)
Definition: qwt_symbol.cpp:773
Triangle pointing right.
Definition: qwt_symbol.h:64
Ellipse or circle.
Definition: qwt_symbol.h:43
static void qwtDrawLineSymbols(QPainter *painter, int orientations, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:424
void setPinPoint(const QPointF &pos, bool enable=true)
Set and enable a pin point.
virtual ~QwtSymbol()
Destructor.
Definition: qwt_symbol.cpp:886
void setCachePolicy(CachePolicy)
Definition: qwt_symbol.cpp:899
static void qwtDrawXCrossSymbols(QPainter *painter, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:494
const QPen & pen() const
backward::SignalHandling sh
Definition: backward.cpp:31
static QwtGraphic qwtPathGraphic(const QPainterPath &path, const QPen &pen, const QBrush &brush)
Definition: qwt_symbol.cpp:34
A paint device for scalable graphics.
Definition: qwt_graphic.h:74
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points.
Definition: qwt_symbol.h:250
X combined with +.
Definition: qwt_symbol.h:79
TFSIMD_FORCE_INLINE const tfScalar & x() const
Vertical line.
Definition: qwt_symbol.h:76
bool isPinPointEnabled() const
const QPainterPath & path() const
Definition: qwt_symbol.cpp:976
static void drawEllipse(QPainter *, const QRectF &)
Wrapper for QPainter::drawEllipse()
void setPixmap(const QPixmap &)
Definition: qwt_symbol.cpp:991
uintptr_t size
void setPath(const QPainterPath &)
Set a painter path as symbol.
Definition: qwt_symbol.cpp:965
Triangle pointing upwards.
Definition: qwt_symbol.h:52
static void qwtDrawGraphicSymbols(QPainter *painter, const QPointF *points, int numPoints, const QwtGraphic &graphic, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:141
static void qwtDrawStar1Symbols(QPainter *painter, const QPointF *points, int numPoints, const QwtSymbol &symbol)
Definition: qwt_symbol.cpp:554
Triangle pointing upwards.
Definition: qwt_symbol.h:58
void setPinPointEnabled(bool)
QRectF scaledBoundingRect(double sx, double sy) const
Calculate the target rectangle for scaling the graphic.
void setSize(const QSize &)
Triangle pointing left.
Definition: qwt_symbol.h:61
int i
CachePolicy cachePolicy() const
Definition: qwt_symbol.cpp:913
static QRectF qwtScaledBoundingRect(const QwtGraphic &graphic, const QSizeF size)
Definition: qwt_symbol.cpp:49
void setBrush(const QBrush &b)
Assign a brush.
void drawSymbol(QPainter *, const QRectF &) const
Draw the symbol into a rectangle.
Always use a pixmap cache.
Definition: qwt_symbol.h:155
void setStyle(Style)
const QBrush & brush() const
virtual void setColor(const QColor &)
Set the color of the symbol.
static bool roundingAlignment()
Definition: qwt_painter.h:176
Triangle pointing downwards.
Definition: qwt_symbol.h:55
static QPixmap backingStore(QWidget *, const QSize &)
No Style. The symbol cannot be drawn.
Definition: qwt_symbol.h:40


plotjuggler
Author(s): Davide Faconti
autogenerated on Sat Jul 6 2019 03:44:18