qlaserdata.cpp
Go to the documentation of this file.
1 #include <QGraphicsScene>
2 #include <QPainter>
3 #include <QStyleOption>
4 
5 #include "qlaserdata.h"
6 #include "qlaserdata.moc"
7 
8 
10 {
11  this->countour = createCountour();
12  double *p = ld->estimate;
13  setPos(QPointF(p[0],p[1]));
14  rotate(CSM::rad2deg(p[2]));
15 }
16 
18 {
19  return countour.boundingRect();
20 }
21 
22 QPainterPath QLaserData::shape() const
23 {
24  return countour;
25 }
26 
29  struct stroke_sequence sequence[ld->nrays];
30  compute_stroke_sequence(ld, sequence, 100, 0.1);
31 
32  QPainterPath path;
33  for(int i=0;i<ld->nrays;i++) {
34  if(sequence[i].valid==0) continue;
35  double *p = sequence[i].p;
36  if(sequence[i].begin_new_stroke)
37  path.moveTo(p[0], p[1]);
38  else
39  path.lineTo(p[0], p[1]);
40  }
41  return path;
42 }
43 
44 void QLaserData::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
45 {
46  // Body
47 // painter->setBrush(color);
48 /* painter->drawEllipse(-10, -20, 20, 40);
49 
50  // Eyes
51  painter->setBrush(Qt::white);
52  painter->drawEllipse(-10, -17, 8, 8);
53  painter->drawEllipse(2, -17, 8, 8);
54 
55  // Nose
56  painter->setBrush(Qt::black);
57  painter->drawEllipse(QRectF(-2, -22, 4, 4));
58 
59 
60  // Ears
61  painter->setBrush(scene()->collidingItems(this).isEmpty() ? Qt::darkYellow : Qt::red);
62  painter->drawEllipse(-17, -12, 16, 16);
63  painter->drawEllipse(1, -12, 16, 16);
64 */
65  // Tail
66  painter->setPen(Qt::black);
67  painter->setBrush(Qt::NoBrush);
68 /* painter->setBrush(Qt::red);*/
69  painter->drawPath(countour);
70 }
71 
72 void QLaserData::timerEvent(QTimerEvent *)
73 {
74 
75  // rotate(dx);
76 // setPos(mapToParent(0, -(3 + sin(speed) * 3)));
77 }
QPainterPath countour
Definition: qlaserdata.h:25
QLaserData(LDP ld)
Definition: qlaserdata.cpp:9
void compute_stroke_sequence(LDP ld, struct stroke_sequence *draw_info, double horizon, double connect_threshold)
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Definition: qlaserdata.cpp:44
QRectF boundingRect() const
Definition: qlaserdata.cpp:17
QPainterPath shape() const
Definition: qlaserdata.cpp:22
void timerEvent(QTimerEvent *event)
Definition: qlaserdata.cpp:72
struct @0 p
QPainterPath createCountour()
Definition: qlaserdata.cpp:27
double estimate[3]
Definition: laser_data.h:40
void ld_compute_cartesian(LDP ld)
Definition: laser_data.c:118
double rad2deg(double rad)
Definition: math_utils.c:79


csm
Author(s): Andrea Censi
autogenerated on Tue May 11 2021 02:18:23