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 ()
 
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)
 

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)
 

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 ( 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
virtual DrawItem::~DrawItem ( )
inlinevirtual

Destructor

Definition at line 43 of file DrawItem.h.

43 {};

Member Function Documentation

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
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, RectangleItem, FillItem, ArrowItem, EllipseItem, PolygonItem, and TextItem.

QColor DrawItem::getColor ( )
inlineslot

Returns the color

Returns
the color

Definition at line 89 of file DrawItem.h.

89 {return color;};
QColor color
Definition: DrawItem.h:184
int DrawItem::getGroupNr ( )
inlineslot

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
int DrawItem::getID ( ) const
inlineslot

Definition at line 152 of file DrawItem.h.

153  {
154  return m_id;
155  };
int m_id
Definition: DrawItem.h:191
int DrawItem::getLineWidth ( )
inlineslot

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
Qt::PenCapStyle DrawItem::getPenCapStyle ( )
inlineslot

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
Qt::PenStyle DrawItem::getPenStyle ( )
inlineslot

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
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
int DrawItem::getPosY ( )
inlineslot

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
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, RectangleItem, ArrowItem, EllipseItem, and PolygonItem.

bool DrawItem::onOpenGL ( )
inlineslot

Definition at line 162 of file DrawItem.h.

162 {return brender_on_opengl;};
bool brender_on_opengl
Definition: DrawItem.h:196
void DrawItem::openGL ( bool  value)
inlineslot

Definition at line 157 of file DrawItem.h.

158  {
159  brender_on_opengl = value;
160  };
bool brender_on_opengl
Definition: DrawItem.h:196
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
virtual void DrawItem::renderOnGl ( QGLWidget &  widget,
QRectF &  source,
QRectF &  target 
)
inlinevirtual

Reimplemented in TextItem.

Definition at line 62 of file DrawItem.h.

62 {};
void DrawItem::setColor ( const QColor &  color)
inlineslot

Sets the color

Parameters
colorthe color

Definition at line 113 of file DrawItem.h.

113 {this->color = color;};
QColor color
Definition: DrawItem.h:184
void DrawItem::setGroupNr ( int  groupNr)
inlineslot

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
void DrawItem::setLineWidth ( int  lineWidth)
inlineslot

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
void DrawItem::setPenCapStyle ( Qt::PenCapStyle  penCapStyle)
inlineslot

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
void DrawItem::setPenStyle ( Qt::PenStyle  penStyle)
inlineslot

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
void DrawItem::setPosFactor ( float  fx,
float  fy 
)
inlineslot

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
void DrawItem::setPosX ( int  posX)
inlineslot

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
void DrawItem::setPosY ( int  posY)
inlineslot

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

int DrawItem::_ID = 0
staticprotected

Definition at line 192 of file DrawItem.h.

bool DrawItem::brender_on_opengl
protected

Definition at line 196 of file DrawItem.h.

QColor DrawItem::color
protected

The color

Definition at line 184 of file DrawItem.h.

int DrawItem::groupNr
protected

The group number

Definition at line 169 of file DrawItem.h.

int DrawItem::lineWidth
protected

the width of the shapes lines

Definition at line 186 of file DrawItem.h.

int DrawItem::m_id
protected

Definition at line 191 of file DrawItem.h.

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.

Qt::PenStyle DrawItem::penStyle
protected

The pen style of the lines

Definition at line 190 of file DrawItem.h.

float DrawItem::position_factor_x
protected

Definition at line 193 of file DrawItem.h.

float DrawItem::position_factor_y
protected

Definition at line 194 of file DrawItem.h.

int DrawItem::posX
protected

The x position

Definition at line 180 of file DrawItem.h.

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: