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/2D/tools/ToolNewStair.h
2018-10-25 12:23:40 +02:00

124 lines
2.5 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)
*/
#ifndef TOOLNEWSTAIR_H
#define TOOLNEWSTAIR_H
#include "ToolNewElement.h"
#include "../../model/MMFloorStairs.h"
class ToolNewStair : public ToolNewElement<Floorplan::StairFreeform, MMFloorStair> {
private:
/** currently edited line node (has multiple) */
int idx = 0;
public:
ToolNewStair(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
;
}
void becomesActive() override {
//create(); // start adding an new element
emit onHelpTextChange("click for the stair's starting point");
}
void becomesInactive() override {
deleteCurrent(); // delete the currently pending and not yet finished stair
}
const std::string getName() const override {
return "new Stair";
}
/** mouse is currently moved */
void moving(const Point2 mapPoint) override {
if (idx > 0) {
setPoint(idx, mapPoint);
}
}
/** next point */
void leftMouse(const Point2 mapPoint) override {
(void) mapPoint;
// start a new stair here
if (idx == 0) {
createEmptyElement();
} else {
;
}
// add a new part to the stair
Floorplan::StairPart sp;
sp.connectWithPrev = false;
sp.width = 1.5;
foEL->parts.push_back(sp);
setPoint(idx, mapPoint); // current element (finished)
++idx;
setPoint(idx, mapPoint); // new element (start at the current)
emit onHelpTextChange("right-click: set end + start new part, left-click set end + finish");
}
void rightMouse(const Point2 mapPoint) override {
(void) mapPoint;
finalizeCurrent();
disableMe();
idx = 0;
}
private:
void setPoint(const int idx, const Point2 mapPoint) {
if (idx == 0) {
Floorplan::StairPart& part = foEL->parts[0];
part.start = Point3(mapPoint.x, mapPoint.y, 0);
part.end = part.start;
} else if (idx == 1) {
Floorplan::StairPart& part = foEL->parts[0];
part.end = Point3(mapPoint.x, mapPoint.y, 0);
} else if (idx > 1) {
Floorplan::StairPart& p1 = foEL->parts[idx-2];
Floorplan::StairPart& p2 = foEL->parts[idx-1];
p2.start = p1.end;
p2.end = Point3(mapPoint.x, mapPoint.y, 0);
}
}
void createEmptyElement() {
foEL = new Floorplan::StairFreeform();
MMFloorStairs* stairs = (MMFloorStairs*)layer;
mmEL = stairs->create(foEL);
}
};
#endif // TOOLNEWSTAIR_H