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


C++ QCPRange类代码示例

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


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

示例1: getValueRange

/*!
  Rescales the value axis of the plottable so the whole plottable is visible.
  
  Returns true if the axis was actually scaled. This might not be the case if this plottable has an
  invalid range, e.g. because it has no data points.
  
  See \ref rescaleAxes for detailed behaviour.
*/
void QCPAbstractPlottable::rescaleValueAxis(bool onlyEnlarge) const
{
  QCPAxis *valueAxis = mValueAxis.data();
  if (!valueAxis) { qDebug() << Q_FUNC_INFO << "invalid value axis"; return; }
  
  SignDomain signDomain = sdBoth;
  if (valueAxis->scaleType() == QCPAxis::stLogarithmic)
    signDomain = (valueAxis->range().upper < 0 ? sdNegative : sdPositive);
  
  bool foundRange;
  QCPRange newRange = getValueRange(foundRange, signDomain);
  if (foundRange)
  {
    if (onlyEnlarge)
      newRange.expand(valueAxis->range());
    if (!QCPRange::validRange(newRange)) // likely due to range being zero (plottable has only constant data in this axis dimension), shift current range to at least center the plottable
    {
      double center = (newRange.lower+newRange.upper)*0.5; // upper and lower should be equal anyway, but just to make sure, incase validRange returned false for other reason
      if (valueAxis->scaleType() == QCPAxis::stLinear)
      {
        newRange.lower = center-valueAxis->range().size()/2.0;
        newRange.upper = center+valueAxis->range().size()/2.0;
      } else // scaleType() == stLogarithmic
      {
        newRange.lower = center/qSqrt(valueAxis->range().upper/valueAxis->range().lower);
        newRange.upper = center*qSqrt(valueAxis->range().upper/valueAxis->range().lower);
      }
    }
    valueAxis->setRange(newRange);
  }
}
开发者ID:pabigot,项目名称:qcustomplot,代码行数:39,代码来源:plottable.cpp

示例2: QCPRange

void RgbImageWindow::scaleRulesForAxis(QCPAxis *axis, double rangeUpper, QCPRange newRange, QCPRange oldRange)
{

    QCPRange boundedRange = newRange;
    double lowerRangeBound = 0;
    double upperRangeBound = rangeUpper;
    const int MAX_ZOOM = 4;
    if((upperRangeBound - lowerRangeBound)/boundedRange.size() > MAX_ZOOM)
    {
        axis->setRange(oldRange);
        return;
    }

    if (boundedRange.size() > upperRangeBound-lowerRangeBound)
    {
        boundedRange = QCPRange(lowerRangeBound, upperRangeBound);
    } else
    {
        double oldSize = boundedRange.size();
        if (boundedRange.lower < lowerRangeBound)
        {
            boundedRange.lower = lowerRangeBound;
            boundedRange.upper = lowerRangeBound+oldSize;
        }
        if (boundedRange.upper > upperRangeBound)
        {
            boundedRange.lower = upperRangeBound-oldSize;
            boundedRange.upper = upperRangeBound;
        }
    }
    axis->setRange(boundedRange);
}
开发者ID:remsens,项目名称:Peleng,代码行数:32,代码来源:rgbimagewindow.cpp

示例3: plotAnalyze

void plot_analytics::plotAnalyze( QCPGraph *target, plotStats *stats, QCPRange keyRange)
{
    QCPGraphDataContainer::const_iterator plotIterator = target->data().data()->findBegin(keyRange.lower,true);
    QCPGraphDataContainer::const_iterator targetDataEnd = target->data().data()->findEnd(keyRange.upper,true);
    QCPGraphData currentPoint, prevPoint;

    //Find the data ranges
    currentPoint.key = keyRange.lower;
    prevPoint = QCPGraphData(plotIterator->key, plotIterator->value);

    while(plotIterator != targetDataEnd && (keyRange.contains(plotIterator->key) || stats->totalData_entrys < 2))
    {
        currentPoint = QCPGraphData(plotIterator->key, plotIterator->value);
        handlePoints(currentPoint, prevPoint, stats);

        //Value is weighted to account for datapoints that may not be equally spaced
        if(!isInvalidData(currentPoint.value) && !isInvalidData(prevPoint.value))
            stats->avgValue += currentPoint.value*(currentPoint.key-prevPoint.key);

        prevPoint = QCPGraphData(plotIterator->key, plotIterator->value);
        ++plotIterator;
    }
    //Divide by total seconds
    stats->avgValue /= stats->totalData_seconds;
}
开发者ID:whidbey,项目名称:SmartPlot,代码行数:25,代码来源:plot_analytics.cpp

