initial commit
This commit is contained in:
71
mapview/tools/ToolMapGrid.h
Normal file
71
mapview/tools/ToolMapGrid.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef TOOLMAPGRID_H
|
||||
#define TOOLMAPGRID_H
|
||||
|
||||
#include "Tool.h"
|
||||
|
||||
class ToolMapGrid : public Tool {
|
||||
|
||||
public:
|
||||
|
||||
void paintBefore(MapView2D* m, Painter& p) override {
|
||||
|
||||
(void) m;
|
||||
|
||||
static const QColor cB(250,250,250);
|
||||
static const QColor cN(235,235,235);
|
||||
static const QColor c0(128,128,128);
|
||||
|
||||
int w = p.width();
|
||||
int h = p.height();
|
||||
|
||||
// grid-size
|
||||
const float step = p.getScaler().getLODstep();
|
||||
const float sStep = step/5;
|
||||
|
||||
// map-region visible on the screen
|
||||
const Rect r = p.getScaler().getMapVisible(w, h, step);
|
||||
|
||||
// x-lines
|
||||
for (float x = r.x0; x < r.x1; x += step) {
|
||||
|
||||
// major-lines (without center)
|
||||
if (std::abs(x) > 0.001) {
|
||||
p.setPenBrush(cN, Qt::NoBrush);
|
||||
p.drawLine(x, r.y0, x, r.y1);
|
||||
}
|
||||
|
||||
// minor-lines
|
||||
p.setPenBrush(cB, Qt::NoBrush);
|
||||
for (float x1 = x+sStep; x1 < x+step; x1 += sStep) {
|
||||
p.drawLine(x1, r.y0, x1, r.y1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// y-lines
|
||||
for (float y = r.y0; y < r.y1; y += step) {
|
||||
|
||||
// major-lines (without center)
|
||||
if (std::abs(y) > 0.001) {
|
||||
p.setPenBrush(cN, Qt::NoBrush);
|
||||
p.drawLine(r.x0, y, r.x1, y);
|
||||
}
|
||||
|
||||
// minor-lines
|
||||
p.setPenBrush(cB, Qt::NoBrush);
|
||||
for (float y1 = y+sStep; y1 < y+step; y1 += sStep) {
|
||||
p.drawLine(r.x0, y1, r.x1, y1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// thick center lines
|
||||
p.setPenBrush(c0, Qt::NoBrush);
|
||||
p.drawLine(0, r.y0, 0, r.y1);
|
||||
p.drawLine(r.x0, 0, r.x1, 0);
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif // TOOLMAPGRID_H
|
||||
Reference in New Issue
Block a user