本文整理汇总了C++中QwtGraphic类的典型用法代码示例。如果您正苦于以下问题:C++ QwtGraphic类的具体用法?C++ QwtGraphic怎么用?C++ QwtGraphic使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QwtGraphic类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: size
/*!
Minimum size hint needed to display an entry
\param data Attributes of the legend entry
\return Minimum size
*/
QSize QwtPlotLegendItem::minimumSize( const QwtLegendData &data ) const
{
QSize size( 2 * d_data->itemMargin, 2 * d_data->itemMargin );
if ( !data.isValid() )
return size;
const QwtGraphic graphic = data.icon();
const QwtText text = data.title();
int w = 0;
int h = 0;
if ( !graphic.isNull() )
{
w = graphic.width();
h = graphic.height();
}
if ( !text.isEmpty() )
{
const QSizeF sz = text.textSize( font() );
w += qCeil( sz.width() );
h = qMax( h, qCeil( sz.height() ) );
}
if ( graphic.width() > 0 && !text.isEmpty() )
w += d_data->itemSpacing;
size += QSize( w, h );
return size;
}
示例2: curveColor
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimPlotCurve::updateUiIconFromPlotSymbol()
{
if (m_pointSymbol() != RiuQwtSymbol::NoSymbol)
{
QColor curveColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte());
QSizeF iconSize(24, 24);
QwtGraphic graphic = m_qwtPlotCurve->legendIcon(0, iconSize);
QPixmap pixmap = graphic.toPixmap();
setUiIcon(QIcon(pixmap));
}
}
示例3: qwtPathGraphic
static QwtGraphic qwtPathGraphic( const QPainterPath &path,
const QPen &pen, const QBrush& brush )
{
QwtGraphic graphic;
graphic.setRenderHint( QwtGraphic::RenderPensUnscaled );
QPainter painter( &graphic );
painter.setPen( pen );
painter.setBrush( brush );
painter.drawPath( path );
painter.end();
return graphic;
}
示例4: style
/*!
\return Icon for the legend
In case of Tube style() the icon is a plain rectangle filled with the brush().
If a symbol is assigned it is scaled to size.
\param index Index of the legend entry
( ignored as there is only one )
\param size Icon size
\sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/
QwtGraphic QwtPlotIntervalCurve::legendIcon(
int index, const QSizeF &size ) const
{
Q_UNUSED( index );
if ( size.isEmpty() )
return QwtGraphic();
QwtGraphic icon;
icon.setDefaultSize( size );
icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
QPainter painter( &icon );
painter.setRenderHint( QPainter::Antialiasing,
testRenderHint( QwtPlotItem::RenderAntialiased ) );
if ( d_data->style == Tube )
{
QRectF r( 0, 0, size.width(), size.height() );
painter.fillRect( r, d_data->brush );
}
if ( d_data->symbol &&
( d_data->symbol->style() != QwtIntervalSymbol::NoSymbol ) )
{
QPen pen = d_data->symbol->pen();
pen.setWidthF( pen.widthF() );
pen.setCapStyle( Qt::FlatCap );
painter.setPen( pen );
painter.setBrush( d_data->symbol->brush() );
if ( orientation() == Qt::Vertical )
{
const double x = 0.5 * size.width();
d_data->symbol->draw( &painter, orientation(),
QPointF( x, 0 ), QPointF( x, size.height() - 1.0 ) );
}
else
{
const double y = 0.5 * size.height();
d_data->symbol->draw( &painter, orientation(),
QPointF( 0.0, y ), QPointF( size.width() - 1.0, y ) );
}
}
return icon;
}
示例5: setLegendIconSize
/*!
\return Icon representing the marker on the legend
\param index Index of the legend entry
( usually there is only one )
\param size Icon size
\sa setLegendIconSize(), legendData()
*/
QwtGraphic QwtPlotMarker::legendIcon( int index,
const QSizeF &size ) const
{
Q_UNUSED( index );
if ( size.isEmpty() )
return QwtGraphic();
QwtGraphic icon;
icon.setDefaultSize( size );
icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
QPainter painter( &icon );
painter.setRenderHint( QPainter::Antialiasing,
testRenderHint( QwtPlotItem::RenderAntialiased ) );
if ( d_data->style != QwtPlotMarker::NoLine )
{
painter.setPen( d_data->pen );
if ( d_data->style == QwtPlotMarker::HLine ||
d_data->style == QwtPlotMarker::Cross )
{
const double y = 0.5 * size.height();
QwtPainter::drawLine( &painter,
0.0, y, size.width(), y );
}
if ( d_data->style == QwtPlotMarker::VLine ||
d_data->style == QwtPlotMarker::Cross )
{
const double x = 0.5 * size.width();
QwtPainter::drawLine( &painter,
x, 0.0, x, size.height() );
}
}
if ( d_data->symbol )
{
const QRect r( 0.0, 0.0, size.width(), size.height() );
d_data->symbol->drawSymbol( &painter, r );
}
return icon;
}
示例6: drawBar
/*!
\return Icon for representing a bar on the legend
\param index Index of the bar
\param size Icon size
\return An icon showing a bar
\sa drawBar(), legendData()
*/
QwtGraphic QwtPlotMultiBarChart::legendIcon( int index,
const QSizeF &size ) const
{
QwtColumnRect column;
column.hInterval = QwtInterval( 0.0, size.width() - 1.0 );
column.vInterval = QwtInterval( 0.0, size.height() - 1.0 );
QwtGraphic icon;
icon.setDefaultSize( size );
icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
QPainter painter( &icon );
painter.setRenderHint( QPainter::Antialiasing,
testRenderHint( QwtPlotItem::RenderAntialiased ) );
drawBar( &painter, -1, index, column );
return icon;
}
示例7: qwtScaledBoundingRect
static inline QRectF qwtScaledBoundingRect(
const QwtGraphic &graphic, const QSizeF size )
{
QSizeF scaledSize = size;
if ( scaledSize.isEmpty() )
scaledSize = graphic.defaultSize();
const QSizeF sz = graphic.controlPointRect().size();
double sx = 1.0;
if ( sz.width() > 0.0 )
sx = scaledSize.width() / sz.width();
double sy = 1.0;
if ( sz.height() > 0.0 )
sy = scaledSize.height() / sz.height();
return graphic.scaledBoundingRect( sx, sy );
}
示例8: QwtGraphic
QwtGraphic Plot2DProfile::legendIcon( int /*index*/, const QSizeF& iconSize ) const {
if ( iconSize.isEmpty() ){
return QwtGraphic();
}
QwtGraphic icon;
icon.setDefaultSize( iconSize );
icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
QPainter painter( &icon );
QPen pen( m_defaultColor );
pen.setStyle( m_penStyle );
pen.setWidth( 3 );
const double y = 0.5 * iconSize.height();
QPainterPath path;
path.moveTo( 0.0, y );
path.lineTo( iconSize.width(), y );
painter.strokePath( path, pen );
return icon;
}
示例9: heightForWidth
/*!
\return The preferred height, for a width.
\param data Attributes of the legend entry
\param width Width
*/
int QwtPlotLegendItem::heightForWidth(
const QwtLegendData &data, int width ) const
{
width -= 2 * d_data->itemMargin;
const QwtGraphic graphic = data.icon();
const QwtText text = data.title();
if ( text.isEmpty() )
return graphic.height();
if ( graphic.width() > 0 )
width -= graphic.width() + d_data->itemSpacing;
int h = text.heightForWidth( width, font() );
h += 2 * d_data->itemMargin;
return qMax( graphic.height(), h );
}
示例10: qwtDrawGraphicSymbols
static inline void qwtDrawGraphicSymbols( QPainter *painter,
const QPointF *points, int numPoints, const QwtGraphic &graphic,
const QwtSymbol &symbol )
{
const QRectF pointRect = graphic.controlPointRect();
if ( pointRect.isEmpty() )
return;
double sx = 1.0;
double sy = 1.0;
const QSize sz = symbol.size();
if ( sz.isValid() )
{
sx = sz.width() / pointRect.width();
sy = sz.height() / pointRect.height();
}
QPointF pinPoint = pointRect.center();
if ( symbol.isPinPointEnabled() )
pinPoint = symbol.pinPoint();
const QTransform transform = painter->transform();
for ( int i = 0; i < numPoints; i++ )
{
QTransform tr = transform;
tr.translate( points[i].x(), points[i].y() );
tr.scale( sx, sy );
tr.translate( -pinPoint.x(), -pinPoint.y() );
painter->setTransform( tr );
graphic.render( painter );
}
painter->setTransform( transform );
}
示例11: brush
/*!
\return A rectangle filled with the color of the brush ( or the pen )
\param index Index of the legend entry
( usually there is only one )
\param size Icon size
\sa setLegendIconSize(), legendData()
*/
QwtGraphic QwtPlotShapeItem::legendIcon( int index,
const QSizeF &size ) const
{
Q_UNUSED( index );
QwtGraphic icon;
icon.setDefaultSize( size );
if ( size.isEmpty() )
return icon;
if ( d_data->legendMode == QwtPlotShapeItem::LegendShape )
{
const QRectF &br = d_data->boundingRect;
QPainter painter( &icon );
painter.setRenderHint( QPainter::Antialiasing,
testRenderHint( QwtPlotItem::RenderAntialiased ) );
painter.translate( -br.topLeft() );
painter.setPen( d_data->pen );
painter.setBrush( d_data->brush );
painter.drawPath( d_data->shape );
}
else
{
QColor iconColor;
if ( d_data->brush.style() != Qt::NoBrush )
iconColor = d_data->brush.color();
else
iconColor = d_data->pen.color();
icon = defaultIcon( iconColor, size );
}
return icon;
}
示例12: legendMode
/*!
\return Icon representing a bar or the chart on the legend
When the legendMode() is LegendBarTitles the icon shows
the bar corresponding to index - otherwise the bar
displays the default symbol.
\param index Index of the legend entry
\param size Icon size
\sa setLegendMode(), drawBar(),
QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/
QwtGraphic QwtPlotBarChart::legendIcon(
int index, const QSizeF &size ) const
{
QwtColumnRect column;
column.hInterval = QwtInterval( 0.0, size.width() - 1.0 );
column.vInterval = QwtInterval( 0.0, size.height() - 1.0 );
QwtGraphic icon;
icon.setDefaultSize( size );
icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
QPainter painter( &icon );
painter.setRenderHint( QPainter::Antialiasing,
testRenderHint( QwtPlotItem::RenderAntialiased ) );
int barIndex = -1;
if ( d_data->legendMode == QwtPlotBarChart::LegendBarTitles )
barIndex = index;
drawBar( &painter, barIndex, QPointF(), column );
return icon;
}
示例13: Q_UNUSED
/*!
Draw an entry on the legend
\param painter Qt Painter
\param plotItem Plot item, represented by the entry
\param data Attributes of the legend entry
\param rect Bounding rectangle for the entry
*/
void QwtPlotLegendItem::drawLegendData( QPainter *painter,
const QwtPlotItem *plotItem, const QwtLegendData &data,
const QRectF &rect ) const
{
Q_UNUSED( plotItem );
const int m = d_data->itemMargin;
const QRectF r = rect.toRect().adjusted( m, m, -m, -m );
painter->setClipRect( r, Qt::IntersectClip );
int titleOff = 0;
const QwtGraphic graphic = data.icon();
if ( !graphic.isEmpty() )
{
QRectF iconRect( r.topLeft(), graphic.defaultSize() );
iconRect.moveCenter(
QPoint( iconRect.center().x(), rect.center().y() ) );
graphic.render( painter, iconRect, Qt::KeepAspectRatio );
titleOff += iconRect.width() + d_data->itemSpacing;
}
const QwtText text = data.title();
if ( !text.isEmpty() )
{
painter->setPen( textPen() );
painter->setFont( font() );
const QRectF textRect = r.adjusted( titleOff, 0, 0, 0 );
text.draw( painter, textRect );
}
}
示例14: legendData
/*!
\brief Return all information, that is needed to represent
the item on the legend
Most items are represented by one entry on the legend
showing an icon and a text.
QwtLegendData is basically a list of QVariants that makes it
possible to overload and reimplement legendData() to
return almost any type of information, that is understood
by the receiver that acts as the legend.
The default implementation returns one entry with
the title() of the item and the legendIcon().
\sa title(), legendIcon(), QwtLegend
*/
QList<QwtLegendData> QwtPolarItem::legendData() const
{
QwtLegendData data;
QwtText label = title();
label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
QVariant titleValue;
qVariantSetValue( titleValue, label );
data.setValue( QwtLegendData::TitleRole, titleValue );
const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
if ( !graphic.isNull() )
{
QVariant iconValue;
qVariantSetValue( iconValue, graphic );
data.setValue( QwtLegendData::IconRole, iconValue );
}
QList<QwtLegendData> list;
list += data;
return list;
}
示例15: Q_UNUSED
/*!
\return Icon representing the curve on the legend
\param index Index of the legend entry
( ignored as there is only one )
\param size Icon size
\sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
*/
QwtGraphic QwtPlotCurve::legendIcon( int index,
const QSizeF &size ) const
{
Q_UNUSED( index );
if ( size.isEmpty() )
return QwtGraphic();
QwtGraphic graphic;
graphic.setDefaultSize( size );
graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
QPainter painter( &graphic );
painter.setRenderHint( QPainter::Antialiasing,
testRenderHint( QwtPlotItem::RenderAntialiased ) );
if ( d_data->legendAttributes == 0 ||
d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
{
QBrush brush = d_data->brush;
if ( brush.style() == Qt::NoBrush &&
d_data->legendAttributes == 0 )
{
if ( style() != QwtPlotCurve::NoCurve )
{
brush = QBrush( pen().color() );
}
else if ( d_data->symbol &&
( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
{
brush = QBrush( d_data->symbol->pen().color() );
}
}
if ( brush.style() != Qt::NoBrush )
{
QRectF r( 0, 0, size.width(), size.height() );
painter.fillRect( r, brush );
}
}
if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )
{
if ( pen() != Qt::NoPen )
{
QPen pn = pen();
pn.setCapStyle( Qt::FlatCap );
painter.setPen( pn );
const double y = 0.5 * size.height();
QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
}
}
if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
{
if ( d_data->symbol )
{
QRectF r( 0, 0, size.width(), size.height() );
d_data->symbol->drawSymbol( &painter, r );
}
}
return graphic;
}