23 #include "rtabmap/gui/rtabmap_gui_export.h"
26 #include <QtCore/QList>
27 #include <QtCore/QMap>
29 #include <QtGui/QBrush>
30 #include <QGraphicsEllipseItem>
31 #include <QtCore/QMutex>
33 #include <QPushButton>
34 #include <QtCore/QTime>
35 #include <QtCore/QElapsedTimer>
47 class RTABMAP_GUI_EXPORT
UPlotItem :
public QGraphicsEllipseItem
53 UPlotItem(qreal dataX, qreal dataY, qreal width=2);
62 void setPreviousItem(
UPlotItem * previousItem);
63 void setData(
const QPointF &
data);
67 const QPointF &
data()
const {
return _data;}
70 virtual void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
71 virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
72 virtual void focusInEvent(QFocusEvent * event);
73 virtual void focusOutEvent(QFocusEvent * event);
74 virtual void keyReleaseEvent(QKeyEvent * keyEvent);
76 virtual void showDescription(
bool shown);
78 void init(qreal dataX, qreal dataY);
105 UPlotCurve(
const QString &
name,
const QVector<UPlotItem *>
data, QObject * parent = 0);
109 UPlotCurve(
const QString &
name,
const QVector<qreal> &
x,
const QVector<qreal> &
y, QObject * parent = 0);
115 const QPen &
pen()
const {
return _pen;}
119 const QBrush &
brush()
const {
return _brush;}
124 void setPen(
const QPen & pen);
128 void setBrush(
const QBrush & brush);
130 void setItemsColor(
const QColor & color);
136 QString
name()
const {
return _name;}
140 int itemsSize()
const;
141 QPointF getItemData(
int index);
143 void setData(QVector<UPlotItem*> & data);
144 void getData(QVector<qreal> & x, QVector<qreal> & y)
const;
145 void getData(QMap<qreal,qreal> & data)
const;
146 void draw(QPainter * painter,
const QRect & limits);
153 virtual void clear();
158 void setVisible(
bool visible);
163 void setXIncrement(qreal increment);
168 void setXStart(qreal val);
197 void addValues(QVector<UPlotItem *> & data);
202 void addValues(
const QVector<qreal> & xs,
const QVector<qreal> & ys);
208 void addValues(
const QVector<qreal> & ys);
209 void addValues(
const QVector<int> & ys);
215 void addValues(
const std::vector<qreal> & ys);
216 void addValues(
const std::vector<int> & ys);
218 void setData(
const QVector<qreal> & x,
const QVector<qreal> & y);
219 void setData(
const std::vector<qreal> & x,
const std::vector<qreal> & y);
220 void setData(
const QVector<qreal> & y);
221 void setData(
const std::vector<qreal> & y);
232 void attach(
UPlot * plot);
233 void detach(
UPlot * plot);
235 const QVector<qreal> &
getMinMax()
const {
return _minMax;}
236 int removeItem(
int index);
239 virtual void update(qreal scaleX, qreal scaleY, qreal offsetX, qreal offsetY, qreal xDir, qreal yDir,
int maxItemsKept);
279 void setThreshold(qreal threshold);
287 virtual void update(qreal scaleX, qreal scaleY, qreal offsetX, qreal offsetY, qreal xDir, qreal yDir,
int maxItemsKept);
312 void setAxis(qreal &
min, qreal &
max);
320 int step()
const {
return _step;}
328 void setReversed(
bool reversed);
331 virtual void paintEvent(QPaintEvent * event);
359 QPixmap createSymbol(
const QPen & pen,
const QBrush & brush);
360 void showStdDevMeanMax(
bool shown);
368 void updateStdDevMeanMax();
371 virtual void contextMenuEvent(QContextMenuEvent * event);
400 void setFlat(
bool on);
404 QString getAllCurveDataAsText()
const;
407 void removeLegendItem(
const UPlotCurve * curve);
412 void legendItemRemoved(
const UPlotCurve * curve);
413 void legendItemToggled(
const UPlotCurve * curve,
bool toggled);
414 void legendItemMoved(
const UPlotCurve * curve,
int);
417 virtual void contextMenuEvent(QContextMenuEvent * event);
420 void redirectToggled(
bool);
454 QSize sizeHint()
const;
455 QSize minimumSizeHint()
const;
457 virtual void paintEvent(QPaintEvent* event);
492 class RTABMAP_GUI_EXPORT
UPlot :
public QWidget
500 UPlot(QWidget * parent = 0);
506 UPlotCurve * addCurve(
const QString & curveName,
const QColor & color = QColor());
510 bool addCurve(
UPlotCurve * curve,
bool ownershipTransferred =
true);
514 QStringList curveNames()
const;
515 bool contains(
const QString & curveName)
const;
516 bool isThreshold(
const QString & curveName)
const;
517 double getThresholdValue(
const QString & curveName)
const;
519 QString getAllCurveDataAsText()
const;
524 QString
title()
const {
return this->objectName();}
525 QPen getRandomPenColored();
526 void showLegend(
bool shown);
527 void showGrid(
bool shown);
528 void showRefreshRate(
bool shown);
529 void trackMouse(
bool tracking);
530 void keepAllData(
bool kept);
531 void showXAxis(
bool shown) {_horizontalAxis->setVisible(shown);}
532 void showYAxis(
bool shown) {_verticalAxis->setVisible(shown);}
535 void setFixedXAxis(qreal x1, qreal x2);
536 void setFixedYAxis(qreal y1, qreal y2);
537 void setMaxVisibleItems(
int maxVisibleItems);
538 void setTitle(
const QString & text);
539 void setXLabel(
const QString & text);
541 void setWorkingDirectory(
const QString & workingDirectory);
542 void setGraphicsView(
bool on);
543 void setBackgroundColor(
const QColor & color);
544 QRectF sceneRect()
const;
552 void showCurve(
const UPlotCurve * curve,
bool shown);
560 void frameData(
bool xAxis =
true,
bool yAxis =
false);
563 void captureScreen();
565 void moveCurve(
const UPlotCurve *,
int index);
568 virtual void contextMenuEvent(QContextMenuEvent * event);
569 virtual void paintEvent(QPaintEvent * event);
570 virtual void resizeEvent(QResizeEvent * event);
571 virtual void mousePressEvent(QMouseEvent * event);
572 virtual void mouseMoveEvent(QMouseEvent * event);
573 virtual void mouseReleaseEvent(QMouseEvent * event);
574 virtual void mouseDoubleClickEvent(QMouseEvent * event);
578 void addItem(QGraphicsItem * item);
581 void replot(QPainter * painter);
582 bool updateAxis(qreal x, qreal y);
583 bool updateAxis(qreal x1, qreal x2, qreal y1, qreal y2);
585 void createActions();
587 void selectScreenCaptureFormat();
588 bool mousePosToValue(
const QPoint &
pos, qreal & x, qreal & y);
595 qreal _axisMaximums[4];
596 bool _axisMaximumsSet[4];