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

#include <LineItem.h>

Inherits DrawItem.

Public Slots

int getEndX ()
 
- Public Slots inherited from DrawItem
int getPosX ()
 

Public Member Functions

 LineItem (int posX, int posY, int groupNr, const QColor &color, int endX, int endY)
 
virtual ~LineItem ()
 
int getEndY ()
 
DrawType getType ()
 
void setEndX (int endX)
 
void setEndY (int endY)
 
void renderOnGl (QGLWidget &widget, QRectF &source, QRectF &target)
 
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)
 
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)
 

Additional Inherited Members

- Protected Member Functions inherited from DrawItem
void addPenStyle (QPainter *painter)
 
- 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

LineItem for drawing a line from one point to another

Definition at line 17 of file LineItem.h.

Constructor & Destructor Documentation

◆ LineItem()

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

Creates a LIneItem

Parameters
posXthe x position of the starting point
posYteh y position of the starting point
groupNrteh group number
colorthe color
endXthe x position of the endpoint
endYthe y position of the end point

Definition at line 12 of file LineItem.cc.

14 {
15  this->endX = endX;
16  this->endY = endY;
17 }
DrawItem(int posX, int posY, int groupNr, const QColor &color)
Definition: DrawItem.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

◆ ~LineItem()

virtual LineItem::~LineItem ( )
inlinevirtual

Destructor

Definition at line 35 of file LineItem.h.

35 {};

Member Function Documentation

◆ draw()

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

avstract method to draw the item

Parameters
painterthe painter with wich to draw the shape

Implements DrawItem.

Definition at line 19 of file LineItem.cc.

20 {
21  float factor_x = ((float)target.width())/source.width();
22  float factor_y = ((float)target.height())/source.height();
23  addPenStyle(painter);
24  painter->drawLine(factor_x*posX+target.x(),
25  posY*factor_y+target.y(),
26  target.x()+factor_x*endX,
27  target.y()+factor_y*endY);
28 }
void addPenStyle(QPainter *painter)
Definition: DrawItem.cc:27
int posY
Definition: DrawItem.h:182
int posX
Definition: DrawItem.h:180

◆ getEndX

int LineItem::getEndX ( )
inlineslot

Returns the x position of the end point

Returns
the x position of the end point

Definition at line 41 of file LineItem.h.

41 {return endX;};

◆ getEndY()

int LineItem::getEndY ( )
inline

Retuns the y position of the end point

Returns
the y poistion of the end point

Definition at line 47 of file LineItem.h.

47 {return endY;};

◆ getType()

DrawType LineItem::getType ( )
inlinevirtual

Returns DrawType::Line

Returns
DrawType::Line

Implements DrawItem.

Definition at line 53 of file LineItem.h.

53 {return Line;};
Definition: DrawItem.h:19

◆ renderOnGl()

void LineItem::renderOnGl ( QGLWidget &  widget,
QRectF &  source,
QRectF &  target 
)
virtual
See also
DrawItem::draw

Reimplemented from DrawItem.

Definition at line 31 of file LineItem.cc.

32 {
33  float factor_x = ((float)target.width())/source.width();
34  float factor_y = ((float)target.height())/source.height();
35  glColor4ub(color.red(),color.green(),color.blue(),color.alpha());
36  glBegin(GL_LINES);
37  glVertex3f(factor_x*posX+target.x(), widget.height()-(posY*factor_y+target.y()), 0.0f); // ending point of the line
38  glVertex3f(target.x()+factor_x*endX, widget.height()-(target.y()+factor_y*endY), 0.0f); // ending point of the line
39  glEnd( );
40 }
int posY
Definition: DrawItem.h:182
int posX
Definition: DrawItem.h:180
QColor color
Definition: DrawItem.h:184

◆ setEndX()

void LineItem::setEndX ( int  endX)
inline

Sets the x position of the end point

Parameters
endXthe x position of the end point

Definition at line 59 of file LineItem.h.

59 {this->endX = endX;};

◆ setEndY()

void LineItem::setEndY ( int  endY)
inline

Sets the y position the end point

Parameters
endYthe y position of the end point

Definition at line 65 of file LineItem.h.

65 {this->endY = endY;};

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