示例4: tickStep

double ProfilePlotView::tickStep(const QCPRange & range, int nSteps)
{
	double step = range.size() / (double)(nSteps+1e-10);
	double factor = qPow(10.0, qFloor(qLn(step) / qLn(10.0)));
	double mantissa = step / factor;

	if (mantissa >= 7)
	{
		factor *= 10.0;
		step = 1;
	}
	else if (mantissa >= 5)
		step = 5;
	else if (mantissa >= 2)
		step = 2;
	else if (mantissa >= 1)
		step = 1;
	else
	{
		factor /= 10.0;
		step = 5;
	}

	return step * factor;
}
开发者ID:asymworks,项目名称:benthos-app,代码行数:25,代码来源:profile_plot.cpp

示例5: onXRangeChanged

void MainWindow::onXRangeChanged(const QCPRange newRange, const QCPRange oldRange)
{
    double newSize = newRange.size();
    bool sizeToSmall = false;

    /* Plot range can't be larger than the time elapsed */
    if (newSize > (plotXAxis_maxRange - plotXAxis_minRange))
        newSize = plotXAxis_maxRange - plotXAxis_minRange;

    /* Don't want the plot to zoom to much */
    else if (newSize < 0.5)
        sizeToSmall = true;

    for (int i = 0; i < controller->getNumSensors(); i++) {
        /* Plot range can't go below the minimal value */
        if (newRange.lower < plotXAxis_minRange) {
            ui->plot_sensors->axisRect(i)->axis(QCPAxis::atBottom)->setRange(plotXAxis_minRange, plotXAxis_minRange + newSize);
            ui->plot_CoM->axisRect()->axis(QCPAxis::atBottom)->setRange(plotXAxis_minRange, plotXAxis_minRange + newSize);
        }

        /* Plot range can't go above the maximal value */
        else if (newRange.upper > plotXAxis_maxRange) {
            ui->plot_sensors->axisRect(i)->axis(QCPAxis::atBottom)->setRange(plotXAxis_maxRange - newSize, plotXAxis_maxRange);
            ui->plot_CoM->axisRect()->axis(QCPAxis::atBottom)->setRange(plotXAxis_maxRange - newSize, plotXAxis_maxRange);
        }

        /* Plot can't zoom infinitely */
        else if (sizeToSmall) {
            ui->plot_sensors->axisRect(i)->axis(QCPAxis::atBottom)->setRange(oldRange.lower, oldRange.upper);
            ui->plot_CoM->axisRect()->axis(QCPAxis::atBottom)->setRange(oldRange.lower, oldRange.upper);
            newSize = oldRange.size();
        }
    }

    ui->plot_sensors->replot();
    ui->plot_CoM->replot();

    /* Adjust the horizontal drag sliders */
    ui->plot_horizontalDrag->setRange(plotXAxis_minRange + newSize / 2, plotXAxis_maxRange - newSize / 2);
    ui->plot_horizontalDrag->setValue(ui->plot_sensors->axisRect()->axis(QCPAxis::atBottom)->range().lower + newSize / 2);

    ui->plotCoM_horizontalDrag->setRange(plotXAxis_minRange + newSize / 2, plotXAxis_maxRange - newSize / 2);
    ui->plotCoM_horizontalDrag->setValue(ui->plot_sensors->axisRect()->axis(QCPAxis::atBottom)->range().lower + newSize / 2);
}
开发者ID:Burn2539,项目名称:CoRo_PW_Qt,代码行数:44,代码来源:mainwindow.cpp

示例6: clearUnwantedPoints

void plot_analytics::clearUnwantedPoints(QCPGraph *target, QCPGraph *enableReference, QCPRange valueEnableRange)
{
    QCPGraphDataContainer::iterator plotIterator = target->data()->begin();
    QCPGraphDataContainer::const_iterator refIterator;

    //First we scan and any time the reference plot is not in range wipe the plot data.
    //TODO: This will break the plot, do we clone the plot? That could be a huge amount of data...
    while(plotIterator != target->data()->end())
    {
        //Find closest reference point
        refIterator = enableReference->data().data()->findBegin(plotIterator->key, true);
        if (!valueEnableRange.contains(refIterator->value))
            plotIterator->value = std::numeric_limits<double>::quiet_NaN();

        ++plotIterator;
    }
}
开发者ID:whidbey,项目名称:SmartPlot,代码行数:17,代码来源:plot_analytics.cpp

