本文整理汇总了C++中QwtInterval::isValid方法的典型用法代码示例。如果您正苦于以下问题:C++ QwtInterval::isValid方法的具体用法?C++ QwtInterval::isValid怎么用?C++ QwtInterval::isValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QwtInterval
的用法示例。
在下文中一共展示了QwtInterval::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: boundingRect
/*!
\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();
}
示例2: pixelHint
/*!
\brief Pixel hint
- NearestNeighbour\n
pixelHint() returns the surrounding pixel of the top left value
in the matrix.
- BilinearInterpolation\n
Returns an empty rectangle recommending
to render in target device ( f.e. screen ) resolution.
\sa ResampleMode, setMatrix(), setInterval()
*/
QRectF QwtMatrixRasterData::pixelHint( const QRectF & ) const
{
QRectF rect;
if ( d_data->resampleMode == NearestNeighbour )
{
const QwtInterval intervalX = interval( Qt::XAxis );
const QwtInterval intervalY = interval( Qt::YAxis );
if ( intervalX.isValid() && intervalY.isValid() )
{
rect = QRectF( intervalX.minValue(), intervalY.minValue(),
d_data->dx, d_data->dy );
}
}
return rect;
}
示例3: drawItems
/*!
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();
}
}
}
示例4: 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() );
}
示例5: isCombinable
static inline bool isCombinable( const QwtInterval &d1,
const QwtInterval &d2 )
{
if ( d1.isValid() && d2.isValid() )
{
if ( d1.maxValue() == d2.minValue() )
{
if ( !( d1.borderFlags() & QwtInterval::ExcludeMaximum
&& d2.borderFlags() & QwtInterval::ExcludeMinimum ) )
{
return true;
}
}
}
return false;
}
示例6: update
void QwtMatrixRasterData::update()
{
d_data->numRows = 0;
d_data->dx = 0.0;
d_data->dy = 0.0;
if ( d_data->numColumns > 0 )
{
d_data->numRows = d_data->values.size() / d_data->numColumns;
const QwtInterval xInterval = interval( Qt::XAxis );
const QwtInterval yInterval = interval( Qt::YAxis );
if ( xInterval.isValid() )
d_data->dx = xInterval.width() / d_data->numColumns;
if ( yInterval.isValid() )
d_data->dy = yInterval.width() / d_data->numRows;
}
}
示例7: colorIndex
/*!
Build and return a color map of 256 colors
The color table is needed for rendering indexed images in combination
with using colorIndex().
\param interval Range for the values
\return A color table, that can be used for a QImage
*/
QVector<QRgb> QwtColorMap::colorTable( const QwtInterval &interval ) const
{
QVector<QRgb> table( 256 );
if ( interval.isValid() )
{
const double step = interval.width() / ( table.size() - 1 );
for ( int i = 0; i < table.size(); i++ )
table[i] = rgb( interval, interval.minValue() + step * i );
}
return table;
}
示例8: boundingRect
/*!
\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
{
const float max = std::numeric_limits<float>::max();
r.setLeft( -0.5 * max );
r.setWidth( max );
}
if ( intervalY.isValid() )
{
r.setTop( intervalY.minValue() );
r.setBottom( intervalY.maxValue() );
}
else
{
const float max = std::numeric_limits<float>::max();
r.setTop( -0.5 * max );
r.setHeight( max );
}
return r.normalized();
}
示例9: contains
/*!
Check if an interval "contains" a value
\param interval Interval
\param value Value
\return True, when the value is inside the interval
*/
bool QwtScaleEngine::contains(
const QwtInterval &interval, double value ) const
{
if ( !interval.isValid() )
return false;
if ( qwtFuzzyCompare( value, interval.minValue(), interval.width() ) < 0 )
return false;
if ( qwtFuzzyCompare( value, interval.maxValue(), interval.width() ) > 0 )
return false;
return true;
}
示例10: renderTile
/*!
\brief Render a tile of an image.
Rendering in tiles can be used to composite an image in parallel
threads.
\param xMap X-Scale Map
\param yMap Y-Scale Map
\param tile Geometry of the tile in image coordinates
\param image Image to be rendered
*/
void QwtPlotSpectrogram::renderTile(
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRect &tile, QImage *image ) const
{
const QwtInterval range = d_data->data->interval( Qt::ZAxis );
if ( !range.isValid() )
return;
if ( d_data->colorMap->format() == QwtColorMap::RGB )
{
for ( int y = tile.top(); y <= tile.bottom(); y++ )
{
const double ty = yMap.invTransform( y );
QRgb *line = reinterpret_cast<QRgb *>( image->scanLine( y ) );
line += tile.left();
for ( int x = tile.left(); x <= tile.right(); x++ )
{
const double tx = xMap.invTransform( x );
*line++ = d_data->colorMap->rgb( range,
d_data->data->value( tx, ty ) );
}
}
}
else if ( d_data->colorMap->format() == QwtColorMap::Indexed )
{
for ( int y = tile.top(); y <= tile.bottom(); y++ )
{
const double ty = yMap.invTransform( y );
unsigned char *line = image->scanLine( y );
line += tile.left();
for ( int x = tile.left(); x <= tile.right(); x++ )
{
const double tx = xMap.invTransform( x );
*line++ = d_data->colorMap->colorIndex( range,
d_data->data->value( tx, ty ) );
}
}
}
}
示例11: draw
/*!
Draw the spectrogram
\param painter Painter
\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 QwtPolarSpectrogram::draw( QPainter *painter,
const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
const QPointF &pole, double,
const QRectF &canvasRect ) const
{
const QRectF plotRect = plot()->plotRect( canvasRect.toRect() );
QRegion clipRegion( canvasRect.toRect() );
if ( qwtNeedsClipping( plotRect, canvasRect ) )
{
// For large plotRects the ellipse becomes a huge polygon.
// So we better clip only, when we really need to.
clipRegion &= QRegion( plotRect.toRect(), QRegion::Ellipse );
}
QRect imageRect = canvasRect.toRect();
if ( painter->hasClipping() )
imageRect &= painter->clipRegion().boundingRect();
const QwtInterval radialInterval =
boundingInterval( QwtPolar::ScaleRadius );
if ( radialInterval.isValid() )
{
const double radius = radialMap.transform( radialInterval.maxValue() ) -
radialMap.transform( radialInterval.minValue() );
QRectF r( 0, 0, 2 * radius, 2 * radius );
r.moveCenter( pole );
clipRegion &= QRegion( r.toRect(), QRegion::Ellipse );;
imageRect &= r.toRect();
}
const QImage image = renderImage( azimuthMap, radialMap, pole, imageRect );
painter->save();
painter->setClipRegion( clipRegion );
painter->drawImage( imageRect, image );
painter->restore();
}
示例12: renderImage
/*!
\brief Render an image from data and color map.
For each pixel of area the value is mapped into a color.
\param xMap X-Scale Map
\param yMap Y-Scale Map
\param area Requested area for the image in scale coordinates
\param imageSize Size of the requested image
\return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending
on the color map.
\sa QwtRasterData::value(), QwtColorMap::rgb(),
QwtColorMap::colorIndex()
*/
QImage QwtPlotSpectrogram::renderImage(
const QwtScaleMap &xMap, const QwtScaleMap &yMap,
const QRectF &area, const QSize &imageSize ) const
{
if ( imageSize.isEmpty() || d_data->data == NULL
|| d_data->colorMap == NULL )
{
return QImage();
}
const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis );
if ( !intensityRange.isValid() )
return QImage();
QImage::Format format = ( d_data->colorMap->format() == QwtColorMap::RGB )
? QImage::Format_ARGB32 : QImage::Format_Indexed8;
QImage image( imageSize, format );
if ( d_data->colorMap->format() == QwtColorMap::Indexed )
image.setColorTable( d_data->colorMap->colorTable( intensityRange ) );
d_data->data->initRaster( area, image.size() );
#if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
uint numThreads = renderThreadCount();
if ( numThreads <= 0 )
numThreads = QThread::idealThreadCount();
if ( numThreads <= 0 )
numThreads = 1;
const int numRows = imageSize.height() / numThreads;
QList< QFuture<void> > futures;
for ( uint i = 0; i < numThreads; i++ )
{
QRect tile( 0, i * numRows, image.width(), numRows );
if ( i == numThreads - 1 )
{
tile.setHeight( image.height() - i * numRows );
renderTile( xMap, yMap, tile, &image );
}
else
{
futures += QtConcurrent::run(
this, &QwtPlotSpectrogram::renderTile,
xMap, yMap, tile, &image );
}
}
for ( int i = 0; i < futures.size(); i++ )
futures[i].waitForFinished();
#else // QT_VERSION < 0x040400
const QRect tile( 0, 0, image.width(), image.height() );
renderTile( xMap, yMap, tile, &image );
#endif
d_data->data->discardRaster();
return image;
}
示例13: renderTile
/*!
\brief Render a sub-rectangle of an image
renderTile() is called by renderImage() to render different parts
of the image by concurrent threads.
\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 imagePos Top/left position of the image in painter coordinates
\param tile Sub-rectangle of the tile in painter coordinates
\param image Image to be rendered
\sa setRenderThreadCount()
\note renderTile needs to be reentrant
*/
void QwtPolarSpectrogram::renderTile(
const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
const QPointF &pole, const QPoint &imagePos,
const QRect &tile, QImage *image ) const
{
const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis );
if ( !intensityRange.isValid() )
return;
const bool doFastAtan = testPaintAttribute( ApproximatedAtan );
const int y0 = imagePos.y();
const int y1 = tile.top();
const int y2 = tile.bottom();
const int x0 = imagePos.x();
const int x1 = tile.left();
const int x2 = tile.right();
if ( d_data->colorMap->format() == QwtColorMap::RGB )
{
for ( int y = y1; y <= y2; y++ )
{
const double dy = pole.y() - y;
const double dy2 = qwtSqr( dy );
QRgb *line = reinterpret_cast<QRgb *>( image->scanLine( y - y0 ) );
line += x1 - x0;
for ( int x = x1; x <= x2; x++ )
{
const double dx = x - pole.x();
double a = doFastAtan ? qwtFastAtan2( dy, dx ) : qAtan2( dy, dx );
if ( a < 0.0 )
a += 2 * M_PI;
if ( a < azimuthMap.p1() )
a += 2 * M_PI;
const double r = qSqrt( qwtSqr( dx ) + dy2 );
const double azimuth = azimuthMap.invTransform( a );
const double radius = radialMap.invTransform( r );
const double value = d_data->data->value( azimuth, radius );
*line++ = d_data->colorMap->rgb( intensityRange, value );
}
}
}
else if ( d_data->colorMap->format() == QwtColorMap::Indexed )
{
for ( int y = y1; y <= y2; y++ )
{
const double dy = pole.y() - y;
const double dy2 = qwtSqr( dy );
unsigned char *line = image->scanLine( y - y0 );
line += x1 - x0;
for ( int x = x1; x <= x2; x++ )
{
const double dx = x - pole.x();
double a = doFastAtan ? qwtFastAtan2( dy, dx ) : qAtan2( dy, dx );
if ( a < 0.0 )
a += 2 * M_PI;
if ( a < azimuthMap.p1() )
a += 2 * M_PI;
const double r = qSqrt( qwtSqr( dx ) + dy2 );
const double azimuth = azimuthMap.invTransform( a );
const double radius = radialMap.invTransform( r );
const double value = d_data->data->value( azimuth, radius );
*line++ = d_data->colorMap->colorIndex( intensityRange, value );
}
}
}
}
示例14: renderImage
/*!
\brief Render an image from the data and color map.
The area is translated into a rect of the paint device.
For each pixel of this rect the intensity is mapped
into a color.
\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 rect Target rectangle of the image in painter coordinates
\return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending
on the color map.
\sa QwtRasterData::intensity(), QwtColorMap::rgb(),
QwtColorMap::colorIndex()
*/
QImage QwtPolarSpectrogram::renderImage(
const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
const QPointF &pole, const QRect &rect ) const
{
if ( d_data->data == NULL || d_data->colorMap == NULL )
return QImage();
QImage image( rect.size(), d_data->colorMap->format() == QwtColorMap::RGB
? QImage::Format_ARGB32 : QImage::Format_Indexed8 );
const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis );
if ( !intensityRange.isValid() )
return image;
if ( d_data->colorMap->format() == QwtColorMap::Indexed )
image.setColorTable( d_data->colorMap->colorTable( intensityRange ) );
/*
For the moment we only announce the composition of the image by
calling initRaster(), but we don't pass any useful parameters.
( How to map rect into something, that is useful to initialize a matrix
of values in polar coordinates ? )
*/
d_data->data->initRaster( QRectF(), QSize() );
#if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
uint numThreads = renderThreadCount();
if ( numThreads <= 0 )
numThreads = QThread::idealThreadCount();
if ( numThreads <= 0 )
numThreads = 1;
const int numRows = rect.height() / numThreads;
QVector<TileInfo> tileInfos;
for ( uint i = 0; i < numThreads; i++ )
{
QRect tile( rect.x(), rect.y() + i * numRows, rect.width(), numRows );
if ( i == numThreads - 1 )
tile.setHeight( rect.height() - i * numRows );
TileInfo tileInfo;
tileInfo.imagePos = rect.topLeft();
tileInfo.rect = tile;
tileInfo.image = ℑ
tileInfos += tileInfo;
}
QVector< QFuture<void> > futures;
for ( int i = 0; i < tileInfos.size(); i++ )
{
if ( i == tileInfos.size() - 1 )
{
renderTile( azimuthMap, radialMap, pole, &tileInfos[i] );
}
else
{
futures += QtConcurrent::run( this, &QwtPolarSpectrogram::renderTile,
azimuthMap, radialMap, pole, &tileInfos[i] );
}
}
for ( int i = 0; i < futures.size(); i++ )
futures[i].waitForFinished();
#else // QT_VERSION < 0x040400
renderTile( azimuthMap, radialMap, pole, rect.topLeft(), rect, &image );
#endif
d_data->data->discardRaster();
return image;
}
示例15: contourLines
/*!
Calculate contour lines
\param rect Bounding rectangle for the contour lines
\param raster Number of data pixels of the raster data
\param levels List of limits, where to insert contour lines
\param flags Flags to customize the contouring algorithm
\return Calculated contour lines
An adaption of CONREC, a simple contouring algorithm.
http://local.wasp.uwa.edu.au/~pbourke/papers/conrec/
*/
QwtRasterData::ContourLines QwtRasterData::contourLines(
const QRectF &rect, const QSize &raster,
const QList<double> &levels, ConrecFlags flags ) const
{
ContourLines contourLines;
if ( levels.size() == 0 || !rect.isValid() || !raster.isValid() )
return contourLines;
const double dx = rect.width() / raster.width();
const double dy = rect.height() / raster.height();
const bool ignoreOnPlane =
flags & QwtRasterData::IgnoreAllVerticesOnLevel;
const QwtInterval range = interval( Qt::ZAxis );
bool ignoreOutOfRange = false;
if ( range.isValid() )
ignoreOutOfRange = flags & IgnoreOutOfRange;
QwtRasterData *that = const_cast<QwtRasterData *>( this );
that->initRaster( rect, raster );
for ( int y = 0; y < raster.height() - 1; y++ )
{
enum Position
{
Center,
TopLeft,
TopRight,
BottomRight,
BottomLeft,
NumPositions
};
QwtPoint3D xy[NumPositions];
for ( int x = 0; x < raster.width() - 1; x++ )
{
const QPointF pos( rect.x() + x * dx, rect.y() + y * dy );
if ( x == 0 )
{
xy[TopRight].setX( pos.x() );
xy[TopRight].setY( pos.y() );
xy[TopRight].setZ(
value( xy[TopRight].x(), xy[TopRight].y() )
);
xy[BottomRight].setX( pos.x() );
xy[BottomRight].setY( pos.y() + dy );
xy[BottomRight].setZ(
value( xy[BottomRight].x(), xy[BottomRight].y() )
);
}
xy[TopLeft] = xy[TopRight];
xy[BottomLeft] = xy[BottomRight];
xy[TopRight].setX( pos.x() + dx );
xy[TopRight].setY( pos.y() );
xy[BottomRight].setX( pos.x() + dx );
xy[BottomRight].setY( pos.y() + dy );
xy[TopRight].setZ(
value( xy[TopRight].x(), xy[TopRight].y() )
);
xy[BottomRight].setZ(
value( xy[BottomRight].x(), xy[BottomRight].y() )
);
double zMin = xy[TopLeft].z();
double zMax = zMin;
double zSum = zMin;
for ( int i = TopRight; i <= BottomLeft; i++ )
{
const double z = xy[i].z();
zSum += z;
if ( z < zMin )
zMin = z;
if ( z > zMax )
zMax = z;
}
//.........这里部分代码省略.........