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

#include <PointItem.h>

Inherits DrawItem.

Public Slots

void setPoints (const QList< int > &points_x, const QList< int > &points_y)
 
DrawType getType ()
 
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

 PointItem (const QList< int > &points_x, const QList< int > &points_y, int groupNr, const QColor &color)
 
virtual ~PointItem ()
 
- 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

PointItem for drawing a line from one point to another

Definition at line 18 of file PointItem.h.

Constructor & Destructor Documentation

PointItem::PointItem ( const QList< int > &  points_x,
const QList< int > &  points_y,
int  groupNr,
const QColor &  color 
)

Definition at line 13 of file PointItem.cc.

14  : DrawItem(0, 0, groupNr, color)
15 {
16  this->points_x = points_x;
17  this->points_y = points_y;
18 
19 }
DrawItem(int posX, int posY, int groupNr, const QColor &color)
Definition: DrawItem.cc:11
int groupNr
Definition: DrawItem.h:169
QColor color
Definition: DrawItem.h:184
virtual PointItem::~PointItem ( )
inlinevirtual

Definition at line 23 of file PointItem.h.

23 {};

Member Function Documentation

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

Definition at line 21 of file PointItem.cc.

22 {
23  //drawing on non opengl contexts is not supported at the moment
24 }
DrawType PointItem::getType ( )
inlineslot

Definition at line 41 of file PointItem.h.

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

Definition at line 27 of file PointItem.cc.

28 {
29  float factor_x = ((float)target.width())/source.width();
30  float factor_y = ((float)target.height())/source.height();
31  glColor4ub(color.red(),color.green(),color.blue(),color.alpha());
32  QList<int>::iterator iter_x = points_x.begin();
33  QList<int>::iterator iter_y = points_y.begin();
34 
35  glBegin(GL_POINTS);
36  while(iter_x != points_x.end())
37  {
38 // std::cout << *iter_x << std::endl;
39  glVertex3f(factor_x*(*(iter_x++))+target.x(), widget.height()-(factor_y*(*(iter_y++))+target.y()), 0.0f);
40  }
41  glEnd( );
42 }
QColor color
Definition: DrawItem.h:184
void PointItem::setPoints ( const QList< int > &  points_x,
const QList< int > &  points_y 
)
inlineslot

Definition at line 26 of file PointItem.h.

27  {
28  if(points_x.size() != points_y.size())
29  throw std::runtime_error("size of points_x differs from the size of points_y");
30 
31  this->points_x = points_x;
32  this->points_y = points_y;
33 
34  if(points_x.size() > 0)
35  {
36  setPosX(points_x.first());
37  setPosY(points_y.first());
38  }
39  }
void setPosY(int posY)
Definition: DrawItem.h:101
void setPosX(int posX)
Definition: DrawItem.h:95

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