rock_widget_collection  0.1
Public Member Functions | List of all members
ArrowItem Class Reference

#include <ArrowItem.h>

Inherits FillItem.

Public Member Functions

 ArrowItem (int posX, int posY, int groupNr, const QColor &color, int endX, int endY)
 
virtual ~ArrowItem ()
 
DrawType getType ()
 
void draw (QPainter *painter, QRectF &source, QRectF &target)
 
- Public Member Functions inherited from FillItem
 FillItem (int posX, int posY, int groupNr, const QColor &color)
 
bool isDrawBorder ()
 
QColor * getInteriorColor ()
 
void setDrawBorder (bool drawBorder)
 
void setInteriorColor (QColor *interiorColor)
 
void draw (QPainter *painter, QRectF &source, QRectF &target)
 
- Public Member Functions inherited from DrawItem
 DrawItem (int posX, int posY, int groupNr, const QColor &color)
 
virtual ~DrawItem ()
 
bool operator== (const DrawItem &other)
 
virtual void renderOnGl (QGLWidget &widget, QRectF &source, QRectF &target)
 

Additional Inherited Members

- Public Slots inherited from DrawItem
int getPosX ()
 
int getPosY ()
 
int getGroupNr ()
 
QColor getColor ()
 
void setPosX (int posX)
 
void setPosY (int posY)
 
void setGroupNr (int groupNr)
 
void setColor (const QColor &color)
 
int getLineWidth ()
 
Qt::PenStyle getPenStyle ()
 
Qt::PenCapStyle getPenCapStyle ()
 
void setLineWidth (int lineWidth)
 
void setPenStyle (Qt::PenStyle penStyle)
 
void setPenCapStyle (Qt::PenCapStyle penCapStyle)
 
int getID () const
 
void openGL (bool value)
 
bool onOpenGL ()
 
void setPosFactor (float fx, float fy)
 
- Protected Member Functions inherited from FillItem
void addBrushStyle (QPainter *painter)
 
- Protected Member Functions inherited from DrawItem
void addPenStyle (QPainter *painter)
 
- Protected Attributes inherited from FillItem
bool drawBorder
 
QColor * interiorColor
 
- Protected Attributes inherited from DrawItem
int groupNr
 
int posX
 
int posY
 
QColor color
 
int lineWidth
 
Qt::PenCapStyle penCapStyle
 
Qt::PenStyle penStyle
 
int m_id
 
float position_factor_x
 
float position_factor_y
 
bool brender_on_opengl
 
- Static Protected Attributes inherited from DrawItem
static int _ID = 0
 

Detailed Description

Arrow shape. This also gives an xample of how to create items that are not composed of multiple shapes. The arrow is composed of a line and a polygon which resides at the end of the line. The endX and endY positions are the end positions of the line. the arrowhead will reside at 10 + (2*lineWidth) further along the line.

Definition at line 23 of file ArrowItem.h.

Constructor & Destructor Documentation

ArrowItem::ArrowItem ( int  posX,
int  posY,
int  groupNr,
const QColor &  color,
int  endX,
int  endY 
)

Creates an arrowitem

Parameters
posXthe starting xposition of the line
posYthe starting y position of the line
groupNrthe group number
colorthe color of the line and the border of the arrow
endXthe x end position of the line NOT the arrow
endYthe y end position of the line NOT the arrow

Definition at line 10 of file ArrowItem.cc.

11  :FillItem(posX, posY, groupNr, color),endX(endX),endY(endY)
12 {
13 
14 }
FillItem(int posX, int posY, int groupNr, const QColor &color)
Definition: FillItem.cc:11
int posY
Definition: DrawItem.h:182
int posX
Definition: DrawItem.h:180
int groupNr
Definition: DrawItem.h:169
QColor color
Definition: DrawItem.h:184
ArrowItem::~ArrowItem ( )
virtual

Destructor

Definition at line 16 of file ArrowItem.cc.

17 {
18 }

Member Function Documentation

void ArrowItem::draw ( QPainter *  painter,
QRectF &  source,
QRectF &  target 
)
virtual
See Also
DrawItem::draw

Implements DrawItem.

Definition at line 20 of file ArrowItem.cc.

21 {
22  FillItem::draw(painter,source,target);
23  QPen pen = painter->pen();
24  painter->drawLine(posX, posY, endX, endY);
25  double arrowWidth = 10 + (2*lineWidth);
26  double deltaX = endX - posX;
27  double deltaY = endY - posY;
28  double xLength = pow(deltaX, 2);
29  double yLength = pow(deltaY, 2);
30  double total = sqrt(xLength + yLength);
31  double sumX = arrowWidth*(-deltaY/total);
32  double sumY = arrowWidth*(deltaX/total);
33  QPoint* points = new QPoint[3];
34  points[0] = QPoint(endX - sumX, endY - sumY);
35  points[1] = QPoint(endX + sumX, endY + sumY);
36  points[2] = QPoint(endX + arrowWidth*(deltaX/total), endY + arrowWidth*(deltaY/total));
37  painter->drawPolygon(points, 3);
38 }
int posY
Definition: DrawItem.h:182
int posX
Definition: DrawItem.h:180
int lineWidth
Definition: DrawItem.h:186
void draw(QPainter *painter, QRectF &source, QRectF &target)
Definition: FillItem.cc:26
DrawType ArrowItem::getType ( )
inlinevirtual

Returns DrawTYpe::Arrow

Returns
DrawTYpe::Arrow

Implements DrawItem.

Definition at line 44 of file ArrowItem.h.

44 {return Arrow;};
Definition: DrawItem.h:19

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