本文整理汇总了C++中RelationPtr::symbolLabelOnTop方法的典型用法代码示例。如果您正苦于以下问题:C++ RelationPtr::symbolLabelOnTop方法的具体用法?C++ RelationPtr::symbolLabelOnTop怎么用?C++ RelationPtr::symbolLabelOnTop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelationPtr
的用法示例。
在下文中一共展示了RelationPtr::symbolLabelOnTop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintRelation
QSize LegendItem::paintRelation(QString name, RelationPtr relation, QPainter *painter, bool draw) {
Label::Parsed *parsed = Label::parse(name);
parsed->chunk->attributes.color = _color;
int fontHeight = painter->fontMetrics().height();
int fontAscent = painter->fontMetrics().ascent();
QSize symbol_size = relation->legendSymbolSize(painter);
int label_width = 0;
int paddingValue = fontHeight / 4;
if (relation->symbolLabelOnTop()) {
Label::RenderContext tmprc(painter->font(), painter);
Label::renderLabel(tmprc, parsed->chunk, false, false);
label_width = tmprc.x;
painter->translate(paddingValue, fontHeight+paddingValue / 2);
symbol_size.setWidth(qMax(label_width, symbol_size.width()));
} else {
painter->translate(paddingValue, paddingValue / 2);
}
if (draw) {
relation->paintLegendSymbol(painter, symbol_size);
}
if (relation->symbolLabelOnTop()) {
painter->translate((symbol_size.width()-label_width)/2, fontAscent - fontHeight);
} else {
painter->translate(symbol_size.width() + paddingValue, 0);
}
Label::RenderContext rc(painter->font(), painter);
if (relation->symbolLabelOnTop()) {
rc.y = 0;
} else {
rc.y = (symbol_size.height()+painter->fontMetrics().boundingRect('M').height())/2;
}
if (parsed) {
Label::renderLabel(rc, parsed->chunk, false, draw);
delete parsed;
parsed = 0;
}
double h = symbol_size.height() + paddingValue;
if (relation->symbolLabelOnTop()) {
h += fontHeight;
}
if (relation->symbolLabelOnTop()) {
return QSize(qMax(rc.x,(symbol_size.width())) + (paddingValue * 2), h);
} else {
return QSize((symbol_size.width()) + (paddingValue * 3) + rc.x, h);
}
}