114 lines
2.2 KiB
C++
114 lines
2.2 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 GRIDMODEL_H
|
||
#define GRIDMODEL_H
|
||
|
||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||
#include <Indoor/grid/Grid.h>
|
||
#include <Indoor/grid/factory/v2/GridFactory.h>
|
||
#include <Indoor/grid/factory/v2/Importance.h>
|
||
|
||
#include <QProgressDialog>
|
||
#include <QApplication>
|
||
#include <QVBoxLayout>
|
||
#include <QLabel>
|
||
#include <QProgressBar>
|
||
|
||
#include "MyNode.h"
|
||
|
||
/**
|
||
* used for 3D grid rendering
|
||
*/
|
||
class GridModel {
|
||
|
||
private:
|
||
|
||
const int gridSize_cm = 30; // TODO
|
||
|
||
Grid<MyNode> grid;
|
||
Floorplan::IndoorMap* im;
|
||
|
||
int buildID = 0;
|
||
|
||
public:
|
||
|
||
GridModel() : grid(gridSize_cm) {
|
||
;
|
||
}
|
||
|
||
Grid<MyNode>* getGrid() {return &grid;}
|
||
|
||
|
||
class Listener : public GridFactoryListener {
|
||
|
||
private:
|
||
QDialog dlg;
|
||
QLabel* lbl1;
|
||
QLabel* lbl2;
|
||
QProgressBar* bar1;
|
||
QProgressBar* bar2;
|
||
|
||
public:
|
||
Listener() {
|
||
QVBoxLayout* lay = new QVBoxLayout(&dlg);
|
||
lbl1 = new QLabel(); lay->addWidget(lbl1);
|
||
bar1 = new QProgressBar(); lay->addWidget(bar1);
|
||
lbl2 = new QLabel(); lay->addWidget(lbl2);
|
||
bar2 = new QProgressBar(); lay->addWidget(bar2);
|
||
dlg.resize(350, 120);
|
||
dlg.show();
|
||
}
|
||
~Listener() {
|
||
dlg.close();
|
||
}
|
||
|
||
void onGridBuildUpdateMajor(const std::string& what) override {
|
||
lbl1->setText(what.c_str());
|
||
QApplication::processEvents();
|
||
}
|
||
void onGridBuildUpdateMajor(const int cnt, const int cur) override {
|
||
bar1->setValue(cur*100/cnt);
|
||
QApplication::processEvents();
|
||
}
|
||
|
||
void onGridBuildUpdateMinor(const std::string& what) override {
|
||
lbl2->setText(what.c_str());
|
||
QApplication::processEvents();
|
||
}
|
||
void onGridBuildUpdateMinor(const int cnt, const int cur) override {
|
||
bar2->setValue(cur*100/cnt);
|
||
QApplication::processEvents();
|
||
}
|
||
|
||
};
|
||
|
||
int getBuildID() const {
|
||
return buildID;
|
||
}
|
||
|
||
void rebuild(Floorplan::IndoorMap* im) {
|
||
|
||
Listener l;
|
||
|
||
GridFactory<MyNode> fac(grid);
|
||
fac.build(im, &l);
|
||
|
||
Importance::addImportance(grid, &l);
|
||
//Importance::addImportance(grid, 400);
|
||
|
||
buildID = rand();
|
||
|
||
}
|
||
|
||
};
|
||
|
||
#endif // GRIDMODEL_H
|