Esempio n. 1
0
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);
}
Esempio n. 2
0
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;
}
Esempio n. 3
0
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);
}
Esempio n. 4
0
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();
}
Esempio n. 5
0
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));
}
Esempio n. 6
0
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
}
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
}
void SequenceDialog::yAxisChanged(QCPRange range)
{
    ui->verticalScrollBar->setValue(qRound(range.center()*100.0));
    ui->verticalScrollBar->setPageStep(qRound(range.size()*100.0));
}
Esempio n. 9
0
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
}
Esempio n. 10
0
void LBMUIMFlowDialog::yAxisChanged(QCPRange range)
{
    m_ui->verticalScrollBar->setValue(qRound(range.center() * 100.0));
    m_ui->verticalScrollBar->setPageStep(qRound(range.size() * 100.0));
}