本文整理汇总了C++中QwtInterval类的典型用法代码示例。如果您正苦于以下问题:C++ QwtInterval类的具体用法?C++ QwtInterval怎么用?C++ QwtInterval使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QwtInterval类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
void QxrdImagePlot::recalculateDisplayedRange()
{
QxrdImagePlotSettingsPtr set(m_ImagePlotSettings);
if (set && m_DataRaster) {
double mindis, maxdis;
if (set->get_DisplayScalingMode() == PercentageMode) {
double minv = m_DataRaster->minValue();
double maxv = m_DataRaster->maxValue();
double del = maxv-minv;
mindis = minv+del*set->get_DisplayMinimumPct()/100.0;
maxdis = minv+del*set->get_DisplayMaximumPct()/100.0;
} else if (set->get_DisplayScalingMode() == PercentileMode) {
QwtInterval range = m_DataRaster->percentileRange(set->get_DisplayMinimumPctle(), set->get_DisplayMaximumPctle());
mindis = range.minValue();
maxdis = range.maxValue();
} else {
mindis = set->get_DisplayMinimumVal();
maxdis = set->get_DisplayMaximumVal();
}
m_DataRaster->setDisplayedRange(mindis, maxdis);
replotImage();
}
}
示例2: intervalHint
double QwtPlotRescaler::pixelDist( int axis, const QSize &size ) const
{
const QwtInterval intv = intervalHint( axis );
double dist = 0.0;
if ( !intv.isNull() )
{
if ( axis == referenceAxis() )
dist = intv.width();
else
{
const double r = aspectRatio( axis );
if ( r > 0.0 )
dist = intv.width() * r;
}
}
if ( dist > 0.0 )
{
if ( orientation( axis ) == Qt::Horizontal )
dist /= size.width();
else
dist /= size.height();
}
return dist;
}
示例3: QwtInterval
/*!
\brief Align an interval to a step size
The limits of an interval are aligned that both are integer
multiples of the step size.
\param interval Interval
\param stepSize Step size
\return Aligned interval
*/
QwtInterval QwtLinearScaleEngine::align(
const QwtInterval &interval, double stepSize ) const
{
double x1 = interval.minValue();
double x2 = interval.maxValue();
// when there is no rounding beside some effect, when
// calculating with doubles, we keep the original value
const double eps = 0.000000000001; // since Qt 4.8: qFuzzyIsNull
if ( -DBL_MAX + stepSize <= x1 )
{
const double x = QwtScaleArithmetic::floorEps( x1, stepSize );
if ( qAbs(x) <= eps || !qFuzzyCompare( x1, x ) )
x1 = x;
}
if ( DBL_MAX - stepSize >= x2 )
{
const double x = QwtScaleArithmetic::ceilEps( x2, stepSize );
if ( qAbs(x) <= eps || !qFuzzyCompare( x2, x ) )
x2 = x;
}
return QwtInterval( x1, x2 );
}
示例4: index
/*!
Synchronize an axis scale according to the scale of the reference axis
\param axis Axis index ( see QwtPlot::AxisId )
\param reference Interval of the reference axis
\param size Size of the canvas
\return New interval for axis
*/
QwtInterval QwtPlotRescaler::syncScale( int axis,
const QwtInterval& reference, const QSize &size ) const
{
double dist;
if ( orientation( referenceAxis() ) == Qt::Horizontal )
dist = reference.width() / size.width();
else
dist = reference.width() / size.height();
if ( orientation( axis ) == Qt::Horizontal )
dist *= size.width();
else
dist *= size.height();
dist /= aspectRatio( axis );
QwtInterval intv;
if ( rescalePolicy() == Fitting )
intv = intervalHint( axis );
else
intv = interval( axis );
intv = expandInterval( intv, dist, expandingDirection( axis ) );
return intv;
}
示例5: interval
/*!
\return Bounding rectangle of the data
\sa QwtPlotRasterItem::interval()
*/
QRectF QwtPlotRasterItem::boundingRect() const
{
const QwtInterval intervalX = interval( Qt::XAxis );
const QwtInterval intervalY = interval( Qt::YAxis );
if ( !intervalX.isValid() && !intervalY.isValid() )
return QRectF(); // no bounding rect
QRectF r;
if ( intervalX.isValid() )
{
r.setLeft( intervalX.minValue() );
r.setRight( intervalX.maxValue() );
}
else
{
r.setLeft(-0.5 * FLT_MAX);
r.setWidth(FLT_MAX);
}
if ( intervalY.isValid() )
{
r.setTop( intervalY.minValue() );
r.setBottom( intervalY.maxValue() );
}
else
{
r.setTop(-0.5 * FLT_MAX);
r.setHeight(FLT_MAX);
}
return r.normalized();
}
示例6: fill
void fill(Plot* plot)
{
plot->setAxisTitle(axis, donor->axisTitle(axis));
const QwtInterval interval = donor->axisInterval(axis);
plot->setAxisScale(axis, interval.minValue(), interval.maxValue(), donor->axisStep(QwtPlot::Axis(axis)));
plot->replot();
}
示例7: QwtInterval
/*!
\brief Calculate a scale division
\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.
*/
QwtScaleDiv QwtLinearScaleEngine::divideScale( double x1, double x2,
int maxMajorSteps, int maxMinorSteps, double stepSize ) const
{
QwtInterval interval = QwtInterval( x1, x2 ).normalized();
if ( interval.width() <= 0 )
return QwtScaleDiv();
stepSize = qAbs( stepSize );
if ( stepSize == 0.0 )
{
if ( maxMajorSteps < 1 )
maxMajorSteps = 1;
stepSize = QwtScaleArithmetic::divideInterval(
interval.width(), maxMajorSteps, base() );
}
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;
}
示例8: drawSeries
/*!
Draw a sample
\param painter Painter
\param xMap x map
\param yMap y map
\param canvasRect Contents rectangle of the canvas
\param boundingInterval Bounding interval of sample values
\param index Index of the sample to be painted
\param sample Sample value
\sa drawSeries()
*/
void QwtPlotMultiBarChart::drawSample( QPainter *painter,
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &canvasRect, const QwtInterval &boundingInterval,
int index, const QwtSetSample& sample ) const
{
if ( sample.set.size() <= 0 )
return;
double sampleW;
if ( orientation() == Qt::Horizontal )
{
sampleW = sampleWidth( yMap, canvasRect.height(),
boundingInterval.width(), sample.value );
}
else
{
sampleW = sampleWidth( xMap, canvasRect.width(),
boundingInterval.width(), sample.value );
}
if ( d_data->style == Stacked )
{
drawStackedBars( painter, xMap, yMap,
canvasRect, index, sampleW, sample );
}
else
{
drawGroupedBars( painter, xMap, yMap,
canvasRect, index, sampleW, sample );
}
}
示例9: plotRect
/*!
Redraw the canvas items.
\param painter Painter used for drawing
\param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
\param radialMap Maps radius values into painter coordinates.
\param pole Position of the pole in painter coordinates
\param radius Radius of the complete plot area in painter coordinates
\param canvasRect Contents rect of the canvas in painter coordinates
*/
void QwtPolarPlot::drawItems( QPainter *painter,
const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
const QPointF &pole, double radius,
const QRectF &canvasRect ) const
{
const QRectF pr = plotRect( canvasRect );
const QwtPolarItemList& itmList = itemList();
for ( QwtPolarItemIterator it = itmList.begin();
it != itmList.end(); ++it )
{
QwtPolarItem *item = *it;
if ( item && item->isVisible() )
{
painter->save();
// Unfortunately circular clipping slows down
// painting a lot. So we better try to avoid it.
bool doClipping = false;
if ( item->rtti() != QwtPolarItem::Rtti_PolarGrid )
{
const QwtInterval intv =
item->boundingInterval( QwtPolar::Radius );
if ( !intv.isValid() )
doClipping = true;
else
{
if ( radialMap.s1() < radialMap.s2() )
doClipping = intv.maxValue() > radialMap.s2();
else
doClipping = intv.minValue() < radialMap.s2();
}
}
if ( doClipping )
{
const int margin = item->marginHint();
const QRectF clipRect = pr.adjusted(
-margin, -margin, margin, margin );
if ( !clipRect.contains( canvasRect ) )
{
QRegion clipRegion( clipRect.toRect(), QRegion::Ellipse );
painter->setClipRegion( clipRegion, Qt::IntersectClip );
}
}
painter->setRenderHint( QPainter::Antialiasing,
item->testRenderHint( QwtPolarItem::RenderAntialiased ) );
item->draw( painter, azimuthMap, radialMap,
pole, radius, canvasRect );
painter->restore();
}
}
}
示例10: detachItems
void SweepInspector::loadSweep(int index) {
//load in new sweep values from data
if (data == NULL) return;
if ( (index < 0) || (index >= data->getNumSweeps())) return;
//remove old data and get new
if (d_curve) d_curve->attach(NULL);
detachItems();
fsweep sweep = data->getSweep(index);
d_curve = new QwtPlotCurve( data->timestampFromIndex(index) ); //Qwt will delete() this when its done with it
d_curve->setRenderHint( QwtPlotItem::RenderAntialiased );
d_curve->setStyle( QwtPlotCurve::Lines );
d_curve->setPen( QColor( Qt::yellow ), 2, Qt::SolidLine );
d_curve->setSamples( sweep );
d_curve->attach(this);
QwtInterval frange = data->limits(FREQ);
//setAxisScale(QwtPlot::xBottom, frange.minValue(), frange.maxValue(), (frange.maxValue() - frange.minValue())/ 5.0);
//setAxisScale(QwtPlot::yLeft, -135, 20, 10.0);
setTitle( QString("RF Sweep @ %1").arg(data->timestampFromIndex(index)) );
//set maximum zoom out
zoomer->setZoomBase(QRectF(QPointF(frange.minValue(), 40), QPointF(frange.maxValue(), -135)));
zoomer->zoomBase();
//find max, min, and average values and drop it on plot as well
double max = sweep.first().y(), min = sweep.first().y(), avg=0;
for(int i=0; i < sweep.size(); i++) {
max = std::max(max, sweep.at(i).y());
min = std::min(min, sweep.at(i).y());
avg += sweep.at(i).y();
} avg /= sweep.size();
//add markers onto the plot
QwtPlotMarker *one = new QwtPlotMarker(), *two = new QwtPlotMarker();
one->attach(this); one->setAxes(QwtPlot::xTop, QwtPlot::yRight);
two->attach(this); two->setAxes(QwtPlot::xTop, QwtPlot::yRight);
QwtText tone = QwtText(QString("Max: %1 dBm\nMin: %2 dBm\nAvg: %3 dBm").arg(max).arg(min).arg(avg));
tone.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
tone.setColor( Qt::green );
tone.setRenderFlags(Qt::AlignTop | Qt::AlignLeft);
one->setLabel(tone);
one->setValue(0, 10);
one->setLabelAlignment(Qt::AlignBottom | Qt::AlignRight);
QwtText ttwo(data->plotText());
ttwo.setFont( QFont( "Helvetica", 10, QFont::Bold ) );
ttwo.setColor( Qt::white );
ttwo.setRenderFlags(Qt::AlignBottom | Qt::AlignRight);
two->setLabel(ttwo);
two->setValue(10, 10);
two->setLabelAlignment(Qt::AlignBottom | Qt::AlignLeft);
replot();
repaint();
}
示例11: qwtIntervalWidthL
static inline long double qwtIntervalWidthL( const QwtInterval &interval )
{
if ( !interval.isValid() )
return 0.0;
return static_cast<long double>( interval.maxValue() )
- static_cast<long double>( interval.minValue() );
}
示例12: QwtInterval
/*!
\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;
}
示例13: QwtPlot
Plot::Plot( QWidget *parent ):
QwtPlot( parent ),
d_formatType( 0 ),
d_alpha(255)
{
d_spectrogram = new QwtPlotSpectrogram();
d_spectrogram->setRenderThreadCount( 0 ); // use system specific thread count
d_spectrogram->setCachePolicy( QwtPlotRasterItem::PaintCache );
QList<double> contourLevels;
for ( double level = 0.5; level < 10.0; level += 1.0 )
contourLevels += level;
d_spectrogram->setContourLevels( contourLevels );
d_spectrogram->setData( new SpectrogramData() );
d_spectrogram->attach( this );
const QwtInterval zInterval = d_spectrogram->data()->interval( Qt::ZAxis );
// A color bar on the right axis
QwtScaleWidget *rightAxis = axisWidget( QwtPlot::yRight );
rightAxis->setTitle( "Intensity" );
rightAxis->setColorBarEnabled( true );
setAxisScale( QwtPlot::yRight, zInterval.minValue(), zInterval.maxValue() );
enableAxis( QwtPlot::yRight );
plotLayout()->setAlignCanvasToScales( true );
setColorMap( Plot::RGBMap );
// LeftButton for the zooming
// MidButton for the panning
// RightButton: zoom out by 1
// Ctrl+RighButton: zoom out to full size
QwtPlotZoomer* zoomer = new MyZoomer( canvas() );
zoomer->setMousePattern( QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier );
zoomer->setMousePattern( QwtEventPattern::MouseSelect3,
Qt::RightButton );
QwtPlotPanner *panner = new QwtPlotPanner( canvas() );
panner->setAxisEnabled( QwtPlot::yRight, false );
panner->setMouseButton( Qt::MidButton );
// Avoid jumping when labels with more/less digits
// appear/disappear when scrolling vertically
const QFontMetrics fm( axisWidget( QwtPlot::yLeft )->font() );
QwtScaleDraw *sd = axisScaleDraw( QwtPlot::yLeft );
sd->setMinimumExtent( fm.width( "100.00" ) );
const QColor c( Qt::darkBlue );
zoomer->setRubberBandPen( c );
zoomer->setTrackerPen( c );
}
示例14: qwtIsSampleInside
static inline bool qwtIsSampleInside( const QwtOHLCSample &sample,
double tMin, double tMax, double vMin, double vMax )
{
const double t = sample.time;
const QwtInterval interval = sample.boundingInterval();
const bool isOffScreen = ( t < tMin ) || ( t > tMax )
|| ( interval.maxValue() < vMin ) || ( interval.minValue() > vMax );
return !isOffScreen;
}
示例15: changeitems
void matrixofpixels::PixPlotSpect(int TypeOfSpec,QwtMatrixRasterData *rasterpixdata)
{
changeitems();
MapPlot->setData(rasterpixdata);
MapPlot->setRenderThreadCount(0);
setAxisAutoScale(this->xTop);
setAxisAutoScale(this->xBottom);
switch (TypeOfSpec)
{
case 1:
MapPlot->setColorMap(new ColorMap(BLUERED));
break;
case 2:
MapPlot->setColorMap(new ColorMap(BLACKWHITE));
break;
default:
MapPlot->setColorMap(new ColorMap(BLUERED));
}
MapPlot->attach(/*MainPlot*/this);
const QwtInterval zInterval = MapPlot->data()->interval(Qt::ZAxis);
setAxisScale(QwtPlot::xBottom, 0, Npix);
setAxisMaxMinor(QwtPlot::xBottom, 0);
setAxisScale(QwtPlot::yLeft, 0, Npix);
setAxisMaxMinor(QwtPlot::yLeft, 0);
//rightAxis = new QwtScaleWidget();
QwtScaleWidget *rightAxis = axisWidget(QwtPlot::yRight);
//rightAxis = axisWidget(QwtPlot::yRight);
rightAxis->setColorBarEnabled(true);
rightAxis->setColorBarWidth(20);
rightAxis->setColorMap(zInterval, new ColorMap(TypeOfSpec) );
//ColorMap(TypeOfSpec);
plotLayout()->setAlignCanvasToScales(true);
setAxisScale(QwtPlot::yRight,zInterval.minValue(),zInterval.maxValue());
enableAxis(QwtPlot::yRight);
replot();
setAutoFillBackground(true);
/**
setAutoFillBackground(true); - autozapolnenie, ctobi isklyuchit'
nalozjeniya graphikov
*/
}