This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/3D/navMesh/QNavMeshSettings.cpp
2018-10-25 12:15:13 +02:00

113 lines
4.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* © 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)
*/
#include "QNavMeshSettings.h"
#include <Indoor/navMesh/NavMeshSettings.h>
#include <QGridLayout>
#include <QLabel>
#include <QSlider>
#include <QSlider>
#include <QDialogButtonBox>
QNavMeshSettings::QNavMeshSettings(NM::NavMeshSettings* settings, QWidget* parent) : QDialog(parent) {
QGridLayout* lay = new QGridLayout(this);
this->setLayout(lay);
int row = 0;
this->setWindowTitle("NavMesh Settings");
this->setMinimumWidth(350);
// MAX QUALITY
{
lay->addWidget(new QLabel("smallest element"), row, 0);
QLabel* lblQuality = new QLabel("");
lay->addWidget(lblQuality, row, 2);
QSlider* sldQuality = new QSlider(Qt::Orientation::Horizontal); sldQuality->setMinimum(10); sldQuality->setMaximum(30);
connect(sldQuality, &QSlider::valueChanged, [settings, sldQuality, lblQuality] () {
settings->maxQuality_m = sldQuality->value() / 100.0f;
lblQuality->setText(QString("%1 m").arg(settings->maxQuality_m, 5, 'f', 2, 0));
});
sldQuality->setValue(settings->maxQuality_m * 100.0f);
lay->addWidget(sldQuality, row, 1);
++row;
}
// AGENT HEIGHT
{
lay->addWidget(new QLabel("agent height"), row, 0);
QLabel* lblHeight = new QLabel("");
lay->addWidget(lblHeight, row, 2);
QSlider* sldHeight = new QSlider(Qt::Orientation::Horizontal); sldHeight->setMinimum(10); sldHeight->setMaximum(200);
connect(sldHeight, &QSlider::valueChanged, [settings, sldHeight, lblHeight] () {
settings->agentHeight = sldHeight->value() / 100.0f;
lblHeight->setText(QString("%1 m").arg(settings->agentHeight, 5, 'f', 2, 0));
});
sldHeight->setValue(settings->agentHeight * 100.0f);
lay->addWidget(sldHeight, row, 1);
++row;
}
// AGENT RADIUS
{
lay->addWidget(new QLabel("agent radius"), row, 0);
QLabel* lblRadius = new QLabel("");
lay->addWidget(lblRadius, row, 2);
QSlider* sldRadius = new QSlider(Qt::Orientation::Horizontal); sldRadius->setMinimum(5); sldRadius->setMaximum(60);
connect(sldRadius, &QSlider::valueChanged, [settings, sldRadius, lblRadius] () {
settings->agentRadius = sldRadius->value() / 100.0f;
lblRadius->setText(QString("%1 m").arg(settings->agentRadius, 5, 'f', 2, 0));
});
sldRadius->setValue(settings->agentRadius * 100.0f);
lay->addWidget(sldRadius, row, 1);
++row;
}
// MAX EDGE LENGTH
{
lay->addWidget(new QLabel("max edge length"), row, 0);
QLabel* lblMaxEdgeLength = new QLabel("");
lay->addWidget(lblMaxEdgeLength, row, 2);
QSlider* sdlMaxEdgeLength = new QSlider(Qt::Orientation::Horizontal); sdlMaxEdgeLength->setMinimum(300); sdlMaxEdgeLength->setMaximum(2000);
connect(sdlMaxEdgeLength, &QSlider::valueChanged, [settings, sdlMaxEdgeLength, lblMaxEdgeLength] () {
settings->edgeMaxLen = sdlMaxEdgeLength->value() / 100.0f;
lblMaxEdgeLength->setText(QString("%1 m").arg(settings->edgeMaxLen, 5, 'f', 2, 0));
});
sdlMaxEdgeLength->setValue(settings->edgeMaxLen * 100.0f);
lay->addWidget(sdlMaxEdgeLength, row, 1);
++row;
}
// MIN REGION SIZE
{
lay->addWidget(new QLabel("min region size"), row, 0);
QLabel* lblMinRegionSize = new QLabel("");
lay->addWidget(lblMinRegionSize, row, 2);
QSlider* sldRegionMinSize = new QSlider(Qt::Orientation::Horizontal); sldRegionMinSize->setMinimum(400); sldRegionMinSize->setMaximum(99900);
connect(sldRegionMinSize, &QSlider::valueChanged, [settings, sldRegionMinSize, lblMinRegionSize] () {
settings->regionMinSize = sldRegionMinSize->value() / 100.0f;
lblMinRegionSize->setText(QString("%1 m").arg(settings->regionMinSize, 5, 'f', 2, 0));
});
sldRegionMinSize->setValue(settings->regionMinSize * 100.0f);
lay->addWidget(sldRegionMinSize, row, 1);
++row;
}
QDialogButtonBox* box = new QDialogButtonBox(QDialogButtonBox::StandardButton::Ok | QDialogButtonBox::StandardButton::Close);
lay->addWidget(box, row, 0, 1, 3);
connect(box, &QDialogButtonBox::accepted, [&] () {ok = true; close();});
connect(box, &QDialogButtonBox::rejected, [&] () {ok = false; close();});
}