fixed some issues

improvied editing
changed toolbox
This commit is contained in:
2017-03-20 19:25:23 +01:00
parent 92e279aefc
commit b7ee7d992a
18 changed files with 583 additions and 262 deletions

View File

@@ -0,0 +1,85 @@
#ifndef TOOLNEWELEVATOR_H
#define TOOLNEWELEVATOR_H
#include "ToolNewElement.h"
#include "../../model/MMFloorElevators.h"
class ToolNewElevator : public ToolNewElement<Floorplan::Elevator, MMFloorElevator> {
private:
/** currently edited line node (has multiple) */
int idx = 0;
Point2 p1;
Point2 p2;
Point2 p3;
public:
ToolNewElevator(Tools& tools, MapLayer* layer) : ToolNewElement(tools, layer) {
create();
}
const std::string getName() const override {
return "new Elevator";
}
void becomesActive() override {
showHelp();
}
void createEmptyElement() override {
foEL = new Floorplan::Elevator();
MMFloorElevators* elevators = (MMFloorElevators*)layer;
mmEL = elevators->create(foEL);
}
/** mouse is currently moved */
void moving(const Point2 mapPoint) override {
if (idx == 0) {
p1 = mapPoint;
p2 = mapPoint;
p3 = mapPoint;
} else if (idx == 1) {
p2 = mapPoint;
p3 = mapPoint;
} else if (idx == 2) {
p3 = mapPoint;
}
foEL->center = (p1+p3)/2;
foEL->width = p1.getDistance(p2);
foEL->depth = p2.getDistance(p3);
foEL->rotation = std::atan2(p2.y-p1.y, p2.x-p1.x);
}
/** next point */
void leftMouse() override {
++idx;
if (idx == 3) {
finalizeCurrent();
disableMe();
}
showHelp();
}
void rightMouse() override {
;
}
void showHelp() {
switch (idx) {
case 0: emit onHelpTextChange("click at the right side of the elevator's door"); break;
case 1: emit onHelpTextChange("click at the left side of the elevator's door"); break;
case 2: emit onHelpTextChange("click at the left backside of the elevator"); break;
}
}
};
#endif // TOOLNEWELEVATOR_H