a lot of work on th map-creator

This commit is contained in:
2016-07-04 15:11:10 +02:00
parent 6243165084
commit 2935f468fc
61 changed files with 2612 additions and 3342 deletions

View File

@@ -2,6 +2,7 @@
#define PAINTER_H
#include <QPainter>
#include <QBitmap>
#include <Indoor/geo/Point2.h>
#include <Indoor/geo/Point3.h>
@@ -36,6 +37,17 @@ public:
p->drawLine(s.xms(p1.x), s.yms(p1.y), s.xms(p2.x), s.yms(p2.y));
}
float radToDeg(const float rad) const {
return rad * 180 / M_PI;
}
void drawArc(const Point2 center, const float radius, const float startAngleRad, const float spanAngleRad) {
const float wh = s.ms(radius) * 2;
const float x1 = s.xms(center.x) - wh/2;
const float y1 = s.yms(center.y) - wh/2;
p->drawArc(x1, y1, wh, wh, radToDeg(startAngleRad)*16, radToDeg(spanAngleRad)*16);
}
void drawCircle(const Point3 center) {
int r = 5;
p->drawEllipse(s.xms(center.x)-r, s.yms(center.y)-r, 2*r, 2*r);
@@ -46,6 +58,11 @@ public:
p->drawEllipse(s.xms(center.x)-r, s.yms(center.y)-r, 2*r, 2*r);
}
void drawDot(const Point2 center) {
int r = 1;
p->drawEllipse(s.xms(center.x)-r, s.yms(center.y)-r, 2*r, 2*r);
}
void drawCircle(const Point2 center, const float size_m) {
int r = s.ms(size_m);
p->drawEllipse(s.xms(center.x)-r, s.yms(center.y)-r, 2*r, 2*r);
@@ -55,14 +72,23 @@ public:
p->drawLine(s.xms(x1), s.yms(y1), s.xms(x2), s.yms(y2));
}
void drawRect(const Point2 p1, const Point2 p2) {
drawRect(p1.x, p1.y, p2.x, p2.y);
}
void drawRect(const float x1, const float y1, const float x2, const float y2) {
float w = x2-x1;
float h = y1-y2;
p->drawRect(s.xms(x1), s.yms(y1), s.ms(w), s.ms(h));
}
void drawRect(const Point2 center) {
float r = s.sm(5); // 5 pixel
drawRect(center-Point2(r,r), center+Point2(r,r));
}
void drawText(const Point2 pos, const std::string& text) {
p->drawText(s.xms(pos.x), s.xms(pos.y), text.c_str());
p->drawText(s.xms(pos.x), s.yms(pos.y), text.c_str());
}
void drawPolygon(const std::vector<Point2>& points) {
@@ -80,6 +106,14 @@ public:
p->drawPolygon(vec.data(), vec.size());
}
void drawPixmap(const Point2 pt, const QPixmap& img) {
p->drawPixmap(s.xms(pt.x)-img.width()/2, s.yms(pt.y)-img.height()/2, img);
}
void drawImage(const Point2 pt, const QImage& img) {
p->drawImage(s.xms(pt.x)-img.width()/2, s.yms(pt.y)-img.height()/2, img);
}
void setBrush(const QBrush& brush) { p->setBrush(brush); }
void setBrush(const Qt::BrushStyle& brush) { p->setBrush(brush); }