示例7: integerTickStepCase_yRangeChanged

void MainWindow::integerTickStepCase_yRangeChanged(QCPRange newRange)
{
	// Generate tick positions according to linear scaling:
	double mTickStep = newRange.size()/(double)(5+1e-10); // mAutoTickCount ticks on average, the small addition is to prevent jitter on exact integers
	double magnitudeFactor = qPow(10.0, qFloor(qLn(mTickStep)/qLn(10.0))); // get magnitude factor e.g. 0.01, 1, 10, 1000 etc.
	double tickStepMantissa = mTickStep/magnitudeFactor;
	if (tickStepMantissa < 5)
	{
		// round digit after decimal point to 0.5
		mTickStep = (int)(tickStepMantissa*2)/2.0*magnitudeFactor;
	} else
	{
		// round to first digit in multiples of 2
		mTickStep = (int)((tickStepMantissa/10.0)*5)/5.0*10*magnitudeFactor;
	}
	mCustomPlot->yAxis->setTickStep(qCeil(mTickStep));
}
开发者ID:shenglonglinapple,项目名称:slin_code,代码行数:17,代码来源:mainwindow.cpp

示例8: on_horizontalSlider_valueChanged

void Window::on_horizontalSlider_valueChanged(int value)
{
    QCPRange range = ui->plot->xAxis->range();

    double real_size = range.size() / old_x_slider_scale;
    double new_size = real_size * value;

    old_x_slider_scale = value;

    ui->plot->xAxis->setRange(QCPRange(range.center() - new_size / 2, range.center() + new_size / 2));
    ui->plot->xAxis2->setRange(QCPRange(range.center() - new_size / 2, range.center() + new_size / 2));
    ui->plot->replot();
}
开发者ID:romcsmv,项目名称:Rasp,代码行数:13,代码来源:window.cpp

示例9: yAxisChanged

void MainWindow::yAxisChanged(QCPRange range)
{
    ui->verticalScrollBar->setValue(qRound(-range.center()*100.0)); // adjust position of scroll bar slider
    ui->verticalScrollBar->setPageStep(qRound(range.size()*100.0)); // adjust size of scroll bar slider
}
开发者ID:tikhoncheva,项目名称:work,代码行数:5,代码来源:mainwindow.cpp

示例10:

void AP2DataPlot2D::xAxisChanged(QCPRange range)
{
    ui.horizontalScrollBar->setValue(qRound(range.center())); // adjust position of scroll bar slider
    ui.horizontalScrollBar->setPageStep(qRound(range.size())); // adjust size of scroll bar slider
}
开发者ID:Blackflappybird,项目名称:apm_planner,代码行数:5,代码来源:AP2DataPlot2D.cpp

示例11: normalized

/*!
  Returns an expanded range that contains this and \a otherRange. It is assumed that both this
  range and \a otherRange are normalized (see \ref normalize).
  
  \see expand
*/
QCPRange QCPRange::expanded(const QCPRange &otherRange) const
{
  QCPRange result = *this;
  result.expand(otherRange);
  return result;
}
开发者ID:alagoutte,项目名称:QCustomPlot,代码行数:12,代码来源:range.cpp

示例12: yAxisChanged

void SequenceDialog::yAxisChanged(QCPRange range)
{
    ui->verticalScrollBar->setValue(qRound(range.center()*100.0));
    ui->verticalScrollBar->setPageStep(qRound(range.size()*100.0));
}
开发者ID:JunichiWatanuki,项目名称:wireshark,代码行数:5,代码来源:sequence_dialog.cpp

示例13: xAxisChanged

void ChartPage::xAxisChanged(QCPRange range)
{
  ui->horizontalScrollBar->setValue(qRound(range.center()/1000000.0)); // adjust position of scroll bar slider
  ui->horizontalScrollBar->setPageStep(qRound(range.size()*1000000.0)); // adjust size of scroll bar slider
}
开发者ID:unitecoin-org,项目名称:Unitecoin,代码行数:5,代码来源:chartpage.cpp

示例14: yAxisChanged

void LBMUIMFlowDialog::yAxisChanged(QCPRange range)
{
    m_ui->verticalScrollBar->setValue(qRound(range.center() * 100.0));
    m_ui->verticalScrollBar->setPageStep(qRound(range.size() * 100.0));
}
开发者ID:appneta,项目名称:wireshark,代码行数:5,代码来源:lbm_uimflow_dialog.cpp


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