本文整理汇总了C++中QwtPlot::axisScaleDiv方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtPlot::axisScaleDiv方法的具体用法?C++ QwtPlot::axisScaleDiv怎么用?C++ QwtPlot::axisScaleDiv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtPlot
的用法示例。
在下文中一共展示了QwtPlot::axisScaleDiv方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rescale
void QwtPlotZoomer::rescale()
{
QwtPlot *plt = plot();
if ( !plt )
return;
const QRectF &rect = d_data->zoomStack[d_data->zoomRectIndex];
if ( rect != scaleRect() )
{
const bool doReplot = plt->autoReplot();
plt->setAutoReplot( false );
double x1 = rect.left();
double x2 = rect.right();
if ( !plt->axisScaleDiv( xAxis() ).isIncreasing() )
qSwap( x1, x2 );
plt->setAxisScale( xAxis(), x1, x2 );
double y1 = rect.top();
double y2 = rect.bottom();
if ( !plt->axisScaleDiv( yAxis() ).isIncreasing() )
qSwap( y1, y2 );
plt->setAxisScale( yAxis(), y1, y2 );
plt->setAutoReplot( doReplot );
plt->replot();
}
}
示例2: updateScales
/*!
Update the axes scales
\param intervals Scale intervals
*/
void QwtPlotRescaler::updateScales(
QwtInterval intervals[QwtPlot::axisCnt] ) const
{
if ( d_data->inReplot >= 5 )
{
return;
}
QwtPlot *plt = const_cast<QwtPlot *>( plot() );
const bool doReplot = plt->autoReplot();
plt->setAutoReplot( false );
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
if ( axis == referenceAxis() || aspectRatio( axis ) > 0.0 )
{
double v1 = intervals[axis].minValue();
double v2 = intervals[axis].maxValue();
if ( plt->axisScaleDiv( axis )->lowerBound() >
plt->axisScaleDiv( axis )->upperBound() )
{
qSwap( v1, v2 );
}
if ( d_data->inReplot >= 1 )
{
d_data->axisData[axis].scaleDiv = *plt->axisScaleDiv( axis );
}
if ( d_data->inReplot >= 2 )
{
QList<double> ticks[QwtScaleDiv::NTickTypes];
for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
ticks[i] = d_data->axisData[axis].scaleDiv.ticks( i );
plt->setAxisScaleDiv( axis, QwtScaleDiv( v1, v2, ticks ) );
}
else
{
plt->setAxisScale( axis, v1, v2 );
}
}
}
const bool immediatePaint =
plt->canvas()->testPaintAttribute( QwtPlotCanvas::ImmediatePaint );
plt->canvas()->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, false );
plt->setAutoReplot( doReplot );
d_data->inReplot++;
plt->replot();
d_data->inReplot--;
plt->canvas()->setPaintAttribute(
QwtPlotCanvas::ImmediatePaint, immediatePaint );
}
示例3: updateScales
/*!
Update the axes scales
\param intervals Scale intervals
*/
void QwtPlotRescaler::updateScales(
QwtDoubleInterval intervals[QwtPlot::axisCnt]) const
{
if ( d_data->inReplot >= 5 )
{
return;
}
QwtPlot *plt = (QwtPlot *)plot();
const bool doReplot = plt->autoReplot();
plt->setAutoReplot(false);
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
if ( axis == referenceAxis() || aspectRatio(axis) > 0.0 )
{
double v1 = intervals[axis].minValue();
double v2 = intervals[axis].maxValue();
if ( plt->axisScaleDiv(axis)->lowerBound() >
plt->axisScaleDiv(axis)->upperBound() )
{
qSwap(v1, v2);
}
if ( d_data->inReplot >= 1 )
{
d_data->axisData[axis].scaleDiv = *plt->axisScaleDiv(axis);
}
if ( d_data->inReplot >= 2 )
{
QwtValueList ticks[QwtScaleDiv::NTickTypes];
for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
ticks[i] = d_data->axisData[axis].scaleDiv.ticks(i);
plt->setAxisScaleDiv(axis, QwtScaleDiv(v1, v2, ticks));
}
else
{
plt->setAxisScale(axis, v1, v2);
}
}
}
plt->setAutoReplot(doReplot);
d_data->inReplot++;
plt->replot();
d_data->inReplot--;
}
示例4: rescale
/*!
Zoom in/out the axes scales
\param factor A value < 1.0 zooms in, a value > 1.0 zooms out.
*/
void QwtPlotMagnifier::rescale(double factor)
{
factor = qwtAbs(factor);
if ( factor == 1.0 || factor == 0.0 )
return;
bool doReplot = false;
QwtPlot* plt = plot();
const bool autoReplot = plt->autoReplot();
plt->setAutoReplot(false);
for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
{
const QwtScaleDiv *scaleDiv = plt->axisScaleDiv(axisId);
if ( isAxisEnabled(axisId) && scaleDiv->isValid() )
{
const double center =
scaleDiv->lowerBound() + scaleDiv->range() / 2;
const double width_2 = scaleDiv->range() / 2 * factor;
plt->setAxisScale(axisId, center - width_2, center + width_2);
doReplot = true;
}
}
plt->setAutoReplot(autoReplot);
if ( doReplot )
plt->replot();
}
示例5: showColorScale
void Spectrogram::showColorScale(int axis, bool on)
{
if (hasColorScale() == on && color_axis == axis)
return;
QwtPlot *plot = this->plot();
if (!plot)
return;
QwtScaleWidget *colorAxis = plot->axisWidget(color_axis);
colorAxis->setColorBarEnabled(false);
color_axis = axis;
// We must switch main and the color scale axes and their respective scales
int xAxis = this->xAxis();
int yAxis = this->yAxis();
int oldMainAxis = yAxis;
if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop)
{
oldMainAxis = xAxis;
xAxis = 5 - color_axis;
}
else if (axis == QwtPlot::yLeft || axis == QwtPlot::yRight)
{
oldMainAxis = yAxis;
yAxis = 1 - color_axis;
}
// First we switch axes
setAxis(xAxis, yAxis);
// Next we switch axes scales
QwtScaleDiv *scDiv = plot->axisScaleDiv(oldMainAxis);
if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop)
plot->setAxisScale(xAxis, scDiv->lBound(), scDiv->hBound());
else if (axis == QwtPlot::yLeft || color_axis == QwtPlot::yRight)
plot->setAxisScale(yAxis, scDiv->lBound(), scDiv->hBound());
colorAxis = plot->axisWidget(color_axis);
plot->setAxisScale(color_axis, data().range().minValue(), data().range().maxValue());
colorAxis->setColorBarEnabled(on);
colorAxis->setColorMap(data().range(), colorMap());
if (!plot->axisEnabled(color_axis))
plot->enableAxis(color_axis);
colorAxis->show();
plot->updateLayout();
}
示例6: moveCanvas
/*!
Adjust the enabled axes according to dx/dy
\param dx Pixel offset in x direction
\param dy Pixel offset in y direction
\sa QwtPanner::panned()
*/
void QwtPlotPanner::moveCanvas( int dx, int dy )
{
if ( dx == 0 && dy == 0 )
return;
QwtPlot *plot = this->plot();
if ( plot == NULL )
return;
const bool doAutoReplot = plot->autoReplot();
plot->setAutoReplot( false );
for ( int axisPos = 0; axisPos < QwtAxis::PosCount; axisPos++ )
{
const int axesCount = plot->axesCount( axisPos );
for ( int i = 0; i < axesCount; i++ )
{
const QwtAxisId axisId( axisPos, i );
if ( !isAxisEnabled( axisId ) )
continue;
const QwtScaleMap map = plot->canvasMap( axisId );
const double p1 = map.transform( plot->axisScaleDiv( axisId ).lowerBound() );
const double p2 = map.transform( plot->axisScaleDiv( axisId ).upperBound() );
double d1, d2;
if ( QwtAxis::isXAxis( axisPos ) )
{
d1 = map.invTransform( p1 - dx );
d2 = map.invTransform( p2 - dx );
}
else
{
d1 = map.invTransform( p1 - dy );
d2 = map.invTransform( p2 - dy );
}
plot->setAxisScale( axisId, d1, d2 );
}
}
plot->setAutoReplot( doAutoReplot );
plot->replot();
}
示例7: moveCanvas
/*!
Adjust the enabled axes according to dx/dy
\param dx Pixel offset in x direction
\param dy Pixel offset in y direction
\sa QwtPanner::panned()
*/
void QwtPlotPanner::moveCanvas(int dx, int dy)
{
if ( dx == 0 && dy == 0 )
return;
QwtPlot *plot = QwtPlotPanner::plot();
if ( plot == NULL )
return;
const bool doAutoReplot = plot->autoReplot();
plot->setAutoReplot(false);
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
if ( !d_data->isAxisEnabled[axis] )
continue;
const QwtScaleMap map = plot->canvasMap(axis);
const int i1 = map.transform(plot->axisScaleDiv(axis)->lowerBound());
const int i2 = map.transform(plot->axisScaleDiv(axis)->upperBound());
double d1, d2;
if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
{
d1 = map.invTransform(i1 - dx);
d2 = map.invTransform(i2 - dx);
}
else
{
d1 = map.invTransform(i1 - dy);
d2 = map.invTransform(i2 - dy);
}
plot->setAxisScale(axis, d1, d2);
}
plot->setAutoReplot(doAutoReplot);
plot->replot();
}
示例8: scaleDivChanged
void PlotMatrix::scaleDivChanged()
{
if ( d_data->inScaleSync )
return;
d_data->inScaleSync = true;
QwtPlot *plt = NULL;
int axisId = -1;
int rowOrColumn = -1;
// find the changed axis
for ( int row = 0; row < numRows(); row++ )
{
for ( int col = 0; col < numColumns(); col++ )
{
QwtPlot *p = plot( row, col );
if ( p )
{
for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
{
if ( p->axisWidget( axis ) == sender() )
{
plt = p;
axisId = axis;
if ( axisId == QwtPlot::xBottom || axisId == QwtPlot::xTop )
rowOrColumn = col;
else
rowOrColumn = row;
}
}
}
}
}
if ( plt )
{
// synchronize the axes
if ( axisId == QwtPlot::xBottom || axisId == QwtPlot::xTop )
{
for ( int row = 0; row < numRows(); row++ )
{
QwtPlot *p = plot( row, rowOrColumn );
if ( p != plt )
p->setAxisScaleDiv( axisId, plt->axisScaleDiv( axisId ) );
}
}
else
{
for ( int col = 0; col < numColumns(); col++ )
{
QwtPlot *p = plot( rowOrColumn, col );
if ( p != plt )
p->setAxisScaleDiv( axisId, plt->axisScaleDiv( axisId ) );
}
}
updateLayout();
}
d_data->inScaleSync = false;
}