added main menu added debug display many debug widgets for plotting live data worked on android live sensors added offline-data sensor feeding some dummy data sensors worked on the map display added ui debug for grid-points, particles and weights added a cool dude to display the estimation added real filtering based on the Indoor components c++11 fixes for android compilation online and offline filtering support new resampling technique for testing map loading via dialog
153 lines
3.1 KiB
C++
153 lines
3.1 KiB
C++
#ifndef MAPVIEW_H
|
|
#define MAPVIEW_H
|
|
|
|
#include <../misc/fixc11.h>
|
|
|
|
|
|
#include <QOpenGLWidget>
|
|
#include <QOpenGLFunctions>
|
|
#include <QOpenGLShaderProgram>
|
|
#include <QBasicTimer>
|
|
|
|
#include <Indoor/geo/Point3.h>
|
|
#include <Indoor/nav/dijkstra/DijkstraPath.h>
|
|
|
|
#include "elements/Path.h"
|
|
#include "elements/ColorPoints.h"
|
|
#include "elements/Object.h"
|
|
|
|
#include "../nav/State.h"
|
|
|
|
namespace Floorplan {
|
|
class IndoorMap;
|
|
}
|
|
|
|
class Renderable;
|
|
class Path;
|
|
|
|
|
|
class MapView : public QOpenGLWidget, protected QOpenGLFunctions {
|
|
|
|
Q_OBJECT
|
|
|
|
private:
|
|
|
|
QMatrix4x4 matProject;
|
|
QMatrix4x4 matView;
|
|
|
|
QVector3D lightPos;
|
|
QVector3D eyePos;
|
|
|
|
|
|
QBasicTimer timer;
|
|
|
|
std::vector<Renderable*> elements;
|
|
Path* path = nullptr;
|
|
ColorPoints* colorPoints = nullptr;
|
|
Object* leDude = nullptr;
|
|
|
|
struct LookAt {
|
|
Point3 eye_m = Point3(0,0,1);
|
|
Point3 dir = Point3(1,0,-0.1);
|
|
Point3 dirOffset = Point3(0,0,0);
|
|
Point3 getDir() const {return dir + dirOffset;}
|
|
} lookAt;
|
|
|
|
struct MouseState {
|
|
float x = 0;
|
|
float y = 0;
|
|
bool down = false;
|
|
} mouseState;
|
|
|
|
void rebuildLookat();
|
|
|
|
void clear();
|
|
|
|
public:
|
|
|
|
MapView(QWidget* parent = 0);
|
|
|
|
/** set the map to display */
|
|
void setMap(Floorplan::IndoorMap* map);
|
|
|
|
/** the position to look at + looking direction */
|
|
void setLookAt(const Point3 pos, const Point3 dir = Point3(1, 0, -0.1));
|
|
|
|
/** set the eye's looking direction (looking from eye into this direction) */
|
|
void setLookDir(const Point3 dir);
|
|
|
|
/** set the eye's position (looking from here) */
|
|
void setLookEye(const Point3 eye_m);
|
|
|
|
|
|
/** set the currently estimated position */
|
|
void setCurrentEstimation(const Point3 pos, const Point3 dir);
|
|
|
|
/** set the path to disply */
|
|
void setPath(const std::vector<Point3>& path);
|
|
|
|
/** NOTE: must be called from Qt's main thread! */
|
|
/** set the path to disply */
|
|
Q_INVOKABLE void setPath(const void* path) {
|
|
setPath( (const DijkstraPath<MyGridNode>*) path);
|
|
}
|
|
|
|
/** NOTE: must be called from Qt's main thread! */
|
|
/** set the path to disply */
|
|
template <typename Node> void setPath(const DijkstraPath<Node>* path) {
|
|
this->path->set(*path);
|
|
}
|
|
|
|
/** NOTE: must be called from Qt's main thread! */
|
|
void showGridImportance(Grid<MyGridNode>* grid) {
|
|
this->colorPoints->setFromGridImportance(grid);
|
|
}
|
|
|
|
/** NOTE: must be called from Qt's main thread! */
|
|
Q_INVOKABLE void showParticles(const void* particles) {
|
|
showParticles((const std::vector<K::Particle<MyState>>*) particles);
|
|
}
|
|
|
|
/** NOTE: must be called from Qt's main thread! */
|
|
void showParticles(const std::vector<K::Particle<MyState>>* particles) {
|
|
this->colorPoints->setFromParticles(*particles);
|
|
}
|
|
|
|
enum RenderMode {
|
|
NORMAL,
|
|
TRANSPARENT,
|
|
OUTLINE,
|
|
};
|
|
|
|
RenderMode renderMode = RenderMode::NORMAL;
|
|
|
|
void toggleRenderMode();
|
|
|
|
public slots:
|
|
|
|
void mousePressEvent(QMouseEvent*);
|
|
void mouseMoveEvent(QMouseEvent*);
|
|
void mouseReleaseEvent(QMouseEvent*);
|
|
|
|
void keyPressEvent(QKeyEvent*);
|
|
|
|
protected:
|
|
|
|
void timerEvent(QTimerEvent *e) Q_DECL_OVERRIDE;
|
|
|
|
void initializeGL();
|
|
|
|
void paintGL();
|
|
|
|
void resizeGL(int width, int height);
|
|
|
|
private:
|
|
|
|
bool isGLInitialized = false;
|
|
|
|
void draw();
|
|
|
|
};
|
|
|
|
#endif // MAPVIEW_H
|