add MapItemBase::renderHints
This commit is contained in:
@@ -4,7 +4,9 @@
|
|||||||
#include "osm_math_p.h"
|
#include "osm_math_p.h"
|
||||||
|
|
||||||
|
|
||||||
MapItemBase::MapItemBase() {}
|
MapItemBase::MapItemBase() {
|
||||||
|
m_hints = QPainter::Antialiasing | QPainter::SmoothPixmapTransform;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MapItemBase::~MapItemBase() {
|
MapItemBase::~MapItemBase() {
|
||||||
@@ -19,6 +21,18 @@ void MapItemBase::setInteracive(bool newInteracive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MapItemBase::setRenderHints(QPainter::RenderHints h) {
|
||||||
|
m_hints = h;
|
||||||
|
updateParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void MapItemBase::setRenderHint(QPainter::RenderHint h, bool on) {
|
||||||
|
m_hints.setFlag(h, on);
|
||||||
|
updateParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void MapItemBase::setVisible(bool newVisible) {
|
void MapItemBase::setVisible(bool newVisible) {
|
||||||
m_visible = newVisible;
|
m_visible = newVisible;
|
||||||
updateParent();
|
updateParent();
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
QAD - Qt ADvanced
|
QAD - Qt ADvanced
|
||||||
|
|
||||||
Ivan Pelipenko peri4ko@yandex.ru
|
Ivan Pelipenko peri4ko@yandex.ru
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU Lesser General Public License as published by
|
it under the terms of the GNU Lesser General Public License as published by
|
||||||
@@ -38,10 +38,13 @@ public:
|
|||||||
explicit MapItemBase();
|
explicit MapItemBase();
|
||||||
virtual ~MapItemBase();
|
virtual ~MapItemBase();
|
||||||
|
|
||||||
|
|
||||||
bool isInteracive() const { return m_interacive; }
|
bool isInteracive() const { return m_interacive; }
|
||||||
void setInteracive(bool newInteracive);
|
void setInteracive(bool newInteracive);
|
||||||
|
|
||||||
|
QPainter::RenderHints renderHints() const { return m_hints; }
|
||||||
|
void setRenderHints(QPainter::RenderHints h);
|
||||||
|
void setRenderHint(QPainter::RenderHint h, bool on = true);
|
||||||
|
|
||||||
bool isVisible() const { return m_visible; }
|
bool isVisible() const { return m_visible; }
|
||||||
void setVisible(bool newVisible);
|
void setVisible(bool newVisible);
|
||||||
bool isHidden() const { return !isVisible(); }
|
bool isHidden() const { return !isVisible(); }
|
||||||
@@ -97,6 +100,7 @@ private:
|
|||||||
QPointF m_position, m_scale = {1., 1.}, m_offset;
|
QPointF m_position, m_scale = {1., 1.}, m_offset;
|
||||||
QRectF m_bounding;
|
QRectF m_bounding;
|
||||||
QCursor m_cursor;
|
QCursor m_cursor;
|
||||||
|
QPainter::RenderHints m_hints;
|
||||||
QMap<int, QVariant> data_;
|
QMap<int, QVariant> data_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -320,8 +320,7 @@ void MapView::drawBackground() {
|
|||||||
|
|
||||||
void MapView::drawItems(QPainter & p) {
|
void MapView::drawItems(QPainter & p) {
|
||||||
auto src_tr = p.transform();
|
auto src_tr = p.transform();
|
||||||
p.setRenderHint(QPainter::Antialiasing);
|
QPainter::RenderHints cur_hints;
|
||||||
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
|
||||||
QPoint mouse = mapFromGlobal(QCursor::pos());
|
QPoint mouse = mapFromGlobal(QCursor::pos());
|
||||||
MapItemBase * hover = nullptr;
|
MapItemBase * hover = nullptr;
|
||||||
for (auto * i: items_) {
|
for (auto * i: items_) {
|
||||||
@@ -332,6 +331,10 @@ void MapView::drawItems(QPainter & p) {
|
|||||||
p.translate(i->m_offset.x(), -i->m_offset.y());
|
p.translate(i->m_offset.x(), -i->m_offset.y());
|
||||||
p.rotate(i->getRotation());
|
p.rotate(i->getRotation());
|
||||||
if (!i->ignore_scale) p.scale(i->getScale().x(), i->getScale().y());
|
if (!i->ignore_scale) p.scale(i->getScale().x(), i->getScale().y());
|
||||||
|
if (cur_hints != i->renderHints()) {
|
||||||
|
cur_hints = i->renderHints();
|
||||||
|
p.setRenderHints(cur_hints);
|
||||||
|
}
|
||||||
i->draw(&p);
|
i->draw(&p);
|
||||||
QTransform mtr;
|
QTransform mtr;
|
||||||
mtr.rotate(-i->getRotation());
|
mtr.rotate(-i->getRotation());
|
||||||
|
|||||||
Reference in New Issue
Block a user