当前位置: 首页>>代码示例>>C++>>正文


C++ RelationPtr::legendName方法代码示例

本文整理汇总了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());
//.........这里部分代码省略.........
开发者ID:Kst-plot,项目名称:kst,代码行数:101,代码来源:legenditem.cpp


注:本文中的RelationPtr::legendName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。