StatsToolBox.h
Go to the documentation of this file.
1 /*
2 Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3 All rights reserved.
4 
5 Redistribution and use in source and binary forms, with or without
6 modification, are permitted provided that the following conditions are met:
7  * Redistributions of source code must retain the above copyright
8  notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright
10  notice, this list of conditions and the following disclaimer in the
11  documentation and/or other materials provided with the distribution.
12  * Neither the name of the Universite de Sherbrooke nor the
13  names of its contributors may be used to endorse or promote products
14  derived from this software without specific prior written permission.
15 
16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27 
28 #ifndef RTABMAP_STATSTOOLBOX_H_
29 #define RTABMAP_STATSTOOLBOX_H_
30 
31 #include "rtabmap/gui/RtabmapGuiExp.h" // DLL export/import defines
32 
33 #include <QWidget>
34 #include <QtCore/QMap>
35 
36 class QToolButton;
37 class QLabel;
38 class QMenu;
39 class QGridLayout;
40 class QToolBox;
41 
42 namespace rtabmap {
43 
44 class RTABMAPGUI_EXP StatItem : public QWidget
45 {
46  Q_OBJECT;
47 
48 public:
49  StatItem(const QString & name, bool cacheOn, const std::vector<qreal> & x, const std::vector<qreal> & y, const QString & unit = QString(), const QMenu * menu = 0, QGridLayout * grid = 0, QWidget * parent = 0);
50  virtual ~StatItem();
51  void addValue(qreal y);
52  void addValue(qreal x, qreal y);
53  void setValues(const std::vector<qreal> & x, const std::vector<qreal> & y);
54  QString value() const;
55  std::vector<qreal> xValues() const {return _x;}
56  std::vector<qreal> yValues() const {return _y;}
57  void setCacheOn(bool on);
58  void clearCache();
59 
60 public Q_SLOTS:
61  void updateMenu(const QMenu * menu);
62 
63 Q_SIGNALS:
64  void valueAdded(qreal);
65  void valueAdded(qreal, qreal);
66  void valuesChanged(const std::vector<qreal> &, const std::vector<qreal> &);
67  void plotRequested(const StatItem *, const QString &);
68 
69 private Q_SLOTS:
70  void preparePlotRequest();
71 
72 private:
73  void setupUi(QGridLayout * grid);
74 
75 private:
76  QToolButton * _button;
77  QLabel * _name;
78  QLabel * _value;
79  QLabel * _unit;
80  QMenu * _menu;
81 
82  bool _cacheOn;
83  std::vector<qreal> _x;
84  std::vector<qreal> _y;
85 };
86 
87 
88 
89 
90 class RTABMAPGUI_EXP StatsToolBox : public QWidget
91 {
92  Q_OBJECT;
93 
94 public:
95  StatsToolBox(QWidget * parent);
96  virtual ~StatsToolBox();
97 
98  void getFiguresSetup(QList<int> & curvesPerFigure, QStringList & curveNames);
99  void addCurve(const QString & name, bool newFigure = true, bool cacheOn = false);
100  void setWorkingDirectory(const QString & workingDirectory);
101  void setNewFigureMaxItems(int value) {_newFigureMaxItems = value;}
102  void closeFigures();
103  void setCacheOn(bool on);
104 
105 public Q_SLOTS:
106  void updateStat(const QString & statFullName, bool cacheOn);
107  void updateStat(const QString & statFullName, qreal y, bool cacheOn);
108  void updateStat(const QString & statFullName, qreal x, qreal y, bool cacheOn);
109  void updateStat(const QString & statFullName, const std::vector<qreal> & x, const std::vector<qreal> & y, bool cacheOn);
110  void clear();
111 
112 Q_SIGNALS:
113  void menuChanged(const QMenu *);
114  void figuresSetupChanged();
115 
116 private Q_SLOTS:
117  void plot(const StatItem * stat, const QString & plotName = QString());
118  void figureDeleted(QObject * obj);
119 
120 protected:
121  virtual void contextMenuEvent(QContextMenuEvent * event);
122 
123 private:
124  QMenu * _plotMenu;
125  QToolBox * _statBox;
128  QMap<QString, QWidget*> _figures;
129 };
130 
131 }
132 
133 #endif /* STATSTOOLBOX_H_ */
#define RTABMAPGUI_EXP
Definition: RtabmapGuiExp.h:38
void setNewFigureMaxItems(int value)
Definition: StatsToolBox.h:101
x
QMap< QString, QWidget * > _figures
Definition: StatsToolBox.h:128
std::vector< qreal > _x
Definition: StatsToolBox.h:83
string name
void addValue(int pos, float val, float *vals, T *point, T *points, int n)
std::vector< qreal > yValues() const
Definition: StatsToolBox.h:56
QToolButton * _button
Definition: StatsToolBox.h:76
std::vector< qreal > xValues() const
Definition: StatsToolBox.h:55
std::vector< qreal > _y
Definition: StatsToolBox.h:84


rtabmap
Author(s): Mathieu Labbe
autogenerated on Mon Jan 23 2023 03:38:57