95 lines
1.9 KiB
C++
95 lines
1.9 KiB
C++
/*
|
||
* © 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 TOOLNEWWALL_H
|
||
#define TOOLNEWWALL_H
|
||
|
||
#include "ToolNewElement.h"
|
||
#include "../../model/MMFloorObstacles.h"
|
||
#include "../../model/MMFloorObstacleWall.h"
|
||
|
||
/** new walls */
|
||
class ToolNewWall : public ToolNewElement<Floorplan::FloorObstacleWall, MMFloorObstacleWall> {
|
||
|
||
private:
|
||
|
||
/** currently edited line node (has 2) */
|
||
int idx = 0;
|
||
|
||
public:
|
||
|
||
ToolNewWall(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||
;
|
||
}
|
||
|
||
void becomesActive() override {
|
||
//create(); // start adding an new element
|
||
}
|
||
|
||
void becomesInactive() override {
|
||
deleteCurrent(); // delete the currently pending and not yet finished wall element
|
||
}
|
||
|
||
const std::string getName() const override {
|
||
return "new Wall";
|
||
}
|
||
|
||
|
||
|
||
/** mouse is currently moved */
|
||
void moving(const Point2 mapPoint) override {
|
||
|
||
// live-moving of the ending point
|
||
if (idx == 1) { foEL->to = mapPoint; }
|
||
|
||
}
|
||
|
||
/** next point */
|
||
void leftMouse(const Point2 mapPoint) override {
|
||
|
||
// 1st click (where to start the line)
|
||
if (idx == 0) {
|
||
createEmptyElement();
|
||
foEL->from = mapPoint; foEL->to = mapPoint;
|
||
++idx;
|
||
|
||
// 2nd click (wehere the line ends)
|
||
} else if (idx == 1) {
|
||
finalizeCurrent();
|
||
idx = 0;
|
||
if (!addAnother) {disableMe();}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
void rightMouse(const Point2 mapPoint) override {
|
||
|
||
(void) mapPoint;
|
||
finalizeCurrent();
|
||
disableMe();
|
||
|
||
}
|
||
|
||
private:
|
||
|
||
void createEmptyElement() {
|
||
|
||
foEL = new Floorplan::FloorObstacleWall(Floorplan::ObstacleType::WALL, Floorplan::Material::DRYWALL, Point2(0, 0), Point2(0, 0));
|
||
MMFloorObstacles* obs = (MMFloorObstacles*)layer;
|
||
mmEL = obs->createWall(foEL);
|
||
|
||
}
|
||
|
||
};
|
||
|
||
|
||
#endif // TOOLNEWWALL_H
|