rock_widget_collection  0.1
Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
DrawItem Class Referenceabstract

#include <DrawItem.h>

Inherits QObject.

Inherited by FillItem, LineItem, PointItem, and TextItem.

Public Slots

int getPosX ()
 

Public Member Functions

 DrawItem (int posX, int posY, int groupNr, const QColor &color)
 
virtual ~DrawItem ()
 
virtual DrawType getType ()=0
 
virtual void draw (QPainter *painter, QRectF &source, QRectF &target)=0
 
bool operator== (const DrawItem &other)
 
virtual void renderOnGl (QGLWidget &widget, QRectF &source, QRectF &target)
 
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

void addPenStyle (QPainter *painter)
 

Protected Attributes

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

static int _ID = 0
 

Detailed Description

Abstract Base class for all shapes. It defines basic members and methods and the abstract getType() method which needs to be overwritten with a type from the DrawType enum. The abstract draw method needs to be overwritten in each item. So each item draws itself.

Definition at line 28 of file DrawItem.h.

Constructor & Destructor Documentation

◆ DrawItem()

DrawItem::DrawItem ( int  posX,
int  posY,
int  groupNr,
const QColor &  color 
)

Generates a DrawItem

Parameters
posXthe starting x position
posYthe starting y position
groupNrthe group number
colorthe color

Definition at line 11 of file DrawItem.cc.

11  :
13 posX(posX),
14 posY(posY),
15 color(color),
16 lineWidth(0),
17 penCapStyle(Qt::SquareCap),
18 penStyle(Qt::SolidLine),
19 m_id(_ID++),
20 brender_on_opengl(false),
23 {
24 
25 }
static int _ID
Definition: DrawItem.h:192
int posY
Definition: DrawItem.h:182
int posX
Definition: DrawItem.h:180
int m_id
Definition: DrawItem.h:191
Qt::PenCapStyle penCapStyle
Definition: DrawItem.h:188
int lineWidth
Definition: DrawItem.h:186
Qt::PenStyle penStyle
Definition: DrawItem.h:190
bool brender_on_opengl
Definition: DrawItem.h:196
float position_factor_y
Definition: DrawItem.h:194
int groupNr
Definition: DrawItem.h:169
float position_factor_x
Definition: DrawItem.h:193
QColor color
Definition: DrawItem.h:184

◆ ~DrawItem()

virtual DrawItem::~DrawItem ( )
inlinevirtual

Destructor

Definition at line 43 of file DrawItem.h.

43 {};

Member Function Documentation

◆ addPenStyle()

void DrawItem::addPenStyle ( QPainter *  painter)
protected

Adds a pen to the given painter with the parameters given to the item

Parameters
painterteh painter with which afterwards teh shape will be drawn

Definition at line 27 of file DrawItem.cc.

28 {
29  QPen pen;
30  pen.setCapStyle(penCapStyle);
31  pen.setStyle(penStyle);
32  pen.setWidth(lineWidth);
33  pen.setColor(color);
34  painter->setPen(pen);
35 }
Qt::PenCapStyle penCapStyle
Definition: DrawItem.h:188
int lineWidth
Definition: DrawItem.h:186
Qt::PenStyle penStyle
Definition: DrawItem.h:190
QColor color
Definition: DrawItem.h:184

◆ draw()

virtual void DrawItem::draw ( QPainter *  painter,
QRectF &  source,
QRectF &  target 
)
pure virtual

avstract method to draw the item

Parameters
painterthe painter with wich to draw the shape

Implemented in PolylineItem, LineItem, RectangleItem, FillItem, ArrowItem, PointItem, EllipseItem, PolygonItem, and TextItem.

◆ getColor()

QColor DrawItem::getColor ( )
inline

Returns the color

Returns
the color

Definition at line 89 of file DrawItem.h.

89 {return color;};
QColor color
Definition: DrawItem.h:184

◆ getGroupNr()

int DrawItem::getGroupNr ( )
inline

Returns the group number

Returns
the group number

Definition at line 83 of file DrawItem.h.

83 {return groupNr;}
int groupNr
Definition: DrawItem.h:169

◆ getID()

int DrawItem::getID ( ) const
inline

Definition at line 152 of file DrawItem.h.

153  {
154  return m_id;
155  };
int m_id
Definition: DrawItem.h:191

◆ getLineWidth()

int DrawItem::getLineWidth ( )
inline

Returns the width of lines drawn. the smallest visible width is zero

Returns
the width of lines drawn

Definition at line 119 of file DrawItem.h.

119 {return lineWidth;};
int lineWidth
Definition: DrawItem.h:186

◆ getPenCapStyle()

Qt::PenCapStyle DrawItem::getPenCapStyle ( )
inline

Return sthe pen cap style

Returns
the qt pen cap style

Definition at line 131 of file DrawItem.h.

131 {return penCapStyle;};
Qt::PenCapStyle penCapStyle
Definition: DrawItem.h:188

◆ getPenStyle()

Qt::PenStyle DrawItem::getPenStyle ( )
inline

Returns the pen style, usually this should be solid

Returns
the Qt Pen style

Definition at line 125 of file DrawItem.h.

125 {return penStyle;};
Qt::PenStyle penStyle
Definition: DrawItem.h:190

◆ getPosX

int DrawItem::getPosX ( )
inlineslot

Returns the x position

Returns
the x position

Definition at line 71 of file DrawItem.h.

71 {return posX;};
int posX
Definition: DrawItem.h:180

◆ getPosY()

int DrawItem::getPosY ( )
inline

