fixed some issues
improvied editing changed toolbox
This commit is contained in:
85
mapview/2D/tools/ToolNewElevator.h
Normal file
85
mapview/2D/tools/ToolNewElevator.h
Normal 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
|
||||
Reference in New Issue
Block a user