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


C++ ScaleDraw::format方法代码示例

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


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

示例1: initWidgets

/** Initialisation method. Sets up all widgets and variables not done in the
 * constructor.
 *
 */
void ScaleDetails::initWidgets() {
  if (m_initialised) {
    return;
  } else {
    Plot *d_plot = m_graph->plotWidget();
    const QwtScaleDiv *scDiv = d_plot->axisScaleDiv(m_mappedaxis);
    double start = qMin(scDiv->lBound(), scDiv->hBound());
    double end = qMax(scDiv->lBound(), scDiv->hBound());
    ScaleDraw::ScaleType type = m_graph->axisType(m_mappedaxis);
    if (type == ScaleDraw::Date) {
      ScaleDraw *sclDraw =
          dynamic_cast<ScaleDraw *>(d_plot->axisScaleDraw(m_mappedaxis));
      if (!sclDraw) {
        throw std::runtime_error("Could not convert the axis Scale Draw object "
                                 "to a ScaleDraw object");
      }
      QDateTime origin = sclDraw->dateTimeOrigin();

      m_dspnStart->hide();
      m_timStartTime->hide();
      m_dteStartDateTime->show();
      m_dteStartDateTime->setDisplayFormat(sclDraw->format());
      m_dteStartDateTime->setDateTime(origin.addSecs((int)start));

      m_dspnEnd->hide();
      m_timEndTime->hide();
      m_dteEndDateTime->show();
      m_dteEndDateTime->setDisplayFormat(sclDraw->format());
      m_dteEndDateTime->setDateTime(origin.addSecs((int)end));

      m_cmbUnit->show();
      m_cmbUnit->addItem(tr("days"));
      m_cmbUnit->addItem(tr("weeks"));
      m_dspnStep->setValue(m_graph->axisStep(m_mappedaxis) / 86400.0);
      m_dspnStep->setSingleStep(1);
    } else if (type == ScaleDraw::Time) {
      if (ScaleDraw *sclDraw =
              dynamic_cast<ScaleDraw *>(d_plot->axisScaleDraw(m_mappedaxis))) {
        QTime origin = sclDraw->dateTimeOrigin().time();

        m_dspnStart->hide();
        m_dteStartDateTime->hide();
        m_timStartTime->show();
        m_timStartTime->setDisplayFormat(sclDraw->format());
        m_timStartTime->setTime(origin.addMSecs((int)start));

        m_dspnEnd->hide();
        m_dteEndDateTime->hide();
        m_timEndTime->show();
        m_timEndTime->setDisplayFormat(sclDraw->format());
        m_timEndTime->setTime(origin.addMSecs((int)end));

        m_cmbUnit->show();
        m_cmbUnit->addItem(tr("millisec."));
        m_cmbUnit->addItem(tr("sec."));
        m_cmbUnit->addItem(tr("min."));
        m_cmbUnit->addItem(tr("hours"));
        m_cmbUnit->setCurrentIndex(1);
        m_dspnStep->setValue(m_graph->axisStep(m_mappedaxis) / 1e3);
        m_dspnStep->setSingleStep(1000);
      }
    } else {
      m_dspnStart->show();
      m_dspnStart->setValue(start);
      m_timStartTime->hide();
      m_dteStartDateTime->hide();
      m_dspnEnd->show();
      m_dspnEnd->setValue(end);
      m_timEndTime->hide();
      m_dteEndDateTime->hide();
      m_dspnStep->setValue(m_graph->axisStep(m_mappedaxis));
      m_dspnStep->setSingleStep(0.1);
    }

    double range = fabs(scDiv->range());
    QwtScaleEngine *qwtsc_engine = d_plot->axisScaleEngine(m_mappedaxis);
    ScaleEngine *sc_engine = dynamic_cast<ScaleEngine *>(qwtsc_engine);
    if (sc_engine) {
      if (sc_engine->axisBreakLeft() > -DBL_MAX) {
        m_dspnBreakStart->setValue(sc_engine->axisBreakLeft());
      } else {
        m_dspnBreakStart->setValue(start + 0.25 * range);
      }

      if (sc_engine->axisBreakRight() < DBL_MAX) {
        m_dspnBreakEnd->setValue(sc_engine->axisBreakRight());
      } else {
        m_dspnBreakEnd->setValue(start + 0.75 * range);
      }
      m_grpAxesBreaks->setChecked(sc_engine->hasBreak());

      m_spnBreakPosition->setValue(sc_engine->breakPosition());
      m_spnBreakWidth->setValue(sc_engine->breakWidth());
      m_dspnStepBeforeBreak->setValue(sc_engine->stepBeforeBreak());
      m_dspnStepAfterBreak->setValue(sc_engine->stepAfterBreak());

//.........这里部分代码省略.........
开发者ID:mantidproject,项目名称:mantid,代码行数:101,代码来源:ScaleDetails.cpp


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