Returns the y poistion

Returns
the y position

Definition at line 77 of file DrawItem.h.

77 {return posY;};
int posY
Definition: DrawItem.h:182

◆ getType()

virtual DrawType DrawItem::getType ( )
pure virtual

virtual method wjich returns the type of teh item

Returns
the type of the item defined by #seeDrawType

Implemented in PolylineItem, TextItem, LineItem, RectangleItem, ArrowItem, EllipseItem, and PolygonItem.

◆ onOpenGL()

bool DrawItem::onOpenGL ( )
inline

Definition at line 162 of file DrawItem.h.

162 {return brender_on_opengl;};
bool brender_on_opengl
Definition: DrawItem.h:196

◆ openGL()

void DrawItem::openGL ( bool  value)
inline

Definition at line 157 of file DrawItem.h.

158  {
159  brender_on_opengl = value;
160  };
bool brender_on_opengl
Definition: DrawItem.h:196

◆ operator==()

bool DrawItem::operator== ( const DrawItem other)
inline

Definition at line 57 of file DrawItem.h.

58  {
59  return (getID() == other.getID());
60  }
int getID() const
Definition: DrawItem.h:152

◆ renderOnGl()

virtual void DrawItem::renderOnGl ( QGLWidget &  widget,
QRectF &  source,
QRectF &  target 
)
inlinevirtual

Reimplemented in LineItem, PointItem, and TextItem.

Definition at line 62 of file DrawItem.h.

62 {};

◆ setColor()

void DrawItem::setColor ( const QColor &  color)
inline

Sets the color

Parameters
colorthe color

Definition at line 113 of file DrawItem.h.

113 {this->color = color;};
QColor color
Definition: DrawItem.h:184

◆ setGroupNr()

void DrawItem::setGroupNr ( int  groupNr)
inline

Sets the group number

Parameters
groupNrthe group number

Definition at line 107 of file DrawItem.h.

107 {this->groupNr = groupNr;};
int groupNr
Definition: DrawItem.h:169

◆ setLineWidth()

void DrawItem::setLineWidth ( int  lineWidth)
inline

Sets the width of the lines drawn, 0 is the smallest visible line available

Parameters
lineWidththe width of the line

Definition at line 138 of file DrawItem.h.

138 {this->lineWidth = lineWidth;};
int lineWidth
Definition: DrawItem.h:186

◆ setPenCapStyle()

void DrawItem::setPenCapStyle ( Qt::PenCapStyle  penCapStyle)
inline

Sets the pen cap style

See also
Qt::PenCapStyle
Parameters
penCapStyle

Definition at line 150 of file DrawItem.h.

150 {this->penCapStyle = penCapStyle;};
Qt::PenCapStyle penCapStyle
Definition: DrawItem.h:188

◆ setPenStyle()

void DrawItem::setPenStyle ( Qt::PenStyle  penStyle)
inline

Sets the pen style

See also
Qt::PenStyle
Parameters
penStylethe penStyle

Definition at line 144 of file DrawItem.h.

144 {this->penStyle = penStyle;};
Qt::PenStyle penStyle
Definition: DrawItem.h:190

◆ setPosFactor()

void DrawItem::setPosFactor ( float  fx,
float  fy 
)
inline

Set the facor to calculate the pos during scaling x = posx + fx*window_width x = posx + fy*window_height

Definition at line 169 of file DrawItem.h.

float position_factor_y
Definition: DrawItem.h:194
float position_factor_x
Definition: DrawItem.h:193

◆ setPosX()

void DrawItem::setPosX ( int  posX)
inline

Sets the x position

Parameters
posXthe x position

Definition at line 95 of file DrawItem.h.

95 {this->posX = posX;};
int posX
Definition: DrawItem.h:180

◆ setPosY()

void DrawItem::setPosY ( int  posY)
inline

Sets the y position

Parameters
posYthe y position

Definition at line 101 of file DrawItem.h.

101 {this->posY = posY;};
int posY
Definition: DrawItem.h:182

Member Data Documentation

◆ _ID

int DrawItem::_ID = 0
staticprotected

Definition at line 192 of file DrawItem.h.

◆ brender_on_opengl

bool DrawItem::brender_on_opengl
protected

Definition at line 196 of file DrawItem.h.

◆ color

QColor DrawItem::color
protected

The color

Definition at line 184 of file DrawItem.h.

◆ groupNr

int DrawItem::groupNr
protected

The group number

Definition at line 169 of file DrawItem.h.

◆ lineWidth

int DrawItem::lineWidth
protected

the width of the shapes lines

Definition at line 186 of file DrawItem.h.

◆ m_id

int DrawItem::m_id
protected

Definition at line 191 of file DrawItem.h.

◆ penCapStyle

Qt::PenCapStyle DrawItem::penCapStyle
protected

the pen cap style of the item, irrelevant for lines which have no start or end point

Definition at line 188 of file DrawItem.h.

◆ penStyle

Qt::PenStyle DrawItem::penStyle
protected

The pen style of the lines

Definition at line 190 of file DrawItem.h.

◆ position_factor_x

float DrawItem::position_factor_x
protected

Definition at line 193 of file DrawItem.h.

◆ position_factor_y

float DrawItem::position_factor_y
protected

Definition at line 194 of file DrawItem.h.

◆ posX

int DrawItem::posX
protected

The x position

Definition at line 180 of file DrawItem.h.

◆ posY

int DrawItem::posY
protected

The y position

Definition at line 182 of file DrawItem.h.


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