rock_widget_collection  0.1
Public Slots | Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PaintWidget Class Reference

#include <PaintWidget.h>

Inherits QWidget.

Inherited by MultiWidget.

Public Slots

QObject * addItem (QObject *object)
 
QObject * addPoints (const QList< int > &points_x, const QList< int > &points_y, int groupNr, const QColor &color)
 
QObject * addText (int xPos, int yPos, int groupNr, const QString &text)
 
QObject * addLine (int xPos, int yPos, int groupNr, const QColor &color, int endX, int endY)
 
QObject * addEllipse (int xPos, int yPos, int groupNr, const QColor &color, int width, int height)
 
QObject * addRectangle (int xPos, int yPos, int groupNr, const QColor &color, int width, int height)
 
QObject * addPolyline (int groupNr, const QColor &color, const QList< QPoint > &points)
 
QObject * addPolygon (int groupNr, const QColor &color, const QList< QPoint > &points)
 
QObject * removeItem (QObject *drawItem, bool delete_object)
 
void removeAllItems (bool delete_objects)
 

Public Member Functions

 PaintWidget (QWidget *parent)
 
 ~PaintWidget ()
 

Protected Member Functions

void drawDrawItemsToImage (QImage &image, bool all=false)
 
void drawDrawItemsToPainter (QPainter &painter, bool all=false)
 
void paintEvent (QPaintEvent *event)
 

Protected Attributes

QList< DrawItem * > items
 
QList< int > disabledGroups
 
bool isOpenGL
 

Detailed Description

Definition at line 7 of file PaintWidget.h.

Constructor & Destructor Documentation

◆ PaintWidget()

PaintWidget::PaintWidget ( QWidget *  parent)

Definition at line 16 of file PaintWidget.cc.

16  :
17 QWidget(parent),
18 isOpenGL(false)
19 //image(0, 0, QImage::Format_RGB888)
20 {
21 };

◆ ~PaintWidget()

PaintWidget::~PaintWidget ( )

Definition at line 23 of file PaintWidget.cc.

24 {
25 };

Member Function Documentation

◆ addEllipse

QObject * PaintWidget::addEllipse ( int  xPos,
int  yPos,
int  groupNr,
const QColor &  color,
int  width,
int  height 
)
slot

Adds an ellipse to the image and all successive images. the elipse will be drawn within an outlying rectangle specified.
The ellipse will not be filles and the border will have the minimum width.

Parameters
xPosthe top left x position of the rectangle
yPosthe top left y position of the rectangle
groupNrteh group number
colorthe color of the ellipses border
widththe width of the rectangle
heightthe height of the rectangle
Returns
pointer to a #seeDrawItem to remove the ellipse afterwards

Definition at line 46 of file PaintWidget.cc.

