Merge branch 'master' of https://git.frank-ebner.de/FHWS/IndoorMap
This commit is contained in:
@@ -53,13 +53,14 @@ public:
|
||||
switch (fo.method) {
|
||||
case Floorplan::OutlineMethod::ADD:
|
||||
brush.setStyle(Qt::BrushStyle::SolidPattern);
|
||||
brush.setColor(QColor(0,0,0,24));
|
||||
brush.setColor( fo.outdoor ? QColor(0,255,0,32) : QColor(0,0,0,24) ); // outdoor = green
|
||||
break;
|
||||
case Floorplan::OutlineMethod::REMOVE:
|
||||
brush.setStyle(Qt::BrushStyle::DiagCrossPattern);
|
||||
brush.setColor(QColor(0,0,0));
|
||||
break;
|
||||
default:
|
||||
// should not happen
|
||||
brush.setStyle(Qt::BrushStyle::SolidPattern);
|
||||
brush.setColor(QColor(255,0,0));
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
|
||||
// if the to-be-displayed image is smaller than the input-one, use a pre-computed downscaled version
|
||||
if (scaledArea < origArea) {
|
||||
if (scaledArea < origArea*0.75) {
|
||||
// does the cached downscaled image needs rebuild? (size changed)
|
||||
if (imgScaled.width() != sw || imgScaled.height() != sh) {
|
||||
imgScaled = img.scaled(sw, sh, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
119
mapview/2D/MV2DElementGroundTruthPoint.h
Normal file
119
mapview/2D/MV2DElementGroundTruthPoint.h
Normal file
@@ -0,0 +1,119 @@
|
||||
#ifndef MV2DELEMENTGROUNDTRUTHPOINT_H
|
||||
#define MV2DELEMENTGROUNDTRUTHPOINT_H
|
||||
|
||||
#include "MV2DElement.h"
|
||||
#include "HasMoveableNodes.h"
|
||||
#include "MapViewElementHelper.h"
|
||||
#include <Indoor/floorplan/v2/Floorplan.h>
|
||||
|
||||
#include "../../UIHelper.h"
|
||||
|
||||
class MV2DElementGroundTruthPoint : public MV2DElement, public HasMoveableNodes {
|
||||
|
||||
private:
|
||||
|
||||
//bool sel = false;
|
||||
Floorplan::GroundTruthPoint* gtp;
|
||||
|
||||
public:
|
||||
|
||||
/** ctor with the AP to render/edit */
|
||||
MV2DElementGroundTruthPoint(Floorplan::GroundTruthPoint* gtp) : gtp(gtp) {;}
|
||||
|
||||
|
||||
/** get the element's 3D bounding box */
|
||||
BBox2 getBoundingBox() const override {
|
||||
BBox2 bbox;
|
||||
bbox.add(Point2(gtp->pos.x, gtp->pos.y));
|
||||
bbox.grow(Point2(0.1, 0.1));
|
||||
return bbox;
|
||||
}
|
||||
|
||||
/** get the element's minimal distance (nearest whatsoever) to the given point */
|
||||
ClickDist getMinDistanceXY(const Point2 p) const override {
|
||||
return ClickDist(p.getDistance(gtp->pos), ClickDistType::DIRECT);
|
||||
}
|
||||
|
||||
/** repaint me */
|
||||
void paint(Painter& p) override {
|
||||
|
||||
static const QPixmap& pixmapUnfocused = UIHelper::getPixmapColored("gtp", CFG::UNFOCUS_COLOR, 16);
|
||||
static const QPixmap& pixmapFocused = UIHelper::getPixmapColored("gtp", CFG::FOCUS_COLOR, 16);
|
||||
static const QPixmap& pixmapSel = UIHelper::getPixmapColored("gtp", CFG::SEL_COLOR, 16);
|
||||
|
||||
|
||||
if (selectedUserIdx == 0) {
|
||||
// p.setPenBrush(Qt::black, CFG::SEL_COLOR);
|
||||
// p.drawCircle(gtp->pos);
|
||||
p.drawPixmap(gtp->pos, pixmapSel);
|
||||
} else if (hasFocus()) {
|
||||
// p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
// p.drawCircle(gtp->pos);
|
||||
p.drawPixmap(gtp->pos, pixmapFocused);
|
||||
} else {
|
||||
// p.setPenBrush(Qt::gray, Qt::NoBrush);
|
||||
// p.drawCircle(gtp->pos);
|
||||
p.drawPixmap(gtp->pos, pixmapUnfocused);
|
||||
}
|
||||
|
||||
// label
|
||||
p.setPenBrush(Qt::black, Qt::NoBrush);
|
||||
p.drawDot(gtp->pos);
|
||||
if (p.getScaler().getScale() >= 10) {
|
||||
const std::string str = std::to_string(gtp->id);
|
||||
p.p->drawText(p.getScaler().xms(gtp->pos.x) + 10, p.getScaler().yms(gtp->pos.y) + 5, str.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
virtual std::vector<MoveableNode> getMoveableNodes() const override {
|
||||
return { MoveableNode(0, gtp->pos) };
|
||||
}
|
||||
|
||||
virtual void onNodeMove(MapView2D* v, const int userIdx, const Point2 newPos) override {
|
||||
(void) v;
|
||||
if (userIdx == 0) {gtp->pos = newPos;}
|
||||
}
|
||||
|
||||
|
||||
/** mouse pressed at the given point */
|
||||
virtual void mousePressed(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
}
|
||||
|
||||
/** mouse moved to the given point */
|
||||
virtual void mouseMove(MapView2D* v, const Point2 p) override {
|
||||
(void) v;
|
||||
(void) p;
|
||||
// if (sel) {
|
||||
// const Point2 p = v->getScaler().snap(_p);
|
||||
// gtp->pos.x = p.x;
|
||||
// gtp->pos.y = p.y;
|
||||
// }
|
||||
}
|
||||
|
||||
/** mouse released */
|
||||
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 {
|
||||
;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // MV2DELEMENTGROUNDTRUTHPOINT_H
|
||||
@@ -299,12 +299,47 @@ private:
|
||||
return true;
|
||||
}
|
||||
|
||||
if (e->key() == Qt::Key_Up || e->key() == Qt::Key_Down || e->key() == Qt::Key_Left || e->key() == Qt::Key_Right) {
|
||||
moveNodes(m, focused, e->key());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void moveNodes(MapView2D* v, MapModelElement* focused, const int key) {
|
||||
|
||||
MV2DElement* me = focused->getMV2D();
|
||||
if (!me) {return;}
|
||||
|
||||
HasMoveableNodes* elem = dynamic_cast<HasMoveableNodes*>(me);
|
||||
if (!elem) {return;}
|
||||
|
||||
// no node selected? -> done
|
||||
if (elem->getSelectedNode() == -1) {return;}
|
||||
|
||||
// get current value
|
||||
MoveableNode& node = elem->getMoveableNodes()[elem->getSelectedNode()];
|
||||
Point2 pos = node.pos;
|
||||
|
||||
// adjust the node
|
||||
switch(key) {
|
||||
case Qt::Key_Up: pos.y += 0.1; break;
|
||||
case Qt::Key_Down: pos.y -= 0.1; break;
|
||||
case Qt::Key_Left: pos.x -= 0.1; break;
|
||||
case Qt::Key_Right: pos.x += 0.1; break;
|
||||
}
|
||||
|
||||
// snap the position
|
||||
pos = v->getScaler().snap(pos);
|
||||
|
||||
// move
|
||||
elem->onNodeMove(v, elem->getSelectedNode(), pos);
|
||||
|
||||
}
|
||||
|
||||
signals:
|
||||
|
||||
/** map element was selected */
|
||||
|
||||
Reference in New Issue
Block a user