#ifndef TOOLNEWDOOR_H #define TOOLNEWDOOR_H #include "ToolNewElement.h" class ToolNewDoor : public ToolNewElement { 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