mirror of
https://github.com/tumic0/QtPBFImagePlugin.git
synced 2024-11-23 19:25:55 +01:00
Optimization/code cleanup
This commit is contained in:
parent
a023975b41
commit
37290e231a
@ -394,7 +394,8 @@ Style::Layer::Layer(const QJsonObject &json)
|
||||
: _type(Unknown), _minZoom(-1), _maxZoom(-1)
|
||||
{
|
||||
// type
|
||||
QString type = json["type"].toString();
|
||||
QString type(json["type"].toString());
|
||||
|
||||
if (type == "fill")
|
||||
_type = Fill;
|
||||
else if (type == "line")
|
||||
@ -440,28 +441,33 @@ bool Style::Layer::match(int zoom, const QVariantHash &tags) const
|
||||
|
||||
void Style::Layer::setPathPainter(Tile &tile, const Sprites &sprites) const
|
||||
{
|
||||
QPen pen(_paint.pen(_type, tile.zoom()));
|
||||
QBrush brush(_paint.brush(_type, tile.zoom(), sprites));
|
||||
|
||||
pen.setJoinStyle(_layout.lineJoin(tile.zoom()));
|
||||
pen.setCapStyle(_layout.lineCap(tile.zoom()));
|
||||
|
||||
QPainter &p = tile.painter();
|
||||
p.setRenderHint(QPainter::Antialiasing, _paint.antialias(_type, tile.zoom()));
|
||||
int zoom = tile.zoom();
|
||||
|
||||
QPen pen(_paint.pen(_type, zoom));
|
||||
pen.setJoinStyle(_layout.lineJoin(zoom));
|
||||
pen.setCapStyle(_layout.lineCap(zoom));
|
||||
|
||||
QBrush brush(_paint.brush(_type, zoom, sprites));
|
||||
|
||||
p.setRenderHint(QPainter::Antialiasing, _paint.antialias(_type, zoom));
|
||||
p.setPen(pen);
|
||||
p.setBrush(brush);
|
||||
p.setOpacity(_paint.opacity(_type, tile.zoom()));
|
||||
p.setOpacity(_paint.opacity(_type, zoom));
|
||||
}
|
||||
|
||||
void Style::Layer::setTextProperties(Tile &tile) const
|
||||
{
|
||||
tile.text().setMaxWidth(_layout.maxTextWidth(tile.zoom()));
|
||||
tile.text().setMaxAngle(_layout.maxTextAngle(tile.zoom()));
|
||||
tile.text().setAnchor(_layout.textAnchor(tile.zoom()));
|
||||
tile.text().setPen(_paint.pen(_type, tile.zoom()));
|
||||
tile.text().setFont(_layout.font(tile.zoom()));
|
||||
tile.text().setSymbolPlacement(_layout.symbolPlacement(tile.zoom()));
|
||||
tile.text().setRotationAlignment(_layout.textRotationAlignment(tile.zoom()));
|
||||
Text &t = tile.text();
|
||||
int zoom = tile.zoom();
|
||||
|
||||
t.setMaxWidth(_layout.maxTextWidth(zoom));
|
||||
t.setMaxAngle(_layout.maxTextAngle(zoom));
|
||||
t.setAnchor(_layout.textAnchor(zoom));
|
||||
t.setPen(_paint.pen(_type, zoom));
|
||||
t.setFont(_layout.font(zoom));
|
||||
t.setSymbolPlacement(_layout.symbolPlacement(zoom));
|
||||
t.setRotationAlignment(_layout.textRotationAlignment(zoom));
|
||||
}
|
||||
|
||||
void Style::Layer::addSymbol(Tile &tile, const QPainterPath &path,
|
||||
|
13
src/text.cpp
13
src/text.cpp
@ -32,24 +32,23 @@ void Text::addLabel(const QString &text, const QImage &icon,
|
||||
_maxWidth, _anchor, icon);
|
||||
else
|
||||
ti = new TextPathItem(text, path, _font, _maxAngle, _sceneRect);
|
||||
if (!_sceneRect.contains(ti->boundingRect()))
|
||||
ti->setVisible(false);
|
||||
break;
|
||||
case LineCenter:
|
||||
ti = new TextPointItem(text, path.pointAtPercent(0.5), _font,
|
||||
_maxWidth, _anchor, icon);
|
||||
if (!_sceneRect.contains(ti->boundingRect()))
|
||||
ti->setVisible(false);
|
||||
break;
|
||||
default:
|
||||
ti = new TextPointItem(text, path.elementAt(0), _font, _maxWidth,
|
||||
_anchor, icon);
|
||||
if (_alignment == Viewport
|
||||
&& !_sceneRect.contains(ti->boundingRect()))
|
||||
ti->setVisible(false);
|
||||
break;
|
||||
}
|
||||
|
||||
// Note: empty path == point geometry (single move)
|
||||
if (!path.isEmpty() && !_sceneRect.contains(ti->boundingRect())) {
|
||||
delete ti;
|
||||
return;
|
||||
}
|
||||
|
||||
ti->setPen(_pen);
|
||||
addItem(ti);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user