102 lines
2.1 KiB
C++
102 lines
2.1 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 TOOLNEWOUTLINE_H
|
||
#define TOOLNEWOUTLINE_H
|
||
|
||
#include "ToolNewElement.h"
|
||
#include "../../model/MMFloorOutline.h"
|
||
#include "../../model/MMFloorOutlinePolygon.h"
|
||
|
||
class ToolNewOutline : public ToolNewElement<Floorplan::FloorOutlinePolygon, MMFloorOutlinePolygon> {
|
||
|
||
private:
|
||
|
||
/** currently edited line node (has multiple) */
|
||
int idx = 0;
|
||
|
||
public:
|
||
|
||
ToolNewOutline(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
|
||
//create();
|
||
}
|
||
|
||
const std::string getName() const override {
|
||
return "new Outline";
|
||
}
|
||
|
||
void becomesActive() override {
|
||
emit onHelpTextChange("left-click for each edge of the outline. right-click to end");
|
||
}
|
||
|
||
|
||
|
||
/** 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;
|
||
|
||
// 1st click
|
||
if (idx == 0) {
|
||
createEmptyElement();
|
||
foEL->poly.points.resize(foEL->poly.points.size() + 1);
|
||
} else {
|
||
;
|
||
}
|
||
|
||
foEL->poly.points.resize(foEL->poly.points.size() + 1);
|
||
setPoint(idx, mapPoint); // current element (finished)
|
||
++idx;
|
||
setPoint(idx, mapPoint); // new element (start at the current)
|
||
|
||
emit onHelpTextChange("left-click to add, right-click to end");
|
||
|
||
}
|
||
|
||
void rightMouse(const Point2 mapPoint) override {
|
||
|
||
(void) mapPoint;
|
||
|
||
if (idx >= 3) {
|
||
finalizeCurrent();
|
||
} else {
|
||
deleteCurrent();
|
||
}
|
||
disableMe();
|
||
}
|
||
|
||
private:
|
||
|
||
void setPoint(const int idx, const Point2 mapPoint) {
|
||
foEL->poly.points[idx] = mapPoint;
|
||
}
|
||
|
||
void createEmptyElement() {
|
||
|
||
foEL = new Floorplan::FloorOutlinePolygon();
|
||
foEL->outdoor = false;
|
||
foEL->method = Floorplan::OutlineMethod::ADD;
|
||
|
||
MMFloorOutline* outlines = (MMFloorOutline*)layer;
|
||
mmEL = outlines->create(foEL);
|
||
|
||
}
|
||
|
||
};
|
||
|
||
#endif // TOOLNEWOUTLINE_H
|