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


C++ QwtPlotMarker::value方法代码示例

本文整理汇总了C++中QwtPlotMarker::value方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlotMarker::value方法的具体用法?C++ QwtPlotMarker::value怎么用?C++ QwtPlotMarker::value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QwtPlotMarker的用法示例。


在下文中一共展示了QwtPlotMarker::value方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: shiftMarkerCursor

// Select the next/previous neighbour of the selected point
// 0 = up
// 1 = down
// 2 = left
// 3 = right
void XtalOptPlot::shiftMarkerCursor(int direction)
{
  if (!m_selectedMarker)
    return;

  QwtPlotMarker* selection = nullptr;

  double dist = 1e300;

  const QwtPlotItemList& itmList = itemList();
  for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it) {
    if ((*it)->rtti() == QwtPlotItem::Rtti_PlotMarker) {
      QwtPlotMarker* m = static_cast<QwtPlotMarker*>(*it);

      // Skip over the point that is already selected
      if (m == m_selectedMarker)
        continue;

      // Find the distance and see if it is the shortest so far

      // If we ever want to do this with canvas coordinates, this is how
      // it is done:

      // double x1 = canvasMap(m->xAxis()).transform(m->xValue());
      // double y1 = canvasMap(m->yAxis()).transform(m->yValue());
      // double x2 = canvasMap(m_selectedMarker->xAxis())
      //                 .transform(m_selectedMarker->xValue());
      // double y2 = canvasMap(m_selectedMarker->yAxis())
      //                 .transform(m_selectedMarker->yValue());
      // double d = distance(QPointF(x1, y1), QPointF(x2, y2));

      double d = distance(m->value(), m_selectedMarker->value());
      if (d > dist)
        continue;

      // Let's make sure the direction is correct as well
      switch (direction) {
        // up
        case 0: {
          // Check to make sure this is actually up
          if (m->yValue() - m_selectedMarker->yValue() > 0.0) {
            selection = m;
            dist = d;
          }
          break;
        }
        // down
        case 1: {
          // Check to make sure this is actually down
          if (m_selectedMarker->yValue() - m->yValue() > 0.0) {
            selection = m;
            dist = d;
          }
          break;
        }
        // left
        case 2: {
          // Check to make sure this is actually left
          if (m_selectedMarker->xValue() - m->xValue() > 0.0) {
            selection = m;
            dist = d;
          }
          break;
        }
        // right
        case 3: {
          // Check to make sure this is actually right
          if (m->xValue() - m_selectedMarker->xValue() > 0.0) {
            selection = m;
            dist = d;
          }
          break;
        }
      }
    }
  }

  selectMarker(selection);
}
开发者ID:xtalopt,项目名称:XtalOpt,代码行数:84,代码来源:xtalopt_plot.cpp


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