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

Public Member Functions

 LineItem (int posX, int posY, int groupNr, const QColor &color, int endX, int endY)
 
virtual ~LineItem ()
 
- Public Member Functions inherited from DrawItem
 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)
 

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

Destructor

Definition at line 35 of file LineItem.h.

35 {};

Member Function Documentation

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

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
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;};
int LineItem::getEndY ( )
inlineslot

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;};
DrawType LineItem::getType ( )
inlineslot

Returns DrawType::Line

Returns
DrawType::Line

Definition at line 53 of file LineItem.h.

53 {return Line;};
Definition: DrawItem.h:19
void LineItem::renderOnGl ( QGLWidget &  widget,
QRectF &  source,
QRectF &  target 
)
slot
See Also
DrawItem::draw

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
void LineItem::setEndX ( int  endX)
inlineslot

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;};
void LineItem::setEndY ( int  endY)
inlineslot

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: