10#include "qwt_symbol.h"
11#include "qwt_painter.h"
12#include "qwt_graphic.h"
16#include <qpainterpath.h>
18#include <qpaintengine.h>
20#include <qsvgrenderer.h>
34static QwtGraphic qwtPathGraphic(
const QPainterPath& path,
35 const QPen& pen,
const QBrush& brush )
40 QPainter painter( &graphic );
41 painter.setPen( pen );
42 painter.setBrush( brush );
43 painter.drawPath( path );
49static inline QRectF qwtScaledBoundingRect(
52 QSizeF scaledSize = size;
53 if ( scaledSize.isEmpty() )
59 if ( sz.width() > 0.0 )
60 sx = scaledSize.width() / sz.width();
63 if ( sz.height() > 0.0 )
64 sy = scaledSize.height() / sz.height();
69static inline void qwtDrawPixmapSymbols( QPainter* painter,
70 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
72 QSize size = symbol.
size();
74 size = symbol.
pixmap().size();
76 const QTransform transform = painter->transform();
77 if ( transform.isScaling() )
79 const QRect r( 0, 0, size.width(), size.height() );
80 size = transform.mapRect( r ).size();
83 QPixmap pm = symbol.
pixmap();
84 if ( pm.size() != size )
85 pm = pm.scaled( size );
87 QPointF pinPoint( 0.5 * size.width(), 0.5 * size.height() );
91 painter->resetTransform();
93 for (
int i = 0; i < numPoints; i++ )
95 const QPointF pos = transform.map( points[i] ) - pinPoint;
98 QRect( pos.toPoint(), pm.size() ), pm );
104static inline void qwtDrawSvgSymbols( QPainter* painter,
105 const QPointF* points,
int numPoints,
106 QSvgRenderer* renderer,
const QwtSymbol& symbol )
108 if ( renderer == NULL || !renderer->isValid() )
111 const QRectF viewBox = renderer->viewBoxF();
112 if ( viewBox.isEmpty() )
115 QSizeF sz = symbol.
size();
119 const double sx = sz.width() / viewBox.width();
120 const double sy = sz.height() / viewBox.height();
122 QPointF pinPoint = viewBox.center();
126 const double dx = sx * ( pinPoint.x() - viewBox.left() );
127 const double dy = sy * ( pinPoint.y() - viewBox.top() );
129 for (
int i = 0; i < numPoints; i++ )
131 const double x = points[i].x() - dx;
132 const double y = points[i].y() - dy;
134 renderer->render( painter,
135 QRectF( x, y, sz.width(), sz.height() ) );
141static inline void qwtDrawGraphicSymbols( QPainter* painter,
142 const QPointF* points,
int numPoints,
const QwtGraphic& graphic,
146 if ( pointRect.isEmpty() )
152 const QSize sz = symbol.
size();
155 sx = sz.width() / pointRect.width();
156 sy = sz.height() / pointRect.height();
159 QPointF pinPoint = pointRect.center();
163 const QTransform transform = painter->transform();
165 for (
int i = 0; i < numPoints; i++ )
167 QTransform tr = transform;
168 tr.translate( points[i].x(), points[i].y() );
170 tr.translate( -pinPoint.x(), -pinPoint.y() );
172 painter->setTransform( tr );
174 graphic.
render( painter );
177 painter->setTransform( transform );
180static inline void qwtDrawEllipseSymbols( QPainter* painter,
181 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
183 painter->setBrush( symbol.
brush() );
184 painter->setPen( symbol.
pen() );
186 const QSize size = symbol.
size();
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;
195 for (
int i = 0; i < numPoints; i++ )
197 const int x = qRound( points[i].x() );
198 const int y = qRound( points[i].y() );
200 const QRectF r( x - sw2, y - sh2, sw, sh );
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();
211 for (
int i = 0; i < numPoints; i++ )
213 const double x = points[i].x();
214 const double y = points[i].y();
216 const QRectF r( x - sw2, y - sh2, sw, sh );
222static inline void qwtDrawRectSymbols( QPainter* painter,
223 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
225 const QSize size = symbol.
size();
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 );
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;
240 for (
int i = 0; i < numPoints; i++ )
242 const int x = qRound( points[i].x() );
243 const int y = qRound( points[i].y() );
245 const QRect r( x - sw2, y - sh2, sw, sh );
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();
256 for (
int i = 0; i < numPoints; i++ )
258 const double x = points[i].x();
259 const double y = points[i].y();
261 const QRectF r( x - sw2, y - sh2, sw, sh );
267static inline void qwtDrawDiamondSymbols( QPainter* painter,
268 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
270 const QSize size = symbol.
size();
272 QPen pen = symbol.
pen();
273 pen.setJoinStyle( Qt::MiterJoin );
274 painter->setPen( pen );
275 painter->setBrush( symbol.
brush() );
279 for (
int i = 0; i < numPoints; i++ )
281 const int x = qRound( points[i].x() );
282 const int y = qRound( points[i].y() );
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();
290 polygon += QPointF( x, y1 );
291 polygon += QPointF( x1, y );
292 polygon += QPointF( x, y2 );
293 polygon += QPointF( x2, y );
300 for (
int i = 0; i < numPoints; i++ )
302 const QPointF& pos = points[i];
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();
310 polygon += QPointF( pos.x(), y1 );
311 polygon += QPointF( x2, pos.y() );
312 polygon += QPointF( pos.x(), y2 );
313 polygon += QPointF( x1, pos.y() );
320static inline void qwtDrawTriangleSymbols(
321 QPainter* painter, QwtTriangle::Type type,
322 const QPointF* points,
int numPoints,
325 const QSize size = symbol.
size();
327 QPen pen = symbol.
pen();
328 pen.setJoinStyle( Qt::MiterJoin );
329 painter->setPen( pen );
331 painter->setBrush( symbol.
brush() );
335 double sw2 = 0.5 * size.width();
336 double sh2 = 0.5 * size.height();
340 sw2 = std::floor( sw2 );
341 sh2 = std::floor( sh2 );
344 QPolygonF triangle( 3 );
345 QPointF* trianglePoints = triangle.data();
347 for (
int i = 0; i < numPoints; i++ )
349 const QPointF& pos = points[i];
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();
367 case QwtTriangle::Left:
369 trianglePoints[0].rx() = x2;
370 trianglePoints[0].ry() = y1;
372 trianglePoints[1].rx() = x1;
373 trianglePoints[1].ry() = y;
375 trianglePoints[2].rx() = x2;
376 trianglePoints[2].ry() = y2;
380 case QwtTriangle::Right:
382 trianglePoints[0].rx() = x1;
383 trianglePoints[0].ry() = y1;
385 trianglePoints[1].rx() = x2;
386 trianglePoints[1].ry() = y;
388 trianglePoints[2].rx() = x1;
389 trianglePoints[2].ry() = y2;
393 case QwtTriangle::Up:
395 trianglePoints[0].rx() = x1;
396 trianglePoints[0].ry() = y2;
398 trianglePoints[1].rx() = x;
399 trianglePoints[1].ry() = y1;
401 trianglePoints[2].rx() = x2;
402 trianglePoints[2].ry() = y2;
406 case QwtTriangle::Down:
408 trianglePoints[0].rx() = x1;
409 trianglePoints[0].ry() = y1;
411 trianglePoints[1].rx() = x;
412 trianglePoints[1].ry() = y2;
414 trianglePoints[2].rx() = x2;
415 trianglePoints[2].ry() = y1;
424static inline void qwtDrawLineSymbols(
425 QPainter* painter,
int orientations,
426 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
428 const QSize size = symbol.
size();
432 QPen pen = symbol.
pen();
433 if ( pen.width() > 1 )
435 pen.setCapStyle( Qt::FlatCap );
439 painter->setPen( pen );
440 painter->setRenderHint( QPainter::Antialiasing,
false );
444 const int sw = qwtFloor( size.width() );
445 const int sh = qwtFloor( size.height() );
446 const int sw2 = size.width() / 2;
447 const int sh2 = size.height() / 2;
449 for (
int i = 0; i < numPoints; i++ )
451 if ( orientations & Qt::Horizontal )
453 const int x = qRound( points[i].x() ) - sw2;
454 const int y = qRound( points[i].y() );
458 if ( orientations & Qt::Vertical )
460 const int x = qRound( points[i].x() );
461 const int y = qRound( points[i].y() ) - sh2;
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();
474 for (
int i = 0; i < numPoints; i++ )
476 if ( orientations & Qt::Horizontal )
478 const double x = points[i].x() - sw2;
479 const double y = points[i].y();
483 if ( orientations & Qt::Vertical )
485 const double y = points[i].y() - sh2;
486 const double x = points[i].x();
494static inline void qwtDrawXCrossSymbols( QPainter* painter,
495 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
497 const QSize size = symbol.
size();
500 QPen pen = symbol.
pen();
501 if ( pen.width() > 1 )
503 pen.setCapStyle( Qt::FlatCap );
506 painter->setPen( pen );
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;
516 for (
int i = 0; i < numPoints; i++ )
518 const QPointF& pos = points[i];
520 const int x = qRound( pos.x() );
521 const int y = qRound( pos.y() );
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;
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();
539 for (
int i = 0; i < numPoints; i++ )
541 const QPointF& pos = points[i];
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;
554static inline void qwtDrawStar1Symbols( QPainter* painter,
555 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
557 const QSize size = symbol.
size();
558 painter->setPen( symbol.
pen() );
562 QRect r( 0, 0, size.width(), size.height() );
564 for (
int i = 0; i < numPoints; i++ )
566 r.moveCenter( points[i].toPoint() );
568 const double sqrt1_2 = 0.70710678118654752440;
570 const double d1 = r.width() / 2.0 * ( 1.0 - sqrt1_2 );
573 qRound( r.left() + d1 ), qRound( r.top() + d1 ),
574 qRound( r.right() - d1 ), qRound( r.bottom() - d1 ) );
576 qRound( r.left() + d1 ), qRound( r.bottom() - d1 ),
577 qRound( r.right() - d1), qRound( r.top() + d1 ) );
579 const QPoint c = r.center();
582 c.x(), r.top(), c.x(), r.bottom() );
584 r.left(), c.y(), r.right(), c.y() );
589 QRectF r( 0, 0, size.width(), size.height() );
591 for (
int i = 0; i < numPoints; i++ )
593 r.moveCenter( points[i] );
595 const double sqrt1_2 = 0.70710678118654752440;
597 const QPointF c = r.center();
598 const double d1 = r.width() / 2.0 * ( 1.0 - sqrt1_2 );
601 r.left() + d1, r.top() + d1,
602 r.right() - d1, r.bottom() - d1 );
604 r.left() + d1, r.bottom() - d1,
605 r.right() - d1, r.top() + d1 );
616static inline void qwtDrawStar2Symbols( QPainter* painter,
617 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
619 QPen pen = symbol.
pen();
620 if ( pen.width() > 1 )
621 pen.setCapStyle( Qt::FlatCap );
622 pen.setJoinStyle( Qt::MiterJoin );
623 painter->setPen( pen );
625 painter->setBrush( symbol.
brush() );
627 const double cos30 = 0.866025;
629 const double dy = 0.25 * symbol.
size().height();
630 const double dx = 0.5 * symbol.
size().width() * cos30 / 3.0;
632 QPolygonF star( 12 );
633 QPointF* starPoints = star.data();
637 for (
int i = 0; i < numPoints; i++ )
639 double x = points[i].x();
640 double y = points[i].y();
647 double x1 = x - 3 * dx;
648 double y1 = y - 2 * dy;
651 x1 = qRound( x - 3 * dx );
652 y1 = qRound( y - 2 * dy );
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;
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;
667 starPoints[0].rx() = x4;
668 starPoints[0].ry() = y1;
670 starPoints[1].rx() = x5;
671 starPoints[1].ry() = y2;
673 starPoints[2].rx() = x7;
674 starPoints[2].ry() = y2;
676 starPoints[3].rx() = x6;
677 starPoints[3].ry() = y3;
679 starPoints[4].rx() = x7;
680 starPoints[4].ry() = y4;
682 starPoints[5].rx() = x5;
683 starPoints[5].ry() = y4;
685 starPoints[6].rx() = x4;
686 starPoints[6].ry() = y5;
688 starPoints[7].rx() = x3;
689 starPoints[7].ry() = y4;
691 starPoints[8].rx() = x1;
692 starPoints[8].ry() = y4;
694 starPoints[9].rx() = x2;
695 starPoints[9].ry() = y3;
697 starPoints[10].rx() = x1;
698 starPoints[10].ry() = y2;
700 starPoints[11].rx() = x3;
701 starPoints[11].ry() = y2;
707static inline void qwtDrawHexagonSymbols( QPainter* painter,
708 const QPointF* points,
int numPoints,
const QwtSymbol& symbol )
710 painter->setBrush( symbol.
brush() );
711 painter->setPen( symbol.
pen() );
713 const double cos30 = 0.866025;
714 const double dx = 0.5 * ( symbol.
size().width() - cos30 );
716 const double dy = 0.25 * symbol.
size().height();
718 QPolygonF hexaPolygon( 6 );
719 QPointF* hexaPoints = hexaPolygon.data();
723 for (
int i = 0; i < numPoints; i++ )
725 double x = points[i].x();
726 double y = points[i].y();
734 double y1 = y - 2 * dy;
737 x1 = std::ceil( x1 );
738 y1 = std::ceil( y1 );
741 const double x2 = x1 + 1 * dx;
742 const double x3 = x1 + 2 * dx;
744 const double y2 = y1 + 1 * dy;
745 const double y3 = y1 + 3 * dy;
746 const double y4 = y1 + 4 * dy;
748 hexaPoints[0].rx() = x2;
749 hexaPoints[0].ry() = y1;
751 hexaPoints[1].rx() = x3;
752 hexaPoints[1].ry() = y2;
754 hexaPoints[2].rx() = x3;
755 hexaPoints[2].ry() = y3;
757 hexaPoints[3].rx() = x2;
758 hexaPoints[3].ry() = y4;
760 hexaPoints[4].rx() = x1;
761 hexaPoints[4].ry() = y3;
763 hexaPoints[5].rx() = x1;
764 hexaPoints[5].ry() = y2;
770class QwtSymbol::PrivateData
774 const QPen& pn,
const QSize& sz )
779 , isPinPointEnabled( false )
799 bool isPinPointEnabled;
824 QSvgRenderer* renderer;
845 m_data =
new PrivateData(
style, QBrush( Qt::gray ),
846 QPen( Qt::black, 0 ), QSize() );
859 const QPen& pen,
const QSize& size )
879 const QBrush& brush,
const QPen& pen )
902 if ( m_data->cache.policy != policy )
904 m_data->cache.policy = policy;
915 return m_data->cache.policy;
969 m_data->path.path =
path;
970 m_data->path.graphic.
reset();
979 return m_data->path.path;
995 m_data->pixmap.pixmap =
pixmap;
1004 return m_data->pixmap.pixmap;
1020 m_data->graphic.graphic =
graphic;
1029 return m_data->graphic.graphic;
1047 if ( m_data->svg.renderer == NULL )
1048 m_data->svg.renderer =
new QSvgRenderer();
1050 m_data->svg.renderer->load( svgDocument );
1069 if ( ( width >= 0 ) && ( height < 0 ) )
1072 setSize( QSize( width, height ) );
1083 if (
size.isValid() &&
size != m_data->size )
1085 m_data->size =
size;
1096 return m_data->size;
1109 if (
brush != m_data->brush )
1111 m_data->brush =
brush;
1115 m_data->path.graphic.
reset();
1125 return m_data->brush;
1142 qreal width, Qt::PenStyle style )
1157 if (
pen != m_data->pen )
1163 m_data->path.graphic.
reset();
1188 switch ( m_data->style )
1201 if ( m_data->brush.color() != color )
1203 m_data->brush.setColor( color );
1214 if ( m_data->pen.color() != color )
1216 m_data->pen.setColor( color );
1223 if ( m_data->brush.color() != color ||
1224 m_data->pen.color() != color )
1229 m_data->brush.setColor( color );
1230 m_data->pen.setColor( color );
1251 if ( m_data->pinPoint != pos )
1253 m_data->pinPoint = pos;
1254 if ( m_data->isPinPointEnabled )
1269 return m_data->pinPoint;
1280 if ( m_data->isPinPointEnabled != on )
1282 m_data->isPinPointEnabled = on;
1293 return m_data->isPinPointEnabled;
1308 const QPointF* points,
int numPoints )
const
1310 if ( numPoints <= 0 )
1313 bool useCache =
false;
1319 !painter->transform().isScaling() )
1327 switch( painter->paintEngine()->type() )
1329 case QPaintEngine::OpenGL:
1330 case QPaintEngine::OpenGL2:
1336 case QPaintEngine::OpenVG:
1337 case QPaintEngine::SVG:
1338 case QPaintEngine::Pdf:
1339 case QPaintEngine::Picture:
1345 case QPaintEngine::X11:
1347 switch( m_data->style )
1363 if ( m_data->size.isEmpty() ||
1364 m_data->size == m_data->pixmap.pixmap.size() )
1390 if ( m_data->cache.pixmap.isNull() )
1393 m_data->cache.pixmap.fill( Qt::transparent );
1395 QPainter p( &m_data->cache.pixmap );
1396 p.setRenderHints( painter->renderHints() );
1397 p.translate( -br.topLeft() );
1399 const QPointF pos( 0.0, 0.0 );
1403 const int dx = br.left();
1404 const int dy = br.top();
1406 for (
int i = 0; i < numPoints; i++ )
1408 const int left = qRound( points[i].x() ) + dx;
1409 const int top = qRound( points[i].y() ) + dy;
1411 painter->drawPixmap( left, top, m_data->cache.pixmap );
1441 m_data->graphic.graphic.
render(
1442 painter, rect, Qt::KeepAspectRatio );
1446 if ( m_data->path.graphic.
isNull() )
1448 m_data->path.graphic = qwtPathGraphic(
1449 m_data->path.path, m_data->pen, m_data->brush );
1452 m_data->path.graphic.
render(
1453 painter, rect, Qt::KeepAspectRatio );
1459 if ( m_data->svg.renderer )
1463 QSizeF sz = m_data->svg.renderer->viewBoxF().size();
1464 if ( !sz.isEmpty() )
1466 sz.scale( rect.size(), Qt::KeepAspectRatio );
1467 scaledRect.setSize( sz );
1468 scaledRect.moveCenter( rect.center() );
1475 m_data->svg.renderer->render(
1476 painter, scaledRect );
1486 const double ratio = qMin( rect.width() / br.width(),
1487 rect.height() / br.height() );
1491 painter->translate( rect.center() );
1492 painter->scale( ratio, ratio );
1495 m_data->isPinPointEnabled =
false;
1514 const QPointF* points,
int numPoints )
const
1516 switch ( m_data->style )
1520 qwtDrawEllipseSymbols( painter, points, numPoints, *
this );
1525 qwtDrawRectSymbols( painter, points, numPoints, *
this );
1530 qwtDrawDiamondSymbols( painter, points, numPoints, *
this );
1535 qwtDrawLineSymbols( painter, Qt::Horizontal | Qt::Vertical,
1536 points, numPoints, *
this );
1541 qwtDrawXCrossSymbols( painter, points, numPoints, *
this );
1547 qwtDrawTriangleSymbols( painter, QwtTriangle::Up,
1548 points, numPoints, *
this );
1553 qwtDrawTriangleSymbols( painter, QwtTriangle::Down,
1554 points, numPoints, *
this );
1559 qwtDrawTriangleSymbols( painter, QwtTriangle::Right,
1560 points, numPoints, *
this );
1565 qwtDrawTriangleSymbols( painter, QwtTriangle::Left,
1566 points, numPoints, *
this );
1571 qwtDrawLineSymbols( painter, Qt::Horizontal,
1572 points, numPoints, *
this );
1577 qwtDrawLineSymbols( painter, Qt::Vertical,
1578 points, numPoints, *
this );
1583 qwtDrawStar1Symbols( painter, points, numPoints, *
this );
1588 qwtDrawStar2Symbols( painter, points, numPoints, *
this );
1593 qwtDrawHexagonSymbols( painter, points, numPoints, *
this );
1598 if ( m_data->path.graphic.
isNull() )
1600 m_data->path.graphic = qwtPathGraphic( m_data->path.path,
1601 m_data->pen, m_data->brush );
1604 qwtDrawGraphicSymbols( painter, points, numPoints,
1605 m_data->path.graphic, *
this );
1610 qwtDrawPixmapSymbols( painter, points, numPoints, *
this );
1615 qwtDrawGraphicSymbols( painter, points, numPoints,
1616 m_data->graphic.graphic, *
this );
1622 qwtDrawSvgSymbols( painter, points, numPoints,
1623 m_data->svg.renderer, *
this );
1641 bool pinPointTranslation =
false;
1643 switch ( m_data->style )
1650 if ( m_data->pen.style() != Qt::NoPen )
1653 rect.setSize( m_data->size + QSizeF( pw, pw ) );
1654 rect.moveCenter( QPointF( 0.0, 0.0 ) );
1669 if ( m_data->pen.style() != Qt::NoPen )
1672 rect.setSize( m_data->size + QSizeF( 2 * pw, 2 * pw ) );
1673 rect.moveCenter( QPointF( 0.0, 0.0 ) );
1678 if ( m_data->path.graphic.
isNull() )
1680 m_data->path.graphic = qwtPathGraphic(
1681 m_data->path.path, m_data->pen, m_data->brush );
1684 rect = qwtScaledBoundingRect(
1685 m_data->path.graphic, m_data->size );
1686 pinPointTranslation =
true;
1692 if ( m_data->size.isEmpty() )
1693 rect.setSize( m_data->pixmap.pixmap.size() );
1695 rect.setSize( m_data->size );
1697 pinPointTranslation =
true;
1703 rect = qwtScaledBoundingRect(
1704 m_data->graphic.graphic, m_data->size );
1705 pinPointTranslation =
true;
1712 if ( m_data->svg.renderer )
1713 rect = m_data->svg.renderer->viewBoxF();
1715 if ( m_data->size.isValid() && !rect.isEmpty() )
1717 QSizeF sz = rect.size();
1719 const double sx = m_data->size.width() / sz.width();
1720 const double sy = m_data->size.height() / sz.height();
1722 QTransform transform;
1723 transform.scale( sx, sy );
1725 rect = transform.mapRect( rect );
1727 pinPointTranslation =
true;
1733 rect.setSize( m_data->size );
1734 rect.moveCenter( QPointF( 0.0, 0.0 ) );
1738 if ( pinPointTranslation )
1741 if ( m_data->isPinPointEnabled )
1742 pinPoint = rect.center() - m_data->pinPoint;
1748 r.setLeft( qwtFloor( rect.left() ) );
1749 r.setTop( qwtFloor( rect.top() ) );
1750 r.setRight( qwtCeil( rect.right() ) );
1751 r.setBottom( qwtCeil( rect.bottom() ) );
1754 r.adjust( -1, -1, 1, 1 );
1772 if ( !m_data->cache.pixmap.isNull() )
1773 m_data->cache.pixmap = QPixmap();
1784 if ( m_data->style !=
style )
1786 m_data->style =
style;
1797 return m_data->style;
A paint device for scalable graphics.
void reset()
Clear all stored commands.
void setRenderHint(RenderHint, bool on=true)
QRectF controlPointRect() const
QSizeF defaultSize() const
Default size.
QRectF scaledBoundingRect(qreal sx, qreal sy) const
Calculate the target rectangle for scaling the graphic.
void render(QPainter *) const
Replay all recorded painter commands.
static void drawEllipse(QPainter *, const QRectF &)
Wrapper for QPainter::drawEllipse()
static void drawPolygon(QPainter *, const QPolygonF &)
Wrapper for QPainter::drawPolygon()
static qreal effectivePenWidth(const QPen &)
static void drawRect(QPainter *, qreal x, qreal y, qreal w, qreal h)
Wrapper for QPainter::drawRect()
static QPixmap backingStore(QWidget *, const QSize &)
static bool roundingAlignment()
static void drawPixmap(QPainter *, const QRectF &, const QPixmap &)
Wrapper for QPainter::drawPixmap()
static void drawLine(QPainter *, qreal x1, qreal y1, qreal x2, qreal y2)
Wrapper for QPainter::drawLine()
A class for drawing symbols.
const QPainterPath & path() const
virtual void setColor(const QColor &)
Set the color of the symbol.
const QBrush & brush() const
const QPixmap & pixmap() const
void setPen(const QColor &, qreal width=0.0, Qt::PenStyle=Qt::SolidLine)
void drawSymbol(QPainter *, const QRectF &) const
Draw the symbol into a rectangle.
void setCachePolicy(CachePolicy)
void setPinPointEnabled(bool)
virtual ~QwtSymbol()
Destructor.
virtual QRect boundingRect() const
void setSvgDocument(const QByteArray &)
void drawSymbols(QPainter *, const QPolygonF &) const
Draw symbols at the specified points.
@ Ellipse
Ellipse or circle.
@ LTriangle
Triangle pointing left.
@ Star1
X combined with +.
@ Triangle
Triangle pointing upwards.
@ XCross
Diagonal cross (X)
@ UTriangle
Triangle pointing upwards.
@ NoSymbol
No Style. The symbol cannot be drawn.
@ DTriangle
Triangle pointing downwards.
@ RTriangle
Triangle pointing right.
void setPath(const QPainterPath &)
Set a painter path as symbol.
void setPixmap(const QPixmap &)
QwtSymbol(Style=NoSymbol)
void setPinPoint(const QPointF &pos, bool enable=true)
Set and enable a pin point.
void setSize(const QSize &)
bool isPinPointEnabled() const
void setGraphic(const QwtGraphic &)
const QSize & size() const
virtual void renderSymbols(QPainter *, const QPointF *, int numPoints) const
@ Cache
Always use a pixmap cache.
CachePolicy cachePolicy() const
const QwtGraphic & graphic() const
void setBrush(const QBrush &)
Assign a brush.