103 lines
2.0 KiB
C++
103 lines
2.0 KiB
C++
/*
|
||
* © Copyright 2014 – Urheberrechtshinweis
|
||
* Alle Rechte vorbehalten / All Rights Reserved
|
||
*
|
||
* Programmcode ist urheberrechtlich geschuetzt.
|
||
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
|
||
* Keine Verwendung ohne explizite Genehmigung.
|
||
* (vgl. § 106 ff UrhG / § 97 UrhG)
|
||
*/
|
||
|
||
#ifndef NAVMESHMODEL_H
|
||
#define NAVMESHMODEL_H
|
||
|
||
|
||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||
#include <Indoor/navMesh/NavMesh.h>
|
||
#include <Indoor/navMesh/NavMeshFactory.h>
|
||
#include <Indoor/navMesh/NavMeshFactoryListener.h>
|
||
|
||
#include <QProgressDialog>
|
||
#include <QApplication>
|
||
#include <QVBoxLayout>
|
||
#include <QLabel>
|
||
#include <QProgressBar>
|
||
#include "QNavMeshSettings.h"
|
||
|
||
/**
|
||
* used for 3D NavMesh rendering
|
||
*/
|
||
class NavMeshModel {
|
||
|
||
private:
|
||
|
||
NM::NavMesh<NM::NavMeshTriangle> navMesh;
|
||
NM::NavMeshSettings settings;
|
||
Floorplan::IndoorMap* im;
|
||
int buildID = 0;
|
||
|
||
public:
|
||
|
||
NavMeshModel() : navMesh() {
|
||
;
|
||
}
|
||
|
||
NM::NavMesh<NM::NavMeshTriangle>* getNavMesh() {return &navMesh;}
|
||
|
||
|
||
class Listener : public NM::NavMeshFactoryListener {
|
||
|
||
private:
|
||
QDialog dlg;
|
||
QLabel* lbl1;
|
||
QProgressBar* bar1;
|
||
|
||
public:
|
||
Listener() {
|
||
QVBoxLayout* lay = new QVBoxLayout(&dlg);
|
||
lbl1 = new QLabel(); lay->addWidget(lbl1);
|
||
bar1 = new QProgressBar(); lay->addWidget(bar1);
|
||
dlg.resize(350, 90);
|
||
dlg.setWindowTitle("NavMesh building");
|
||
dlg.show();
|
||
}
|
||
~Listener() {
|
||
dlg.close();
|
||
}
|
||
|
||
void onNavMeshBuildUpdateMajor(const std::string& what) override {
|
||
lbl1->setText(what.c_str());
|
||
QApplication::processEvents();
|
||
}
|
||
void onNavMeshBuildUpdateMajor(const int cnt, const int cur) override {
|
||
bar1->setValue(cur*100/cnt);
|
||
QApplication::processEvents();
|
||
}
|
||
|
||
};
|
||
|
||
int getBuildID() const {
|
||
return buildID;
|
||
}
|
||
|
||
void rebuild(Floorplan::IndoorMap* im) {
|
||
|
||
Listener l;
|
||
|
||
QNavMeshSettings qs(&settings);
|
||
qs.exec();
|
||
|
||
if (qs.ok) {
|
||
NM::NavMeshFactory<NM::NavMeshTriangle> fac(&navMesh, settings);
|
||
fac.build(im, &l);
|
||
}
|
||
|
||
buildID = rand();
|
||
|
||
}
|
||
|
||
};
|
||
|
||
|
||
#endif // NAVMESHMODEL_H
|