added "new map" button
fixed minor model/logic issues
This commit is contained in:
@@ -81,7 +81,8 @@ MainController::MainController() {
|
|||||||
connect(mapModel, SIGNAL(reset()), this, SLOT(onMapModelReset()));
|
connect(mapModel, SIGNAL(reset()), this, SLOT(onMapModelReset()));
|
||||||
mapModel->addListener(this);
|
mapModel->addListener(this);
|
||||||
|
|
||||||
// load/save
|
// new/load/save
|
||||||
|
connect(mw->getActionWidget(), SIGNAL(onNew()), this, SLOT(onNew()));
|
||||||
connect(mw->getActionWidget(), SIGNAL(onLoad()), this, SLOT(onLoad()));
|
connect(mw->getActionWidget(), SIGNAL(onLoad()), this, SLOT(onLoad()));
|
||||||
connect(mw->getActionWidget(), SIGNAL(onSave()), this, SLOT(onSave()));
|
connect(mw->getActionWidget(), SIGNAL(onSave()), this, SLOT(onSave()));
|
||||||
|
|
||||||
@@ -96,6 +97,8 @@ MainController::MainController() {
|
|||||||
|
|
||||||
|
|
||||||
mapModel->load("../IndoorMap/maps/SHL38_no_elev.xml");
|
mapModel->load("../IndoorMap/maps/SHL38_no_elev.xml");
|
||||||
|
//mapModel->load("/apps/android/workspace/testmap.xml");
|
||||||
|
|
||||||
//mapModel->resize(0.983, 0.983, 1, -0.2, -0.3, 0);
|
//mapModel->resize(0.983, 0.983, 1, -0.2, -0.3, 0);
|
||||||
|
|
||||||
|
|
||||||
@@ -168,6 +171,8 @@ void MainController::onMapModelAboutToReset() {
|
|||||||
mw->getLayerParamWidget()->setElement(nullptr);
|
mw->getLayerParamWidget()->setElement(nullptr);
|
||||||
mw->getToolBoxWidget()->setSelectedLayer(nullptr);
|
mw->getToolBoxWidget()->setSelectedLayer(nullptr);
|
||||||
mw->getMapView2D()->update();
|
mw->getMapView2D()->update();
|
||||||
|
mw->getMapView3D()->update();
|
||||||
|
//mw->getToolBoxWidget()->
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainController::onMapModelNeedsRepaint() {
|
void MainController::onMapModelNeedsRepaint() {
|
||||||
@@ -180,6 +185,14 @@ void MainController::onMapModelReset() {
|
|||||||
mw->getLINT()->update(mapModel->getMap());
|
mw->getLINT()->update(mapModel->getMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MainController::onNew() {
|
||||||
|
const int res = QMessageBox::question(nullptr, "New Map", "really start a new map?", QMessageBox::Yes, QMessageBox::No);
|
||||||
|
if (res == QMessageBox::Yes) {
|
||||||
|
mapModel->startEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainController::onLoad() {
|
void MainController::onLoad() {
|
||||||
QString file = QFileDialog::getOpenFileName(mw, "open a map");
|
QString file = QFileDialog::getOpenFileName(mw, "open a map");
|
||||||
if (file != "") {
|
if (file != "") {
|
||||||
|
|||||||
@@ -55,9 +55,8 @@ public slots:
|
|||||||
/** the currently selected MapElement has changed */
|
/** the currently selected MapElement has changed */
|
||||||
void curMapElementChanged();
|
void curMapElementChanged();
|
||||||
|
|
||||||
|
void onNew();
|
||||||
void onLoad();
|
void onLoad();
|
||||||
|
|
||||||
void onSave();
|
void onSave();
|
||||||
|
|
||||||
void onMapModelAboutToReset();
|
void onMapModelAboutToReset();
|
||||||
|
|||||||
@@ -181,8 +181,10 @@ private:
|
|||||||
// set the currently focused object (if any)
|
// set the currently focused object (if any)
|
||||||
focused = el;
|
focused = el;
|
||||||
|
|
||||||
// focus the new one (if any)
|
// focus the new one (if any, and focus supported)
|
||||||
if (focused) {focused->getMV2D()->focus();}
|
if (focused && focused->getMV2D()) {
|
||||||
|
focused->getMV2D()->focus();
|
||||||
|
}
|
||||||
|
|
||||||
// update the help-text
|
// update the help-text
|
||||||
showHelp();
|
showHelp();
|
||||||
|
|||||||
@@ -185,12 +185,21 @@ void MapView3D::showFloorplan() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MapView3D::showGrid() {
|
void MapView3D::showGrid() {
|
||||||
|
|
||||||
|
// delete the previous grid (if any)
|
||||||
if (gridModel) {delete gridModel; gridModel = nullptr;}
|
if (gridModel) {delete gridModel; gridModel = nullptr;}
|
||||||
|
|
||||||
|
// build a new model
|
||||||
GridModel* gm = new GridModel();
|
GridModel* gm = new GridModel();
|
||||||
Floorplan::IndoorMap* im = getModel()->getMap();
|
Floorplan::IndoorMap* im = getModel()->getMap();
|
||||||
gm->rebuild(im);
|
gm->rebuild(im);
|
||||||
|
|
||||||
|
// remember
|
||||||
this->gridModel = gm;
|
this->gridModel = gm;
|
||||||
|
|
||||||
|
// update UI
|
||||||
update();
|
update();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MapView3D::draw() {
|
void MapView3D::draw() {
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ class GridModel {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int gridSize_cm = 20;
|
int gridSize_cm = 30; // TODO
|
||||||
|
|
||||||
Grid<MyNode> grid;
|
Grid<MyNode> grid;
|
||||||
Floorplan::IndoorMap* im;
|
Floorplan::IndoorMap* im;
|
||||||
|
|
||||||
|
|||||||
@@ -53,10 +53,17 @@ public:
|
|||||||
|
|
||||||
/** create a new, empty root node */
|
/** create a new, empty root node */
|
||||||
void startEmpty() {
|
void startEmpty() {
|
||||||
|
|
||||||
|
emit aboutToReset();
|
||||||
|
cleanup();
|
||||||
|
|
||||||
im = new Floorplan::IndoorMap();
|
im = new Floorplan::IndoorMap();
|
||||||
root = new MMRoot(nullptr, im);
|
root = new MMRoot(nullptr, im);
|
||||||
root->addListener(this);
|
root->addListener(this);
|
||||||
//root->addSublayer(new MMFloors(root, im));
|
//root->addSublayer(new MMFloors(root, im));
|
||||||
|
|
||||||
|
emit reset();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup() {
|
void cleanup() {
|
||||||
|
|||||||
@@ -7,15 +7,21 @@ ActionWidget::ActionWidget(QWidget *parent) : QWidget(parent) {
|
|||||||
|
|
||||||
QHBoxLayout* lay = new QHBoxLayout(this);
|
QHBoxLayout* lay = new QHBoxLayout(this);
|
||||||
|
|
||||||
|
|
||||||
|
QPushButton* btnNew = new QPushButton("new");
|
||||||
|
lay->addWidget(btnNew);
|
||||||
|
|
||||||
QPushButton* btnLoad = new QPushButton("load");
|
QPushButton* btnLoad = new QPushButton("load");
|
||||||
lay->addWidget(btnLoad);
|
lay->addWidget(btnLoad);
|
||||||
|
|
||||||
QPushButton* btnSave = new QPushButton("save");
|
QPushButton* btnSave = new QPushButton("save");
|
||||||
lay->addWidget(btnSave);
|
lay->addWidget(btnSave);
|
||||||
|
|
||||||
|
// events
|
||||||
|
connect(btnNew, SIGNAL(clicked(bool)), this, SIGNAL(onNew()));
|
||||||
|
|
||||||
connect(btnLoad, SIGNAL(clicked(bool)), this, SIGNAL(onLoad()));
|
connect(btnLoad, SIGNAL(clicked(bool)), this, SIGNAL(onLoad()));
|
||||||
|
|
||||||
connect(btnSave, SIGNAL(clicked(bool)), this, SIGNAL(onSave()));
|
connect(btnSave, SIGNAL(clicked(bool)), this, SIGNAL(onSave()));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,10 +13,15 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
/** request: load a map */
|
||||||
void onLoad();
|
void onLoad();
|
||||||
|
|
||||||
|
/** request: save a map */
|
||||||
void onSave();
|
void onSave();
|
||||||
|
|
||||||
|
/** request: new map */
|
||||||
|
void onNew();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user