This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
IndoorMap/mapview/2D/MV2DElementFloorObstacleCircle.cpp
2018-10-25 12:15:13 +02:00

92 lines
2.4 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* © Copyright 2014 Urheberrechtshinweis
* Alle Rechte vorbehalten / All Rights Reserved
*
* Programmcode ist urheberrechtlich geschuetzt.
* Das Urheberrecht liegt, soweit nicht ausdruecklich anders gekennzeichnet, bei Frank Ebner.
* Keine Verwendung ohne explizite Genehmigung.
* (vgl. § 106 ff UrhG / § 97 UrhG)
*/
#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;
}