本文整理汇总了C++中RelationPtr::legendName方法的典型用法代码示例。如果您正苦于以下问题:C++ RelationPtr::legendName方法的具体用法?C++ RelationPtr::legendName怎么用?C++ RelationPtr::legendName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelationPtr
的用法示例。
在下文中一共展示了RelationPtr::legendName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paint
void LegendItem::paint(QPainter *painter) {
if (!isVisible()) {
return;
}
RelationList legendItems;
if (_auto) {
legendItems = plot()->renderItem(PlotRenderItem::Cartesian)->relationList();
} else {
legendItems = _relations;
}
int count = legendItems.count();
if (count <= 0) { // no legend or box if there are no legend items
return;
}
QFont font(_font);
font.setPointSizeF(view()->scaledFontSize(_fontScale, *painter->device()));
painter->setFont(font);
// generate string list of relation names
QStringList names;
//bool allAuto = true;
bool sameX = true;
bool sameYUnits = true;
LabelInfo label_info = legendItems.at(0)->xLabelInfo();
QString yUnits = legendItems.at(0)->yLabelInfo().units;
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
if (relation->descriptiveNameIsManual()) {
//allAuto = false;
}
if (relation->xLabelInfo() != label_info) {
sameX = false;
}
// sameYUnits is false if any non empty units are defined differently.
if (yUnits.isEmpty()) {
yUnits = relation->yLabelInfo().units;
} else if (relation->yLabelInfo().units != yUnits) {
if (!relation->yLabelInfo().units.isEmpty()) {
sameYUnits = false;
}
}
}
// if (!allAuto) {
// for (int i = 0; i<count; i++) {
// names.append(legendItems.at(i)->descriptiveName());
// }
// } else {
// FIXME: move most of this into a new function, relation->legend_name
// then create separate [legend_name] and Auto in the relation dialog.
// show relation->legend_name in dialog when [x] Auto
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
QString label = relation->legendName(sameX, sameYUnits);
int i_dup = names.indexOf(label);
if (i_dup<0) {
names.append(label);
} else {
RelationPtr dup_relation = legendItems.at(i_dup);
if (!dup_relation->yLabelInfo().file.isEmpty()) {
names.replace(i_dup, label + " (" + dup_relation->yLabelInfo().escapedFile() + ')');
}
if (!relation->yLabelInfo().file.isEmpty()) {
names.append(label + " (" + relation->yLabelInfo().escapedFile() + ')');
}
}
}
QSize legendSize(0, 0);
QSize titleSize(0,0);
Label::Parsed *parsed = Label::parse(_title, _color);
int pad = painter->fontMetrics().ascent()/4;
Label::RenderContext rc(painter->font(), painter);
Label::renderLabel(rc, parsed->chunk, false, false);
if (!_title.isEmpty()) {
titleSize.setWidth(rc.x+3*pad);
titleSize.setHeight(painter->fontMetrics().height()+pad);
}
QList<QSize> sizes;
int max_w = 0;
int max_h = 0;
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
QSize size;
painter->save();
size = paintRelation(names.at(i), relation, painter, false);
painter->restore();
sizes.append(size);
max_w = qMax(max_w, size.width());
//.........这里部分代码省略.........