added more cpp files for faster compile speeds

removed many obsolte elements
many improvements and fixes
This commit is contained in:
2018-07-20 15:00:43 +02:00
parent 7ee4e122e8
commit 5d002c3f2b
43 changed files with 1257 additions and 1361 deletions

View File

@@ -4,9 +4,7 @@
#include "MV2DElement.h"
#include "HasMoveableNodes.h"
#include "MapViewElementHelper.h"
#include <Indoor/floorplan/v2/Floorplan.h>
#include <stdio.h>
class MV2DElementFloorObstacleLine : public MV2DElement, public HasMoveableNodes {
@@ -17,90 +15,26 @@ private:
public:
/** ctor */
MV2DElementFloorObstacleLine(Floorplan::FloorObstacleLine* fo) : fo(fo) {;}
MV2DElementFloorObstacleLine(Floorplan::FloorObstacleLine* fo);
/** get the element's 3D bounding box */
BBox2 getBoundingBox() const override {
BBox2 bbox;
bbox.add(fo->from);
bbox.add(fo->to);
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 {
return MapElementHelper::getLineDistanceXY(fo->from, fo->to, p);
}
ClickDist getMinDistanceXY(const Point2 p) const override;
/** repaint me */
void paint(Painter& p) override {
void paint(Painter& p) override;
// selected endpoints?
if (hasFocus()) {
p.setPenBrush(Qt::NoPen, CFG::SEL_COLOR);
if (selectedUserIdx == 0) {p.drawCircle(fo->from);}
if (selectedUserIdx == 1) {p.drawCircle(fo->to);}
}
void onFocus() override;
// convert wall's thickness from meter to pixels
const float thickness_px = p.s.ms(fo->thickness_m);
void onUnfocus() override;
// remember the old pen
QPen pen = p.getPen();
virtual std::vector<MoveableNode> getMoveableNodes() const override;
// see notes within MapElementHelper!
// lines only get thicker, but not longer!
p.setPenBrush(MapElementHelper::getPen(fo->material, fo->type, hasFocus(), thickness_px), Qt::NoBrush);
p.drawLine(fo->from, fo->to);
void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override;
// reset the old pen
p.setPen(pen);
// available endpoints
if (hasFocus()) {
p.setPenBrush(Qt::black, Qt::NoBrush);
p.drawCircle(fo->from);
p.drawCircle(fo->to);
// obstacle length
p.setPenBrush(Qt::black, Qt::NoBrush);
p.drawLength(fo->from, fo->to, fo->from.getDistance(fo->to), thickness_px/2);
} else {
//p.setPenBrush(Qt::NoPen, Qt::black);
p.drawCircle_px(fo->from, 3);
p.drawCircle_px(fo->to, 3);
}
}
void onFocus() override {
;
}
void onUnfocus() override {
selectedUserIdx = -1; // clear selection
}
virtual std::vector<MoveableNode> getMoveableNodes() const override {
return {
MoveableNode(0, fo->from),
MoveableNode(1, fo->to)
};
}
void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
(void) v;
if (userIdx == 0) {fo->from.x = newPos.x; fo->from.y = newPos.y;}
if (userIdx == 1) {fo->to.x = newPos.x; fo->to.y = newPos.y;}
}
void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) {
(void) userIdx;
(void) newPos;
emit v->onElementChange(this);
}
void onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos);
};