82 lines
2.1 KiB
C++
82 lines
2.1 KiB
C++
#include "MV2DElementFloorObstacleCircle.h"
|
|
|
|
#include "MV2DElement.h"
|
|
#include "MapViewElementHelper.h"
|
|
#include <Indoor/floorplan/v2/Floorplan.h>
|
|
|
|
MV2DElementFloorObstacleCircle::MV2DElementFloorObstacleCircle(Floorplan::FloorObstacleCircle* c) : c(c) {
|
|
;
|
|
}
|
|
|
|
BBox2 MV2DElementFloorObstacleCircle::getBoundingBox() const {
|
|
BBox2 bbox;
|
|
bbox.add(c->center);
|
|
bbox.grow(Point2(c->radius, c->radius));
|
|
return bbox;
|
|
}
|
|
|
|
ClickDist MV2DElementFloorObstacleCircle::getMinDistanceXY(const Point2 p) const {
|
|
return ClickDist(p.getDistance(c->center), ClickDistType::DIRECT);
|
|
}
|
|
|
|
void MV2DElementFloorObstacleCircle::paint(Painter& p) {
|
|
|
|
QPen pen;// = MapElementHelper::getPen(c->material, c->type, hasFocus());
|
|
|
|
p.setPenBrush(pen, Qt::NoBrush);
|
|
p.drawCircle(c->center, c->radius);
|
|
|
|
//QBrush brush = MapElementHelper::getBru(c->material, c->type, _focused);
|
|
|
|
// // selected endpoints?
|
|
// if (hasFocus()) {
|
|
// p.setPenBrush(Qt::NoPen, CFG::SEL_COLOR);
|
|
// if (selPoint == 0) {p.drawCircle(getSelPoints()[0]);}
|
|
// if (selPoint == 1) {p.drawCircle(getSelPoints()[1]);}
|
|
// }
|
|
|
|
// // available endpoints
|
|
// if (hasFocus()) {
|
|
// p.setPenBrush(Qt::black, Qt::NoBrush);
|
|
// p.drawCircle(getSelPoints()[0]);
|
|
// p.drawCircle(getSelPoints()[1]);
|
|
// }
|
|
|
|
}
|
|
|
|
std::vector<MoveableNode> MV2DElementFloorObstacleCircle::getMoveableNodes() const {
|
|
return {
|
|
MoveableNode(0, c->center),
|
|
MoveableNode(1, c->center+Point2(c->radius,0))
|
|
};
|
|
}
|
|
|
|
void MV2DElementFloorObstacleCircle::onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) {
|
|
(void) v;
|
|
switch(userIdx) {
|
|
case 0: c->center.x = newPos.x; c->center.y = newPos.y; break;
|
|
case 1: c->radius = newPos.getDistance(c->center); break;
|
|
}
|
|
}
|
|
|
|
void MV2DElementFloorObstacleCircle::onNodeMoved(MapView2D* v, const int userIdx, const Point2 newPos) {
|
|
(void) userIdx;
|
|
(void) newPos;
|
|
emit v->onElementChange(this);
|
|
}
|
|
|
|
//std::vector<Point2> MV2DElementFloorObstacleCircle::getSelPoints() const {
|
|
// return {c->center, (c->center + Point2(c->radius,0))};
|
|
//}
|
|
|
|
void MV2DElementFloorObstacleCircle::onFocus() {
|
|
;
|
|
}
|
|
|
|
void MV2DElementFloorObstacleCircle::onUnfocus() {
|
|
selPoint = -1;
|
|
}
|
|
|
|
|
|
|