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
2018-10-25 12:23:40 +02:00

87 lines
1.7 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 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