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
kazu 7a23001b82 fixed some issues
added new tools for creating APs, Beacons, GTP, POI, Fingerprints
fixed selection issue
changed new-element creation
added missing layer parameters
2017-06-01 16:26:09 +02:00

114 lines
2.2 KiB
C++

#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