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/ToolNewDoor.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

77 lines
1.4 KiB
C++

#ifndef TOOLNEWDOOR_H
#define TOOLNEWDOOR_H
#include "ToolNewElement.h"
class ToolNewDoor : public ToolNewElement<Floorplan::FloorObstacleDoor, MMFloorObstacleDoor> {
private:
/** currently edited line node (has 2) */
int idx = 0;
public:
ToolNewDoor(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
//create();
}
const std::string getName() const override {
return "new Door";
}
/** 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);
finalizeCurrent();
idx = 0;
if (!addAnother) {disableMe();}
}
}
void rightMouse(const Point2 mapPoint) override {
(void) mapPoint;
finalizeCurrent();
disableMe();
}
private:
void createEmptyElement() {
foEL = new Floorplan::FloorObstacleDoor(Floorplan::DoorType::SWING, Floorplan::Material::WOOD, Point2(0, 0), Point2(0, 0));
MMFloorObstacles* obs = (MMFloorObstacles*)layer;
mmEL = obs->createDoor(foEL);
}
void setPoint(const int idx, const Point2 mapPoint) {
if (idx == 0) { foEL->from = mapPoint; foEL->to = mapPoint; }
if (idx == 1) { foEL->to = mapPoint; }
}
};
#endif // TOOLNEWDOOR_H