mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-08 12:30:20 +08:00
UPlot: changed float to qreal (double). Added UPlot::frameData() function.
This commit is contained in:
@@ -246,7 +246,7 @@ Q_SIGNALS:
|
|||||||
void timeLimitChanged(float);
|
void timeLimitChanged(float);
|
||||||
void mappingModeChanged(bool);
|
void mappingModeChanged(bool);
|
||||||
void noMoreImagesReceived();
|
void noMoreImagesReceived();
|
||||||
void loopClosureThrChanged(float);
|
void loopClosureThrChanged(qreal);
|
||||||
void twistReceived(float x, float y, float z, float roll, float pitch, float yaw, int row, int col);
|
void twistReceived(float x, float y, float z, float roll, float pitch, float yaw, int row, int col);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -46,14 +46,14 @@ class RTABMAPGUI_EXP StatItem : public QWidget
|
|||||||
Q_OBJECT;
|
Q_OBJECT;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
StatItem(const QString & name, bool cacheOn, const std::vector<float> & x, const std::vector<float> & y, const QString & unit = QString(), const QMenu * menu = 0, QGridLayout * grid = 0, QWidget * parent = 0);
|
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);
|
||||||
virtual ~StatItem();
|
virtual ~StatItem();
|
||||||
void addValue(float y);
|
void addValue(qreal y);
|
||||||
void addValue(float x, float y);
|
void addValue(qreal x, qreal y);
|
||||||
void setValues(const std::vector<float> & x, const std::vector<float> & y);
|
void setValues(const std::vector<qreal> & x, const std::vector<qreal> & y);
|
||||||
QString value() const;
|
QString value() const;
|
||||||
std::vector<float> xValues() const {return _x;}
|
std::vector<qreal> xValues() const {return _x;}
|
||||||
std::vector<float> yValues() const {return _y;}
|
std::vector<qreal> yValues() const {return _y;}
|
||||||
void setCacheOn(bool on);
|
void setCacheOn(bool on);
|
||||||
void clearCache();
|
void clearCache();
|
||||||
|
|
||||||
@@ -61,9 +61,9 @@ public Q_SLOTS:
|
|||||||
void updateMenu(const QMenu * menu);
|
void updateMenu(const QMenu * menu);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void valueAdded(float);
|
void valueAdded(qreal);
|
||||||
void valueAdded(float, float);
|
void valueAdded(qreal, qreal);
|
||||||
void valuesChanged(const std::vector<float> &, const std::vector<float> &);
|
void valuesChanged(const std::vector<qreal> &, const std::vector<qreal> &);
|
||||||
void plotRequested(const StatItem *, const QString &);
|
void plotRequested(const StatItem *, const QString &);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
@@ -80,8 +80,8 @@ private:
|
|||||||
QMenu * _menu;
|
QMenu * _menu;
|
||||||
|
|
||||||
bool _cacheOn;
|
bool _cacheOn;
|
||||||
std::vector<float> _x;
|
std::vector<qreal> _x;
|
||||||
std::vector<float> _y;
|
std::vector<qreal> _y;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -104,9 +104,9 @@ public:
|
|||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void updateStat(const QString & statFullName, bool cacheOn);
|
void updateStat(const QString & statFullName, bool cacheOn);
|
||||||
void updateStat(const QString & statFullName, float y, bool cacheOn);
|
void updateStat(const QString & statFullName, qreal y, bool cacheOn);
|
||||||
void updateStat(const QString & statFullName, float x, float y, bool cacheOn);
|
void updateStat(const QString & statFullName, qreal x, qreal y, bool cacheOn);
|
||||||
void updateStat(const QString & statFullName, const std::vector<float> & x, const std::vector<float> & y, bool cacheOn);
|
void updateStat(const QString & statFullName, const std::vector<qreal> & x, const std::vector<qreal> & y, bool cacheOn);
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Constructor 3
|
* Constructor 3
|
||||||
*/
|
*/
|
||||||
UPlotCurve(const QString & name, const QVector<float> & x, const QVector<float> & y, QObject * parent = 0);
|
UPlotCurve(const QString & name, const QVector<qreal> & x, const QVector<qreal> & y, QObject * parent = 0);
|
||||||
virtual ~UPlotCurve();
|
virtual ~UPlotCurve();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,8 +140,8 @@ public:
|
|||||||
QPointF getItemData(int index);
|
QPointF getItemData(int index);
|
||||||
bool isVisible() const {return _visible;}
|
bool isVisible() const {return _visible;}
|
||||||
void setData(QVector<UPlotItem*> & data); // take the ownership
|
void setData(QVector<UPlotItem*> & data); // take the ownership
|
||||||
void getData(QVector<float> & x, QVector<float> & y) const; // only call in Qt MainThread
|
void getData(QVector<qreal> & x, QVector<qreal> & y) const; // only call in Qt MainThread
|
||||||
void getData(QMap<float,float> & data) const; // only call in Qt MainThread
|
void getData(QMap<qreal,qreal> & data) const; // only call in Qt MainThread
|
||||||
void draw(QPainter * painter, const QRect & limits);
|
void draw(QPainter * painter, const QRect & limits);
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
@@ -159,12 +159,12 @@ public Q_SLOTS:
|
|||||||
*
|
*
|
||||||
* Set increment of the x values (when auto-increment is used).
|
* Set increment of the x values (when auto-increment is used).
|
||||||
*/
|
*/
|
||||||
void setXIncrement(float increment);
|
void setXIncrement(qreal increment);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Set starting x value (when auto-increment is used).
|
* Set starting x value (when auto-increment is used).
|
||||||
*/
|
*/
|
||||||
void setXStart(float val);
|
void setXStart(qreal val);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Add a single value, using a custom UPlotItem.
|
* Add a single value, using a custom UPlotItem.
|
||||||
@@ -175,12 +175,12 @@ public Q_SLOTS:
|
|||||||
* Add a single value y, x is auto-incremented by the increment set with setXIncrement().
|
* Add a single value y, x is auto-incremented by the increment set with setXIncrement().
|
||||||
* @see setXStart()
|
* @see setXStart()
|
||||||
*/
|
*/
|
||||||
void addValue(float y);
|
void addValue(qreal y);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Add a single value y at x.
|
* Add a single value y at x.
|
||||||
*/
|
*/
|
||||||
void addValue(float x, float y);
|
void addValue(qreal x, qreal y);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* For convenience...
|
* For convenience...
|
||||||
@@ -198,26 +198,26 @@ public Q_SLOTS:
|
|||||||
*
|
*
|
||||||
* Add multiple values y at x. Vectors must have the same size.
|
* Add multiple values y at x. Vectors must have the same size.
|
||||||
*/
|
*/
|
||||||
void addValues(const QVector<float> & xs, const QVector<float> & ys);
|
void addValues(const QVector<qreal> & xs, const QVector<qreal> & ys);
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Add multiple values y, x is auto-incremented by the increment set with setXIncrement().
|
* Add multiple values y, x is auto-incremented by the increment set with setXIncrement().
|
||||||
* @see setXStart()
|
* @see setXStart()
|
||||||
*/
|
*/
|
||||||
void addValues(const QVector<float> & ys);
|
void addValues(const QVector<qreal> & ys);
|
||||||
void addValues(const QVector<int> & ys); // for convenience
|
void addValues(const QVector<int> & ys); // for convenience
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Add multiple values y, x is auto-incremented by the increment set with setXIncrement().
|
* Add multiple values y, x is auto-incremented by the increment set with setXIncrement().
|
||||||
* @see setXStart()
|
* @see setXStart()
|
||||||
*/
|
*/
|
||||||
void addValues(const std::vector<float> & ys); // for convenience
|
void addValues(const std::vector<qreal> & ys); // for convenience
|
||||||
void addValues(const std::vector<int> & ys); // for convenience
|
void addValues(const std::vector<int> & ys); // for convenience
|
||||||
|
|
||||||
void setData(const QVector<float> & x, const QVector<float> & y);
|
void setData(const QVector<qreal> & x, const QVector<qreal> & y);
|
||||||
void setData(const std::vector<float> & x, const std::vector<float> & y);
|
void setData(const std::vector<qreal> & x, const std::vector<qreal> & y);
|
||||||
void setData(const QVector<float> & y);
|
void setData(const QVector<qreal> & y);
|
||||||
void setData(const std::vector<float> & y);
|
void setData(const std::vector<qreal> & y);
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
/**
|
/**
|
||||||
@@ -231,11 +231,11 @@ protected:
|
|||||||
void attach(UPlot * plot);
|
void attach(UPlot * plot);
|
||||||
void detach(UPlot * plot);
|
void detach(UPlot * plot);
|
||||||
void updateMinMax();
|
void updateMinMax();
|
||||||
const QVector<float> & getMinMax() const {return _minMax;}
|
const QVector<qreal> & getMinMax() const {return _minMax;}
|
||||||
int removeItem(int index);
|
int removeItem(int index);
|
||||||
void _addValue(UPlotItem * data);;
|
void _addValue(UPlotItem * data);;
|
||||||
virtual bool isMinMaxValid() const {return _minMax.size();}
|
virtual bool isMinMaxValid() const {return _minMax.size();}
|
||||||
virtual void update(float scaleX, float scaleY, float offsetX, float offsetY, float xDir, float yDir, int maxItemsKept);
|
virtual void update(qreal scaleX, qreal scaleY, qreal offsetX, qreal offsetY, qreal xDir, qreal yDir, int maxItemsKept);
|
||||||
QList<QGraphicsItem *> _items;
|
QList<QGraphicsItem *> _items;
|
||||||
UPlot * _plot;
|
UPlot * _plot;
|
||||||
|
|
||||||
@@ -246,11 +246,11 @@ private:
|
|||||||
QString _name;
|
QString _name;
|
||||||
QPen _pen;
|
QPen _pen;
|
||||||
QBrush _brush;
|
QBrush _brush;
|
||||||
float _xIncrement;
|
qreal _xIncrement;
|
||||||
float _xStart;
|
qreal _xStart;
|
||||||
bool _visible;
|
bool _visible;
|
||||||
bool _valuesShown;
|
bool _valuesShown;
|
||||||
QVector<float> _minMax; // minX, maxX, minY, maxY
|
QVector<qreal> _minMax; // minX, maxX, minY, maxY
|
||||||
QGraphicsRectItem * _rootItem;
|
QGraphicsRectItem * _rootItem;
|
||||||
QColor _itemsColor;
|
QColor _itemsColor;
|
||||||
};
|
};
|
||||||
@@ -267,14 +267,14 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
UPlotCurveThreshold(const QString & name, float thesholdValue, Qt::Orientation orientation = Qt::Horizontal, QObject * parent = 0);
|
UPlotCurveThreshold(const QString & name, qreal thesholdValue, Qt::Orientation orientation = Qt::Horizontal, QObject * parent = 0);
|
||||||
virtual ~UPlotCurveThreshold();
|
virtual ~UPlotCurveThreshold();
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
/**
|
/**
|
||||||
* Set threshold value.
|
* Set threshold value.
|
||||||
*/
|
*/
|
||||||
void setThreshold(float threshold);
|
void setThreshold(qreal threshold);
|
||||||
/**
|
/**
|
||||||
* Set orientation (Qt::Horizontal or Qt::Vertical).
|
* Set orientation (Qt::Horizontal or Qt::Vertical).
|
||||||
*/
|
*/
|
||||||
@@ -282,7 +282,7 @@ public Q_SLOTS:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class UPlot;
|
friend class UPlot;
|
||||||
virtual void update(float scaleX, float scaleY, float offsetX, float offsetY, float xDir, float yDir, int maxItemsKept);
|
virtual void update(qreal scaleX, qreal scaleY, qreal offsetX, qreal offsetY, qreal xDir, qreal yDir, int maxItemsKept);
|
||||||
virtual bool isMinMaxValid() const {return false;}
|
virtual bool isMinMaxValid() const {return false;}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -298,7 +298,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*/
|
*/
|
||||||
UPlotAxis(Qt::Orientation orientation = Qt::Horizontal, float min=0, float max=1, QWidget * parent = 0);
|
UPlotAxis(Qt::Orientation orientation = Qt::Horizontal, qreal min=0, qreal max=1, QWidget * parent = 0);
|
||||||
virtual ~UPlotAxis();
|
virtual ~UPlotAxis();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -306,7 +306,7 @@ public:
|
|||||||
* Set axis minimum and maximum values, compute the resulting
|
* Set axis minimum and maximum values, compute the resulting
|
||||||
* intervals depending on the size of the axis.
|
* intervals depending on the size of the axis.
|
||||||
*/
|
*/
|
||||||
void setAxis(float & min, float & max);
|
void setAxis(qreal & min, qreal & max);
|
||||||
/**
|
/**
|
||||||
* Size of the border between the first line and the beginning of the widget.
|
* Size of the border between the first line and the beginning of the widget.
|
||||||
*/
|
*/
|
||||||
@@ -329,8 +329,8 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Qt::Orientation _orientation;
|
Qt::Orientation _orientation;
|
||||||
float _min;
|
qreal _min;
|
||||||
float _max;
|
qreal _max;
|
||||||
int _count;
|
int _count;
|
||||||
int _step;
|
int _step;
|
||||||
bool _reversed;
|
bool _reversed;
|
||||||
@@ -472,8 +472,8 @@ private:
|
|||||||
* QApplication app(argc, argv);
|
* QApplication app(argc, argv);
|
||||||
* UPlot plot;
|
* UPlot plot;
|
||||||
* UPlotCurve * curve = plot.addCurve("My curve");
|
* UPlotCurve * curve = plot.addCurve("My curve");
|
||||||
* float y[10] = {0, 1, 2, 3, -3, -2, -1, 0, 1, 2};
|
* qreal y[10] = {0, 1, 2, 3, -3, -2, -1, 0, 1, 2};
|
||||||
* curve->addValues(std::vector<float>(y, y+10));
|
* curve->addValues(std::vector<qreal>(y, y+10));
|
||||||
* plot.showGrid(true);
|
* plot.showGrid(true);
|
||||||
* plot.setGraphicsView(true);
|
* plot.setGraphicsView(true);
|
||||||
* plot.show();
|
* plot.show();
|
||||||
@@ -513,7 +513,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Add a threshold to the plot.
|
* Add a threshold to the plot.
|
||||||
*/
|
*/
|
||||||
UPlotCurveThreshold * addThreshold(const QString & name, float value, Qt::Orientation orientation = Qt::Horizontal);
|
UPlotCurveThreshold * addThreshold(const QString & name, qreal value, Qt::Orientation orientation = Qt::Horizontal);
|
||||||
QString title() const {return this->objectName();}
|
QString title() const {return this->objectName();}
|
||||||
QPen getRandomPenColored();
|
QPen getRandomPenColored();
|
||||||
void showLegend(bool shown);
|
void showLegend(bool shown);
|
||||||
@@ -525,8 +525,8 @@ public:
|
|||||||
void showYAxis(bool shown) {_verticalAxis->setVisible(shown);}
|
void showYAxis(bool shown) {_verticalAxis->setVisible(shown);}
|
||||||
void setVariableXAxis() {_fixedAxis[0] = false;}
|
void setVariableXAxis() {_fixedAxis[0] = false;}
|
||||||
void setVariableYAxis() {_fixedAxis[1] = false;}
|
void setVariableYAxis() {_fixedAxis[1] = false;}
|
||||||
void setFixedXAxis(float x1, float x2);
|
void setFixedXAxis(qreal x1, qreal x2);
|
||||||
void setFixedYAxis(float y1, float y2);
|
void setFixedYAxis(qreal y1, qreal y2);
|
||||||
void setMaxVisibleItems(int maxVisibleItems);
|
void setMaxVisibleItems(int maxVisibleItems);
|
||||||
void setTitle(const QString & text);
|
void setTitle(const QString & text);
|
||||||
void setXLabel(const QString & text);
|
void setXLabel(const QString & text);
|
||||||
@@ -550,6 +550,8 @@ public Q_SLOTS:
|
|||||||
*/
|
*/
|
||||||
void clearData();
|
void clearData();
|
||||||
|
|
||||||
|
void frameData(bool xAxis = true, bool yAxis = false);
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void captureScreen();
|
void captureScreen();
|
||||||
void updateAxis(const UPlotCurve * curve);
|
void updateAxis(const UPlotCurve * curve);
|
||||||
@@ -570,20 +572,20 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void replot(QPainter * painter);
|
void replot(QPainter * painter);
|
||||||
bool updateAxis(float x, float y);
|
bool updateAxis(qreal x, qreal y);
|
||||||
bool updateAxis(float x1, float x2, float y1, float y2);
|
bool updateAxis(qreal x1, qreal x2, qreal y1, qreal y2);
|
||||||
void setupUi();
|
void setupUi();
|
||||||
void createActions();
|
void createActions();
|
||||||
void createMenus();
|
void createMenus();
|
||||||
void selectScreenCaptureFormat();
|
void selectScreenCaptureFormat();
|
||||||
bool mousePosToValue(const QPoint & pos, float & x, float & y);
|
bool mousePosToValue(const QPoint & pos, qreal & x, qreal & y);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UPlotLegend * _legend;
|
UPlotLegend * _legend;
|
||||||
QGraphicsView * _view;
|
QGraphicsView * _view;
|
||||||
QGraphicsItem * _sceneRoot;
|
QGraphicsItem * _sceneRoot;
|
||||||
QWidget * _graphicsViewHolder;
|
QWidget * _graphicsViewHolder;
|
||||||
float _axisMaximums[4]; // {x1->x2, y1->y2}
|
qreal _axisMaximums[4]; // {x1->x2, y1->y2}
|
||||||
bool _axisMaximumsSet[4]; // {x1->x2, y1->y2}
|
bool _axisMaximumsSet[4]; // {x1->x2, y1->y2}
|
||||||
bool _fixedAxis[2];
|
bool _fixedAxis[2];
|
||||||
UPlotAxis * _verticalAxis;
|
UPlotAxis * _verticalAxis;
|
||||||
|
|||||||
@@ -2090,7 +2090,7 @@ void DatabaseViewer::updateStatistics()
|
|||||||
double firstStamp = 0.0;
|
double firstStamp = 0.0;
|
||||||
std::map<int, std::pair<std::map<std::string, float>, double> > allStats = dbDriver_->getAllStatistics();
|
std::map<int, std::pair<std::map<std::string, float>, double> > allStats = dbDriver_->getAllStatistics();
|
||||||
|
|
||||||
std::map<std::string, std::pair<std::vector<float>, std::vector<float> > > allData;
|
std::map<std::string, std::pair<std::vector<qreal>, std::vector<qreal> > > allData;
|
||||||
std::map<std::string, int > allDataOi;
|
std::map<std::string, int > allDataOi;
|
||||||
|
|
||||||
for(int i=0; i<ids_.size(); ++i)
|
for(int i=0; i<ids_.size(); ++i)
|
||||||
@@ -2111,18 +2111,18 @@ void DatabaseViewer::updateStatistics()
|
|||||||
if(allData.find(iter->first) == allData.end())
|
if(allData.find(iter->first) == allData.end())
|
||||||
{
|
{
|
||||||
//initialize data vectors
|
//initialize data vectors
|
||||||
allData.insert(std::make_pair(iter->first, std::make_pair(std::vector<float>(ids_.size(), 0.0f), std::vector<float>(ids_.size(), 0.0f) )));
|
allData.insert(std::make_pair(iter->first, std::make_pair(std::vector<qreal>(ids_.size(), 0.0f), std::vector<qreal>(ids_.size(), 0.0f) )));
|
||||||
allDataOi.insert(std::make_pair(iter->first, 0));
|
allDataOi.insert(std::make_pair(iter->first, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
int & oi = allDataOi.at(iter->first);
|
int & oi = allDataOi.at(iter->first);
|
||||||
allData.at(iter->first).first[oi] = ui_->checkBox_timeStats->isChecked()?float(stamp-firstStamp):ids_[i];
|
allData.at(iter->first).first[oi] = ui_->checkBox_timeStats->isChecked()?qreal(stamp-firstStamp):ids_[i];
|
||||||
allData.at(iter->first).second[oi] = iter->second;
|
allData.at(iter->first).second[oi] = iter->second;
|
||||||
++oi;
|
++oi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(std::map<std::string, std::pair<std::vector<float>, std::vector<float> > >::iterator iter=allData.begin(); iter!=allData.end(); ++iter)
|
for(std::map<std::string, std::pair<std::vector<qreal>, std::vector<qreal> > >::iterator iter=allData.begin(); iter!=allData.end(); ++iter)
|
||||||
{
|
{
|
||||||
int oi = allDataOi.at(iter->first);
|
int oi = allDataOi.at(iter->first);
|
||||||
iter->second.first.resize(oi);
|
iter->second.first.resize(oi);
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ MainWindow::MainWindow(PreferencesDialog * prefDialog, QWidget * parent, bool sh
|
|||||||
_ui->posteriorPlot->setFixedYAxis(0,1);
|
_ui->posteriorPlot->setFixedYAxis(0,1);
|
||||||
UPlotCurveThreshold * tc;
|
UPlotCurveThreshold * tc;
|
||||||
tc = _ui->posteriorPlot->addThreshold("Loop closure thr", float(_preferencesDialog->getLoopThr()));
|
tc = _ui->posteriorPlot->addThreshold("Loop closure thr", float(_preferencesDialog->getLoopThr()));
|
||||||
connect(this, SIGNAL(loopClosureThrChanged(float)), tc, SLOT(setThreshold(float)));
|
connect(this, SIGNAL(loopClosureThrChanged(qreal)), tc, SLOT(setThreshold(qreal)));
|
||||||
|
|
||||||
_likelihoodCurve = new PdfPlotCurve("Likelihood", &_cachedSignatures, this);
|
_likelihoodCurve = new PdfPlotCurve("Likelihood", &_cachedSignatures, this);
|
||||||
_ui->likelihoodPlot->addCurve(_likelihoodCurve, false);
|
_ui->likelihoodPlot->addCurve(_likelihoodCurve, false);
|
||||||
@@ -1985,9 +1985,7 @@ void MainWindow::processStats(const rtabmap::Statistics & stat)
|
|||||||
|
|
||||||
ULOGGER_DEBUG("");
|
ULOGGER_DEBUG("");
|
||||||
//Adjust thresholds
|
//Adjust thresholds
|
||||||
float value;
|
Q_EMIT(loopClosureThrChanged(_preferencesDialog->getLoopThr()));
|
||||||
value = float(_preferencesDialog->getLoopThr());
|
|
||||||
Q_EMIT(loopClosureThrChanged(value));
|
|
||||||
}
|
}
|
||||||
if(!stat.likelihood().empty() && _ui->dockWidget_likelihood->isVisible())
|
if(!stat.likelihood().empty() && _ui->dockWidget_likelihood->isVisible())
|
||||||
{
|
{
|
||||||
@@ -4328,9 +4326,7 @@ void MainWindow::applyPrefSettings(const rtabmap::ParametersMap & parameters, bo
|
|||||||
_ui->doubleSpinBox_stats_timeLimit->setValue(_preferencesDialog->getTimeLimit());
|
_ui->doubleSpinBox_stats_timeLimit->setValue(_preferencesDialog->getTimeLimit());
|
||||||
_ui->actionSLAM_mode->setChecked(_preferencesDialog->isSLAMMode());
|
_ui->actionSLAM_mode->setChecked(_preferencesDialog->isSLAMMode());
|
||||||
|
|
||||||
float value;
|
Q_EMIT(loopClosureThrChanged(_preferencesDialog->getLoopThr()));
|
||||||
value = float(_preferencesDialog->getLoopThr());
|
|
||||||
Q_EMIT(loopClosureThrChanged(value));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords, const std::multimap<int, cv::KeyPoint> & loopWords)
|
void MainWindow::drawKeypoints(const std::multimap<int, cv::KeyPoint> & refWords, const std::multimap<int, cv::KeyPoint> & loopWords)
|
||||||
|
|||||||
@@ -4576,8 +4576,8 @@ void PreferencesDialog::updatePredictionPlot()
|
|||||||
_ui->lineEdit_bayes_predictionLC->text().toStdString().c_str());
|
_ui->lineEdit_bayes_predictionLC->text().toStdString().c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
QVector<float> dataX((values.size()-2)*2 + 1);
|
QVector<qreal> dataX((values.size()-2)*2 + 1);
|
||||||
QVector<float> dataY((values.size()-2)*2 + 1);
|
QVector<qreal> dataY((values.size()-2)*2 + 1);
|
||||||
double value;
|
double value;
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
int lvl = 1;
|
int lvl = 1;
|
||||||
|
|||||||
+19
-19
@@ -44,7 +44,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||||||
|
|
||||||
namespace rtabmap {
|
namespace rtabmap {
|
||||||
|
|
||||||
StatItem::StatItem(const QString & name, bool cacheOn, const std::vector<float> & x, const std::vector<float> & y, const QString & unit, const QMenu * menu, QGridLayout * grid, QWidget * parent) :
|
StatItem::StatItem(const QString & name, bool cacheOn, const std::vector<qreal> & x, const std::vector<qreal> & y, const QString & unit, const QMenu * menu, QGridLayout * grid, QWidget * parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
_button(0),
|
_button(0),
|
||||||
_name(0),
|
_name(0),
|
||||||
@@ -84,7 +84,7 @@ void StatItem::clearCache()
|
|||||||
_value->clear();
|
_value->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatItem::addValue(float y)
|
void StatItem::addValue(qreal y)
|
||||||
{
|
{
|
||||||
if(_cacheOn)
|
if(_cacheOn)
|
||||||
{
|
{
|
||||||
@@ -94,7 +94,7 @@ void StatItem::addValue(float y)
|
|||||||
Q_EMIT valueAdded(y);
|
Q_EMIT valueAdded(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatItem::addValue(float x, float y)
|
void StatItem::addValue(qreal x, qreal y)
|
||||||
{
|
{
|
||||||
if(_cacheOn)
|
if(_cacheOn)
|
||||||
{
|
{
|
||||||
@@ -111,7 +111,7 @@ void StatItem::addValue(float x, float y)
|
|||||||
Q_EMIT valueAdded(x,y);
|
Q_EMIT valueAdded(x,y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatItem::setValues(const std::vector<float> & x, const std::vector<float> & y)
|
void StatItem::setValues(const std::vector<qreal> & x, const std::vector<qreal> & y)
|
||||||
{
|
{
|
||||||
if(_cacheOn)
|
if(_cacheOn)
|
||||||
{
|
{
|
||||||
@@ -254,30 +254,30 @@ void StatsToolBox::setCacheOn(bool on)
|
|||||||
|
|
||||||
void StatsToolBox::updateStat(const QString & statFullName, bool cacheOn)
|
void StatsToolBox::updateStat(const QString & statFullName, bool cacheOn)
|
||||||
{
|
{
|
||||||
std::vector<float> vx,vy;
|
std::vector<qreal> vx,vy;
|
||||||
updateStat(statFullName, vx, vy, cacheOn);
|
updateStat(statFullName, vx, vy, cacheOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsToolBox::updateStat(const QString & statFullName, float y, bool cacheOn)
|
void StatsToolBox::updateStat(const QString & statFullName, qreal y, bool cacheOn)
|
||||||
{
|
{
|
||||||
std::vector<float> vx,vy(1);
|
std::vector<qreal> vx,vy(1);
|
||||||
vy[0] = y;
|
vy[0] = y;
|
||||||
updateStat(statFullName, vx, vy, cacheOn);
|
updateStat(statFullName, vx, vy, cacheOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsToolBox::updateStat(const QString & statFullName, float x, float y, bool cacheOn)
|
void StatsToolBox::updateStat(const QString & statFullName, qreal x, qreal y, bool cacheOn)
|
||||||
{
|
{
|
||||||
std::vector<float> vx(1),vy(1);
|
std::vector<qreal> vx(1),vy(1);
|
||||||
vx[0] = x;
|
vx[0] = x;
|
||||||
vy[0] = y;
|
vy[0] = y;
|
||||||
updateStat(statFullName, vx, vy, cacheOn);
|
updateStat(statFullName, vx, vy, cacheOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatsToolBox::updateStat(const QString & statFullName, const std::vector<float> & x, const std::vector<float> & y, bool cacheOn)
|
void StatsToolBox::updateStat(const QString & statFullName, const std::vector<qreal> & x, const std::vector<qreal> & y, bool cacheOn)
|
||||||
{
|
{
|
||||||
// round float to max 2 numbers after the dot
|
// round qreal to max 2 numbers after the dot
|
||||||
//x = (float(int(100*x)))/100;
|
//x = (qreal(int(100*x)))/100;
|
||||||
//y = (float(int(100*y)))/100;
|
//y = (qreal(int(100*y)))/100;
|
||||||
|
|
||||||
StatItem * item = _statBox->findChild<StatItem *>(statFullName);
|
StatItem * item = _statBox->findChild<StatItem *>(statFullName);
|
||||||
if(item)
|
if(item)
|
||||||
@@ -393,9 +393,9 @@ void StatsToolBox::plot(const StatItem * stat, const QString & plotName)
|
|||||||
{
|
{
|
||||||
UPlotCurve * curve = new UPlotCurve(stat->objectName(), plot);
|
UPlotCurve * curve = new UPlotCurve(stat->objectName(), plot);
|
||||||
curve->setPen(plot->getRandomPenColored());
|
curve->setPen(plot->getRandomPenColored());
|
||||||
connect(stat, SIGNAL(valueAdded(float)), curve, SLOT(addValue(float)));
|
connect(stat, SIGNAL(valueAdded(qreal)), curve, SLOT(addValue(qreal)));
|
||||||
connect(stat, SIGNAL(valueAdded(float, float)), curve, SLOT(addValue(float, float)));
|
connect(stat, SIGNAL(valueAdded(qreal, qreal)), curve, SLOT(addValue(qreal, qreal)));
|
||||||
connect(stat, SIGNAL(valuesChanged(const std::vector<float> &, const std::vector<float> &)), curve, SLOT(setData(const std::vector<float> &, const std::vector<float> &)));
|
connect(stat, SIGNAL(valuesChanged(const std::vector<qreal> &, const std::vector<qreal> &)), curve, SLOT(setData(const std::vector<qreal> &, const std::vector<qreal> &)));
|
||||||
if(stat->value().compare("*") == 0)
|
if(stat->value().compare("*") == 0)
|
||||||
{
|
{
|
||||||
plot->setMaxVisibleItems(0);
|
plot->setMaxVisibleItems(0);
|
||||||
@@ -453,9 +453,9 @@ void StatsToolBox::plot(const StatItem * stat, const QString & plotName)
|
|||||||
//Add a new curve linked to the statBox
|
//Add a new curve linked to the statBox
|
||||||
UPlotCurve * curve = new UPlotCurve(stat->objectName(), newPlot);
|
UPlotCurve * curve = new UPlotCurve(stat->objectName(), newPlot);
|
||||||
curve->setPen(newPlot->getRandomPenColored());
|
curve->setPen(newPlot->getRandomPenColored());
|
||||||
connect(stat, SIGNAL(valueAdded(float)), curve, SLOT(addValue(float)));
|
connect(stat, SIGNAL(valueAdded(qreal)), curve, SLOT(addValue(qreal)));
|
||||||
connect(stat, SIGNAL(valueAdded(float, float)), curve, SLOT(addValue(float, float)));
|
connect(stat, SIGNAL(valueAdded(qreal, qreal)), curve, SLOT(addValue(qreal, qreal)));
|
||||||
connect(stat, SIGNAL(valuesChanged(const std::vector<float> &, const std::vector<float> &)), curve, SLOT(setData(const std::vector<float> &, const std::vector<float> &)));
|
connect(stat, SIGNAL(valuesChanged(const std::vector<qreal> &, const std::vector<qreal> &)), curve, SLOT(setData(const std::vector<qreal> &, const std::vector<qreal> &)));
|
||||||
if(stat->value().compare("*") == 0)
|
if(stat->value().compare("*") == 0)
|
||||||
{
|
{
|
||||||
newPlot->setMaxVisibleItems(0);
|
newPlot->setMaxVisibleItems(0);
|
||||||
|
|||||||
+149
-96
@@ -280,7 +280,7 @@ UPlotCurve::UPlotCurve(const QString & name, QVector<UPlotItem *> data, QObject
|
|||||||
this->setData(data);
|
this->setData(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
UPlotCurve::UPlotCurve(const QString & name, const QVector<float> & x, const QVector<float> & y, QObject * parent) :
|
UPlotCurve::UPlotCurve(const QString & name, const QVector<qreal> & x, const QVector<qreal> & y, QObject * parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
_plot(0),
|
_plot(0),
|
||||||
_name(name),
|
_name(name),
|
||||||
@@ -338,15 +338,15 @@ void UPlotCurve::detach(UPlot * plot)
|
|||||||
|
|
||||||
void UPlotCurve::updateMinMax()
|
void UPlotCurve::updateMinMax()
|
||||||
{
|
{
|
||||||
float x,y;
|
qreal x,y;
|
||||||
const UPlotItem * item;
|
const UPlotItem * item;
|
||||||
if(!_items.size())
|
if(!_items.size())
|
||||||
{
|
{
|
||||||
_minMax = QVector<float>();
|
_minMax = QVector<qreal>();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_minMax = QVector<float>(4);
|
_minMax = QVector<qreal>(4);
|
||||||
}
|
}
|
||||||
for(int i=0; i<_items.size(); ++i)
|
for(int i=0; i<_items.size(); ++i)
|
||||||
{
|
{
|
||||||
@@ -378,12 +378,12 @@ void UPlotCurve::_addValue(UPlotItem * data)
|
|||||||
// add item
|
// add item
|
||||||
if(data)
|
if(data)
|
||||||
{
|
{
|
||||||
float x = data->data().x();
|
qreal x = data->data().x();
|
||||||
float y = data->data().y();
|
qreal y = data->data().y();
|
||||||
|
|
||||||
if(_minMax.size() != 4)
|
if(_minMax.size() != 4)
|
||||||
{
|
{
|
||||||
_minMax = QVector<float>(4);
|
_minMax = QVector<qreal>(4);
|
||||||
}
|
}
|
||||||
if(_items.size())
|
if(_items.size())
|
||||||
{
|
{
|
||||||
@@ -429,7 +429,7 @@ void UPlotCurve::addValue(UPlotItem * data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::addValue(float x, float y)
|
void UPlotCurve::addValue(qreal x, qreal y)
|
||||||
{
|
{
|
||||||
if(_items.size() &&
|
if(_items.size() &&
|
||||||
_minMax[0] != _minMax[1] &&
|
_minMax[0] != _minMax[1] &&
|
||||||
@@ -441,13 +441,13 @@ void UPlotCurve::addValue(float x, float y)
|
|||||||
this->clear();
|
this->clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
float width = 2; // TODO warn : hard coded value!
|
qreal width = 2; // TODO warn : hard coded value!
|
||||||
this->addValue(new UPlotItem(x,y,width));
|
this->addValue(new UPlotItem(x,y,width));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::addValue(float y)
|
void UPlotCurve::addValue(qreal y)
|
||||||
{
|
{
|
||||||
float x = 0;
|
qreal x = 0;
|
||||||
if(_items.size())
|
if(_items.size())
|
||||||
{
|
{
|
||||||
UPlotItem * lastItem = (UPlotItem *)_items.last();
|
UPlotItem * lastItem = (UPlotItem *)_items.last();
|
||||||
@@ -463,7 +463,7 @@ void UPlotCurve::addValue(float y)
|
|||||||
void UPlotCurve::addValue(const QString & value)
|
void UPlotCurve::addValue(const QString & value)
|
||||||
{
|
{
|
||||||
bool ok;
|
bool ok;
|
||||||
float v = value.toFloat(&ok);
|
qreal v = value.toDouble(&ok);
|
||||||
if(ok)
|
if(ok)
|
||||||
{
|
{
|
||||||
this->addValue(v);
|
this->addValue(v);
|
||||||
@@ -483,9 +483,9 @@ void UPlotCurve::addValues(QVector<UPlotItem *> & data)
|
|||||||
Q_EMIT dataChanged(this);
|
Q_EMIT dataChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::addValues(const QVector<float> & xs, const QVector<float> & ys)
|
void UPlotCurve::addValues(const QVector<qreal> & xs, const QVector<qreal> & ys)
|
||||||
{
|
{
|
||||||
float width = 2; // TODO warn : hard coded value!
|
qreal width = 2; // TODO warn : hard coded value!
|
||||||
for(int i=0; i<xs.size() && i<ys.size(); ++i)
|
for(int i=0; i<xs.size() && i<ys.size(); ++i)
|
||||||
{
|
{
|
||||||
this->_addValue(new UPlotItem(xs.at(i),ys.at(i),width));
|
this->_addValue(new UPlotItem(xs.at(i),ys.at(i),width));
|
||||||
@@ -493,10 +493,10 @@ void UPlotCurve::addValues(const QVector<float> & xs, const QVector<float> & ys)
|
|||||||
Q_EMIT dataChanged(this);
|
Q_EMIT dataChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::addValues(const QVector<float> & ys)
|
void UPlotCurve::addValues(const QVector<qreal> & ys)
|
||||||
{
|
{
|
||||||
float x = 0;
|
qreal x = 0;
|
||||||
float width = 2; // TODO warn : hard coded value!
|
qreal width = 2; // TODO warn : hard coded value!
|
||||||
for(int i=0; i<ys.size(); ++i)
|
for(int i=0; i<ys.size(); ++i)
|
||||||
{
|
{
|
||||||
if(_items.size())
|
if(_items.size())
|
||||||
@@ -515,8 +515,8 @@ void UPlotCurve::addValues(const QVector<float> & ys)
|
|||||||
|
|
||||||
void UPlotCurve::addValues(const QVector<int> & ys)
|
void UPlotCurve::addValues(const QVector<int> & ys)
|
||||||
{
|
{
|
||||||
float x = 0;
|
qreal x = 0;
|
||||||
float width = 2; // TODO warn : hard coded value!
|
qreal width = 2; // TODO warn : hard coded value!
|
||||||
for(int i=0; i<ys.size(); ++i)
|
for(int i=0; i<ys.size(); ++i)
|
||||||
{
|
{
|
||||||
if(_items.size())
|
if(_items.size())
|
||||||
@@ -535,8 +535,8 @@ void UPlotCurve::addValues(const QVector<int> & ys)
|
|||||||
|
|
||||||
void UPlotCurve::addValues(const std::vector<int> & ys)
|
void UPlotCurve::addValues(const std::vector<int> & ys)
|
||||||
{
|
{
|
||||||
float x = 0;
|
qreal x = 0;
|
||||||
float width = 2; // TODO warn : hard coded value!
|
qreal width = 2; // TODO warn : hard coded value!
|
||||||
for(unsigned int i=0; i<ys.size(); ++i)
|
for(unsigned int i=0; i<ys.size(); ++i)
|
||||||
{
|
{
|
||||||
if(_items.size())
|
if(_items.size())
|
||||||
@@ -553,10 +553,10 @@ void UPlotCurve::addValues(const std::vector<int> & ys)
|
|||||||
Q_EMIT dataChanged(this);
|
Q_EMIT dataChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::addValues(const std::vector<float> & ys)
|
void UPlotCurve::addValues(const std::vector<qreal> & ys)
|
||||||
{
|
{
|
||||||
float x = 0;
|
qreal x = 0;
|
||||||
float width = 2; // TODO warn : hard coded value!
|
qreal width = 2; // TODO warn : hard coded value!
|
||||||
for(unsigned int i=0; i<ys.size(); ++i)
|
for(unsigned int i=0; i<ys.size(); ++i)
|
||||||
{
|
{
|
||||||
if(_items.size())
|
if(_items.size())
|
||||||
@@ -596,8 +596,8 @@ int UPlotCurve::removeItem(int index)
|
|||||||
if(_items.size())
|
if(_items.size())
|
||||||
{
|
{
|
||||||
UPlotItem * tmp = (UPlotItem *)_items.at(0);
|
UPlotItem * tmp = (UPlotItem *)_items.at(0);
|
||||||
float x = tmp->data().x();
|
qreal x = tmp->data().x();
|
||||||
float y = tmp->data().y();
|
qreal y = tmp->data().y();
|
||||||
_minMax[0]=x;
|
_minMax[0]=x;
|
||||||
_minMax[1]=x;
|
_minMax[1]=x;
|
||||||
_minMax[2]=y;
|
_minMax[2]=y;
|
||||||
@@ -615,7 +615,7 @@ int UPlotCurve::removeItem(int index)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_minMax = QVector<float>();
|
_minMax = QVector<qreal>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -687,7 +687,7 @@ void UPlotCurve::setItemsColor(const QColor & color)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::update(float scaleX, float scaleY, float offsetX, float offsetY, float xDir, float yDir, int maxItemsKept)
|
void UPlotCurve::update(qreal scaleX, qreal scaleY, qreal offsetX, qreal offsetY, qreal xDir, qreal yDir, int maxItemsKept)
|
||||||
{
|
{
|
||||||
//ULOGGER_DEBUG("scaleX=%f, scaleY=%f, offsetX=%f, offsetY=%f, xDir=%d, yDir=%d, _plot->scene()->width()=%f, _plot->scene()->height=%f", scaleX, scaleY, offsetX, offsetY, xDir, yDir,_plot->scene()->width(),_plot->scene()->height());
|
//ULOGGER_DEBUG("scaleX=%f, scaleY=%f, offsetX=%f, offsetY=%f, xDir=%d, yDir=%d, _plot->scene()->width()=%f, _plot->scene()->height=%f", scaleX, scaleY, offsetX, offsetY, xDir, yDir,_plot->scene()->width(),_plot->scene()->height());
|
||||||
//make sure direction values are 1 or -1
|
//make sure direction values are 1 or -1
|
||||||
@@ -865,12 +865,12 @@ void UPlotCurve::setVisible(bool visible)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::setXIncrement(float increment)
|
void UPlotCurve::setXIncrement(qreal increment)
|
||||||
{
|
{
|
||||||
_xIncrement = increment;
|
_xIncrement = increment;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::setXStart(float val)
|
void UPlotCurve::setXStart(qreal val)
|
||||||
{
|
{
|
||||||
_xStart = val;
|
_xStart = val;
|
||||||
}
|
}
|
||||||
@@ -884,7 +884,7 @@ void UPlotCurve::setData(QVector<UPlotItem*> & data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::setData(const QVector<float> & x, const QVector<float> & y)
|
void UPlotCurve::setData(const QVector<qreal> & x, const QVector<qreal> & y)
|
||||||
{
|
{
|
||||||
if(x.size() == y.size())
|
if(x.size() == y.size())
|
||||||
{
|
{
|
||||||
@@ -904,8 +904,8 @@ void UPlotCurve::setData(const QVector<float> & x, const QVector<float> & y)
|
|||||||
|
|
||||||
// update values
|
// update values
|
||||||
int index = 0;
|
int index = 0;
|
||||||
QVector<float>::const_iterator i=x.begin();
|
QVector<qreal>::const_iterator i=x.begin();
|
||||||
QVector<float>::const_iterator j=y.begin();
|
QVector<qreal>::const_iterator j=y.begin();
|
||||||
for(; i!=x.end() && j!=y.end(); ++i, ++j, index+=2)
|
for(; i!=x.end() && j!=y.end(); ++i, ++j, index+=2)
|
||||||
{
|
{
|
||||||
((UPlotItem*)_items[index])->setData(QPointF(*i, *j));
|
((UPlotItem*)_items[index])->setData(QPointF(*i, *j));
|
||||||
@@ -925,7 +925,7 @@ void UPlotCurve::setData(const QVector<float> & x, const QVector<float> & y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::setData(const std::vector<float> & x, const std::vector<float> & y)
|
void UPlotCurve::setData(const std::vector<qreal> & x, const std::vector<qreal> & y)
|
||||||
{
|
{
|
||||||
if(x.size() == y.size())
|
if(x.size() == y.size())
|
||||||
{
|
{
|
||||||
@@ -945,8 +945,8 @@ void UPlotCurve::setData(const std::vector<float> & x, const std::vector<float>
|
|||||||
|
|
||||||
// update values
|
// update values
|
||||||
int index = 0;
|
int index = 0;
|
||||||
std::vector<float>::const_iterator i=x.begin();
|
std::vector<qreal>::const_iterator i=x.begin();
|
||||||
std::vector<float>::const_iterator j=y.begin();
|
std::vector<qreal>::const_iterator j=y.begin();
|
||||||
for(; i!=x.end() && j!=y.end(); ++i, ++j, index+=2)
|
for(; i!=x.end() && j!=y.end(); ++i, ++j, index+=2)
|
||||||
{
|
{
|
||||||
((UPlotItem*)_items[index])->setData(QPointF(*i, *j));
|
((UPlotItem*)_items[index])->setData(QPointF(*i, *j));
|
||||||
@@ -966,12 +966,12 @@ void UPlotCurve::setData(const std::vector<float> & x, const std::vector<float>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::setData(const QVector<float> & y)
|
void UPlotCurve::setData(const QVector<qreal> & y)
|
||||||
{
|
{
|
||||||
this->setData(y.toStdVector());
|
this->setData(y.toStdVector());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::setData(const std::vector<float> & y)
|
void UPlotCurve::setData(const std::vector<qreal> & y)
|
||||||
{
|
{
|
||||||
//match the size of the current data
|
//match the size of the current data
|
||||||
int margin = int((_items.size()+1)/2) - int(y.size());
|
int margin = int((_items.size()+1)/2) - int(y.size());
|
||||||
@@ -989,8 +989,8 @@ void UPlotCurve::setData(const std::vector<float> & y)
|
|||||||
|
|
||||||
// update values
|
// update values
|
||||||
int index = 0;
|
int index = 0;
|
||||||
float x = 0;
|
qreal x = 0;
|
||||||
std::vector<float>::const_iterator j=y.begin();
|
std::vector<qreal>::const_iterator j=y.begin();
|
||||||
for(; j!=y.end(); ++j, index+=2)
|
for(; j!=y.end(); ++j, index+=2)
|
||||||
{
|
{
|
||||||
((UPlotItem*)_items[index])->setData(QPointF(x++, *j));
|
((UPlotItem*)_items[index])->setData(QPointF(x++, *j));
|
||||||
@@ -1001,7 +1001,7 @@ void UPlotCurve::setData(const std::vector<float> & y)
|
|||||||
Q_EMIT dataChanged(this);
|
Q_EMIT dataChanged(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::getData(QVector<float> & x, QVector<float> & y) const
|
void UPlotCurve::getData(QVector<qreal> & x, QVector<qreal> & y) const
|
||||||
{
|
{
|
||||||
x.clear();
|
x.clear();
|
||||||
y.clear();
|
y.clear();
|
||||||
@@ -1018,7 +1018,7 @@ void UPlotCurve::getData(QVector<float> & x, QVector<float> & y) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurve::getData(QMap<float,float> & data) const
|
void UPlotCurve::getData(QMap<qreal,qreal> & data) const
|
||||||
{
|
{
|
||||||
data.clear();
|
data.clear();
|
||||||
if(_items.size())
|
if(_items.size())
|
||||||
@@ -1034,7 +1034,7 @@ void UPlotCurve::getData(QMap<float,float> & data) const
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
UPlotCurveThreshold::UPlotCurveThreshold(const QString & name, float thesholdValue, Qt::Orientation orientation, QObject * parent) :
|
UPlotCurveThreshold::UPlotCurveThreshold(const QString & name, qreal thesholdValue, Qt::Orientation orientation, QObject * parent) :
|
||||||
UPlotCurve(name, parent),
|
UPlotCurve(name, parent),
|
||||||
_orientation(orientation)
|
_orientation(orientation)
|
||||||
{
|
{
|
||||||
@@ -1055,7 +1055,7 @@ UPlotCurveThreshold::~UPlotCurveThreshold()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurveThreshold::setThreshold(float threshold)
|
void UPlotCurveThreshold::setThreshold(qreal threshold)
|
||||||
{
|
{
|
||||||
#if PRINT_DEBUG
|
#if PRINT_DEBUG
|
||||||
ULOGGER_DEBUG("%f", threshold);
|
ULOGGER_DEBUG("%f", threshold);
|
||||||
@@ -1104,7 +1104,7 @@ void UPlotCurveThreshold::setOrientation(Qt::Orientation orientation)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotCurveThreshold::update(float scaleX, float scaleY, float offsetX, float offsetY, float xDir, float yDir, int maxItemsKept)
|
void UPlotCurveThreshold::update(qreal scaleX, qreal scaleY, qreal offsetX, qreal offsetY, qreal xDir, qreal yDir, int maxItemsKept)
|
||||||
{
|
{
|
||||||
if(_items.size() == 3)
|
if(_items.size() == 3)
|
||||||
{
|
{
|
||||||
@@ -1142,7 +1142,7 @@ void UPlotCurveThreshold::update(float scaleX, float scaleY, float offsetX, floa
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
UPlotAxis::UPlotAxis(Qt::Orientation orientation, float min, float max, QWidget * parent) :
|
UPlotAxis::UPlotAxis(Qt::Orientation orientation, qreal min, qreal max, QWidget * parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
_orientation(orientation),
|
_orientation(orientation),
|
||||||
_min(0),
|
_min(0),
|
||||||
@@ -1177,14 +1177,14 @@ void UPlotAxis::setReversed(bool reversed)
|
|||||||
{
|
{
|
||||||
if(_reversed != reversed)
|
if(_reversed != reversed)
|
||||||
{
|
{
|
||||||
float min = _min;
|
qreal min = _min;
|
||||||
_min = _max;
|
_min = _max;
|
||||||
_max = min;
|
_max = min;
|
||||||
}
|
}
|
||||||
_reversed = reversed;
|
_reversed = reversed;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlotAxis::setAxis(float & min, float & max)
|
void UPlotAxis::setAxis(qreal & min, qreal & max)
|
||||||
{
|
{
|
||||||
int borderMin = 0;
|
int borderMin = 0;
|
||||||
int borderMax = 0;
|
int borderMax = 0;
|
||||||
@@ -1241,13 +1241,13 @@ void UPlotAxis::setAxis(float & min, float & max)
|
|||||||
// Rounding min and max
|
// Rounding min and max
|
||||||
if(min != max)
|
if(min != max)
|
||||||
{
|
{
|
||||||
float mul = 1;
|
qreal mul = 1;
|
||||||
float rangef = max - min;
|
qreal rangef = max - min;
|
||||||
int countStep = _count/5;
|
int countStep = _count/5;
|
||||||
float val;
|
qreal val;
|
||||||
for(int i=0; i<6; ++i)
|
for(int i=0; i<6; ++i)
|
||||||
{
|
{
|
||||||
val = (rangef/float(countStep)) * mul;
|
val = (rangef/qreal(countStep)) * mul;
|
||||||
if( val >= 1.0f && val < 10.0f)
|
if( val >= 1.0f && val < 10.0f)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -1264,8 +1264,8 @@ void UPlotAxis::setAxis(float & min, float & max)
|
|||||||
//ULOGGER_DEBUG("min=%f, max=%f", min, max);
|
//ULOGGER_DEBUG("min=%f, max=%f", min, max);
|
||||||
int minR = min*mul-0.9;
|
int minR = min*mul-0.9;
|
||||||
int maxR = max*mul+0.9;
|
int maxR = max*mul+0.9;
|
||||||
min = float(minR)/mul;
|
min = qreal(minR)/mul;
|
||||||
max = float(maxR)/mul;
|
max = qreal(maxR)/mul;
|
||||||
//ULOGGER_DEBUG("mul=%f, minR=%d, maxR=%d,countStep=%d", mul, minR, maxR, countStep);
|
//ULOGGER_DEBUG("mul=%f, minR=%d, maxR=%d,countStep=%d", mul, minR, maxR, countStep);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1430,8 +1430,8 @@ void UPlotLegendItem::contextMenuEvent(QContextMenuEvent * event)
|
|||||||
{
|
{
|
||||||
if(_curve)
|
if(_curve)
|
||||||
{
|
{
|
||||||
QVector<float> x;
|
QVector<qreal> x;
|
||||||
QVector<float> y;
|
QVector<qreal> y;
|
||||||
_curve->getData(x, y);
|
_curve->getData(x, y);
|
||||||
QString text;
|
QString text;
|
||||||
text.append("x");
|
text.append("x");
|
||||||
@@ -1501,11 +1501,11 @@ QPixmap UPlotLegendItem::createSymbol(const QPen & pen, const QBrush & brush)
|
|||||||
|
|
||||||
void UPlotLegendItem::updateStdDevMeanMax()
|
void UPlotLegendItem::updateStdDevMeanMax()
|
||||||
{
|
{
|
||||||
QVector<float> x, y;
|
QVector<qreal> x, y;
|
||||||
_curve->getData(x, y);
|
_curve->getData(x, y);
|
||||||
float mean = uMean(y.data(), y.size());
|
qreal mean = uMean(y.data(), y.size());
|
||||||
float stdDev = std::sqrt(uVariance(y.data(), y.size(), mean));
|
qreal stdDev = std::sqrt(uVariance(y.data(), y.size(), mean));
|
||||||
float max = uMax(y.data(), y.size());
|
qreal max = uMax(y.data(), y.size());
|
||||||
QString nameSpaced = _curve->name();
|
QString nameSpaced = _curve->name();
|
||||||
nameSpaced.replace('_', ' ');
|
nameSpaced.replace('_', ' ');
|
||||||
nameSpaced += QString("\n(%1=%2, %3=%4, max=%5, n=%6)").arg(QChar(0xbc, 0x03)).arg(QString::number(mean, 'f', 3)).arg(QChar(0xc3, 0x03)).arg(QString::number(stdDev, 'f', 3)).arg(QString::number(max, 'f', 3)).arg(y.size());
|
nameSpaced += QString("\n(%1=%2, %3=%4, max=%5, n=%6)").arg(QChar(0xbc, 0x03)).arg(QString::number(mean, 'f', 3)).arg(QChar(0xc3, 0x03)).arg(QString::number(stdDev, 'f', 3)).arg(QString::number(max, 'f', 3)).arg(y.size());
|
||||||
@@ -1691,28 +1691,28 @@ void UPlotLegend::contextMenuEvent(QContextMenuEvent * event)
|
|||||||
if(items.size())
|
if(items.size())
|
||||||
{
|
{
|
||||||
// create common x-axis
|
// create common x-axis
|
||||||
QMap<float, float> xAxisMap;
|
QMap<qreal, qreal> xAxisMap;
|
||||||
for(int i=0; i<items.size(); ++i)
|
for(int i=0; i<items.size(); ++i)
|
||||||
{
|
{
|
||||||
QMap<float, float> data;
|
QMap<qreal, qreal> data;
|
||||||
items.at(i)->curve()->getData(data);
|
items.at(i)->curve()->getData(data);
|
||||||
for(QMap<float, float>::iterator iter=data.begin(); iter!=data.end(); ++iter)
|
for(QMap<qreal, qreal>::iterator iter=data.begin(); iter!=data.end(); ++iter)
|
||||||
{
|
{
|
||||||
xAxisMap.insert(iter.key(), iter.value());
|
xAxisMap.insert(iter.key(), iter.value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QList<float> xAxis = xAxisMap.uniqueKeys();
|
QList<qreal> xAxis = xAxisMap.uniqueKeys();
|
||||||
|
|
||||||
QVector<QVector<float> > axes;
|
QVector<QVector<qreal> > axes;
|
||||||
for(int i=0; i<items.size(); ++i)
|
for(int i=0; i<items.size(); ++i)
|
||||||
{
|
{
|
||||||
QMap<float, float> data;
|
QMap<qreal, qreal> data;
|
||||||
items.at(i)->curve()->getData(data);
|
items.at(i)->curve()->getData(data);
|
||||||
|
|
||||||
QVector<float> y(xAxis.size(), std::numeric_limits<float>::quiet_NaN());
|
QVector<qreal> y(xAxis.size(), std::numeric_limits<qreal>::quiet_NaN());
|
||||||
// just to make sure that we have the same number of data on each curve, set NAN for unknowns
|
// just to make sure that we have the same number of data on each curve, set NAN for unknowns
|
||||||
int j=0;
|
int j=0;
|
||||||
for(QList<float>::iterator iter=xAxis.begin(); iter!=xAxis.end(); ++iter)
|
for(QList<qreal>::iterator iter=xAxis.begin(); iter!=xAxis.end(); ++iter)
|
||||||
{
|
{
|
||||||
if(data.contains(*iter))
|
if(data.contains(*iter))
|
||||||
{
|
{
|
||||||
@@ -2226,7 +2226,7 @@ void UPlot::replot(QPainter * painter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float axis[4] = {0};
|
qreal axis[4] = {0};
|
||||||
for(int i=0; i<4; ++i)
|
for(int i=0; i<4; ++i)
|
||||||
{
|
{
|
||||||
axis[i] = _axisMaximums[i];
|
axis[i] = _axisMaximums[i];
|
||||||
@@ -2244,8 +2244,8 @@ void UPlot::replot(QPainter * painter)
|
|||||||
|
|
||||||
QRectF newRect(0,0, _graphicsViewHolder->size().width(), _graphicsViewHolder->size().height());
|
QRectF newRect(0,0, _graphicsViewHolder->size().width(), _graphicsViewHolder->size().height());
|
||||||
_view->scene()->setSceneRect(newRect);
|
_view->scene()->setSceneRect(newRect);
|
||||||
float borderHor = (float)_horizontalAxis->border();
|
qreal borderHor = (qreal)_horizontalAxis->border();
|
||||||
float borderVer = (float)_verticalAxis->border();
|
qreal borderVer = (qreal)_verticalAxis->border();
|
||||||
|
|
||||||
//grid
|
//grid
|
||||||
qDeleteAll(hGridLines);
|
qDeleteAll(hGridLines);
|
||||||
@@ -2255,14 +2255,14 @@ void UPlot::replot(QPainter * painter)
|
|||||||
if(_aShowGrid->isChecked())
|
if(_aShowGrid->isChecked())
|
||||||
{
|
{
|
||||||
// TODO make a PlotGrid class ?
|
// TODO make a PlotGrid class ?
|
||||||
float w = newRect.width()-(borderHor*2);
|
qreal w = newRect.width()-(borderHor*2);
|
||||||
float h = newRect.height()-(borderVer*2);
|
qreal h = newRect.height()-(borderVer*2);
|
||||||
float stepH = w / float(_horizontalAxis->count());
|
qreal stepH = w / qreal(_horizontalAxis->count());
|
||||||
float stepV = h / float(_verticalAxis->count());
|
qreal stepV = h / qreal(_verticalAxis->count());
|
||||||
QPen dashPen(Qt::DashLine);
|
QPen dashPen(Qt::DashLine);
|
||||||
dashPen.setColor(QColor(255-_bgColor.red(), 255-_bgColor.green(), 255-_bgColor.blue(), 100));
|
dashPen.setColor(QColor(255-_bgColor.red(), 255-_bgColor.green(), 255-_bgColor.blue(), 100));
|
||||||
QPen pen(dashPen.color());
|
QPen pen(dashPen.color());
|
||||||
for(float i=0.0f; i*stepV <= h+stepV; i+=5.0f)
|
for(qreal i=0.0f; i*stepV <= h+stepV; i+=5.0f)
|
||||||
{
|
{
|
||||||
//horizontal lines
|
//horizontal lines
|
||||||
if(!_aGraphicsView->isChecked())
|
if(!_aGraphicsView->isChecked())
|
||||||
@@ -2291,7 +2291,7 @@ void UPlot::replot(QPainter * painter)
|
|||||||
hGridLines.last()->setPen(pen);
|
hGridLines.last()->setPen(pen);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(float i=0; i*stepH < w+stepH; i+=5.0f)
|
for(qreal i=0; i*stepH < w+stepH; i+=5.0f)
|
||||||
{
|
{
|
||||||
//vertical lines
|
//vertical lines
|
||||||
if(!_aGraphicsView->isChecked())
|
if(!_aGraphicsView->isChecked())
|
||||||
@@ -2323,9 +2323,9 @@ void UPlot::replot(QPainter * painter)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// curves
|
// curves
|
||||||
float scaleX = 1;
|
qreal scaleX = 1;
|
||||||
float scaleY = 1;
|
qreal scaleY = 1;
|
||||||
float den = 0;
|
qreal den = 0;
|
||||||
den = axis[1] - axis[0];
|
den = axis[1] - axis[0];
|
||||||
if(den != 0)
|
if(den != 0)
|
||||||
{
|
{
|
||||||
@@ -2340,8 +2340,8 @@ void UPlot::replot(QPainter * painter)
|
|||||||
{
|
{
|
||||||
if((*i)->isVisible())
|
if((*i)->isVisible())
|
||||||
{
|
{
|
||||||
float xDir = 1.0f;
|
qreal xDir = 1.0f;
|
||||||
float yDir = -1.0f;
|
qreal yDir = -1.0f;
|
||||||
(*i)->update(scaleX,
|
(*i)->update(scaleX,
|
||||||
scaleY,
|
scaleY,
|
||||||
xDir<0?axis[1]+borderHor/scaleX:-(axis[0]-borderHor/scaleX),
|
xDir<0?axis[1]+borderHor/scaleX:-(axis[0]-borderHor/scaleX),
|
||||||
@@ -2359,7 +2359,7 @@ void UPlot::replot(QPainter * painter)
|
|||||||
// Update refresh rate
|
// Update refresh rate
|
||||||
if(_aShowRefreshRate->isChecked())
|
if(_aShowRefreshRate->isChecked())
|
||||||
{
|
{
|
||||||
int refreshRate = qRound(1000.0f/float(_refreshIntervalTime.restart()));
|
int refreshRate = qRound(1000.0f/qreal(_refreshIntervalTime.restart()));
|
||||||
if(refreshRate > 0 && refreshRate < _lowestRefreshRate)
|
if(refreshRate > 0 && refreshRate < _lowestRefreshRate)
|
||||||
{
|
{
|
||||||
_lowestRefreshRate = refreshRate;
|
_lowestRefreshRate = refreshRate;
|
||||||
@@ -2374,14 +2374,14 @@ void UPlot::replot(QPainter * painter)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlot::setFixedXAxis(float x1, float x2)
|
void UPlot::setFixedXAxis(qreal x1, qreal x2)
|
||||||
{
|
{
|
||||||
_fixedAxis[0] = true;
|
_fixedAxis[0] = true;
|
||||||
_axisMaximums[0] = x1;
|
_axisMaximums[0] = x1;
|
||||||
_axisMaximums[1] = x2;
|
_axisMaximums[1] = x2;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UPlot::setFixedYAxis(float y1, float y2)
|
void UPlot::setFixedYAxis(qreal y1, qreal y2)
|
||||||
{
|
{
|
||||||
_fixedAxis[1] = true;
|
_fixedAxis[1] = true;
|
||||||
_axisMaximums[2] = y1;
|
_axisMaximums[2] = y1;
|
||||||
@@ -2392,7 +2392,7 @@ void UPlot::updateAxis(const UPlotCurve * curve)
|
|||||||
{
|
{
|
||||||
if(curve && curve->isVisible() && curve->itemsSize() && curve->isMinMaxValid())
|
if(curve && curve->isVisible() && curve->itemsSize() && curve->isMinMaxValid())
|
||||||
{
|
{
|
||||||
const QVector<float> & minMax = curve->getMinMax();
|
const QVector<qreal> & minMax = curve->getMinMax();
|
||||||
//ULOGGER_DEBUG("x1=%f, x2=%f, y1=%f, y2=%f", minMax[0], minMax[1], minMax[2], minMax[3]);
|
//ULOGGER_DEBUG("x1=%f, x2=%f, y1=%f, y2=%f", minMax[0], minMax[1], minMax[2], minMax[3]);
|
||||||
if(minMax.size() != 4)
|
if(minMax.size() != 4)
|
||||||
{
|
{
|
||||||
@@ -2404,7 +2404,7 @@ void UPlot::updateAxis(const UPlotCurve * curve)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UPlot::updateAxis(float x1, float x2, float y1, float y2)
|
bool UPlot::updateAxis(qreal x1, qreal x2, qreal y1, qreal y2)
|
||||||
{
|
{
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
modified = updateAxis(x1,y1);
|
modified = updateAxis(x1,y1);
|
||||||
@@ -2419,7 +2419,7 @@ bool UPlot::updateAxis(float x1, float x2, float y1, float y2)
|
|||||||
return modified;
|
return modified;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UPlot::updateAxis(float x, float y)
|
bool UPlot::updateAxis(qreal x, qreal y)
|
||||||
{
|
{
|
||||||
//ULOGGER_DEBUG("x=%f, y=%f", x,y);
|
//ULOGGER_DEBUG("x=%f, y=%f", x,y);
|
||||||
bool modified = false;
|
bool modified = false;
|
||||||
@@ -2470,7 +2470,7 @@ void UPlot::updateAxis()
|
|||||||
{
|
{
|
||||||
if(_curves.at(i)->isVisible() && _curves.at(i)->isMinMaxValid())
|
if(_curves.at(i)->isVisible() && _curves.at(i)->isMinMaxValid())
|
||||||
{
|
{
|
||||||
const QVector<float> & minMax = _curves.at(i)->getMinMax();
|
const QVector<qreal> & minMax = _curves.at(i)->getMinMax();
|
||||||
this->updateAxis(minMax[0], minMax[1], minMax[2], minMax[3]);
|
this->updateAxis(minMax[0], minMax[1], minMax[2], minMax[3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2561,7 +2561,7 @@ void UPlot::mouseMoveEvent(QMouseEvent * event)
|
|||||||
_mousePressedPos = _mouseCurrentPos;
|
_mousePressedPos = _mouseCurrentPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
float x,y;
|
qreal x,y;
|
||||||
if(mousePosToValue(event->pos(), x ,y))
|
if(mousePosToValue(event->pos(), x ,y))
|
||||||
{
|
{
|
||||||
if(QApplication::mouseButtons() & Qt::LeftButton)
|
if(QApplication::mouseButtons() & Qt::LeftButton)
|
||||||
@@ -2603,7 +2603,7 @@ void UPlot::mouseReleaseEvent(QMouseEvent * event)
|
|||||||
|
|
||||||
if(right - left > 5 || bottom - top > 5)
|
if(right - left > 5 || bottom - top > 5)
|
||||||
{
|
{
|
||||||
float axis[4];
|
qreal axis[4];
|
||||||
if(mousePosToValue(QPoint(left, top), axis[0], axis[3]) && mousePosToValue(QPoint(right, bottom), axis[1], axis[2]))
|
if(mousePosToValue(QPoint(left, top), axis[0], axis[3]) && mousePosToValue(QPoint(right, bottom), axis[1], axis[2]))
|
||||||
{
|
{
|
||||||
#if PRINT_DEBUG
|
#if PRINT_DEBUG
|
||||||
@@ -2631,7 +2631,7 @@ void UPlot::mouseDoubleClickEvent(QMouseEvent * event)
|
|||||||
QWidget::mouseDoubleClickEvent(event);
|
QWidget::mouseDoubleClickEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool UPlot::mousePosToValue(const QPoint & pos, float & x, float & y)
|
bool UPlot::mousePosToValue(const QPoint & pos, qreal & x, qreal & y)
|
||||||
{
|
{
|
||||||
int xPos = pos.x() - _graphicsViewHolder->pos().x() - _horizontalAxis->border();
|
int xPos = pos.x() - _graphicsViewHolder->pos().x() - _horizontalAxis->border();
|
||||||
int yPos = pos.y() - _graphicsViewHolder->pos().y() - _verticalAxis->border();
|
int yPos = pos.y() - _graphicsViewHolder->pos().y() - _verticalAxis->border();
|
||||||
@@ -2662,15 +2662,15 @@ bool UPlot::mousePosToValue(const QPoint & pos, float & x, float & y)
|
|||||||
|
|
||||||
//UDEBUG("IN");
|
//UDEBUG("IN");
|
||||||
//UDEBUG("x1=%f, x2=%f, y1=%f, y2=%f", _axisMaximums[0], _axisMaximums[1], _axisMaximums[2], _axisMaximums[3]);
|
//UDEBUG("x1=%f, x2=%f, y1=%f, y2=%f", _axisMaximums[0], _axisMaximums[1], _axisMaximums[2], _axisMaximums[3]);
|
||||||
//UDEBUG("border hor=%f ver=%f", (float)_horizontalAxis->border(), (float)_verticalAxis->border());
|
//UDEBUG("border hor=%f ver=%f", (qreal)_horizontalAxis->border(), (qreal)_verticalAxis->border());
|
||||||
//UDEBUG("rect = %d,%d %d,%d", _graphicsViewHolder->pos().x(), _graphicsViewHolder->pos().y(), _graphicsViewHolder->width(), _graphicsViewHolder->height());
|
//UDEBUG("rect = %d,%d %d,%d", _graphicsViewHolder->pos().x(), _graphicsViewHolder->pos().y(), _graphicsViewHolder->width(), _graphicsViewHolder->height());
|
||||||
//UDEBUG("%d,%d", event->pos().x(), event->pos().y());
|
//UDEBUG("%d,%d", event->pos().x(), event->pos().y());
|
||||||
//UDEBUG("x/y %d,%d", x, y);
|
//UDEBUG("x/y %d,%d", x, y);
|
||||||
//UDEBUG("max %d,%d", maxX, maxY);
|
//UDEBUG("max %d,%d", maxX, maxY);
|
||||||
|
|
||||||
//UDEBUG("map %f,%f", x, y);
|
//UDEBUG("map %f,%f", x, y);
|
||||||
x = _axisMaximums[0] + float(xPos)*(_axisMaximums[1] - _axisMaximums[0]) / float(maxX);
|
x = _axisMaximums[0] + qreal(xPos)*(_axisMaximums[1] - _axisMaximums[0]) / qreal(maxX);
|
||||||
y = _axisMaximums[2] + float(maxY - yPos)*(_axisMaximums[3] - _axisMaximums[2]) / float(maxY);
|
y = _axisMaximums[2] + qreal(maxY - yPos)*(_axisMaximums[3] - _axisMaximums[2]) / qreal(maxY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2943,8 +2943,61 @@ void UPlot::clearData()
|
|||||||
_aGraphicsView->isChecked()?this->replot(0):this->update();
|
_aGraphicsView->isChecked()?this->replot(0):this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UPlot::frameData(bool xAxis, bool yAxis)
|
||||||
|
{
|
||||||
|
if(!xAxis && !yAxis)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
qreal minX = std::numeric_limits<qreal>::max();
|
||||||
|
qreal minY = std::numeric_limits<qreal>::max();
|
||||||
|
for(int i=0; i<_curves.size(); ++i)
|
||||||
|
{
|
||||||
|
if(qobject_cast<UPlotCurveThreshold*>(_curves.at(i)) == 0)
|
||||||
|
{
|
||||||
|
const QVector<qreal> & minMax = _curves.at(i)->getMinMax();
|
||||||
|
if(minMax.size() == 4)
|
||||||
|
{
|
||||||
|
if(minMax[0] < minX)
|
||||||
|
{
|
||||||
|
minX = minMax[0];
|
||||||
|
}
|
||||||
|
if(minMax[2] < minY)
|
||||||
|
{
|
||||||
|
minY = minMax[2];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(minX != std::numeric_limits<qreal>::max())
|
||||||
|
{
|
||||||
|
for(int i=0; i<_curves.size(); ++i)
|
||||||
|
{
|
||||||
|
if(qobject_cast<UPlotCurveThreshold*>(_curves.at(i)) == 0)
|
||||||
|
{
|
||||||
|
QVector<qreal> x;
|
||||||
|
QVector<qreal> y;
|
||||||
|
_curves.at(i)->getData(x,y);
|
||||||
|
for(int j=0; j<x.size(); ++j)
|
||||||
|
{
|
||||||
|
if(xAxis)
|
||||||
|
{
|
||||||
|
x[j]-=minX;
|
||||||
|
}
|
||||||
|
if(yAxis)
|
||||||
|
{
|
||||||
|
y[j]-=minY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_curves.at(i)->setData(x,y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_aGraphicsView->isChecked()?this->replot(0):this->update();
|
||||||
|
}
|
||||||
|
|
||||||
// for convenience...
|
// for convenience...
|
||||||
UPlotCurveThreshold * UPlot::addThreshold(const QString & name, float value, Qt::Orientation orientation)
|
UPlotCurveThreshold * UPlot::addThreshold(const QString & name, qreal value, Qt::Orientation orientation)
|
||||||
{
|
{
|
||||||
UPlotCurveThreshold * curve = new UPlotCurveThreshold(name, value, orientation, this);
|
UPlotCurveThreshold * curve = new UPlotCurveThreshold(name, value, orientation, this);
|
||||||
QPen pen = curve->pen();
|
QPen pen = curve->pen();
|
||||||
|
|||||||
@@ -322,7 +322,6 @@ int main(int argc, char * argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::map<std::string, UPlotCurve*> curves;
|
std::map<std::string, UPlotCurve*> curves;
|
||||||
std::map<std::string, double> firstStamps;
|
|
||||||
if(statsToShow.empty())
|
if(statsToShow.empty())
|
||||||
{
|
{
|
||||||
for(std::map<std::string, UPlot*>::iterator iter=figures.begin(); iter!=figures.end(); ++iter)
|
for(std::map<std::string, UPlot*>::iterator iter=figures.begin(); iter!=figures.end(); ++iter)
|
||||||
@@ -435,16 +434,12 @@ int main(int argc, char * argv[])
|
|||||||
{
|
{
|
||||||
if(uContains(stat, jter->first) && *iter >= startId)
|
if(uContains(stat, jter->first) && *iter >= startId)
|
||||||
{
|
{
|
||||||
if(!uContains(firstStamps, jter->first))
|
double x = s;
|
||||||
{
|
|
||||||
firstStamps.insert(std::make_pair(jter->first, s));
|
|
||||||
}
|
|
||||||
float x = s - firstStamps.at(jter->first);
|
|
||||||
if(useIds)
|
if(useIds)
|
||||||
{
|
{
|
||||||
x = *iter;
|
x = *iter;
|
||||||
}
|
}
|
||||||
float y = stat.at(jter->first);
|
double y = stat.at(jter->first);
|
||||||
jter->second->addValue(x,y);
|
jter->second->addValue(x,y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -929,6 +924,10 @@ int main(int argc, char * argv[])
|
|||||||
{
|
{
|
||||||
for(std::map<std::string, UPlot*>::iterator iter=figures.begin(); iter!=figures.end(); ++iter)
|
for(std::map<std::string, UPlot*>::iterator iter=figures.begin(); iter!=figures.end(); ++iter)
|
||||||
{
|
{
|
||||||
|
if(!useIds)
|
||||||
|
{
|
||||||
|
iter->second->frameData();
|
||||||
|
}
|
||||||
iter->second->show();
|
iter->second->show();
|
||||||
}
|
}
|
||||||
return app.exec();
|
return app.exec();
|
||||||
|
|||||||
Reference in New Issue
Block a user