本文整理汇总了C++中QwtLinearScaleEngine::divideScale方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtLinearScaleEngine::divideScale方法的具体用法?C++ QwtLinearScaleEngine::divideScale怎么用?C++ QwtLinearScaleEngine::divideScale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtLinearScaleEngine
的用法示例。
在下文中一共展示了QwtLinearScaleEngine::divideScale方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateScale
/**
* Update the colour scale after the range changes.
*/
void ColorMapWidget::updateScale()
{
double minValue = m_minValueBox->displayText().toDouble();
double maxValue = m_maxValueBox->displayText().toDouble();
GraphOptions::ScaleType type = (GraphOptions::ScaleType)m_scaleOptions->itemData(m_scaleOptions->currentIndex()).toUInt();
if (type == GraphOptions::Linear)
{
QwtLinearScaleEngine linScaler;
m_scaleWidget->setScaleDiv(linScaler.transformation(), linScaler.divideScale(minValue, maxValue, 20, 5));
}
else if (type == GraphOptions::Power)
{
PowerScaleEngine powerScaler;
m_scaleWidget->setScaleDiv(powerScaler.transformation(), powerScaler.divideScale(minValue, maxValue, 20, 5));
}
else
{
QwtLog10ScaleEngine logScaler;
double logmin(minValue);
if (logmin <= 0.0)
{
logmin = m_minPositiveValue;
}
m_scaleWidget->setScaleDiv(logScaler.transformation(), logScaler.divideScale(logmin, maxValue, 20, 5));
}
}
示例2: updateColorMap
/** Update the widget when the color map is changed */
void ColorBarWidget::updateColorMap()
{
// The color bar alway shows the same range. Doesn't matter since the ticks don't show up
QwtDoubleInterval range(1.0, 100.0);
m_colorBar->setColorBarEnabled(true);
m_colorBar->setColorMap( range, m_colorMap);
m_colorBar->setColorBarWidth(15);
m_colorBar->setEnabled(true);
// Try to limit the number of steps based on the height of the color bar
int maxMajorSteps = m_colorBar->height()/15; // 15 pixels per div looked about right
//std::cout << "maxMajorSteps" << maxMajorSteps << std::endl;
if (maxMajorSteps > 10) maxMajorSteps = 10;
// Show the scale on the right
double minValue = m_min;
double maxValue = m_max;
GraphOptions::ScaleType type = m_colorMap.getScaleType();
if( type == GraphOptions::Linear )
{
QwtLinearScaleEngine linScaler;
m_colorBar->setScaleDiv(linScaler.transformation(), linScaler.divideScale(minValue, maxValue, maxMajorSteps, 5));
m_colorBar->setColorMap(QwtDoubleInterval(minValue, maxValue),m_colorMap);
}
else
{
QwtLog10ScaleEngine logScaler;
m_colorBar->setScaleDiv(logScaler.transformation(), logScaler.divideScale(minValue, maxValue, maxMajorSteps, 5));
m_colorBar->setColorMap(QwtDoubleInterval(minValue, maxValue), m_colorMap);
}
}
示例3: divideScale
/*!
\brief Calculate a scale division for an interval
\param x1 First interval limit
\param x2 Second interval limit
\param maxMajorSteps Maximum for the number of major steps
\param maxMinorSteps Maximum number of minor steps
\param stepSize Step size. If stepSize == 0, the engine
calculates one.
\return Calculated scale division
*/
QwtScaleDiv QwtLogScaleEngine::divideScale( double x1, double x2,
int maxMajorSteps, int maxMinorSteps, double stepSize ) const
{
QwtInterval interval = QwtInterval( x1, x2 ).normalized();
interval = interval.limited( LOG_MIN, LOG_MAX );
if ( interval.width() <= 0 )
return QwtScaleDiv();
const double logBase = base();
if ( interval.maxValue() / interval.minValue() < logBase )
{
// scale width is less than one decade -> build linear scale
QwtLinearScaleEngine linearScaler;
linearScaler.setAttributes( attributes() );
linearScaler.setReference( reference() );
linearScaler.setMargins( lowerMargin(), upperMargin() );
if ( stepSize != 0.0 )
{
if ( stepSize < 0.0 )
stepSize = -qPow( logBase, -stepSize );
else
stepSize = qPow( logBase, stepSize );
}
return linearScaler.divideScale( x1, x2,
maxMajorSteps, maxMinorSteps, stepSize );
}
stepSize = qAbs( stepSize );
if ( stepSize == 0.0 )
{
if ( maxMajorSteps < 1 )
maxMajorSteps = 1;
stepSize = divideInterval(
qwtLogInterval( logBase, interval ).width(), maxMajorSteps );
if ( stepSize < 1.0 )
stepSize = 1.0; // major step must be >= 1 decade
}
QwtScaleDiv scaleDiv;
if ( stepSize != 0.0 )
{
QList<double> ticks[QwtScaleDiv::NTickTypes];
buildTicks( interval, stepSize, maxMinorSteps, ticks );
scaleDiv = QwtScaleDiv( interval, ticks );
}
if ( x1 > x2 )
scaleDiv.invert();
return scaleDiv;
}
示例4: divideScale
/*!
\brief Calculate a scale division
\param x1 First interval limit
\param x2 Second interval limit
\param maxMajSteps Maximum for the number of major steps
\param maxMinSteps Maximum number of minor steps
\param stepSize Step size. If stepSize == 0, the scaleEngine
calculates one.
\sa QwtScaleEngine::stepSize, LogTimeScaleEngine::subDivide
*/
QwtScaleDiv LogTimeScaleEngine::divideScale(double x1, double x2,
int maxMajSteps, int maxMinSteps, double stepSize) const
{
QwtDoubleInterval interval = QwtDoubleInterval(x1, x2).normalized();
interval = interval.limited(LOG_MIN, LOG_MAX);
if (interval.width() <= 0 )
return QwtScaleDiv();
if (interval.maxValue() / interval.minValue() < 10.0)
{
// scale width is less than one decade -> build linear scale
QwtLinearScaleEngine linearScaler;
linearScaler.setAttributes(attributes());
linearScaler.setReference(reference());
linearScaler.setMargins(
#if (QWT_VERSION >= 0x050200)
lowerMargin(), upperMargin()
#else
loMargin(), hiMargin()
#endif
);
return linearScaler.divideScale(x1, x2,
maxMajSteps, maxMinSteps, stepSize);
}
stepSize = qwtAbs(stepSize);
if ( stepSize == 0.0 )
{
if ( maxMajSteps < 1 )
maxMajSteps = 1;
stepSize = divideInterval(log10(interval).width(), maxMajSteps);
if ( stepSize < 1.0 )
stepSize = 1.0; // major step must be >= 1 decade
}
QwtScaleDiv scaleDiv;
if ( stepSize != 0.0 )
{
QwtValueList ticks[QwtScaleDiv::NTickTypes];
buildTicks(interval, stepSize, maxMinSteps, ticks);
scaleDiv = QwtScaleDiv(interval, ticks);
}
if ( x1 > x2 )
scaleDiv.invert();
return scaleDiv;
}
示例5: updateScale
/*!
Update the scale with the current attributes
\sa QwtDial::setScale
*/
void QwtDial::updateScale()
{
if ( d_data->scaleDraw )
{
QwtLinearScaleEngine scaleEngine;
const QwtScaleDiv scaleDiv = scaleEngine.divideScale(
minValue(), maxValue(),
d_data->maxMajIntv, d_data->maxMinIntv, d_data->scaleStep);
d_data->scaleDraw->setTransformation(scaleEngine.transformation());
d_data->scaleDraw->setScaleDiv(scaleDiv);
}
}
示例6: setupColorBarScaling
/**
* Set up a new colour map.
* @param colorMap :: Reference to the new colour map.
*/
void ColorMapWidget::setupColorBarScaling(const MantidColorMap& colorMap)
{
double minValue = m_minValueBox->displayText().toDouble();
double maxValue = m_maxValueBox->displayText().toDouble();
GraphOptions::ScaleType type = colorMap.getScaleType();
if( type == GraphOptions::Linear )
{
QwtLinearScaleEngine linScaler;
m_scaleWidget->setScaleDiv(linScaler.transformation(), linScaler.divideScale(minValue, maxValue, 20, 5));
m_scaleWidget->setColorMap(QwtDoubleInterval(minValue, maxValue),colorMap);
}
else if( type == GraphOptions::Power )
{
PowerScaleEngine powerScaler;
m_scaleWidget->setScaleDiv(powerScaler.transformation(), powerScaler.divideScale(minValue, maxValue, 20, 5));
m_scaleWidget->setColorMap(QwtDoubleInterval(minValue, maxValue),colorMap);
}
else
{
QwtLog10ScaleEngine logScaler;
double logmin(minValue);
if( logmin <= 0.0 )
{
logmin = m_minPositiveValue;
m_minValueBox->blockSignals(true);
setMinValue(logmin);
m_minValueBox->blockSignals(false);
}
if (maxValue <= 0)
{
maxValue = 10.;
m_maxValueBox->blockSignals(true);
setMaxValue(maxValue);
m_maxValueBox->blockSignals(false);
}
m_scaleWidget->setScaleDiv(logScaler.transformation(), logScaler.divideScale(logmin, maxValue, 20, 5));
m_scaleWidget->setColorMap(QwtDoubleInterval(logmin, maxValue), colorMap);
}
m_scaleOptions->blockSignals(true);
m_scaleOptions->setCurrentIndex(m_scaleOptions->findData(type));
m_dspnN->setEnabled(false);
if (m_scaleOptions->findData(type) == 2) {
m_dspnN->setEnabled(true);
}
m_scaleOptions->blockSignals(false);
}
示例7: QwtScaleDiv
/*!
\brief Calculate a scale division
\param x1 First interval limit
\param x2 Second interval limit
\param maxMajSteps Maximum for the number of major steps
\param maxMinSteps Maximum number of minor steps
\param stepSize Step size. If stepSize == 0, the scaleEngine
calculates one.
*/
QwtScaleDiv Log2ScaleEngine::divideScale(double x1, double x2,
int maxMajSteps, int maxMinSteps, double stepSize) const
{
QwtDoubleInterval interval = QwtDoubleInterval(x1, x2).normalized();
interval = interval.limited(LOG_MIN, LOG_MAX);
if (interval.width() <= 0 )
return QwtScaleDiv();
if (interval.maxValue() / interval.minValue() < 2){
// scale width is less than 2 -> build linear scale
QwtLinearScaleEngine linearScaler;
linearScaler.setAttributes(attributes());
linearScaler.setReference(reference());
linearScaler.setMargins(lowerMargin(), upperMargin());
return linearScaler.divideScale(x1, x2,
maxMajSteps, maxMinSteps, stepSize);
}
stepSize = qwtAbs(stepSize);
if ( stepSize == 0.0 ){
if ( maxMajSteps < 1 )
maxMajSteps = 1;
stepSize = ceil(log2(interval).width()/double(maxMajSteps));
}
QwtScaleDiv scaleDiv;
if ( stepSize != 0.0 ){
QwtValueList ticks[QwtScaleDiv::NTickTypes];
buildTicks(interval, stepSize, maxMinSteps, ticks);
scaleDiv = QwtScaleDiv(interval, ticks);
}
if ( x1 > x2 )
scaleDiv.invert();
return scaleDiv;
}
示例8: scopePlotPlugin
//.........这里部分代码省略.........
connect(xminCounter, SIGNAL(valueChanged(double)), this, SLOT(slotXminChanged(double)));
xminCounter->setDisabled(TRUE);
QLabel *x_max = new QLabel(tr("X max:"));
plotTools->addWidget( x_max );
xmaxCounter = new QwtCounter( );
plotTools->addWidget( xmaxCounter );
xmaxCounter->setRange(-1, 20.0);
xmaxCounter->setSingleStep(0.01);
xmaxCounter->setNumButtons(2);
xmaxCounter->setIncSteps(QwtCounter::Button1, 10);
xmaxCounter->setIncSteps(QwtCounter::Button2, 100);
xmaxCounter->setValue(1);
connect(xmaxCounter, SIGNAL(valueChanged(double)), this, SLOT(slotXmaxChanged(double)));
xmaxCounter->setDisabled(TRUE);
//plotTools->addSeparator();
QLabel *dataPoints = new QLabel(tr("Data Points:"));
plotTools->addWidget( dataPoints );
rangeCounter = new QwtCounter( );
plotTools->addWidget( rangeCounter );
rangeCounter->setRange(0, plotLength);
rangeCounter->setSingleStep(1);
rangeCounter->setNumButtons(2);
rangeCounter->setIncSteps(QwtCounter::Button1, 100);
rangeCounter->setIncSteps(QwtCounter::Button3, 1000);
rangeCounter->setValue(100);
connect(rangeCounter, SIGNAL(valueChanged(double)), this, SLOT(slotRangeChanged(double)));
rangeCounter->setDisabled(FALSE);
//plotTools->addSeparator();
autoscaleCheck = new QCheckBox("Autoscale");
plotTools->addWidget( autoscaleCheck );
autoscaleCheck->setChecked(TRUE);
connect(autoscaleCheck, SIGNAL(clicked()), this, SLOT(slotAutoscaleToggled()));
//moveDockWindow( plotTools, Qt::DockLeft );
// contruct a QwtPlot Widget
plotWidget = new QwtPlot(this);
// QwtPlot specific defaults:
// colour
plotWidget->setCanvasBackground(Qt::white);
// outline
//plotWidget->enableOutline(FALSE);
// no legend
//plotWidget->enableLegend(FALSE);
// no grid
grid = new QwtPlotGrid();
grid->enableX(true);
grid->enableXMin(true);
// for major grid line
grid->setMajorPen( QPen(Qt::black,1) );
// for minor grid line
grid->setMinorPen( QPen(Qt::gray,1) );
QwtScaleDiv div;
QwtLinearScaleEngine *lineSE = new QwtLinearScaleEngine();
div = lineSE->divideScale(0, 150, 2, 5, 15);
grid->attach( plotWidget );
// set some defaults for the axes
plotWidget->setAxisTitle(QwtPlot::xBottom, "Amplitude/V");
plotWidget->setAxisTitle(QwtPlot::yLeft, "Amplitude/V");
// default xrange
plotWidget->setAxisScale( QwtPlot::xBottom, 0, 1000);
// yrange autoscale
plotWidget->setAxisAutoScale(QwtPlot::yLeft);
plotWidget->setAxisAutoScale(QwtPlot::xBottom);
curve = new QwtPlotCurve("Graph");
//set curve color
curve->setPen(QPen(Qt::green, 2));
// add curves
curve->attach(plotWidget);
// copy the data into the curves
curve->setRawSamples(x, y, plotLength);
// finally, refresh the plot
plotWidget->replot();
groupTools->setLayout(plotTools);
QSize size = groupTools->sizeHint();
size.setWidth( size.width()*1.3 );
groupTools->setFixedSize( size );
QHBoxLayout *hbox = new QHBoxLayout();
hbox->addWidget(groupTools);
hbox->addWidget(plotWidget);
setLayout(hbox);
}