added new param-editing to APs and Beacons
changed drawing for better debuging changed layer editing option to add and delete layers some minor changes
This commit is contained in:
@@ -37,7 +37,8 @@ SOURCES += \
|
||||
tree/MapTreeModel.cpp \
|
||||
mapview/3D/MapView3D.cpp \
|
||||
params/StairBuilder.cpp \
|
||||
mapview/2D/tools/Tools.cpp
|
||||
mapview/2D/tools/Tools.cpp \
|
||||
params/LayerTree.cpp
|
||||
|
||||
|
||||
HEADERS += MainWindow.h \
|
||||
@@ -125,7 +126,9 @@ HEADERS += MainWindow.h \
|
||||
mapview/2D/Scaler.h \
|
||||
mapview/2D/MV2DElementElevator.h \
|
||||
mapview/model/MMFloorElevators.h \
|
||||
mapview/model/MMFloorElevator.h
|
||||
mapview/model/MMFloorElevator.h \
|
||||
params/LayerTree.h \
|
||||
params/EditFields.h
|
||||
|
||||
|
||||
FORMS += MainWindow.ui
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "params/LayerParamWidget.h"
|
||||
#include "params/ToolBoxWidget.h"
|
||||
#include "params/ActionWidget.h"
|
||||
#include "params/LayerTree.h"
|
||||
|
||||
#include "tree/MapTreeModel.h"
|
||||
|
||||
@@ -32,7 +33,7 @@ MainController::MainController() {
|
||||
|
||||
MapView2D* mapView2D = mw->getMapView2D();
|
||||
MapView3D* mapView3D = mw->getMapView3D();
|
||||
QTreeView* layerTree = mw->getTree();
|
||||
LayerTree* layerTree = mw->getTree();
|
||||
|
||||
|
||||
// model setup
|
||||
@@ -58,7 +59,8 @@ MainController::MainController() {
|
||||
|
||||
|
||||
//connect(layerTree, SIGNAL(activated(QModelIndex)), this, SLOT(layerSelected(QModelIndex)));
|
||||
connect(layerTree->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(layerSelected(QModelIndex)));
|
||||
//connect(layerTree->getTree()->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(layerSelected(QModelIndex)));
|
||||
connect(layerTree, SIGNAL(layerSelected(QModelIndex)), this, SLOT(layerSelected(QModelIndex)));
|
||||
|
||||
connect(mapSelector, SIGNAL(onMapElementSelected(MapModelElement*)), this, SLOT(mapElementSelected(MapModelElement*)));
|
||||
connect(mw->getMapView2D(), SIGNAL(onElementChange(MV2DElement*)), this, SLOT(curMapElementChanged()));
|
||||
@@ -81,17 +83,20 @@ MainController::MainController() {
|
||||
connect(mw, &MainWindow::onGridShowEdges, [&] (const bool show) {mw->getMapView3D()->getGridRenderer()->setShowEdges(show);} );
|
||||
|
||||
|
||||
//mapModel->load("../IndoorMap/maps/SHL21.xml");
|
||||
//mapModel->load("../IndoorMap/maps/SHL25.xml");
|
||||
//mapModel->load("../IndoorMap/maps/test.xml");
|
||||
//mapModel->load("../IndoorMap/maps/APs.xml");
|
||||
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/CAR/CAR9.xml");
|
||||
mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UAH/UAH9.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UAH/UAH9.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UJI-TI/UJI-TI4.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/UJI-UB/UJI-UB4.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/Indoor/tests/data/WalkHeadingMap.xml");
|
||||
//mapModel->load("/mnt/data/workspaces/IPIN2016/IPIN2016/competition/maps/test.xml");
|
||||
//mapModel->load("/mnt/vm/workspace/IRGame/IndoorServer/maps/map6.xml");
|
||||
//mapModel->load("/mnt/vm/workspace/IRGame/IndoorServer/maps/keller.xml");
|
||||
|
||||
|
||||
//mapModel->startEmpty();
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "params/LayerParamWidget.h"
|
||||
#include "params/ActionWidget.h"
|
||||
#include "params/ToolBoxWidget.h"
|
||||
#include "params/LayerTree.h"
|
||||
|
||||
#include "tree/MapTreeModel.h"
|
||||
|
||||
@@ -39,7 +40,7 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
this->setStyleSheet(css);
|
||||
|
||||
{
|
||||
layerTree = new QTreeView();
|
||||
layerTree = new LayerTree();
|
||||
QString css;
|
||||
//css += "QTreeView::item:selected:active {background-color: #888888;}";
|
||||
//css += "QTreeView::item:selected:!active {background-color: #888888;}";
|
||||
@@ -140,6 +141,3 @@ MainWindow::~MainWindow() {
|
||||
}
|
||||
|
||||
|
||||
QTreeView* MainWindow::getTree() {
|
||||
return layerTree;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ class ElementParamWidget;
|
||||
class LayerParamWidget;
|
||||
class ActionWidget;
|
||||
class ToolBoxWidget;
|
||||
class LayerTree;
|
||||
|
||||
namespace Ui {
|
||||
class MainWindow;
|
||||
@@ -32,9 +33,7 @@ public:
|
||||
LayerParamWidget* getLayerParamWidget() {return layerParamWidget;}
|
||||
ToolBoxWidget* getToolBoxWidget() {return toolBoxWidget;}
|
||||
ActionWidget* getActionWidget() {return actionWidget;}
|
||||
|
||||
|
||||
QTreeView* getTree();
|
||||
LayerTree* getTree() {return layerTree;}
|
||||
|
||||
signals:
|
||||
|
||||
@@ -47,7 +46,7 @@ signals:
|
||||
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
QTreeView* layerTree;
|
||||
LayerTree* layerTree;
|
||||
MapView2D* mapView2D;
|
||||
MapView3D* mapView3D;
|
||||
ElementParamWidget* elementParamWidget;
|
||||
|
||||
20
main.cpp
20
main.cpp
@@ -11,6 +11,26 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
QApplication a(argc, argv);
|
||||
|
||||
QString str = R"(
|
||||
|
||||
QDockWidget {
|
||||
border: 1px solid #000;
|
||||
}
|
||||
|
||||
QDockWidget::title {
|
||||
text-align: left; /* align the text to the left */
|
||||
background: #ccc;
|
||||
padding: 1px;
|
||||
}
|
||||
|
||||
QDockWidget::title:hover {
|
||||
background: #bbb;
|
||||
}
|
||||
|
||||
)";
|
||||
|
||||
a.setStyleSheet(str);
|
||||
|
||||
MainController mc;
|
||||
mc.show();
|
||||
|
||||
|
||||
@@ -60,6 +60,10 @@ public:
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
p.drawCircle(fo->from);
|
||||
p.drawCircle(fo->to);
|
||||
} else {
|
||||
//p.setPenBrush(Qt::NoPen, Qt::black);
|
||||
p.drawCircle(fo->from, 0.1);
|
||||
p.drawCircle(fo->to, 0.1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -96,9 +96,19 @@ public:
|
||||
p.p->drawLine(mouseX, 0, mouseX, rs);
|
||||
|
||||
|
||||
|
||||
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
char buf[128];
|
||||
|
||||
// coordinates
|
||||
QRect ru(0,0,rs-1,rs-1);
|
||||
p.p->fillRect(ru, Qt::white);
|
||||
std::sprintf(buf, "%.1f", p.getScaler().xsm(this->mouseX));
|
||||
p.p->drawText(5,15, buf);
|
||||
std::sprintf(buf, "%.1f", p.getScaler().ysm(this->mouseY));
|
||||
p.p->drawText(5,30, buf);
|
||||
|
||||
// y-axis
|
||||
p.p->setClipRect(ry);
|
||||
for (float y = r.y0; y <= r.y1; y += step) {
|
||||
@@ -141,6 +151,8 @@ public:
|
||||
|
||||
p.p->setClipping(false);
|
||||
|
||||
|
||||
|
||||
// snapped dot
|
||||
const Point2 mouseOnScreen(mouseX, mouseY);
|
||||
const Point2 mouseInMap = p.s.sm(mouseOnScreen);
|
||||
|
||||
@@ -31,7 +31,7 @@ protected:
|
||||
glColor3f(1,1,1);
|
||||
break;
|
||||
case Floorplan::OutlineMethod::REMOVE:
|
||||
glColor3f(0.2, 0.2, 0.2);
|
||||
glColor3f(0.3, 0.3, 0.3);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,12 @@ void MapView3D::initializeGL() {
|
||||
|
||||
QGLWidget::initializeGL();
|
||||
|
||||
//glCullFace(GL_FRONT);
|
||||
glCullFace(GL_FRONT);
|
||||
//glDisable(GL_CULL_FACE);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
// culling, lighting, depth-test, ...
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
|
||||
@@ -25,13 +25,15 @@ class MMFloor : public MapLayer, public IHasParams {
|
||||
|
||||
private:
|
||||
|
||||
Floorplan::IndoorMap* map;
|
||||
|
||||
/** the underlying data-structure */
|
||||
Floorplan::Floor* floor;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor. existing floor */
|
||||
MMFloor(MapLayer* parent, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR), floor(floor) {
|
||||
MMFloor(MapLayer* parent, Floorplan::IndoorMap* map, Floorplan::Floor* floor) : MapLayer(parent, MapLayerType::FLOOR), map(map), floor(floor) {
|
||||
|
||||
new MMFloorUnderlays(this, floor);
|
||||
elements.push_back(new MMFloorOutline(this, floor));
|
||||
@@ -56,12 +58,14 @@ public:
|
||||
std::string getLayerName() const override {return floor->name;}
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 1;
|
||||
return 3;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("anem", ParamType::STRING);
|
||||
case 0: return Param("name", ParamType::STRING);
|
||||
case 1: return Param("height", ParamType::FLOAT);
|
||||
case 2: return Param("at height", ParamType::FLOAT);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
@@ -69,6 +73,8 @@ public:
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return floor->name;
|
||||
case 1: return floor->height;
|
||||
case 2: return floor->atHeight;
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
@@ -76,9 +82,16 @@ public:
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch(idx) {
|
||||
case 0: floor->name = val.toString(); break;
|
||||
case 1: floor->height = val.toFloat(); break;
|
||||
case 2: floor->atHeight = val.toFloat(); break;
|
||||
}
|
||||
}
|
||||
|
||||
void deleteMe() {
|
||||
parent->removeSublayer(this);
|
||||
map->floors.erase(std::remove(map->floors.begin(), map->floors.end(), floor), map->floors.end());
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOOR_H
|
||||
|
||||
@@ -26,7 +26,7 @@ public:
|
||||
}
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 3;
|
||||
return 6;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
@@ -34,6 +34,9 @@ public:
|
||||
case 0: return Param("name", ParamType::STRING);
|
||||
case 1: return Param("MAC", ParamType::STRING);
|
||||
case 2: return Param("Position", ParamType::POINT3);
|
||||
case 3: return Param("TXP", ParamType::FLOAT);
|
||||
case 4: return Param("EXP", ParamType::FLOAT);
|
||||
case 5: return Param("WAF", ParamType::FLOAT);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
@@ -43,6 +46,9 @@ public:
|
||||
case 0: return ap->name;
|
||||
case 1: return ap->mac;
|
||||
case 2: return ap->pos;
|
||||
case 3: return ap->model.txp;
|
||||
case 4: return ap->model.exp;
|
||||
case 5: return ap->model.waf;
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
@@ -52,6 +58,9 @@ public:
|
||||
case 0: ap->name = val.toString(); break;
|
||||
case 1: ap->mac = val.toString(); break;
|
||||
case 2: ap->pos = val.toPoint3(); break;
|
||||
case 3: ap->model.txp = val.toFloat(); break;
|
||||
case 4: ap->model.exp = val.toFloat(); break;
|
||||
case 5: ap->model.waf = val.toFloat(); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,14 +23,20 @@ public:
|
||||
}
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 3;
|
||||
return 9;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("name", ParamType::STRING);
|
||||
case 1: return Param("MAC", ParamType::STRING);
|
||||
case 2: return Param("Position", ParamType::POINT3);
|
||||
case 1: return Param("Position", ParamType::POINT3);
|
||||
case 2: return Param("MAC", ParamType::STRING);
|
||||
case 3: return Param("major", ParamType::STRING);
|
||||
case 4: return Param("minor", ParamType::STRING);
|
||||
case 5: return Param("UUDI", ParamType::STRING);
|
||||
case 6: return Param("TXP", ParamType::FLOAT);
|
||||
case 7: return Param("EXP", ParamType::FLOAT);
|
||||
case 8: return Param("WAF", ParamType::FLOAT);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
@@ -38,8 +44,14 @@ public:
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return b->name;
|
||||
case 1: return b->mac;
|
||||
case 2: return b->pos;
|
||||
case 1: return b->pos;
|
||||
case 2: return b->mac;
|
||||
case 3: return b->major;
|
||||
case 4: return b->minor;
|
||||
case 5: return b->uuid;
|
||||
case 6: return b->model.txp;
|
||||
case 7: return b->model.exp;
|
||||
case 8: return b->model.waf;
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
@@ -47,8 +59,14 @@ public:
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch(idx) {
|
||||
case 0: b->name = val.toString(); break;
|
||||
case 1: b->mac = val.toString(); break;
|
||||
case 2: b->pos = val.toPoint3(); break;
|
||||
case 1: b->pos = val.toPoint3(); break;
|
||||
case 2: b->mac = val.toString(); break;
|
||||
case 3: b->major = val.toString(); break;
|
||||
case 4: b->minor = val.toString(); break;
|
||||
case 5: b->uuid = val.toString(); break;
|
||||
case 6: b->uuid = val.toFloat(); break;
|
||||
case 7: b->uuid = val.toFloat(); break;
|
||||
case 8: b->uuid = val.toFloat(); break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
|
||||
#include "IHasMaterial.h"
|
||||
#include "IHasObstacleType.h"
|
||||
#include "IHasParams.h"
|
||||
|
||||
#include "../2D/MV2DElementFloorObstacleLine.h"
|
||||
#include "../3D/MV3DElementFloorObstacleWall.h"
|
||||
@@ -13,7 +14,7 @@
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
|
||||
class MMFloorObstacleLine : public MapModelElement, public IHasMaterial, public IHasObstacleType {
|
||||
class MMFloorObstacleLine : public MapModelElement, public IHasMaterial, public IHasObstacleType, public IHasParams {
|
||||
|
||||
public:
|
||||
|
||||
@@ -43,6 +44,31 @@ public:
|
||||
mf->obstacles.erase(std::remove(mf->obstacles.begin(), mf->obstacles.end(), fo), mf->obstacles.end());
|
||||
}
|
||||
|
||||
|
||||
virtual int getNumParams() const override {
|
||||
return 1;
|
||||
}
|
||||
|
||||
virtual Param getParamDesc(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return Param("length", ParamType::FLOAT, true);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual ParamValue getParamValue(const int idx) const override {
|
||||
switch(idx) {
|
||||
case 0: return fo->from.getDistance(fo->to);
|
||||
}
|
||||
throw 1;
|
||||
}
|
||||
|
||||
virtual void setParamValue(const int idx, const ParamValue& val) const override {
|
||||
switch(idx) {
|
||||
case 0: break;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MAPELEMENTOBSTACLE_H
|
||||
|
||||
@@ -22,7 +22,7 @@ public:
|
||||
|
||||
// add all floors
|
||||
for (Floorplan::Floor* floor : map->floors) {
|
||||
new MMFloor(this, floor);
|
||||
new MMFloor(this, map, floor);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,6 +32,22 @@ public:
|
||||
/** get the underlying model */
|
||||
Floorplan::IndoorMap* getMap() {return map;}
|
||||
|
||||
MMFloor* createFloor() {
|
||||
|
||||
// add to underlying model
|
||||
Floorplan::Floor* floor = new Floorplan::Floor();
|
||||
floor->name = "floor";
|
||||
map->floors.push_back(floor);
|
||||
|
||||
// add to UI model
|
||||
MMFloor* mmfloor = new MMFloor(this, map, floor);
|
||||
//elements.push_back(mmfloor);
|
||||
|
||||
return mmfloor;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // MMFLOORS_H
|
||||
|
||||
@@ -78,6 +78,8 @@ public:
|
||||
/** remove the given element from the elements list */
|
||||
void removeElement(const MapModelElement* elem) { elements.erase(std::remove(elements.begin(), elements.end(), elem), elements.end()); }
|
||||
|
||||
/** remove the given sublayer from this layer */
|
||||
void removeSublayer(const MapLayer* layer) { sublayers.erase(std::remove(sublayers.begin(), sublayers.end(), layer), sublayers.end()); }
|
||||
|
||||
/** is this layer currently visible? */
|
||||
bool isVisible() const {return visible;}
|
||||
@@ -101,7 +103,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
public:
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -42,6 +42,13 @@ public:
|
||||
cleanup();
|
||||
}
|
||||
|
||||
/** create a new, empty root node */
|
||||
void startEmpty() {
|
||||
im = new Floorplan::IndoorMap();
|
||||
root = new MMRoot(nullptr, im);
|
||||
//root->addSublayer(new MMFloors(root, im));
|
||||
}
|
||||
|
||||
void cleanup() {
|
||||
selLayer = nullptr;
|
||||
//selElements.clear();
|
||||
|
||||
143
params/EditFields.h
Normal file
143
params/EditFields.h
Normal file
@@ -0,0 +1,143 @@
|
||||
#ifndef EDITFIELDS_H
|
||||
#define EDITFIELDS_H
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QLineEdit>
|
||||
#include "../mapview/model/IHasParams.h"
|
||||
|
||||
class EditFields {
|
||||
|
||||
public:
|
||||
|
||||
static void get(QGridLayout* lay, IHasParams* elem) {
|
||||
|
||||
int r = 0;
|
||||
|
||||
for(int i = 0; i < elem->getNumParams(); ++i) {
|
||||
|
||||
const Param param = elem->getParamDesc(i);
|
||||
const ParamValue value = elem->getParamValue(i);
|
||||
|
||||
// skip Not-Available entries
|
||||
if (param.type == ParamType::NOT_AVAILABLE) {continue;}
|
||||
|
||||
lay->addWidget(new QLabel(param.name.c_str()),r,0);
|
||||
|
||||
switch(param.type) {
|
||||
|
||||
case ParamType::BOOL: {
|
||||
QCheckBox* chk = new QCheckBox( );
|
||||
chk->setChecked(value.toBool());
|
||||
if (param.readOnly) {
|
||||
chk->setEnabled(false);
|
||||
} else {
|
||||
chk->connect(chk, &QCheckBox::clicked, [i,elem] (const bool checked) {
|
||||
elem->setParamValue(i, ParamValue(checked));
|
||||
});
|
||||
}
|
||||
lay->addWidget(chk,r,1);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::FLOAT: {
|
||||
const std::string str = std::to_string(value.toFloat());
|
||||
if (param.readOnly) {
|
||||
lay->addWidget(new QLabel(str.c_str()),r,1);
|
||||
} else {
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
le->connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const float val = str.toFloat();
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::INT: {
|
||||
const std::string str = std::to_string(value.toInt());
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
le->connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
const int val = str.toInt();
|
||||
elem->setParamValue(i, ParamValue(val));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::STRING: {
|
||||
const std::string str = value.toString();
|
||||
QLineEdit* le = new QLineEdit( str.c_str() );
|
||||
le->connect(le, &QLineEdit::textChanged, [i,elem] (const QString& str) {
|
||||
elem->setParamValue(i, ParamValue(str.toStdString()));
|
||||
});
|
||||
lay->addWidget(le,r,1);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::FILE: {
|
||||
const std::string str = value.toString();
|
||||
QLabel* lblFile = new QLabel(str.c_str());
|
||||
QPushButton* btn = new QPushButton("<");
|
||||
btn->setMaximumSize(32,32);
|
||||
btn->connect(btn, &QPushButton::clicked, [i,elem,lblFile] (const bool checked) {
|
||||
QString res = QFileDialog::getOpenFileName();
|
||||
elem->setParamValue(i, ParamValue(res.toStdString()));
|
||||
lblFile->setText(res);
|
||||
});
|
||||
lay->addWidget(lblFile,r,1);
|
||||
lay->addWidget(btn,r,2);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::POINT2: {
|
||||
const Point2 p2 = value.toPoint2();
|
||||
QWidget* subWidget = new QWidget();
|
||||
QGridLayout* laySub = new QGridLayout(subWidget); laySub->setMargin(0);
|
||||
QLineEdit* txtX = new QLineEdit(QString::number(p2.x));
|
||||
QLineEdit* txtY = new QLineEdit(QString::number(p2.y));
|
||||
laySub->addWidget(txtX,0,0);
|
||||
laySub->addWidget(txtY,0,1);
|
||||
lay->addWidget(subWidget,r,1);
|
||||
auto onChange = [i,elem,txtX,txtY] (const QString& str) {
|
||||
elem->setParamValue(i, ParamValue( Point2(txtX->text().toFloat(), txtY->text().toFloat()) ));
|
||||
};
|
||||
txtX->connect(txtX, &QLineEdit::textChanged, onChange);
|
||||
txtY->connect(txtY, &QLineEdit::textChanged, onChange);
|
||||
break;
|
||||
}
|
||||
|
||||
case ParamType::POINT3: {
|
||||
const Point3 p3 = value.toPoint3();
|
||||
QWidget* subWidget = new QWidget();
|
||||
QGridLayout* laySub = new QGridLayout(subWidget); laySub->setMargin(0);
|
||||
QLineEdit* txtX = new QLineEdit(QString::number(p3.x));
|
||||
QLineEdit* txtY = new QLineEdit(QString::number(p3.y));
|
||||
QLineEdit* txtZ = new QLineEdit(QString::number(p3.z));
|
||||
laySub->addWidget(txtX,0,0);
|
||||
laySub->addWidget(txtY,0,1);
|
||||
laySub->addWidget(txtZ,0,2);
|
||||
lay->addWidget(subWidget,r,1);
|
||||
auto onChange = [i,elem,txtX,txtY,txtZ] (const QString& str) {
|
||||
(void) str;
|
||||
elem->setParamValue(i, ParamValue( Point3(txtX->text().toFloat(), txtY->text().toFloat(), txtZ->text().toFloat()) ));
|
||||
};
|
||||
txtX->connect(txtX, &QLineEdit::textChanged, onChange);
|
||||
txtY->connect(txtY, &QLineEdit::textChanged, onChange);
|
||||
txtZ->connect(txtZ, &QLineEdit::textChanged, onChange);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
++r;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // EDITFIELDS_H
|
||||
@@ -68,11 +68,14 @@ ElementParamWidget::ElementParamWidget(QWidget *parent) : QWidget(parent) {
|
||||
|
||||
this->lay = new QGridLayout(this);
|
||||
|
||||
setMinimumSize(100, 100);
|
||||
setMaximumWidth(250);
|
||||
//setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
|
||||
//lay->setSizeConstraint(QLayout::SetMinAndMaxSize);
|
||||
setMinimumSize(200, 25);
|
||||
setMaximumSize(200, 9999);
|
||||
//setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding);
|
||||
|
||||
//setTitle("MapElement Parameters");
|
||||
QGridLayout* lay = new QGridLayout();
|
||||
lay = new QGridLayout();
|
||||
|
||||
// start empty
|
||||
setElement(nullptr);
|
||||
@@ -90,7 +93,6 @@ void ElementParamWidget::refresh() {
|
||||
|
||||
while ( QWidget* w = this->findChild<QWidget*>() ) {delete w;}
|
||||
delete this->layout();
|
||||
|
||||
this->lay = new QGridLayout();
|
||||
this->setLayout(lay);
|
||||
int r = 0;
|
||||
@@ -269,8 +271,20 @@ void ElementParamWidget::refresh() {
|
||||
}
|
||||
}
|
||||
|
||||
//setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
||||
//lay->setSizeConstraint(QLayout::SetMinimumSize);
|
||||
//setLayout(lay);
|
||||
setMinimumSize(150, 30+r*24);
|
||||
setMaximumSize(250, 30+r*24);
|
||||
//resize(100, 20+r*22);
|
||||
//emit update();
|
||||
//setVisible(false);
|
||||
//setVisible(true);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ElementParamWidget::onMaterialChange() {
|
||||
IHasMaterial* el = dynamic_cast<IHasMaterial*>(this->curElement);
|
||||
if (el) {el->setMaterial( (Floorplan::Material) material.cmb->currentData().toInt() );}
|
||||
|
||||
@@ -21,6 +21,7 @@ public:
|
||||
/** refresh the currently selected element */
|
||||
void refresh();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
QGridLayout* lay;
|
||||
|
||||
@@ -7,13 +7,15 @@
|
||||
#include "mapview/model/IHasName.h"
|
||||
#include "mapview/model/MMFloor.h"
|
||||
|
||||
#include "EditFields.h"
|
||||
|
||||
LayerParamWidget::LayerParamWidget(QWidget *parent) : QWidget(parent) {
|
||||
|
||||
setMinimumSize(100, 100);
|
||||
setMinimumSize(100, 50);
|
||||
setMaximumWidth(250);
|
||||
//setTitle("MapLayer Parameters");
|
||||
|
||||
QGridLayout* lay = new QGridLayout(this);
|
||||
lay = new QGridLayout(this);
|
||||
int r = 0;
|
||||
|
||||
|
||||
@@ -53,35 +55,50 @@ 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("-");
|
||||
}
|
||||
// if (l) {
|
||||
// std::string info = l->getLayerName() + " (" + std::to_string(l->getNumElements()) + " elements)";
|
||||
// selected.info->setText(info.c_str());
|
||||
// } else {
|
||||
// selected.info->setText("-");
|
||||
// }
|
||||
|
||||
while ( QWidget* w = this->findChild<QWidget*>() ) {delete w;}
|
||||
delete this->layout();
|
||||
this->lay = new QGridLayout();
|
||||
this->setLayout(lay);
|
||||
int r = 0;
|
||||
|
||||
|
||||
// {
|
||||
// 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());}
|
||||
// }
|
||||
|
||||
|
||||
{
|
||||
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() );
|
||||
IHasParams* elem = dynamic_cast<IHasParams*>(l);
|
||||
if (elem) {
|
||||
EditFields::get(lay, elem);
|
||||
}
|
||||
}
|
||||
|
||||
// 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());}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,11 +8,16 @@ class MapLayer;
|
||||
class QLabel;
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
class QGridLayout;
|
||||
|
||||
class LayerParamWidget : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
private:
|
||||
|
||||
QGridLayout* lay;
|
||||
|
||||
public:
|
||||
|
||||
explicit LayerParamWidget(QWidget *parent = 0);
|
||||
|
||||
92
params/LayerTree.cpp
Normal file
92
params/LayerTree.cpp
Normal file
@@ -0,0 +1,92 @@
|
||||
#include "LayerTree.h"
|
||||
|
||||
#include <QTreeView>
|
||||
#include <QPushButton>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include "../tree/MapTreeModel.h"
|
||||
#include "../UIHelper.h"
|
||||
|
||||
LayerTree::LayerTree(QWidget *parent) : QWidget(parent) {
|
||||
|
||||
QGridLayout* layGrid = new QGridLayout(this);
|
||||
|
||||
tree = new QTreeView(this);
|
||||
tree->setMinimumSize(150, 200);
|
||||
|
||||
QWidget* wButtons = new QWidget();
|
||||
QHBoxLayout* layButtons = new QHBoxLayout(wButtons);
|
||||
|
||||
btnNew = new QPushButton(this);
|
||||
btnNew->setIcon(UIHelper::getIcon("add"));
|
||||
btnNew->setMaximumSize(32,32);
|
||||
btnNew->setMinimumSize(32,32);
|
||||
btnNew->setEnabled(false);
|
||||
layButtons->addWidget(btnNew);
|
||||
|
||||
|
||||
btnDelete = new QPushButton(this);
|
||||
btnDelete->setIcon(UIHelper::getIcon("remove"));
|
||||
btnDelete->setMaximumSize(32,32);
|
||||
btnDelete->setMinimumSize(32,32);
|
||||
btnDelete->setEnabled(false);
|
||||
layButtons->addWidget(btnDelete);
|
||||
|
||||
layGrid->addWidget(tree, 0,0,1,1);
|
||||
layGrid->addWidget(wButtons, 1, 0, 1, 1);
|
||||
|
||||
connect(btnNew, SIGNAL(clicked(bool)), this, SLOT(onBtnNew()));
|
||||
connect(btnDelete, SIGNAL(clicked(bool)), this, SLOT(onBtnDelete()));
|
||||
|
||||
|
||||
}
|
||||
|
||||
void LayerTree::expandAll() {
|
||||
tree->expandAll();
|
||||
}
|
||||
|
||||
void LayerTree::setModel(MapTreeModel* model) {
|
||||
|
||||
this->model = model;
|
||||
this->tree->setModel(model);
|
||||
|
||||
// tree model selection events
|
||||
if (!connect(tree->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(onLayerSelected(QModelIndex)))) {throw "error";}
|
||||
|
||||
}
|
||||
|
||||
void LayerTree::onLayerSelected(QModelIndex idx) {
|
||||
|
||||
MapLayer* ml = static_cast<MapLayer*>(idx.internalPointer());
|
||||
|
||||
MMFloors* floors = dynamic_cast<MMFloors*>(ml);
|
||||
btnNew->setEnabled( floors != nullptr );
|
||||
|
||||
MMFloor* floor = dynamic_cast<MMFloor*>(ml);
|
||||
btnDelete->setEnabled( floor != nullptr );
|
||||
|
||||
emit layerSelected(idx);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void LayerTree::onBtnNew() {
|
||||
QModelIndex idx = tree->selectionModel()->selectedIndexes().first();
|
||||
MapLayer* ml = static_cast<MapLayer*>(idx.internalPointer());
|
||||
MMFloors* floors = dynamic_cast<MMFloors*>(ml);
|
||||
if (floors) {
|
||||
floors->createFloor();
|
||||
model->getMapModel()->reset();
|
||||
}
|
||||
}
|
||||
|
||||
void LayerTree::onBtnDelete() {
|
||||
QModelIndex idx = tree->selectionModel()->selectedIndexes().first();
|
||||
MapLayer* ml = static_cast<MapLayer*>(idx.internalPointer());
|
||||
MMFloor* floor= dynamic_cast<MMFloor*>(ml);
|
||||
if (floor) {
|
||||
floor->deleteMe();
|
||||
model->getMapModel()->reset();
|
||||
}
|
||||
}
|
||||
49
params/LayerTree.h
Normal file
49
params/LayerTree.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef LAYERTREE_H
|
||||
#define LAYERTREE_H
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
class QTreeView;
|
||||
class QPushButton;
|
||||
class MapTreeModel;
|
||||
|
||||
#include <QModelIndex>
|
||||
|
||||
class LayerTree : public QWidget {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
explicit LayerTree(QWidget *parent = 0);
|
||||
|
||||
//QTreeView* getTree() const {return tree;}
|
||||
|
||||
void setModel(MapTreeModel* model);
|
||||
|
||||
void expandAll();
|
||||
|
||||
signals:
|
||||
|
||||
void layerSelected(QModelIndex);
|
||||
|
||||
private slots:
|
||||
|
||||
void onLayerSelected(QModelIndex);
|
||||
|
||||
void onBtnNew();
|
||||
|
||||
void onBtnDelete();
|
||||
|
||||
private:
|
||||
|
||||
QTreeView* tree;
|
||||
QPushButton* btnNew;
|
||||
QPushButton* btnDelete;
|
||||
MapTreeModel* model;
|
||||
|
||||
public slots:
|
||||
|
||||
};
|
||||
|
||||
#endif // LAYERTREE_H
|
||||
2
res.qrc
2
res.qrc
@@ -14,5 +14,7 @@
|
||||
<file>res/icons/door.svg</file>
|
||||
<file>res/icons/cursor.svg</file>
|
||||
<file>res/icons/elevator.svg</file>
|
||||
<file>res/icons/add.svg</file>
|
||||
<file>res/icons/remove.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
||||
42
res/icons/add.svg
Normal file
42
res/icons/add.svg
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="510px" height="510px" viewBox="0 0 510 510" style="enable-background:new 0 0 510 510;" xml:space="preserve">
|
||||
<g>
|
||||
<g id="add-circle">
|
||||
<path d="M255,0C114.75,0,0,114.75,0,255s114.75,255,255,255s255-114.75,255-255S395.25,0,255,0z M382.5,280.5h-102v102h-51v-102
|
||||
h-102v-51h102v-102h51v102h102V280.5z"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 871 B |
42
res/icons/remove.svg
Normal file
42
res/icons/remove.svg
Normal file
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
width="510px" height="510px" viewBox="0 0 510 510" style="enable-background:new 0 0 510 510;" xml:space="preserve">
|
||||
<g>
|
||||
<g id="remove-circle">
|
||||
<path d="M255,0C114.75,0,0,114.75,0,255s114.75,255,255,255s255-114.75,255-255S395.25,0,255,0z M382.5,280.5h-255v-51h255V280.5z
|
||||
"/>
|
||||
</g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
<g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 840 B |
8
res/icons/sources.txt
Normal file
8
res/icons/sources.txt
Normal file
@@ -0,0 +1,8 @@
|
||||
www.flaticon.com
|
||||
https://icons8.com/web-app/for/all/Ibeacon
|
||||
|
||||
|
||||
# add
|
||||
http://www.flaticon.com/free-icon/add-button-inside-black-circle_60740
|
||||
# remove
|
||||
http://www.flaticon.com/free-icon/rounded-remove-button_60951#term=remove%20button&page=1&position=6
|
||||
@@ -25,6 +25,10 @@ public:
|
||||
|
||||
virtual ~MapTreeModel() {;}
|
||||
|
||||
MapModel* getMapModel() {
|
||||
return mdl;
|
||||
}
|
||||
|
||||
virtual QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override {
|
||||
|
||||
MapLayer* _parent = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user