-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
*/
Plot2d_QwtLegendLabel::~Plot2d_QwtLegendLabel()
{
+ delete mySymbol;
}
/*!
*/
void Plot2d_QwtLegendLabel::setSymbol( const QwtSymbol* theSymbol )
{
+ delete mySymbol;
mySymbol = new QwtSymbol( theSymbol->style(), theSymbol->brush(),
theSymbol->pen(), theSymbol->size() );
}
QRect iconRect = cr;
if ( !icon().isNull() )
{
- if ( itemMode() != QwtLegendData::ReadOnly )
+ if ( itemMode() != QwtLegendData::ReadOnly ) {
iconRect.setX( iconRect.x() + ButtonFrame );
iconRect.setSize( QSize( icon().size().width() + spacing() ,
- icon().size().height() + spacing() ) );
+ icon().size().height() + spacing() ) );
iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) );
+ }
}
drawIdentifier( &painter, iconRect );
return qwtMin(myMin.size(), myMax.size());
}
bool values(size_t i, double &min, double &max) {
- if(myMin.contains(i) && myMax.contains(i)) {
- min = myMin[i];
- max = myMax[i];
+ if(myMin.contains((int)i) && myMax.contains((int)i)) { //!< TODO: conversion from size_t to int
+ min = myMin[(int)i];
+ max = myMax[(int)i];
return true;
}
return false;
*/
Plot2d_QwtPlotCurve::Plot2d_QwtPlotCurve( const QString& title,
QwtPlot::Axis yAxis /*const int index*/ ) :
- Plot2d_SelectableItem(),
QwtPlotCurve( title ),
+ Plot2d_SelectableItem(),
myYAxis( yAxis ),
myYAxisIdentifierEnabled( false ),
myDeviationData(0)
if( QWidget* widget = legend->legendWidget( itemInfo ) ) {
QwtLegendLabel* label = dynamic_cast<QwtLegendLabel*>( widget );
if( Plot2d_QwtLegendLabel* anItem = (Plot2d_QwtLegendLabel*)label ) {
- int aMode = Plot2d_QwtLegendLabel::IM_None;
- if( myYAxisIdentifierEnabled )
- aMode = myYAxis == QwtPlot::yRight ?
- Plot2d_QwtLegendLabel::IM_Right :
- Plot2d_QwtLegendLabel::IM_Left;
- anItem->setYAxisIdentifierMode( aMode );
-
- anItem->setSymbol( legendSymbol() );
- if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
- anItem->setSymbolType( plot->getLegendSymbolType() );
- anItem->setPen( legendPen() );
-
- anItem->setSelected( isSelected() );
- anItem->updateHighlit();
- anItem->repaint();
+ int aMode = Plot2d_QwtLegendLabel::IM_None;
+ if( myYAxisIdentifierEnabled )
+ aMode = myYAxis == QwtPlot::yRight ?
+ Plot2d_QwtLegendLabel::IM_Right :
+ Plot2d_QwtLegendLabel::IM_Left;
+ anItem->setYAxisIdentifierMode( aMode );
+
+ anItem->setSymbol( legendSymbol() );
+ if( Plot2d_Plot2d* plot = dynamic_cast<Plot2d_Plot2d*>( thePlotItem->plot() ) )
+ anItem->setSymbolType( plot->getLegendSymbolType() );
+ anItem->setPen( legendPen() );
+
+ anItem->setSelected( isSelected() );
+ anItem->updateHighlit();
+ anItem->repaint();
}
}
}
int from, int to) const
{
if (to < 0)
- to = dataSize() - 1;
+ to = (int)dataSize() - 1; //!< TODO: conversion from size_t to int
QwtPlotCurve::drawSeries(painter, xMap, yMap, canvasRect, from, to);
//draw deviation data
painter->drawLine(xp,ytop,xp,ybtm);
painter->drawLine(tickl,ybtm,tickr,ybtm);
}
- painter->restore();
+ painter->restore();
}
}
*/
Plot2d_SelectableItem::Plot2d_SelectableItem():
myIsSelected(false),
- myLegendSymbol( new QwtSymbol() ),
- myLegendPen( QPen() )
+ myLegendPen( QPen() ),
+ myLegendSymbol( new QwtSymbol() )
{
}
Sets histogram attributes
*/
void Plot2d_HistogramQwtItem::setHistogramAttribute( HistogramAttribute theAttr,
- bool isOn )
+ bool isOn )
{
if ( testHistogramAttribute( theAttr ) != isOn ) {
if ( isOn )
Draws histogram object
*/
void Plot2d_HistogramQwtItem::draw( QPainter* thePainter,
- const QwtScaleMap& theXMap,
- const QwtScaleMap& theYMap,
- const QRectF& ) const
+ const QwtScaleMap& theXMap,
+ const QwtScaleMap& theYMap,
+ const QRectF& ) const
{
thePainter->setPen( QPen( myColor ) );
Draws single bar of histogram
*/
void Plot2d_HistogramQwtItem::drawBar( QPainter* thePainter,
- Qt::Orientation,
- const QRect& theRect ) const
+ Qt::Orientation,
+ const QRect& theRect ) const
{
thePainter->save();
/*!
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() );
Draws histogram object
*/
void Plot2d_HistogramItem::draw( QPainter* thePainter,
- const QwtScaleMap& theXMap,
- const QwtScaleMap& theYMap,
- const QRectF& ) const
+ const QwtScaleMap& theXMap,
+ const QwtScaleMap& theYMap,
+ const QRectF& ) const
{
// nds: clear list of bar items
Plot2d_HistogramItem* anItem = (Plot2d_HistogramItem*)this;
Draws bar of histogram and on it bars of histograms with lower height.
*/
void Plot2d_HistogramItem::drawRectAndLowers( QPainter* thePainter,
- Qt::Orientation theOr,
- const QRect& theRect ) const
+ Qt::Orientation /*theOr*/,
+ const QRect& theRect ) const
{
QRect aRect = theRect;
// theRect has inversed coordinates on Y axis.
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.
qMin( theRect.left(), aRects[i].left() ) ) {
if ( theRect.bottom() < aRects[i].bottom() )
if ( aRects[i].bottom() < aRes )
- aRes = aRects[i].bottom();
+ aRes = aRects[i].bottom();
}
}
}
return aRes;
}
+QwtGraphic Plot2d_HistogramItem::legendIcon( int /*index*/, const QSizeF &size ) const
+{
+ return defaultIcon( color(), size );
+}
+
Plot2d_QwtLegend::Plot2d_QwtLegend( QWidget *parent ):
QwtLegend( parent )
{
/*!
Redefined method, which create a widget to be inserted into the legend.
*/
-QWidget *Plot2d_QwtLegend::createWidget( const QwtLegendData &data ) const
+QWidget *Plot2d_QwtLegend::createWidget( const QwtLegendData& /*data*/ ) const
{
- Q_UNUSED( data );
-
Plot2d_QwtLegendLabel *label = new Plot2d_QwtLegendLabel();
label->setItemMode( defaultItemMode() );