/*!
Set to legend item symbol with color of item
*/
-void Plot2d_HistogramItem::updateLegend( QwtPlotItem* thePlotItem,
- QList<QwtLegendData>& theLegendData )
+void Plot2d_HistogramItem::updateLegend( const QwtPlotItem* thePlotItem,
+ const QList<QwtLegendData>& theLegendData )
{
if ( !thePlotItem || !thePlotItem->plot() )
return;
QwtLegend *legend = dynamic_cast<QwtLegend *>( thePlotItem->plot()->legend() );
QWidget* widget = legend->legendWidget( itemInfo );
- if ( !widget || !widget->inherits( "QwtLegendItem" ) )
+ if ( !widget || !widget->inherits( "QwtLegendLabel" ) )
return;
QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( widget );
if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)( label ) ) {
QFontMetrics aFMetrics( anItem->font() );
int aSize = aFMetrics.height();
+ QPen aPen( legendPen().color() );
+ aPen.setStyle(Qt::NoPen);
+ anItem->setPen(aPen);
QwtSymbol* aSymbol = new QwtSymbol( QwtSymbol::Rect, QBrush( legendPen().color() ),
- QPen( legendPen().color() ), QSize( aSize, aSize ) );
+ aPen, QSize( aSize, aSize ) );
anItem->setSymbol( aSymbol );
if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
anItem->setSymbolType( plot->getLegendSymbolType() );
drawBar( thePainter, Qt::Horizontal, aRect );
}
+void Plot2d_HistogramItem::itemChanged()
+{
+ if ( plot() )
+ updateLegend( this, legendData() );
+
+ QwtPlotItem::itemChanged();
+}
+
+
/*!
Returns top value of the given rect in the context of other bars.
return aRes;
}
+QwtGraphic Plot2d_HistogramItem::legendIcon( int index, const QSizeF &size ) const
+{
+ return defaultIcon( color(), size );
+}
+
Plot2d_QwtLegend::Plot2d_QwtLegend( QWidget *parent ):
QwtLegend( parent )
{
QList<QRect> getBars() const;
- virtual void updateLegend( QwtPlotItem*,
- QList<QwtLegendData>& );
+
+ virtual void updateLegend( const QwtPlotItem *,
+ const QList<QwtLegendData> & );
virtual void draw( QPainter*, const QwtScaleMap&,
const QwtScaleMap&, const QRectF& ) const;
+ virtual void itemChanged();
+
+ virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
+
void setCrossItems( bool theCross );
bool isCrossItems() const;