added more cpp files for faster compile speeds
removed many obsolte elements many improvements and fixes
This commit is contained in:
@@ -4,11 +4,8 @@
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
|
||||
#include "MapViewElementHelper.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include "../../UIHelper.h"
|
||||
|
||||
class MV2DElementElevator : public MV2DElement, public HasMoveableNodes {
|
||||
|
||||
private:
|
||||
@@ -20,117 +17,26 @@ private:
|
||||
public:
|
||||
|
||||
/** ctor with the AP to render/edit */
|
||||
MV2DElementElevator(Floorplan::IndoorMap* map, Floorplan::Floor* floor, Floorplan::Elevator* elevator) : map(map), floor(floor), elevator(elevator) {;}
|
||||
MV2DElementElevator(Floorplan::IndoorMap* map, Floorplan::Floor* floor, Floorplan::Elevator* elevator);
|
||||
|
||||
|
||||
BBox2 getBoundingBox() const override {
|
||||
BBox2 bbox;
|
||||
const float max = std::max(elevator->width, elevator->depth);
|
||||
bbox.add(Point2(elevator->center.x, elevator->center.y));
|
||||
bbox.grow(Point2(max/2, max/2));
|
||||
return bbox;
|
||||
}
|
||||
BBox2 getBoundingBox() const override;
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override {
|
||||
// std::vector<Point2> points = elevator->getPoints().points;
|
||||
// points.push_back(elevator->center);
|
||||
// auto it minEl = std::min_element(points.begin(), points.end(),
|
||||
return ClickDist(p.getDistance(elevator->center), ClickDistType::DIRECT);
|
||||
}
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override;
|
||||
|
||||
/** repaint me */
|
||||
void paint(Painter& p) override {
|
||||
void paint(Painter& p) override;
|
||||
|
||||
// area
|
||||
const Floorplan::Polygon2 poly = elevator->getPoints();
|
||||
p.setPenBrush(Qt::gray, Qt::lightGray);
|
||||
p.drawPolygon(poly.points);
|
||||
virtual std::vector<MoveableNode> getMoveableNodes() const override;
|
||||
|
||||
// outline
|
||||
QPen pen; pen.setWidth(2); pen.setColor(QColor(0,0,0));
|
||||
virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override;
|
||||
|
||||
if (!elevatorEndConnected(map, floor, elevator)) {pen.setColor(QColor(255,0,0));}
|
||||
if (elevator->height_m == 0) {pen.setColor(QColor(255,0,0));}
|
||||
void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override;
|
||||
|
||||
p.setPenBrush(pen, Qt::NoBrush);
|
||||
//p.drawLine(poly.points[0], poly.points[1]);
|
||||
p.drawLine(poly.points[1], poly.points[2]);
|
||||
p.drawLine(poly.points[2], poly.points[3]);
|
||||
p.drawLine(poly.points[3], poly.points[0]);
|
||||
virtual void onFocus() override;
|
||||
|
||||
if (selectedUserIdx == 0) {
|
||||
p.setPenBrush(Qt::black, CFG::SEL_COLOR);
|
||||
p.drawCircle(elevator->center);
|
||||
} else if (hasFocus()) {
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
p.drawCircle(elevator->center);
|
||||
} else {
|
||||
//p.setPenBrush(Qt::gray, Qt::NoBrush);
|
||||
//p.drawCircle(elevator->center);
|
||||
p.drawCircle_px(elevator->center, 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** is the given elevator's end connected to ANY of the floorplan's floors? */
|
||||
static inline bool elevatorEndConnected(const Floorplan::IndoorMap* map, const Floorplan::Floor* floor, const Floorplan::Elevator* e) {
|
||||
const int elevatorEnd_cm = std::round( (floor->atHeight + e->height_m) * 100 );
|
||||
std::vector<int> floorsAtHeight_cm;
|
||||
for (const Floorplan::Floor* f : map->floors) {
|
||||
const int height_cm = std::round(f->atHeight*100);
|
||||
floorsAtHeight_cm.push_back(height_cm);
|
||||
}
|
||||
const bool connected = std::find(floorsAtHeight_cm.begin(), floorsAtHeight_cm.end(), elevatorEnd_cm) != floorsAtHeight_cm.end();
|
||||
return connected;
|
||||
}
|
||||
|
||||
virtual std::vector<MoveableNode> getMoveableNodes() const override {
|
||||
return { MoveableNode(0, elevator->center) };
|
||||
}
|
||||
|
||||
virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
|
||||
(void) v;
|
||||
if (userIdx == 0) {elevator->center.x = newPos.x; elevator->center.y = newPos.y;}
|
||||
}
|
||||
|
||||
void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) override {
|
||||
(void) userIdx;
|
||||
(void) newPos;
|
||||
emit v->onElementChange(this);
|
||||
}
|
||||
|
||||
|
||||
virtual void mousePressed(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual void mouseMove(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual void mouseReleased(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
virtual bool keyPressEvent(MapView2D* v, QKeyEvent *e) override {
|
||||
(void) v;
|
||||
(void) e;
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void onFocus() override {
|
||||
;
|
||||
}
|
||||
|
||||
virtual void onUnfocus() override {
|
||||
;
|
||||
}
|
||||
virtual void onUnfocus() override;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // MV2DELEMENTELEVATOR_H
|
||||
|
||||
Reference in New Issue
Block a user