initial commit
This commit is contained in:
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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user