we are now able to record bluetooth fingerprints
for this, we use the same ui interface and fingerprint positions as wifi. if wifi has done 30 scans, also the ble scans will be stopped. this is just a quick and dirte solution, as changing the gui completely for this two options was to time consuming
This commit is contained in:
@@ -20,32 +20,32 @@
|
||||
|
||||
MapView2D::MapView2D(QWidget *parent) : QWidget(parent) {
|
||||
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setRenderHeight(0);
|
||||
setFocusPolicy(Qt::StrongFocus);
|
||||
setRenderHeight(0);
|
||||
|
||||
|
||||
colorPoints = new ColorPoints2D();
|
||||
elementsB.push_back(colorPoints);
|
||||
colorPoints = new ColorPoints2D();
|
||||
elementsB.push_back(colorPoints);
|
||||
|
||||
pathToDest = new Path2D();
|
||||
pathToDest->setColor(Qt::blue);
|
||||
pathToDest->setWidth(10);
|
||||
elementsB.push_back(pathToDest);
|
||||
pathToDest = new Path2D();
|
||||
pathToDest->setColor(Qt::blue);
|
||||
pathToDest->setWidth(10);
|
||||
elementsB.push_back(pathToDest);
|
||||
|
||||
pathWalked = new Path2D();
|
||||
pathToDest->setColor(Qt::black);
|
||||
pathToDest->setWidth(5);
|
||||
elementsB.push_back(pathWalked);
|
||||
pathWalked = new Path2D();
|
||||
pathToDest->setColor(Qt::black);
|
||||
pathToDest->setWidth(5);
|
||||
elementsB.push_back(pathWalked);
|
||||
|
||||
// buttons
|
||||
//menu = new QWidget(this);
|
||||
QGridLayout* lay = new QGridLayout(this);
|
||||
int row = 0;
|
||||
// buttons
|
||||
//menu = new QWidget(this);
|
||||
QGridLayout* lay = new QGridLayout(this);
|
||||
int row = 0;
|
||||
|
||||
|
||||
lay->addItem(new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding), row, 0, 1, 1);
|
||||
lay->addItem(new QSpacerItem(0,0,QSizePolicy::Minimum,QSizePolicy::Expanding), row, 0, 1, 1);
|
||||
|
||||
++ row;
|
||||
++ row;
|
||||
|
||||
// // map-layer slider
|
||||
// sldLayer = new QSlider();
|
||||
@@ -54,65 +54,65 @@ MapView2D::MapView2D(QWidget *parent) : QWidget(parent) {
|
||||
// connect(sldLayer, &QSlider::sliderReleased, this, &MapView2D::onLayerSelect);
|
||||
// lay->addWidget(sldLayer, row, 0, 1, 1);
|
||||
|
||||
// show/hide button
|
||||
const int bs = UIHelper::getButtonSize(this);
|
||||
btnColorPoints = new QPushButton(Icons::getIcon("dots", bs), "");
|
||||
btnColorPoints->connect(btnColorPoints, &QPushButton::clicked, [&] () {colorPoints->setVisible(!colorPoints->isVisible()); emit update();} );
|
||||
lay->addWidget(btnColorPoints, row, 0, 1, 1);
|
||||
// show/hide button
|
||||
const int bs = UIHelper::getButtonSize(this);
|
||||
btnColorPoints = new QPushButton(Icons::getIcon("dots", bs), "");
|
||||
btnColorPoints->connect(btnColorPoints, &QPushButton::clicked, [&] () {colorPoints->setVisible(!colorPoints->isVisible()); emit update();} );
|
||||
lay->addWidget(btnColorPoints, row, 0, 1, 1);
|
||||
|
||||
btnLayerMinus = new QPushButton("-");
|
||||
connect(btnLayerMinus, &QPushButton::clicked, this, &MapView2D::onLayerMinus);
|
||||
lay->addWidget(btnLayerMinus, row, 1, 1, 1);
|
||||
btnLayerMinus = new QPushButton("-");
|
||||
connect(btnLayerMinus, &QPushButton::clicked, this, &MapView2D::onLayerMinus);
|
||||
lay->addWidget(btnLayerMinus, row, 1, 1, 1);
|
||||
|
||||
btnLayerPlus = new QPushButton("+");
|
||||
connect(btnLayerPlus, &QPushButton::clicked, this, &MapView2D::onLayerPlus);
|
||||
lay->addWidget(btnLayerPlus, row, 2, 1, 1);
|
||||
btnLayerPlus = new QPushButton("+");
|
||||
connect(btnLayerPlus, &QPushButton::clicked, this, &MapView2D::onLayerPlus);
|
||||
lay->addWidget(btnLayerPlus, row, 2, 1, 1);
|
||||
|
||||
|
||||
// start with invisible particles. speeds things up a bit
|
||||
colorPoints->setVisible(false);
|
||||
// start with invisible particles. speeds things up a bit
|
||||
colorPoints->setVisible(false);
|
||||
|
||||
// we want to receive pinch gestures
|
||||
//setAttribute(Qt::WA_AcceptTouchEvents, true);
|
||||
grabGesture(Qt::PinchGesture);
|
||||
// we want to receive pinch gestures
|
||||
//setAttribute(Qt::WA_AcceptTouchEvents, true);
|
||||
grabGesture(Qt::PinchGesture);
|
||||
|
||||
}
|
||||
|
||||
void MapView2D::onLayerSelect() {
|
||||
setRenderHeight(sldLayer->value());
|
||||
setRenderHeight(sldLayer->value());
|
||||
}
|
||||
|
||||
void MapView2D::onLayerMinus() {
|
||||
if (layerHeight_m <= 0) {return;}
|
||||
layerHeight_m -= 1;
|
||||
setRenderHeight(layerHeight_m);
|
||||
if (layerHeight_m <= 0) {return;}
|
||||
layerHeight_m -= 1;
|
||||
setRenderHeight(layerHeight_m);
|
||||
}
|
||||
void MapView2D::onLayerPlus() {
|
||||
if (layerHeight_m >= 16) {return;}
|
||||
layerHeight_m += 1;
|
||||
setRenderHeight(layerHeight_m);
|
||||
if (layerHeight_m >= 16) {return;}
|
||||
layerHeight_m += 1;
|
||||
setRenderHeight(layerHeight_m);
|
||||
}
|
||||
|
||||
void MapView2D::setMap(WiFiCalibrationDataModel* mdl, Floorplan::IndoorMap* map) {
|
||||
void MapView2D::setMap(WiFiCalibrationDataModel* wifiMdl, BLECalibrationDataModel* bleMdl, Floorplan::IndoorMap* map) {
|
||||
|
||||
for (Floorplan::Floor* floor : map->floors) {
|
||||
Floor2D* f = new Floor2D(floor);
|
||||
elementsA.push_back(f);
|
||||
}
|
||||
for (Floorplan::Floor* floor : map->floors) {
|
||||
Floor2D* f = new Floor2D(floor);
|
||||
elementsA.push_back(f);
|
||||
}
|
||||
|
||||
wifiCalib = new WiFiCalibTool(mdl, map);
|
||||
elementsB.push_back(wifiCalib);
|
||||
wifiCalib = new WiFiCalibTool(wifiMdl, bleMdl, map);
|
||||
elementsB.push_back(wifiCalib);
|
||||
|
||||
const BBox3 bbox3 = FloorplanHelper::getBBox(map);
|
||||
const BBox2 bbox2 = BBox2(bbox3.getMin().xy(), bbox3.getMax().xy());
|
||||
const BBox3 bbox3 = FloorplanHelper::getBBox(map);
|
||||
const BBox2 bbox2 = BBox2(bbox3.getMin().xy(), bbox3.getMax().xy());
|
||||
|
||||
scaler.setMapBBox(bbox2);
|
||||
scaler.setCenterM(Point2(bbox2.getCenter().x, bbox2.getCenter().y));
|
||||
scaler.setMapBBox(bbox2);
|
||||
scaler.setCenterM(Point2(bbox2.getCenter().x, bbox2.getCenter().y));
|
||||
|
||||
}
|
||||
|
||||
void MapView2D::showParticles(const std::vector<SMC::Particle<GridBased::MyState>>* particles) {
|
||||
this->colorPoints->setFromParticles(*particles);
|
||||
this->colorPoints->setFromParticles(*particles);
|
||||
}
|
||||
|
||||
void MapView2D::showParticles(const std::vector<SMC::Particle<MeshBased::MyState>>* particles) {
|
||||
@@ -120,130 +120,130 @@ void MapView2D::showParticles(const std::vector<SMC::Particle<MeshBased::MyState
|
||||
}
|
||||
|
||||
void MapView2D::setCurrentEstimation(const Point3 pos_m, const Point3 dir) {
|
||||
(void) dir;
|
||||
setRenderHeight(pos_m.z);
|
||||
scaler.setCenterM(pos_m.xy());
|
||||
(void) dir;
|
||||
setRenderHeight(pos_m.z);
|
||||
scaler.setCenterM(pos_m.xy());
|
||||
}
|
||||
|
||||
void MapView2D::setRenderHeight(const float height_m) {
|
||||
renderParams.clip.aboveHeight_m = height_m + 1.5;
|
||||
renderParams.clip.belowHeight_m = height_m - 1.5;
|
||||
emit update();
|
||||
renderParams.clip.aboveHeight_m = height_m + 1.5;
|
||||
renderParams.clip.belowHeight_m = height_m - 1.5;
|
||||
emit update();
|
||||
}
|
||||
|
||||
void MapView2D::showGridImportance(Grid<MyGridNode>* grid) {
|
||||
colorPoints->showGridImportance(grid);
|
||||
colorPoints->showGridImportance(grid);
|
||||
}
|
||||
|
||||
void MapView2D::resizeEvent(QResizeEvent* evt) {
|
||||
(void) evt;
|
||||
int s = UIHelper::getButtonSize(this->parent()) * 1.5;
|
||||
//sldLayer->setMinimumHeight(s);
|
||||
//sldLayer->setMinimum(0);
|
||||
//sldLayer->setMaximum(16);
|
||||
btnColorPoints->setMinimumHeight(s);
|
||||
btnColorPoints->setMinimumWidth(s);
|
||||
btnLayerMinus->setMinimumHeight(s);
|
||||
btnLayerMinus->setMinimumWidth(s);
|
||||
btnLayerPlus->setMinimumHeight(s);
|
||||
btnLayerPlus->setMinimumWidth(s);
|
||||
(void) evt;
|
||||
int s = UIHelper::getButtonSize(this->parent()) * 1.5;
|
||||
//sldLayer->setMinimumHeight(s);
|
||||
//sldLayer->setMinimum(0);
|
||||
//sldLayer->setMaximum(16);
|
||||
btnColorPoints->setMinimumHeight(s);
|
||||
btnColorPoints->setMinimumWidth(s);
|
||||
btnLayerMinus->setMinimumHeight(s);
|
||||
btnLayerMinus->setMinimumWidth(s);
|
||||
btnLayerPlus->setMinimumHeight(s);
|
||||
btnLayerPlus->setMinimumWidth(s);
|
||||
|
||||
scaler.setScreenSize(width(), height());
|
||||
scaler.setScale( UIHelper::isLarge(this->parent()) ? 2 : 1 );
|
||||
scaler.setScreenSize(width(), height());
|
||||
scaler.setScale( UIHelper::isLarge(this->parent()) ? 2 : 1 );
|
||||
|
||||
}
|
||||
|
||||
void MapView2D::mousePressEvent(QMouseEvent* evt) {
|
||||
move.startCenter_px = scaler.getCenterPX();
|
||||
move.startMouse_px = Point2(evt->x(), evt->y());
|
||||
move.startCenter_px = scaler.getCenterPX();
|
||||
move.startMouse_px = Point2(evt->x(), evt->y());
|
||||
}
|
||||
|
||||
void MapView2D::mouseMoveEvent(QMouseEvent* evt) {
|
||||
Point2 pt(evt->x(), evt->y());
|
||||
pt -= move.startMouse_px;
|
||||
pt.x = -pt.x;
|
||||
pt += move.startCenter_px;
|
||||
scaler.setCenterPX(pt);
|
||||
emit update();
|
||||
Point2 pt(evt->x(), evt->y());
|
||||
pt -= move.startMouse_px;
|
||||
pt.x = -pt.x;
|
||||
pt += move.startCenter_px;
|
||||
scaler.setCenterPX(pt);
|
||||
emit update();
|
||||
}
|
||||
|
||||
void MapView2D::mouseReleaseEvent(QMouseEvent* evt) {
|
||||
|
||||
if (!wifiCalib) {return;}
|
||||
if (!wifiCalib) {return;}
|
||||
|
||||
const Point2 p1(evt->x(), evt->y());
|
||||
const Point2 p1(evt->x(), evt->y());
|
||||
|
||||
// fingerprint node pressed?
|
||||
const int fpSize = UIHelper::isLarge(this->parent()) ? (40) : (25);
|
||||
int idx = 0;
|
||||
for (const Point2 p2 : wifiCalib->getNodes()) {
|
||||
const float dist = p1.getDistance(p2);
|
||||
if (dist < fpSize) { wifiCalib->selectNode(idx); emit update(); break; }
|
||||
++idx;
|
||||
}
|
||||
// fingerprint node pressed?
|
||||
const int fpSize = UIHelper::isLarge(this->parent()) ? (40) : (25);
|
||||
int idx = 0;
|
||||
for (const Point2 p2 : wifiCalib->getNodes()) {
|
||||
const float dist = p1.getDistance(p2);
|
||||
if (dist < fpSize) { wifiCalib->selectNode(idx); emit update(); break; }
|
||||
++idx;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void MapView2D::wheelEvent(QWheelEvent* event) {
|
||||
if (event->delta() < 0) {
|
||||
scaler.mulScale(0.5);
|
||||
emit update();
|
||||
} else {
|
||||
scaler.mulScale(2.0);
|
||||
emit update();
|
||||
}
|
||||
if (event->delta() < 0) {
|
||||
scaler.mulScale(0.5);
|
||||
emit update();
|
||||
} else {
|
||||
scaler.mulScale(2.0);
|
||||
emit update();
|
||||
}
|
||||
}
|
||||
|
||||
void MapView2D::paintEvent(QPaintEvent*) {
|
||||
|
||||
QPainter qp(this);
|
||||
QPainter qp(this);
|
||||
|
||||
// clear
|
||||
qp.fillRect(0, 0, width(), height(), Qt::white);
|
||||
// clear
|
||||
qp.fillRect(0, 0, width(), height(), Qt::white);
|
||||
|
||||
// render elements
|
||||
for (Renderable2D* r : elementsA) {r->render(qp, scaler, renderParams);}
|
||||
for (Renderable2D* r : elementsB) {r->render(qp, scaler, renderParams);}
|
||||
// render elements
|
||||
for (Renderable2D* r : elementsA) {r->render(qp, scaler, renderParams);}
|
||||
for (Renderable2D* r : elementsB) {r->render(qp, scaler, renderParams);}
|
||||
|
||||
qp.end();
|
||||
qp.end();
|
||||
|
||||
}
|
||||
|
||||
bool MapView2D::event(QEvent *event) {
|
||||
|
||||
switch (event->type()) {
|
||||
case QEvent::Gesture:
|
||||
return gestureEvent(static_cast<QGestureEvent*>(event));
|
||||
switch (event->type()) {
|
||||
case QEvent::Gesture:
|
||||
return gestureEvent(static_cast<QGestureEvent*>(event));
|
||||
|
||||
case QEvent::TouchBegin:
|
||||
case QEvent::TouchUpdate:
|
||||
case QEvent::TouchEnd:
|
||||
case QEvent::TouchBegin:
|
||||
case QEvent::TouchUpdate:
|
||||
case QEvent::TouchEnd:
|
||||
|
||||
// prevent [additional] mouse events for undetected gestures [more than 1 finger]
|
||||
// TODO: not yet stable... improvements?
|
||||
if (static_cast<QTouchEvent*>(event)->touchPoints().count() == 2) {return true;}
|
||||
break;
|
||||
// prevent [additional] mouse events for undetected gestures [more than 1 finger]
|
||||
// TODO: not yet stable... improvements?
|
||||
if (static_cast<QTouchEvent*>(event)->touchPoints().count() == 2) {return true;}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// event not consumed. bubble it to following stages.
|
||||
// this will e.g. generate mouseMoveEvent etc.
|
||||
return QWidget::event(event);
|
||||
// event not consumed. bubble it to following stages.
|
||||
// this will e.g. generate mouseMoveEvent etc.
|
||||
return QWidget::event(event);
|
||||
|
||||
}
|
||||
|
||||
bool MapView2D::gestureEvent(QGestureEvent *event) {
|
||||
|
||||
if (QGesture* pinch = event->gesture(Qt::PinchGesture)) {
|
||||
const QPinchGesture* pg = static_cast<QPinchGesture *>(pinch);
|
||||
scaler.mulScale(pg->scaleFactor());
|
||||
emit update();
|
||||
return true; // event consumed
|
||||
}
|
||||
if (QGesture* pinch = event->gesture(Qt::PinchGesture)) {
|
||||
const QPinchGesture* pg = static_cast<QPinchGesture *>(pinch);
|
||||
scaler.mulScale(pg->scaleFactor());
|
||||
emit update();
|
||||
return true; // event consumed
|
||||
}
|
||||
|
||||
// event not consumed
|
||||
return false;
|
||||
// event not consumed
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,10 @@
|
||||
#include "nav/grid/State.h"
|
||||
#include "nav/mesh/State.h"
|
||||
|
||||
#include "../tools/calibration/BLECalibrationDataModel.h"
|
||||
|
||||
namespace Floorplan {
|
||||
class IndoorMap;
|
||||
class IndoorMap;
|
||||
}
|
||||
|
||||
template <typename T> class Grid;
|
||||
@@ -30,7 +32,7 @@ class Path2D;
|
||||
|
||||
template <typename T> class DijkstraPath;
|
||||
namespace SMC {
|
||||
template <typename T> class Particle;
|
||||
template <typename T> class Particle;
|
||||
}
|
||||
class MyState;
|
||||
|
||||
@@ -39,73 +41,73 @@ class WiFiCalibrationDataModel;
|
||||
|
||||
class MapView2D : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
std::vector<Renderable2D*> elementsA;
|
||||
std::vector<Renderable2D*> elementsB;
|
||||
std::vector<Renderable2D*> elementsA;
|
||||
std::vector<Renderable2D*> elementsB;
|
||||
|
||||
ColorPoints2D* colorPoints = nullptr;
|
||||
Path2D* pathToDest = nullptr;
|
||||
Path2D* pathWalked = nullptr;
|
||||
WiFiCalibTool* wifiCalib = nullptr;
|
||||
ColorPoints2D* colorPoints = nullptr;
|
||||
Path2D* pathToDest = nullptr;
|
||||
Path2D* pathWalked = nullptr;
|
||||
WiFiCalibTool* wifiCalib = nullptr;
|
||||
|
||||
Scaler2D scaler;
|
||||
RenderParams2D renderParams;
|
||||
float layerHeight_m = 0;
|
||||
Scaler2D scaler;
|
||||
RenderParams2D renderParams;
|
||||
float layerHeight_m = 0;
|
||||
|
||||
struct Move {
|
||||
Point2 startCenter_px;
|
||||
Point2 startMouse_px;
|
||||
} move;
|
||||
struct Move {
|
||||
Point2 startCenter_px;
|
||||
Point2 startMouse_px;
|
||||
} move;
|
||||
|
||||
QWidget* menu = nullptr;
|
||||
QSlider* sldLayer = nullptr;
|
||||
QPushButton* btnColorPoints = nullptr;
|
||||
QPushButton* btnLayerPlus = nullptr;
|
||||
QPushButton* btnLayerMinus = nullptr;
|
||||
QWidget* menu = nullptr;
|
||||
QSlider* sldLayer = nullptr;
|
||||
QPushButton* btnColorPoints = nullptr;
|
||||
QPushButton* btnLayerPlus = nullptr;
|
||||
QPushButton* btnLayerMinus = nullptr;
|
||||
|
||||
public:
|
||||
|
||||
explicit MapView2D(QWidget *parent = 0);
|
||||
explicit MapView2D(QWidget *parent = 0);
|
||||
|
||||
/** set the to-be-shown map */
|
||||
void setMap(WiFiCalibrationDataModel* mdl, Floorplan::IndoorMap* map);
|
||||
/** set the to-be-shown map */
|
||||
void setMap(WiFiCalibrationDataModel* wifiMdl, BLECalibrationDataModel* bleMdl, Floorplan::IndoorMap* map);
|
||||
|
||||
/** show importance factors for the grid */
|
||||
void showGridImportance(Grid<MyGridNode>* grid);
|
||||
/** show importance factors for the grid */
|
||||
void showGridImportance(Grid<MyGridNode>* grid);
|
||||
|
||||
/** set the height-slice to be visible */
|
||||
void setRenderHeight(const float height_m);
|
||||
/** set the height-slice to be visible */
|
||||
void setRenderHeight(const float height_m);
|
||||
|
||||
|
||||
|
||||
/** set the path to the destination MUST BE CALLED FROM THE MAIN THREAD */
|
||||
void setPathToDestination(const std::vector<Point3>& path);
|
||||
/** set the path to the destination MUST BE CALLED FROM THE MAIN THREAD */
|
||||
void setPathToDestination(const std::vector<Point3>& path);
|
||||
|
||||
/** set the path to disply. MUST BE CALLED FROM THE MAIN THREAD */
|
||||
template <typename Node> void setPathToDestination(const DijkstraPath<Node>* path) {this->pathToDest->set(*path);}
|
||||
/** set the path to disply. MUST BE CALLED FROM THE MAIN THREAD */
|
||||
template <typename Node> void setPathToDestination(const DijkstraPath<Node>* path) {this->pathToDest->set(*path);}
|
||||
|
||||
/** set the path to disply. MUST BE CALLED FROM THE MAIN THREAD*/
|
||||
Q_INVOKABLE void setPathToDestination(const void* path) { setPathToDestination( (const DijkstraPath<MyGridNode>*) path); }
|
||||
/** set the path to disply. MUST BE CALLED FROM THE MAIN THREAD*/
|
||||
Q_INVOKABLE void setPathToDestination(const void* path) { setPathToDestination( (const DijkstraPath<MyGridNode>*) path); }
|
||||
|
||||
|
||||
|
||||
/** set the walked path. MUST BE CALLED FROM THE MAIN THREAD */
|
||||
void setPathWalked(const std::vector<Point3>& path) {this->pathWalked->set(path);}
|
||||
/** set the walked path. MUST BE CALLED FROM THE MAIN THREAD */
|
||||
void setPathWalked(const std::vector<Point3>& path) {this->pathWalked->set(path);}
|
||||
|
||||
/** set the walked path. MUST BE CALLED FROM THE MAIN THREAD */
|
||||
Q_INVOKABLE void setPathWalked(const void* path) { this->pathWalked->set( *((const std::vector<Point3>*) path)); }
|
||||
/** set the walked path. MUST BE CALLED FROM THE MAIN THREAD */
|
||||
Q_INVOKABLE void setPathWalked(const void* path) { this->pathWalked->set( *((const std::vector<Point3>*) path)); }
|
||||
|
||||
|
||||
|
||||
/** NOTE: must be called from Qt's main thread! */
|
||||
Q_INVOKABLE void showParticles(const void* particles) {
|
||||
/** NOTE: must be called from Qt's main thread! */
|
||||
Q_INVOKABLE void showParticles(const void* particles) {
|
||||
showParticles((const std::vector<SMC::Particle<MeshBased::MyState>>*) particles);
|
||||
}
|
||||
}
|
||||
|
||||
/** NOTE: must be called from Qt's main thread! */
|
||||
/** NOTE: must be called from Qt's main thread! */
|
||||
void showParticles(const std::vector<SMC::Particle<GridBased::MyState>>* particles);
|
||||
|
||||
|
||||
@@ -113,31 +115,31 @@ public:
|
||||
void showParticles(const std::vector<SMC::Particle<MeshBased::MyState>>* particles);
|
||||
|
||||
|
||||
/** set the currently estimated position */
|
||||
void setCurrentEstimation(const Point3 pos, const Point3 dir);
|
||||
/** set the currently estimated position */
|
||||
void setCurrentEstimation(const Point3 pos, const Point3 dir);
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
protected slots:
|
||||
|
||||
void onLayerSelect();
|
||||
void onLayerPlus();
|
||||
void onLayerMinus();
|
||||
void onLayerSelect();
|
||||
void onLayerPlus();
|
||||
void onLayerMinus();
|
||||
|
||||
public slots:
|
||||
|
||||
void resizeEvent(QResizeEvent*);
|
||||
void resizeEvent(QResizeEvent*);
|
||||
|
||||
void paintEvent(QPaintEvent*);
|
||||
void paintEvent(QPaintEvent*);
|
||||
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
void mouseMoveEvent(QMouseEvent*);
|
||||
void mouseReleaseEvent(QMouseEvent*);
|
||||
void wheelEvent(QWheelEvent*);
|
||||
void mousePressEvent(QMouseEvent*);
|
||||
void mouseMoveEvent(QMouseEvent*);
|
||||
void mouseReleaseEvent(QMouseEvent*);
|
||||
void wheelEvent(QWheelEvent*);
|
||||
|
||||
bool event(QEvent*);
|
||||
bool gestureEvent(QGestureEvent *event);
|
||||
bool event(QEvent*);
|
||||
bool gestureEvent(QGestureEvent *event);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -20,91 +20,96 @@
|
||||
#include "../../../sensors/SensorFactory.h"
|
||||
|
||||
struct WiFiCalibPoint {
|
||||
std::string name; // title
|
||||
Point3 pos_m; // map position + smartphone height
|
||||
Point2 pos_px; // screen position
|
||||
WiFiCalibPoint(const std::string& name, const Point3 pos_m, const Point2 pos_px) : name(name), pos_m(pos_m), pos_px(pos_px) {;}
|
||||
WiFiCalibPoint() {;}
|
||||
std::string name; // title
|
||||
Point3 pos_m; // map position + smartphone height
|
||||
Point2 pos_px; // screen position
|
||||
WiFiCalibPoint(const std::string& name, const Point3 pos_m, const Point2 pos_px) : name(name), pos_m(pos_m), pos_px(pos_px) {;}
|
||||
WiFiCalibPoint() {;}
|
||||
};
|
||||
|
||||
/**
|
||||
* helper for wifi calibration
|
||||
* TODO: Make this generic for BLE and WiFI
|
||||
*/
|
||||
class WiFiCalibTool : public Renderable2D {
|
||||
|
||||
private:
|
||||
|
||||
WiFiCalibrationDataModel* mdl;
|
||||
Floorplan::IndoorMap* map;
|
||||
WiFiCalibrationDataModel* wifiMdl;
|
||||
BLECalibrationDataModel* bleMdl;
|
||||
|
||||
std::vector<WiFiCalibPoint> currentlyVisible;
|
||||
WiFiCalibPoint currentlySelected;
|
||||
Floorplan::IndoorMap* map;
|
||||
|
||||
std::vector<WiFiCalibPoint> currentlyVisible;
|
||||
WiFiCalibPoint currentlySelected;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
/** ctor */
|
||||
WiFiCalibTool(WiFiCalibrationDataModel* mdl, Floorplan::IndoorMap* map) : mdl(mdl), map(map) {
|
||||
/** ctor */
|
||||
WiFiCalibTool(WiFiCalibrationDataModel* wifiMdl, BLECalibrationDataModel* bleMdl, Floorplan::IndoorMap* map) : wifiMdl(wifiMdl), bleMdl(bleMdl), map(map) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
virtual void selectNode(const int idx) {
|
||||
currentlySelected = currentlyVisible[idx];
|
||||
showCalib(currentlySelected);
|
||||
}
|
||||
virtual void selectNode(const int idx) {
|
||||
currentlySelected = currentlyVisible[idx];
|
||||
showCalib(currentlySelected);
|
||||
}
|
||||
|
||||
/** get all selectable caliration nodes */
|
||||
virtual std::vector<Point2> getNodes() const {
|
||||
std::vector<Point2> pts;
|
||||
for (const WiFiCalibPoint& cp : currentlyVisible) {pts.push_back(cp.pos_px);}
|
||||
return pts;
|
||||
}
|
||||
/** get all selectable caliration nodes */
|
||||
virtual std::vector<Point2> getNodes() const {
|
||||
std::vector<Point2> pts;
|
||||
for (const WiFiCalibPoint& cp : currentlyVisible) {pts.push_back(cp.pos_px);}
|
||||
return pts;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
void doRender(QPainter& qp, const Scaler2D& s, const RenderParams2D& r) override {
|
||||
void doRender(QPainter& qp, const Scaler2D& s, const RenderParams2D& r) override {
|
||||
|
||||
currentlyVisible.clear();
|
||||
const QFont font("Arial", 10);
|
||||
qp.setFont(font);
|
||||
currentlyVisible.clear();
|
||||
const QFont font("Arial", 10);
|
||||
qp.setFont(font);
|
||||
|
||||
// get all fingerprint-locations that are currently visible on the 2D map
|
||||
for (const Floorplan::Floor* floor : map->floors) {
|
||||
for (const Floorplan::FingerprintLocation* fpLoc : floor->fpLocations) {
|
||||
// get all fingerprint-locations that are currently visible on the 2D map
|
||||
for (const Floorplan::Floor* floor : map->floors) {
|
||||
for (const Floorplan::FingerprintLocation* fpLoc : floor->fpLocations) {
|
||||
|
||||
//const Point3 p = beacon->pos + Point3(0,0,floor->atHeight) + Point3(0,0,Settings::smartphoneAboveGround);
|
||||
const Point3 p = fpLoc->getPosition(*floor); // is already above ground as configured within the map
|
||||
const Point2 pt = s.mapToScreen(p.xy());
|
||||
//const Point3 p = beacon->pos + Point3(0,0,floor->atHeight) + Point3(0,0,Settings::smartphoneAboveGround);
|
||||
const Point3 p = fpLoc->getPosition(*floor); // is already above ground as configured within the map
|
||||
const Point2 pt = s.mapToScreen(p.xy());
|
||||
|
||||
if (floor->atHeight < r.clip.belowHeight_m) {continue;}
|
||||
if (floor->atHeight > r.clip.aboveHeight_m) {continue;}
|
||||
if (floor->atHeight < r.clip.belowHeight_m) {continue;}
|
||||
if (floor->atHeight > r.clip.aboveHeight_m) {continue;}
|
||||
|
||||
const WiFiCalibPoint cp(fpLoc->name, p, pt);
|
||||
currentlyVisible.push_back(cp);
|
||||
const WiFiCalibPoint cp(fpLoc->name, p, pt);
|
||||
currentlyVisible.push_back(cp);
|
||||
|
||||
const WiFiFingerprint& fp = mdl->getFingerprint(cp.pos_m);
|
||||
const QString txt1(fpLoc->name.c_str());
|
||||
const QString txt2 = QString::number(fp.measurements.entries.size());
|
||||
qp.setPen(Qt::black);
|
||||
const WiFiFingerprint& wfp = wifiMdl->getFingerprint(cp.pos_m);
|
||||
const BeaconFingerprint& bfp = bleMdl->getFingerprint(cp.pos_m);
|
||||
|
||||
if (currentlySelected.name == cp.name) {
|
||||
qp.setBrush(Qt::blue);
|
||||
} else {
|
||||
qp.setBrush(Qt::NoBrush);
|
||||
}
|
||||
const QString txt1(fpLoc->name.c_str());
|
||||
const QString txt2 = QString::number(wfp.measurements.entries.size());
|
||||
qp.setPen(Qt::black);
|
||||
|
||||
//FONT SIZE??
|
||||
if (currentlySelected.name == cp.name) {
|
||||
qp.setBrush(Qt::blue);
|
||||
} else {
|
||||
qp.setBrush(Qt::NoBrush);
|
||||
}
|
||||
|
||||
//FONT SIZE??
|
||||
|
||||
|
||||
int s = 20;
|
||||
qp.drawEllipse(pt.x-s, pt.y-s, s*2, s*2);
|
||||
qp.drawText(pt.x+s*2, pt.y-s, txt1);
|
||||
qp.drawText(pt.x+s*2, pt.y+s, txt2);
|
||||
int s = 20;
|
||||
qp.drawEllipse(pt.x-s, pt.y-s, s*2, s*2);
|
||||
qp.drawText(pt.x+s*2, pt.y-s, txt1);
|
||||
qp.drawText(pt.x+s*2, pt.y+s, txt2);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -113,18 +118,21 @@ private:
|
||||
|
||||
|
||||
|
||||
void showCalib(const WiFiCalibPoint& cp) {
|
||||
void showCalib(const WiFiCalibPoint& cp) {
|
||||
|
||||
// get (or create an empty one) the fingerprint for this location
|
||||
WiFiFingerprint& fp = mdl->getFingerprint(cp.pos_m);
|
||||
// get (or create an empty one) the fingerprint for this location
|
||||
WiFiFingerprint& wfp = wifiMdl->getFingerprint(cp.pos_m);
|
||||
BeaconFingerprint& bfp = bleMdl->getFingerprint(cp.pos_m);
|
||||
|
||||
// edit it (blocking!)
|
||||
WiFiCalibrationScanDialog::get(fp);
|
||||
// edit it (blocking!)
|
||||
WiFiCalibrationScanDialog::get(wfp, bfp);
|
||||
|
||||
// save the model
|
||||
mdl->save();
|
||||
// save the model
|
||||
wifiMdl->save();
|
||||
|
||||
}
|
||||
//save bluetooth model here!
|
||||
bleMdl->save();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user