Qt 4.8
Public Functions | Properties | List of all members
QSvgLine Class Reference

#include <qsvggraphics_p.h>

Inheritance diagram for QSvgLine:
QSvgNode

Public Functions

virtual QRectF bounds (QPainter *p, QSvgExtraStates &states) const
 
virtual void draw (QPainter *p, QSvgExtraStates &states)
 
 QSvgLine (QSvgNode *parent, const QLineF &line)
 
virtual Type type () const
 
- Public Functions inherited from QSvgNode
void appendStyleProperty (QSvgStyleProperty *prop, const QString &id)
 
void applyStyle (QPainter *p, QSvgExtraStates &states) const
 
DisplayMode displayMode () const
 
QSvgTinyDocumentdocument () const
 
bool isVisible () const
 
QString nodeId () const
 
QSvgNodeparent () const
 
 QSvgNode (QSvgNode *parent=0)
 
const QStringListrequiredExtensions () const
 
const QStringListrequiredFeatures () const
 
const QStringListrequiredFonts () const
 
const QStringListrequiredFormats () const
 
const QStringListrequiredLanguages () const
 
void revertStyle (QPainter *p, QSvgExtraStates &states) const
 
void setDisplayMode (DisplayMode display)
 
void setNodeId (const QString &i)
 
void setRequiredExtensions (const QStringList &lst)
 
void setRequiredFeatures (const QStringList &lst)
 
void setRequiredFonts (const QStringList &lst)
 
void setRequiredFormats (const QStringList &lst)
 
void setRequiredLanguages (const QStringList &lst)
 
void setVisible (bool visible)
 
void setXmlClass (const QString &str)
 
QSvgStylePropertystyleProperty (QSvgStyleProperty::Type type) const
 
QSvgFillStylePropertystyleProperty (const QString &id) const
 
virtual QRectF transformedBounds (QPainter *p, QSvgExtraStates &states) const
 
QRectF transformedBounds () const
 
QString xmlClass () const
 
virtual ~QSvgNode ()
 

Properties

QLineF m_line
 

Additional Inherited Members

- Public Types inherited from QSvgNode
enum  DisplayMode {
  InlineMode, BlockMode, ListItemMode, RunInMode,
  CompactMode, MarkerMode, TableMode, InlineTableMode,
  TableRowGroupMode, TableHeaderGroupMode, TableFooterGroupMode, TableRowMode,
  TableColumnGroupMode, TableColumnMode, TableCellMode, TableCaptionMode,
  NoneMode, InheritMode
}
 
enum  Type {
  DOC, G, DEFS, SWITCH,
  ANIMATION, ARC, CIRCLE, ELLIPSE,
  IMAGE, LINE, PATH, POLYGON,
  POLYLINE, RECT, TEXT, TEXTAREA,
  TSPAN, USE, VIDEO
}
 
- Static Protected Functions inherited from QSvgNode
static qreal strokeWidth (QPainter *p)
 
- Protected Variables inherited from QSvgNode
QSvgStyle m_style
 

Detailed Description

Definition at line 119 of file qsvggraphics_p.h.

Constructors and Destructors

◆ QSvgLine()

QSvgLine::QSvgLine ( QSvgNode parent,
const QLineF line 
)

Definition at line 146 of file qsvggraphics.cpp.

147  : QSvgNode(parent), m_line(line)
148 {
149 }
QLineF m_line
QSvgNode(QSvgNode *parent=0)
Definition: qsvgnode.cpp:52

Functions

◆ bounds()

QRectF QSvgLine::bounds ( QPainter p,
QSvgExtraStates states 
) const
virtual

Reimplemented from QSvgNode.

Definition at line 594 of file qsvggraphics.cpp.

595 {
596  qreal sw = strokeWidth(p);
597  if (qFuzzyIsNull(sw)) {
598  QPointF p1 = p->transform().map(m_line.p1());
599  QPointF p2 = p->transform().map(m_line.p2());
600  qreal minX = qMin(p1.x(), p2.x());
601  qreal minY = qMin(p1.y(), p2.y());
602  qreal maxX = qMax(p1.x(), p2.x());
603  qreal maxY = qMax(p1.y(), p2.y());
604  return QRectF(minX, minY, maxX - minX, maxY - minY);
605  } else {
606  QPainterPath path;
607  path.moveTo(m_line.p1());
608  path.lineTo(m_line.p2());
609  return boundsOnStroke(p, path, sw);
610  }
611 }
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
const QTransform & transform() const
Returns the world transformation matrix.
Definition: qpainter.cpp:9558
QLineF m_line
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
Definition: qpainterpath.h:67
QPointF p1() const
Returns the line&#39;s start point.
Definition: qline.h:314
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal x() const
Returns the x-coordinate of this point.
Definition: qpoint.h:282
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
QPoint map(const QPoint &p) const
Creates and returns a QPoint object that is a copy of the given point, mapped into the coordinate sys...
static qreal strokeWidth(QPainter *p)
Definition: qsvgnode.cpp:335
static QRectF boundsOnStroke(QPainter *p, const QPainterPath &path, qreal width)
QPointF p2() const
Returns the line&#39;s end point.
Definition: qline.h:319
qreal y() const
Returns the y-coordinate of this point.
Definition: qpoint.h:287
static Q_DECL_CONSTEXPR bool qFuzzyIsNull(double d)
Definition: qglobal.h:2043

◆ draw()

void QSvgLine::draw ( QPainter p,
QSvgExtraStates states 
)
virtual

Implements QSvgNode.

Definition at line 152 of file qsvggraphics.cpp.

153 {
154  applyStyle(p, states);
155  if (p->pen().widthF() != 0) {
156  qreal oldOpacity = p->opacity();
157  p->setOpacity(oldOpacity * states.strokeOpacity);
158  p->drawLine(m_line);
159  p->setOpacity(oldOpacity);
160  }
161  revertStyle(p, states);
162 }
double qreal
Definition: qglobal.h:1193
qreal opacity() const
Returns the opacity of the painter.
Definition: qpainter.cpp:2115
QLineF m_line
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition: qpainter.h:573
void applyStyle(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:118
const QPen & pen() const
Returns the painter&#39;s current pen.
Definition: qpainter.cpp:4152
qreal widthF() const
Returns the pen width with floating point precision.
Definition: qpen.cpp:645
void setOpacity(qreal opacity)
Sets the opacity of the painter to opacity.
Definition: qpainter.cpp:2139
void revertStyle(QPainter *p, QSvgExtraStates &states) const
Definition: qsvgnode.cpp:123

◆ type()

QSvgNode::Type QSvgLine::type ( ) const
virtual

Implements QSvgNode.

Definition at line 519 of file qsvggraphics.cpp.

520 {
521  return LINE;
522 }

Properties

◆ m_line

QLineF QSvgLine::m_line
private

Definition at line 127 of file qsvggraphics_p.h.

Referenced by draw().


The documentation for this class was generated from the following files: