initial commit
This commit is contained in:
23
params/ActionWidget.cpp
Normal file
23
params/ActionWidget.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#include "ActionWidget.h"
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
ActionWidget::ActionWidget(QWidget *parent) : QGroupBox(parent) {
|
||||
|
||||
setTitle("actions");
|
||||
|
||||
QHBoxLayout* lay = new QHBoxLayout(this);
|
||||
|
||||
QPushButton* btnLoad = new QPushButton("load");
|
||||
lay->addWidget(btnLoad);
|
||||
|
||||
QPushButton* btnSave = new QPushButton("save");
|
||||
lay->addWidget(btnSave);
|
||||
|
||||
connect(btnLoad, SIGNAL(clicked(bool)), this, SIGNAL(onLoad()));
|
||||
|
||||
connect(btnSave, SIGNAL(clicked(bool)), this, SIGNAL(onSave()));
|
||||
|
||||
|
||||
}
|
||||
24
params/ActionWidget.h
Normal file
24
params/ActionWidget.h
Normal file
@@ -0,0 +1,24 @@
|
||||
#ifndef ACTIONWIDGET_H
|
||||
#define ACTIONWIDGET_H
|
||||
|
||||
#include <QGroupBox>
|
||||
|
||||
class ActionWidget : public QGroupBox {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit ActionWidget(QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
void onLoad();
|
||||
|
||||
void onSave();
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // ACTIONWIDGET_H
|
||||
226
params/ElementParamWidget.cpp
Normal file
226
params/ElementParamWidget.cpp
Normal file
@@ -0,0 +1,226 @@
|
||||
#include "ElementParamWidget.h"
|
||||
|
||||
#include "../mapview/model/MapModelElement.h"
|
||||
#include "../mapview/model/MMFloorObstacleLine.h"
|
||||
#include "../mapview/model/MMFloorOutlinePolygon.h"
|
||||
|
||||
#include "../mapview/model/IHasMAC.h"
|
||||
#include "../mapview/model/IHasFile.h"
|
||||
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include <QLabel>
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QFileDialog>
|
||||
|
||||
QComboBox* getMaterials() {
|
||||
using namespace Floorplan;
|
||||
QComboBox* cmbMaterial = new QComboBox();
|
||||
for (int i = 0; i < (int)Material::_END; ++i) {
|
||||
switch ((Material)i) {
|
||||
case Material::CONCRETE: cmbMaterial->addItem("Concrete", i); break;
|
||||
case Material::UNKNOWN: cmbMaterial->addItem("Unknown ", i); break;
|
||||
case Material::DRYWALL: cmbMaterial->addItem("Drywall", i); break;
|
||||
case Material::WOOD: cmbMaterial->addItem("Wood", i); break;
|
||||
case Material::GLASS: cmbMaterial->addItem("Glass", i); break;
|
||||
case Material::_END: throw 1;
|
||||
}
|
||||
}
|
||||
return cmbMaterial;
|
||||
}
|
||||
|
||||
QComboBox* getObstacleTypes() {
|
||||
using namespace Floorplan;
|
||||
QComboBox* cmb = new QComboBox();
|
||||
for (int i = 0; i < (int)ObstacleType::_END; ++i) {
|
||||
switch ((ObstacleType)i) {
|
||||
case ObstacleType::DOOR: cmb->addItem("Door", i); break;
|
||||
case ObstacleType::UNKNOWN: cmb->addItem("Unknown ", i); break;
|
||||
case ObstacleType::WALL: cmb->addItem("Wall", i); break;
|
||||
case ObstacleType::WINDOW: cmb->addItem("Window", i); break;
|
||||
case ObstacleType::HANDRAIL:cmb->addItem("Handrail", i); break;
|
||||
case ObstacleType::PILLAR: cmb->addItem("Pillar", i); break;
|
||||
case ObstacleType::_END: throw 1;
|
||||
}
|
||||
}
|
||||
return cmb;
|
||||
}
|
||||
|
||||
QComboBox* getOutlineMethods() {
|
||||
using namespace Floorplan;
|
||||
QComboBox* cmb = new QComboBox();
|
||||
for (int i = 0; i < (int)OutlineMethod::_END; ++i) {
|
||||
switch ((OutlineMethod)i) {
|
||||
case OutlineMethod::ADD: cmb->addItem("add", i); break;
|
||||
case OutlineMethod::REMOVE: cmb->addItem("remove ", i); break;
|
||||
case OutlineMethod::_END: throw 1;
|
||||
}
|
||||
}
|
||||
return cmb;
|
||||
}
|
||||
|
||||
|
||||
ElementParamWidget::ElementParamWidget(QWidget *parent) : QGroupBox(parent) {
|
||||
|
||||
setMinimumSize(100, 100);
|
||||
setMaximumWidth(200);
|
||||
|
||||
setTitle("MapElement Parameters");
|
||||
QGridLayout* lay = new QGridLayout(this);
|
||||
int r = 0;
|
||||
|
||||
lblDetails = new QLabel();
|
||||
lay->addWidget(new QLabel("selected"),r,0);
|
||||
lay->addWidget(lblDetails,r,1);
|
||||
++r;
|
||||
|
||||
name.txt = new QLineEdit();
|
||||
name.lbl = new QLabel("name");
|
||||
lay->addWidget(name.lbl,r,0);
|
||||
lay->addWidget(name.txt,r,1);
|
||||
connect(name.txt , SIGNAL(textChanged(QString)), this, SLOT(onNameChange()));
|
||||
++r;
|
||||
|
||||
mac.lbl = new QLabel("MAC");
|
||||
mac.txt = new QLineEdit();
|
||||
lay->addWidget(mac.lbl, r, 0);
|
||||
lay->addWidget(mac.txt, r, 1);
|
||||
connect(mac.txt, SIGNAL(textChanged(QString)), this, SLOT(onMACChanged()));
|
||||
++r;
|
||||
|
||||
|
||||
obstacleType.cmb = getObstacleTypes();
|
||||
obstacleType.lbl = new QLabel("type");
|
||||
lay->addWidget(obstacleType.lbl,r,0);
|
||||
lay->addWidget(obstacleType.cmb,r,1);
|
||||
connect(obstacleType.cmb, SIGNAL(currentIndexChanged(int)), this, SLOT(onObstacleTypeChange()));
|
||||
++r;
|
||||
|
||||
material.cmb = getMaterials();
|
||||
material.lbl = new QLabel("material");
|
||||
lay->addWidget(material.lbl,r,0);
|
||||
lay->addWidget(material.cmb,r,1);
|
||||
connect(material.cmb , SIGNAL(currentIndexChanged(int)), this, SLOT(onMaterialChange()));
|
||||
++r;
|
||||
|
||||
fileName.txt = new QLabel();
|
||||
fileName.lbl = new QLabel("file");
|
||||
fileName.btn = new QPushButton("op");
|
||||
lay->addWidget(fileName.lbl,r,0);
|
||||
lay->addWidget(fileName.txt,r,1);
|
||||
lay->addWidget(fileName.btn,r,2);
|
||||
connect(fileName.btn , SIGNAL(clicked(bool)), this, SLOT(onSelectFileName()));
|
||||
++r;
|
||||
|
||||
outlineMethod.cmb = getOutlineMethods();
|
||||
outlineMethod.lbl = new QLabel("outline");
|
||||
lay->addWidget(outlineMethod.lbl,r,0);
|
||||
lay->addWidget(outlineMethod.cmb,r,1);
|
||||
connect(outlineMethod.cmb , SIGNAL(currentIndexChanged(int)), this, SLOT(onOutlineMethodChange()));
|
||||
++r;
|
||||
|
||||
// start empty
|
||||
setElement(nullptr);
|
||||
|
||||
}
|
||||
|
||||
void ElementParamWidget::setElement(MapModelElement* el) {
|
||||
|
||||
this->curElement = el;
|
||||
|
||||
if (el == nullptr) {
|
||||
lblDetails->setText("-");
|
||||
} else if (dynamic_cast<MMFloorObstacleLine*>(el)) {
|
||||
MMFloorObstacleLine* obs = dynamic_cast<MMFloorObstacleLine*>(el);
|
||||
lblDetails->setText("Obstacle");
|
||||
} else if (dynamic_cast<MMFloorOutlinePolygon*>(el)) {
|
||||
MMFloorOutlinePolygon* poly = dynamic_cast<MMFloorOutlinePolygon*>(el);
|
||||
std::string txt = "Polygon (" + std::to_string(poly->getPolygon()->poly.points.size()) + " Points)";
|
||||
lblDetails->setText(txt.c_str());
|
||||
} else {
|
||||
lblDetails->setText("?");
|
||||
}
|
||||
|
||||
// material? -> select in combo-box
|
||||
{
|
||||
IHasMaterial* elem = dynamic_cast<IHasMaterial*>(el);
|
||||
material.cmb->setVisible(elem != nullptr);
|
||||
material.lbl->setVisible(elem != nullptr);
|
||||
if (elem) {material.cmb->setCurrentIndex((int)elem->getMaterial());}
|
||||
}
|
||||
|
||||
// obstacle-type? -> select in combo-box
|
||||
{
|
||||
IHasObstacleType* elem = dynamic_cast<IHasObstacleType*>(el);
|
||||
obstacleType.cmb->setVisible(elem != nullptr);
|
||||
obstacleType.lbl->setVisible(elem != nullptr);
|
||||
if (elem) {obstacleType.cmb->setCurrentIndex((int)elem->getObatcleType());}
|
||||
}
|
||||
|
||||
// has name?
|
||||
{
|
||||
IHasName* elem = dynamic_cast<IHasName*>(el);
|
||||
name.txt->setVisible(elem != nullptr);
|
||||
name.lbl->setVisible(elem != nullptr);
|
||||
if (elem) {name.txt->setText(elem->getName().c_str());}
|
||||
}
|
||||
|
||||
// has MAC?
|
||||
{
|
||||
IHasMAC* elem = dynamic_cast<IHasMAC*>(el);
|
||||
mac.lbl->setVisible(elem);
|
||||
mac.txt->setVisible(elem);
|
||||
if (elem) {mac.txt->setText(elem->getMAC().c_str());}
|
||||
}
|
||||
|
||||
// has outline method?
|
||||
{
|
||||
MMFloorOutlinePolygon* elem = dynamic_cast<MMFloorOutlinePolygon*>(el);
|
||||
outlineMethod.cmb->setVisible(elem);
|
||||
outlineMethod.lbl->setVisible(elem);
|
||||
if (elem) {outlineMethod.cmb->setCurrentIndex((int)elem->getMethod());}
|
||||
}
|
||||
|
||||
// has File
|
||||
{
|
||||
IHasFile* elem = dynamic_cast<IHasFile*>(el);
|
||||
fileName.lbl->setVisible(elem);
|
||||
fileName.txt->setVisible(elem);
|
||||
fileName.btn->setVisible(elem);
|
||||
if (elem) {fileName.txt->setText(elem->getFileName().c_str());}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ElementParamWidget::onMaterialChange() {
|
||||
IHasMaterial* el = dynamic_cast<IHasMaterial*>(this->curElement);
|
||||
if (el) {el->setMaterial( (Floorplan::Material) material.cmb->currentData().toInt() );}
|
||||
}
|
||||
|
||||
void ElementParamWidget::onObstacleTypeChange() {
|
||||
IHasObstacleType* el = dynamic_cast<IHasObstacleType*>(this->curElement);
|
||||
if (el) {el->setObstacleType((Floorplan::ObstacleType) obstacleType.cmb->currentData().toInt() );}
|
||||
}
|
||||
|
||||
void ElementParamWidget::onNameChange() {
|
||||
IHasName* el = dynamic_cast<IHasName*>(this->curElement);
|
||||
if (el) {el->setName(name.txt->text().toStdString());}
|
||||
}
|
||||
|
||||
void ElementParamWidget::onOutlineMethodChange() {
|
||||
MMFloorOutlinePolygon* el = dynamic_cast<MMFloorOutlinePolygon*>(this->curElement);
|
||||
if (el) {el->setMethod( (Floorplan::OutlineMethod) outlineMethod.cmb->currentData().toInt() );}
|
||||
}
|
||||
|
||||
void ElementParamWidget::onMACChanged() {
|
||||
dynamic_cast<IHasMAC*>(curElement)->setMAC(mac.txt->text().toStdString());
|
||||
}
|
||||
|
||||
void ElementParamWidget::onSelectFileName() {
|
||||
QString res = QFileDialog::getOpenFileName(this);
|
||||
dynamic_cast<IHasFile*>(curElement)->setFileName(res.toStdString());
|
||||
fileName.lbl->setText(res);
|
||||
}
|
||||
76
params/ElementParamWidget.h
Normal file
76
params/ElementParamWidget.h
Normal file
@@ -0,0 +1,76 @@
|
||||
#ifndef PARAMWIDGET_H
|
||||
#define PARAMWIDGET_H
|
||||
|
||||
#include <QGroupBox>
|
||||
#include "../mapview/model/MapModelElement.h"
|
||||
|
||||
class QLabel;
|
||||
class QComboBox;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
|
||||
class ElementParamWidget : public QGroupBox {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit ElementParamWidget(QWidget *parent = 0);
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
QLabel* lblDetails;
|
||||
MapModelElement* curElement = nullptr;
|
||||
|
||||
struct {
|
||||
QComboBox* cmb;
|
||||
QLabel* lbl;
|
||||
} material;
|
||||
|
||||
struct {
|
||||
QComboBox* cmb;
|
||||
QLabel* lbl;
|
||||
} obstacleType;
|
||||
|
||||
struct {
|
||||
QLineEdit* txt;
|
||||
QLabel* lbl;
|
||||
} name;
|
||||
|
||||
struct {
|
||||
QLineEdit* txt;
|
||||
QLabel* lbl;
|
||||
} mac;
|
||||
|
||||
struct {
|
||||
QLabel* txt;
|
||||
QPushButton* btn;
|
||||
QLabel* lbl;
|
||||
} fileName;
|
||||
|
||||
struct {
|
||||
QComboBox* cmb;
|
||||
QLabel* lbl;
|
||||
} outlineMethod;
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
/** set the to-be-edited element */
|
||||
void setElement(MapModelElement* el);
|
||||
|
||||
private slots:
|
||||
|
||||
void onMaterialChange();
|
||||
void onObstacleTypeChange();
|
||||
void onNameChange();
|
||||
void onMACChanged();
|
||||
void onOutlineMethodChange();
|
||||
void onSelectFileName();
|
||||
|
||||
};
|
||||
|
||||
#endif // PARAMWIDGET_H
|
||||
106
params/LayerParamWidget.cpp
Normal file
106
params/LayerParamWidget.cpp
Normal file
@@ -0,0 +1,106 @@
|
||||
#include "LayerParamWidget.h"
|
||||
#include <QGridLayout>
|
||||
|
||||
#include <QLineEdit>
|
||||
#include <QLabel>
|
||||
|
||||
#include "mapview/model/MMFloor.h"
|
||||
|
||||
LayerParamWidget::LayerParamWidget(QWidget *parent) : QGroupBox(parent) {
|
||||
|
||||
setMinimumSize(100, 100);
|
||||
setMaximumWidth(200);
|
||||
setTitle("MapLayer Parameters");
|
||||
|
||||
QGridLayout* lay = new QGridLayout(this);
|
||||
int r = 0;
|
||||
|
||||
|
||||
selected.lbl = new QLabel("selected");
|
||||
selected.info = new QLabel();
|
||||
lay->addWidget(selected.lbl, r, 0);
|
||||
lay->addWidget(selected.info, r, 1);
|
||||
++r;
|
||||
|
||||
name.lbl = new QLabel("name");
|
||||
name.txt = new QLineEdit();
|
||||
lay->addWidget(name.lbl, r, 0);
|
||||
lay->addWidget(name.txt, r, 1);
|
||||
connect(name.txt, SIGNAL(textChanged(QString)), this, SLOT(onNameChanged()));
|
||||
++r;
|
||||
|
||||
atHeight.lbl = new QLabel("at height");
|
||||
atHeight.txt = new QLineEdit();
|
||||
lay->addWidget(atHeight.lbl, r, 0);
|
||||
lay->addWidget(atHeight.txt, r, 1);
|
||||
connect(atHeight.txt, SIGNAL(textChanged(QString)), this, SLOT(onAtHeightChanged()));
|
||||
++r;
|
||||
|
||||
height.lbl = new QLabel("height");
|
||||
height.txt = new QLineEdit();
|
||||
lay->addWidget(height.lbl, r, 0);
|
||||
lay->addWidget(height.txt, r, 1);
|
||||
connect(height.txt, SIGNAL(textChanged(QString)), this, SLOT(onHeightChanged()));
|
||||
++r;
|
||||
|
||||
// start empty
|
||||
setElement(nullptr);
|
||||
|
||||
}
|
||||
|
||||
void LayerParamWidget::setElement(MapLayer* l) {
|
||||
|
||||
this->curElement = l;
|
||||
|
||||
if (l) {
|
||||
std::string info = l->getLayerName() + " (" + std::to_string(l->getNumElements()) + " elements)";
|
||||
selected.info->setText(info.c_str());
|
||||
} else {
|
||||
selected.info->setText("-");
|
||||
}
|
||||
|
||||
{
|
||||
MMFloor* floor = dynamic_cast<MMFloor*>(l);
|
||||
atHeight.lbl->setVisible(floor);
|
||||
atHeight.txt->setVisible(floor);
|
||||
height.lbl->setVisible(floor);
|
||||
height.txt->setVisible(floor);
|
||||
if (floor) {
|
||||
std::string _atHeight = std::to_string(floor->getFloor().atHeight);
|
||||
atHeight.txt->setText( _atHeight.c_str() );
|
||||
std::string _height = std::to_string(floor->getFloor().height);
|
||||
height.txt->setText( _height.c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
// has name
|
||||
{
|
||||
IHasName* elem = dynamic_cast<IHasName*>(l);
|
||||
name.lbl->setVisible(elem);
|
||||
name.txt->setVisible(elem);
|
||||
if (elem) {name.txt->setText(elem->getName().c_str());}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void LayerParamWidget::onAtHeightChanged() {
|
||||
MMFloor* floor = dynamic_cast<MMFloor*>(curElement);
|
||||
try {
|
||||
if (floor) {floor->getFloor().atHeight = std::stof(atHeight.txt->text().toStdString());}
|
||||
} catch (...) {;}
|
||||
}
|
||||
|
||||
void LayerParamWidget::onHeightChanged() {
|
||||
MMFloor* floor = dynamic_cast<MMFloor*>(curElement);
|
||||
try {
|
||||
if (floor) {floor->getFloor().height = std::stof(height.txt->text().toStdString());}
|
||||
} catch (...) {;}
|
||||
}
|
||||
|
||||
void LayerParamWidget::onNameChanged() {
|
||||
dynamic_cast<IHasName*>(curElement)->setName(name.txt->text().toStdString());
|
||||
}
|
||||
|
||||
|
||||
61
params/LayerParamWidget.h
Normal file
61
params/LayerParamWidget.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef LAYERPARAMWIDGET_H
|
||||
#define LAYERPARAMWIDGET_H
|
||||
|
||||
#include <QGroupBox>
|
||||
|
||||
class MapLayer;
|
||||
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
|
||||
class LayerParamWidget : public QGroupBox {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit LayerParamWidget(QWidget *parent = 0);
|
||||
|
||||
private:
|
||||
|
||||
MapLayer* curElement = nullptr;
|
||||
|
||||
struct {
|
||||
QLabel* info;
|
||||
QLabel* lbl;
|
||||
} selected;
|
||||
|
||||
struct {
|
||||
QLineEdit* txt;
|
||||
QLabel* lbl;
|
||||
} name;
|
||||
|
||||
struct {
|
||||
QLineEdit* txt;
|
||||
QLabel* lbl;
|
||||
} atHeight;
|
||||
|
||||
struct {
|
||||
QLineEdit* txt;
|
||||
QLabel* lbl;
|
||||
} height;
|
||||
|
||||
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
/** set the to-be-edited element */
|
||||
void setElement(MapLayer* l);
|
||||
|
||||
private slots:
|
||||
|
||||
void onAtHeightChanged();
|
||||
void onHeightChanged();
|
||||
void onNameChanged();
|
||||
|
||||
};
|
||||
|
||||
#endif // LAYERPARAMWIDGET_H
|
||||
174
params/ToolBox.cpp
Normal file
174
params/ToolBox.cpp
Normal file
@@ -0,0 +1,174 @@
|
||||
#include "ToolBoxWidget.h"
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include <QPushButton>
|
||||
#include <QPixmap>
|
||||
|
||||
#include "../mapview/model/MapLayers.h"
|
||||
|
||||
#include "../mapview/MapView2D.h"
|
||||
#include "../mapview/model/MapModel.h"
|
||||
#include "../mapview/model/MMFloorAccessPoint.h"
|
||||
#include "../mapview/model/MMFloorBeacon.h"
|
||||
|
||||
#include "../UIHelper.h"
|
||||
|
||||
ToolBoxWidget::ToolBoxWidget(MapView2D* view, QWidget *parent) : QWidget(parent), view(view) {
|
||||
|
||||
const int s = 32;
|
||||
setMaximumWidth(48);
|
||||
setMinimumWidth(48);
|
||||
|
||||
QGridLayout* lay = new QGridLayout(this);
|
||||
int r = 0;
|
||||
|
||||
// OBSTACLES
|
||||
btnGround = new QPushButton(UIHelper::getIcon("floor"), "");
|
||||
btnGround->setMinimumSize(s,s);
|
||||
lay->addWidget(btnGround, r++, 0, 1,1,Qt::AlignTop);
|
||||
connect(btnGround, SIGNAL(clicked(bool)), this, SLOT(onNewGround()));
|
||||
|
||||
btnWall = new QPushButton(UIHelper::getIcon("wall"), "");
|
||||
btnWall->setMinimumSize(s,s);
|
||||
lay->addWidget(btnWall, r++, 0, 1,1,Qt::AlignTop);
|
||||
connect(btnWall, SIGNAL(clicked(bool)), this, SLOT(onNewWall()));
|
||||
|
||||
btnPillar = new QPushButton(UIHelper::getIcon("pillar"), "");
|
||||
btnPillar->setMinimumSize(s,s);
|
||||
lay->addWidget(btnPillar, r++, 0, 1,1,Qt::AlignTop);
|
||||
connect(btnPillar, SIGNAL(clicked(bool)), this, SLOT(onNewPillar()));
|
||||
|
||||
// TRANSMITTERS
|
||||
btnWifi = new QPushButton(UIHelper::getIcon("wifi"), "");
|
||||
btnWifi->setMinimumSize(s,s);
|
||||
lay->addWidget(btnWifi, r++, 0, 1,1,Qt::AlignTop);
|
||||
connect(btnWifi, SIGNAL(clicked(bool)), this, SLOT(onNewAccessPoint()));
|
||||
|
||||
btnBeacon = new QPushButton(UIHelper::getIcon("beacon"), "");
|
||||
btnBeacon->setMinimumSize(s,s);
|
||||
lay->addWidget(btnBeacon, r++, 0, 1,1,Qt::AlignTop);
|
||||
connect(btnBeacon, SIGNAL(clicked(bool)), this, SLOT(onNewBeacon()));
|
||||
|
||||
// IMAGES
|
||||
btnImage = new QPushButton(UIHelper::getIcon("image"), "");
|
||||
btnImage->setMinimumSize(s,s);
|
||||
lay->addWidget(btnImage, r++, 0, 1,1,Qt::AlignTop);
|
||||
connect(btnImage, SIGNAL(clicked(bool)), this, SLOT(onNewImage()));
|
||||
|
||||
|
||||
// FILL
|
||||
lay->addItem(new QSpacerItem(0,0,QSizePolicy::Minimum, QSizePolicy::MinimumExpanding), r, 0);
|
||||
|
||||
// start empty
|
||||
setSelectedLayer(nullptr);
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::setSelectedLayer(MapLayer *ml) {
|
||||
|
||||
this->curLayer = ml;
|
||||
|
||||
btnGround->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_GROUND));
|
||||
|
||||
btnWall->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_OBSTACLES));
|
||||
btnPillar->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_OBSTACLES));
|
||||
|
||||
btnWifi->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_ACCESS_POINTS));
|
||||
btnBeacon->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_BEACONS));
|
||||
|
||||
btnImage->setEnabled(ml && (ml->getLayerType() == MapLayerType::FLOOR_UNDERLAY));
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ToolBoxWidget::onNewGround() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
float s = view->getScaler().sm(50);
|
||||
|
||||
Floorplan::FloorOutlinePolygon* poly = new Floorplan::FloorOutlinePolygon();
|
||||
poly->name = "new";
|
||||
poly->poly.points.push_back(Point2(center.x-s, center.y-s));
|
||||
poly->poly.points.push_back(Point2(center.x+s, center.y-s));
|
||||
poly->poly.points.push_back(Point2(center.x, center.y+s));
|
||||
|
||||
|
||||
MMFloorOutline* ml = (MMFloorOutline*)curLayer;
|
||||
ml->create(poly);
|
||||
|
||||
view->getModel()->reselect();
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewWall() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
float s = view->getScaler().sm(50);
|
||||
|
||||
Floorplan::FloorObstacleLine* wall = new Floorplan::FloorObstacleLine(
|
||||
Floorplan::ObstacleType::WALL,
|
||||
Floorplan::Material::DRYWALL,
|
||||
Point2(center.x-s, center.y),
|
||||
Point2(center.x+s, center.y)
|
||||
);
|
||||
|
||||
MMFloorObstacles* obs = (MMFloorObstacles*)curLayer;
|
||||
obs->createLine(wall);
|
||||
|
||||
view->getModel()->reselect();
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewPillar() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
float s = view->getScaler().sm(50);
|
||||
|
||||
Floorplan::FloorObstacleCircle* pillar = new Floorplan::FloorObstacleCircle(
|
||||
Floorplan::ObstacleType::PILLAR,
|
||||
Floorplan::Material::DRYWALL,
|
||||
Point2(center.x-s, center.y),
|
||||
s
|
||||
);
|
||||
|
||||
MMFloorObstacles* obs = (MMFloorObstacles*)curLayer;
|
||||
obs->createCircle(pillar);
|
||||
|
||||
view->getModel()->reselect();
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewAccessPoint() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
Floorplan::AccessPoint* ap = new Floorplan::AccessPoint(
|
||||
"noname", "00:00:00:00:00:00", Point3(center.x, center.y, 0)
|
||||
);
|
||||
|
||||
MMFloorAccessPoints* aps = (MMFloorAccessPoints*) curLayer;
|
||||
aps->createAP(ap);
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewBeacon() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
Floorplan::Beacon* b = new Floorplan::Beacon(
|
||||
"noname", "00:00:00:00:00:00", Point3(center.x, center.y, 0)
|
||||
);
|
||||
|
||||
MMFloorBeacons* beacons = (MMFloorBeacons*) curLayer;
|
||||
beacons->createBeacon(b);
|
||||
|
||||
}
|
||||
|
||||
void ToolBoxWidget::onNewImage() {
|
||||
|
||||
const Point2 center = view->getScaler().getCenter();
|
||||
|
||||
MMFloorUnderlay* underlay = (MMFloorUnderlay*) curLayer;
|
||||
underlay->createImage(center);
|
||||
|
||||
}
|
||||
53
params/ToolBoxWidget.h
Normal file
53
params/ToolBoxWidget.h
Normal file
@@ -0,0 +1,53 @@
|
||||
#ifndef TOOLBOX_H
|
||||
#define TOOLBOX_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class MapLayer;
|
||||
class QPushButton;
|
||||
class MapView2D;
|
||||
|
||||
class ToolBoxWidget : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit ToolBoxWidget(MapView2D* view, QWidget *parent = 0);
|
||||
|
||||
signals:
|
||||
|
||||
public slots:
|
||||
|
||||
/** set the currently selected map layer */
|
||||
void setSelectedLayer(MapLayer* ml);
|
||||
|
||||
private:
|
||||
|
||||
MapView2D* view;
|
||||
MapLayer* curLayer;
|
||||
|
||||
QPushButton* btnGround;
|
||||
QPushButton* btnWall;
|
||||
QPushButton* btnPillar;
|
||||
|
||||
QPushButton* btnWifi;
|
||||
QPushButton* btnBeacon;
|
||||
|
||||
QPushButton* btnImage;
|
||||
|
||||
private slots:
|
||||
|
||||
void onNewGround();
|
||||
void onNewWall();
|
||||
void onNewPillar();
|
||||
|
||||
void onNewAccessPoint();
|
||||
void onNewBeacon();
|
||||
|
||||
void onNewImage();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLBOX_H
|
||||
Reference in New Issue
Block a user