47 {
48  EllipseItem* item = new EllipseItem(xPos, yPos, groupNr, color, width, height);
49  if(isOpenGL)
50  item->openGL(true);
51 
52  items.push_back(item);
53  return item;
54 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
void openGL(bool value)
Definition: DrawItem.h:157

◆ addItem

QObject * PaintWidget::addItem ( QObject *  object)
slot

Adds a shape to the image

Parameters
drawItemteh itrem which to draw. keep the item given to remove it afterwards

Definition at line 85 of file PaintWidget.cc.

86 {
87  DrawItem* drawItem = dynamic_cast<DrawItem*>(object);
88  if(isOpenGL)
89  drawItem->openGL(true);
90 
91  items.push_back(drawItem);
92  return object;
93 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
void openGL(bool value)
Definition: DrawItem.h:157

◆ addLine

QObject * PaintWidget::addLine ( int  xPos,
int  yPos,
int  groupNr,
const QColor &  color,
int  endX,
int  endY 
)
slot

Adds a line to the images and all successive images

Parameters
xPosthe starting x position
yPosthe starting y position
groupNrthe group number
colorthe color of the line
endXthe ending x position
endYthe ending y position
Returns
pointer to a #seeDrawItem to remove the line afterwards

Definition at line 36 of file PaintWidget.cc.

37 {
38  LineItem* item = new LineItem(xPos, yPos, groupNr, color, endX, endY);
39  if(isOpenGL)
40  item->openGL(true);
41 
42  items.push_back(item);
43  return item;
44 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
void openGL(bool value)
Definition: DrawItem.h:157

◆ addPoints

QObject * PaintWidget::addPoints ( const QList< int > &  points_x,
const QList< int > &  points_y,
int  groupNr,
const QColor &  color 
)
slot

Definition at line 95 of file PaintWidget.cc.

96 {
97  DrawItem* drawItem = new PointItem(points_x,points_y,groupNr,color);
98  if(isOpenGL)
99  drawItem->openGL(true);
100  items.push_back(drawItem);
101  return drawItem;
102 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
void openGL(bool value)
Definition: DrawItem.h:157

◆ addPolygon

QObject * PaintWidget::addPolygon ( int  groupNr,
const QColor &  color,
const QList< QPoint > &  points 
)
slot

Adds a Polygon with the given points. An additional line will be drawn between the last and the first poin t given. Polygons can be filles unlike Polylines

Parameters
groupNrthe group number
colorthe color of the lines
pointsthe points of the polygon
numberOfPointsthe number of points in the points array
Returns
a DrawItem containing the Polygon

Definition at line 75 of file PaintWidget.cc.

76 {
77  PolygonItem* item = new PolygonItem(color, groupNr, points);
78  if(isOpenGL)
79  item->openGL(true);
80 
81  items.push_back(item);
82  return item;
83 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
void openGL(bool value)
Definition: DrawItem.h:157

◆ addPolyline

QObject * PaintWidget::addPolyline ( int  groupNr,
const QColor &  color,
const QList< QPoint > &  points 
)
slot

Adds multiple lines

Parameters
groupNrthe number of the group
colorthe color of the lines
pointsthe points weher a line starts/ends
numberOfPointsthe number of points in the points array
Returns
pointer to a DrawItem

Definition at line 65 of file PaintWidget.cc.

66 {
67  PolylineItem* item = new PolylineItem(color, groupNr, points);
68  if(isOpenGL)
69  item->openGL(true);
70 
71  items.push_back(item);
72  return item;
73 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
void openGL(bool value)
Definition: DrawItem.h:157

◆ addRectangle

QObject * PaintWidget::addRectangle ( int  xPos,
int  yPos,
int  groupNr,
const QColor &  color,
int  width,
int  height 
)
slot

Adds a rectangle to the image and all successive images. The rectangle will not be filles and the border will have the minimum width.

Parameters
xPosthe top left x position of the rectangle
yPosthe top left y position of the rectangle
groupNrthe group number
colorthe color of the rectangles border
widththe width of the rectangle Adds a rectangle to the image and all successive images. The rectangle will not be filles and the border will have the minimum width.
xPosthe top left x position of the rectangle
yPosthe top left y position of the rectangle
groupNrthe group number
colorthe color of the rectangles border
widththe width of the rectangle
heightthe height of the rectangle
Returns
pointer to a #seeDrawItem to remove the ellipse afterwards

Definition at line 56 of file PaintWidget.cc.

57 {
58  RectangleItem* item = new RectangleItem(xPos, yPos, groupNr, color, width, height);
59  if(isOpenGL)
60  item->openGL(true);
61 
62  items.push_back(item);
63  return item;
64 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
void openGL(bool value)
Definition: DrawItem.h:157

◆ addText

QObject * PaintWidget::addText ( int  xPos,
int  yPos,
int  groupNr,
const QString &  text 
)
slot

Adds a Text to the image and all successive images

Parameters
xPosthe starting x position
yPosthe starting y position
groupNrthe group number
textthe text to be displayed
Returns
pointer to a #seeDrawItem to remove the text afterwards.

Definition at line 27 of file PaintWidget.cc.

28 {
29  TextItem* textItem = new TextItem(xPos, yPos, groupNr, text);
30  if(isOpenGL)
31  textItem->openGL(true);
32  items.push_back(textItem);
33  return textItem;
34 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
void openGL(bool value)
Definition: DrawItem.h:157

◆ drawDrawItemsToImage()

void PaintWidget::drawDrawItemsToImage ( QImage &  image,
bool  all = false 
)
protected

Adds all shapes to the image

Parameters
shownImageteh iamge to add the shapes to

◆ drawDrawItemsToPainter()

void PaintWidget::drawDrawItemsToPainter ( QPainter &  painter,
bool  all = false 
)
protected

Definition at line 134 of file PaintWidget.cc.

135 {
136  if(!isOpenGL)
137  all = true;
138 
139  QRectF target = painter.viewport();
140 
141  if(!items.empty())
142  {
143  painter.setRenderHint(QPainter::TextAntialiasing, true);
144  QList<DrawItem*>::iterator iter = items.begin();
145  for(;iter != items.end();++iter)
146  {
147  if(!disabledGroups.contains((*iter)->getGroupNr()))
148  if(!(*iter)->onOpenGL() || all == true)
149  (*iter)->draw(&painter,target,target);
150  }
151  }
152 }
QList< DrawItem * > items
Definition: PaintWidget.h:127
QList< int > disabledGroups
Definition: PaintWidget.h:129

◆ paintEvent()

void PaintWidget::paintEvent ( QPaintEvent *  event)
protected

Definition at line 128 of file PaintWidget.cc.

129 {
130  QPainter painter(this);
131  drawDrawItemsToPainter(painter,true);
132 }
void drawDrawItemsToPainter(QPainter &painter, bool all=false)
Definition: PaintWidget.cc:134

◆ removeAllItems

void PaintWidget::removeAllItems ( bool  delete_objects)
slot

Removes all shapes from the iamges

Definition at line 116 of file PaintWidget.cc.

117 {
118  if(delete_objects)
119  {
120  QList<DrawItem*>::iterator iter = items.begin();
121  for(;iter != items.end();++iter)
122  delete(*iter);
123  }
124  items.clear();
125 }
QList< DrawItem * > items
Definition: PaintWidget.h:127

◆ removeItem

QObject * PaintWidget::removeItem ( QObject *  drawItem,
bool  delete_object 
)
slot

Remobves a shape from the image

Parameters
drawItemthe shape to remove

Definition at line 104 of file PaintWidget.cc.

105 {
106  DrawItem *draw_item = dynamic_cast<DrawItem*>(object);
107  items.removeAll(draw_item);
108  if(delete_object)
109  {
110  delete object;
111  object = NULL;
112  }
113  return object;
114 }
QList< DrawItem * > items
Definition: PaintWidget.h:127

Member Data Documentation

◆ disabledGroups

QList<int> PaintWidget::disabledGroups
protected

List of group numbers currently disabled

Definition at line 129 of file PaintWidget.h.

◆ isOpenGL

bool PaintWidget::isOpenGL
protected

Definition at line 130 of file PaintWidget.h.

◆ items

QList<DrawItem*> PaintWidget::items
protected

The format used in the widget List of all Draw Items

Definition at line 127 of file PaintWidget.h.


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