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/ToolNewElevator.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.1 KiB
C++

#ifndef TOOLNEWELEVATOR_H
#define TOOLNEWELEVATOR_H
#include "ToolNewElement.h"
#include "../../model/MMFloorElevators.h"
class ToolNewElevator : public ToolNewElement<Floorplan::Elevator, MMFloorElevator> {
private:
/** currently edited line node (has multiple) */
int idx = 0;
Point2 p1;
Point2 p2;
Point2 p3;
public:
ToolNewElevator(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
;
}
void becomesActive() override {
//create(); // start adding an new element
showHelp();
}
void becomesInactive() override {
deleteCurrent(); // delete the currently pending and not yet finished elevator
}
const std::string getName() const override {
return "new Elevator";
}
/** 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;
if (idx == 0) {
createEmptyElement();
setPoint(idx, mapPoint);
++idx;
} else if (idx == 1) {
setPoint(idx, mapPoint);
++idx;
} else if (idx == 2) {
setPoint(idx, mapPoint);
finalizeCurrent();
disableMe();
idx = 0;
}
showHelp();
}
void rightMouse(const Point2 mapPoint) override {
(void) mapPoint;
}
void showHelp() {
switch (idx) {
case 0: emit onHelpTextChange("click at the right side of the elevator's door"); break;
case 1: emit onHelpTextChange("click at the left side of the elevator's door"); break;
case 2: emit onHelpTextChange("click at the left backside of the elevator"); break;
}
}
private:
void createEmptyElement() {
foEL = new Floorplan::Elevator();
MMFloorElevators* elevators = (MMFloorElevators*)layer;
mmEL = elevators->create(foEL);
}
void setPoint(const int idx, const Point2 mapPoint) {
if (idx == 0) {
p1 = mapPoint;
p2 = mapPoint;
p3 = mapPoint;
} else if (idx == 1) {
p2 = mapPoint;
p3 = mapPoint;
} else if (idx == 2) {
p3 = mapPoint;
}
foEL->center = (p1+p3)/2;
foEL->width = p1.getDistance(p2);
foEL->depth = p2.getDistance(p3);
foEL->rotation = std::atan2(p2.y-p1.y, p2.x-p1.x);
}
};
#endif // TOOLNEWELEVATOR_H