Engauge Digitizer  2
 All Classes Files Functions Variables Enumerations Enumerator Friends Pages
GraphicsArcItem.cpp
1 /******************************************************************************************************
2  * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3  * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4  * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5  ******************************************************************************************************/
6 
7 #include "GraphicsArcItem.h"
8 #include <QDebug>
9 #include <QPainter>
10 #include <QGraphicsScene>
11 
13  double y,
14  double width,
15  double height,
16  QGraphicsItem *parent) :
17  QGraphicsEllipseItem(x,
18  y,
19  width,
20  height,
21  parent)
22 {
23 }
24 
26  QGraphicsItem *parent) :
27  QGraphicsEllipseItem (rect,
28  parent)
29 {
30 }
31 
33 {
34  // Untransformed bounding rectangle is worthless since there will be, if there was any shear or rotation,
35  // parts of the curve left after this graphics item is hidden. Trying to compute the actual extent is surprisingly
36  // hard when startAngle, spanAngle, shear and rotation are all considered.
37  //
38  // Since the GraphicsArcItem should ideally have spanned most of the image (for the most accurate digitizing
39  // results), we simply mark the whole image as part of the boundingRect
40  return scene()->sceneRect();
41 }
42 
43 void GraphicsArcItem::paint (QPainter *painter,
44  const QStyleOptionGraphicsItem * /* option */,
45  QWidget * /* widget */)
46 {
47  painter->setPen (pen ());
48  painter->drawArc (rect(),
49  startAngle (),
50  spanAngle());
51 }
virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Paint without interior fill.
GraphicsArcItem(double x, double y, double width, double height, QGraphicsItem *parent=0)
Constructor with individual coordinates.
virtual QRectF boundingRect() const
QGraphicsEllipseItem ignored transformation when computing bounding rectangle, although it should so ...