本文整理汇总了C++中RelationPtr::xLabelInfo方法的典型用法代码示例。如果您正苦于以下问题:C++ RelationPtr::xLabelInfo方法的具体用法?C++ RelationPtr::xLabelInfo怎么用?C++ RelationPtr::xLabelInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelationPtr
的用法示例。
在下文中一共展示了RelationPtr::xLabelInfo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 {
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
QString label = relation->titleInfo().singleRenderItemLabel();
if (label.isEmpty()) {
label_info = relation->yLabelInfo();
QString y_label = label_info.name;
if (!sameYUnits) {
if (!label_info.units.isEmpty()) {
y_label = tr("%1 \\[%2\\]", "axis labels. %1 is quantity, %2 is units. eg Time [s]. '[' must be escaped.").arg(y_label).arg(label_info.units);
}
}
if (!y_label.isEmpty()) {
LabelInfo xlabel_info = relation->xLabelInfo();
if (!sameX) {
label = tr("%1 vs %2", "describes a plot. %1 is X axis. %2 is Y axis").arg(y_label).arg(xlabel_info.name);
} else if (xlabel_info.quantity.isEmpty()) {
label = y_label;
} else if (xlabel_info.quantity != xlabel_info.name) {
label = tr("%1 vs %2", "describes a plot. %1 is X axis. %2 is Y axis").arg(y_label).arg(xlabel_info.name);
} else {
label = y_label;
}
} else {
label = relation->descriptiveName();
}
}
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);
//.........这里部分代码省略.........
示例2: 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;
}
QList<DrawnLegendItem> legendPixmaps;
QSize legendSize(0, 0);
QFont font(_font);
font.setPointSizeF(view()->viewScaledFontSize(_fontScale));
// 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 {
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
QString label = relation->titleInfo().singleRenderItemLabel();
if (label.isEmpty()) {
label_info = relation->yLabelInfo();
QString y_label = label_info.name;
if (!sameYUnits) {
if (!label_info.units.isEmpty()) {
y_label = i18n("%1 \\[%2\\]").arg(y_label).arg(label_info.units);
}
}
if (!y_label.isEmpty()) {
LabelInfo xlabel_info = relation->xLabelInfo();
if (!sameX) {
label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
} else if (xlabel_info.quantity.isEmpty()) {
label = y_label;
} else if (xlabel_info.quantity != xlabel_info.name) {
label = i18n("%1 vs %2").arg(y_label).arg(xlabel_info.name);
} else {
label = y_label;
}
} else {
label = relation->descriptiveName();
}
}
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().file + ')');
}
if (!relation->yLabelInfo().file.isEmpty()) {
names.append(label + " (" + relation->yLabelInfo().file + ')');
}
}
}
}
for (int i = 0; i<count; i++) {
RelationPtr relation = legendItems.at(i);
DrawnLegendItem item;
//.........这里部分代码省略.........