From: ema Date: Wed, 23 Nov 2011 12:11:16 +0000 (+0000) Subject: 1.Porting to QWT 6.0rc5 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bcb231006a807ba0a597ee9cd89b1f0a5bb54cff;p=modules%2Fgui.git 1.Porting to QWT 6.0rc5 2.Porting to QT 4.7.1 --- diff --git a/src/Plot2d/Plot2d.h b/src/Plot2d/Plot2d.h index 965f67eb2..6317133bf 100755 --- a/src/Plot2d/Plot2d.h +++ b/src/Plot2d/Plot2d.h @@ -35,6 +35,7 @@ #include #include +#include class QPainter; diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index 43e91a991..174e421cf 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -118,10 +118,11 @@ void Plot2d_Curve::updatePlotItem( QwtPlotItem* theItem ) QwtSymbol::Style ms = Plot2d::plot2qwtMarker( getMarker() ); aCurve->setPen( QPen( getColor(), getLineWidth(), ps ) ); - aCurve->setSymbol( QwtSymbol( ms, QBrush( getColor() ), + aCurve->setSymbol( new QwtSymbol( ms, QBrush( getColor() ), QPen( getColor() ), QSize( myMarkerSize, myMarkerSize ) ) ); - aCurve->setData( horData(), verData(), nbPoints() ); + aCurve->setSamples( horData(), verData(), nbPoints() ); + //aCurve->setLegendAttribute( QwtPlotCurve::LegendShowSymbol,true );//ema:TODO } /*! @@ -301,7 +302,7 @@ bool Plot2d_Curve::existMarker( const QwtPlot* thePlot, const QwtSymbol::Style t if( anItem && anItem->rtti() == rtti() ) { QwtPlotCurve* crv = dynamic_cast( anItem ); if ( crv ) { - QwtSymbol::Style aStyle = crv->symbol().style(); + QwtSymbol::Style aStyle = crv->symbol()->style(); QColor aColor = crv->pen().color(); Qt::PenStyle aLine = crv->pen().style(); if ( aStyle == typeMarker && closeColors( aColor,color ) && aLine == typeLine ) diff --git a/src/Plot2d/Plot2d_Histogram.cxx b/src/Plot2d/Plot2d_Histogram.cxx index 2676172ff..cb5e6f392 100644 --- a/src/Plot2d/Plot2d_Histogram.cxx +++ b/src/Plot2d/Plot2d_Histogram.cxx @@ -6,10 +6,9 @@ #include -#include -#include +#include #include - +//#include #include #include @@ -95,22 +94,24 @@ void Plot2d_Histogram::setData( const QList& theXVals, /** * Returns data */ -QwtIntervalData Plot2d_Histogram::getData() const +QwtIntervalSeriesData Plot2d_Histogram::getData() const { pointList aPoints = getPointList(); int aSize = aPoints.size(); - + QVector anIntervalsVect; QwtArray anIntervals( aSize ); QwtArray aValues( aSize ); double aX; double aWidth = isAutoAssign() ? m_dDefWidth : m_dWidth; for ( int i = 0; i < aSize; i++ ) { aX = aPoints[i].x; - anIntervals[i] = QwtDoubleInterval( aX - aWidth/2, aX + aWidth/2 ); - aValues[i] = aPoints[i].y; + //anIntervals[i] = QwtDoubleInterval( aX - aWidth/2, aX + aWidth/2 ); + //aValues[i] = aPoints[i].y; + QwtIntervalSample anInt( aPoints[i].y, QwtDoubleInterval( aX - aWidth/2, aX + aWidth/2 ) ); + anIntervalsVect.append( anInt ); } - return QwtIntervalData( anIntervals, aValues ); + return QwtIntervalSeriesData( anIntervalsVect ); } /** diff --git a/src/Plot2d/Plot2d_Histogram.h b/src/Plot2d/Plot2d_Histogram.h index 7703c8213..8f750e1a5 100644 --- a/src/Plot2d/Plot2d_Histogram.h +++ b/src/Plot2d/Plot2d_Histogram.h @@ -14,7 +14,7 @@ class QString; class QColor; -class QwtIntervalData; +class QwtIntervalSeriesData; class PLOT2D_EXPORT Plot2d_Histogram : public Plot2d_Object { @@ -28,7 +28,7 @@ public: virtual void updatePlotItem( QwtPlotItem* ); void setData( const QList&, const QList& ); - QwtIntervalData getData() const; + QwtIntervalSeriesData getData() const; QColor getColor() const; void setColor( const QColor& ); diff --git a/src/Plot2d/Plot2d_HistogramItem.cxx b/src/Plot2d/Plot2d_HistogramItem.cxx index 9893c8a10..144d35883 100644 --- a/src/Plot2d/Plot2d_HistogramItem.cxx +++ b/src/Plot2d/Plot2d_HistogramItem.cxx @@ -11,13 +11,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include /** @@ -83,18 +83,18 @@ double Plot2d_HistogramQwtItem::baseline() const /** * Sets data to object */ -void Plot2d_HistogramQwtItem::setData( const QwtIntervalData& theData ) +void Plot2d_HistogramQwtItem::setData( const QwtIntervalSeriesData& theData ) { - m_pData->data = theData; + m_pData->data = theData.samples(); itemChanged(); } /** * Returns data from object */ -const QwtIntervalData &Plot2d_HistogramQwtItem::data() const +const QwtIntervalSeriesData &Plot2d_HistogramQwtItem::data() const { - return m_pData->data; + return QwtIntervalSeriesData( m_pData->data ); } /** @@ -120,7 +120,9 @@ QColor Plot2d_HistogramQwtItem::color() const */ QwtDoubleRect Plot2d_HistogramQwtItem::boundingRect() const { - QwtDoubleRect aRect = m_pData->data.boundingRect(); + QwtIntervalSeriesData iData( m_pData->data ); + //QwtDoubleRect aRect = m_pData->data.boundingRect(); + QwtDoubleRect aRect = iData.boundingRect(); if ( !aRect.isValid() ) return aRect; @@ -180,29 +182,29 @@ bool Plot2d_HistogramQwtItem::testHistogramAttribute( void Plot2d_HistogramQwtItem::draw( QPainter *thePainter, const QwtScaleMap& theXMap, const QwtScaleMap& theYMap, - const QRect& ) const + const QRectF& ) const { - const QwtIntervalData &iData = m_pData->data; thePainter->setPen( QPen( m_pData->color ) ); - const int x0 = theXMap.transform( baseline() ); - const int y0 = theYMap.transform( baseline() ); - + const double x0 = theXMap.transform( baseline() ); + const double y0 = theYMap.transform( baseline() ); + const QVector& iData = m_pData->data; for ( int i = 0; i < (int)iData.size(); i++ ) { + if ( m_pData->attributes & Plot2d_HistogramQwtItem::Xfy ) { - const int x2 = theXMap.transform( iData.value( i ) ); + const double x2 = theXMap.transform( iData.at(i).value ); if ( x2 == x0 ) continue; - int y1 = theYMap.transform( iData.interval( i ).minValue() ); - int y2 = theYMap.transform( iData.interval( i ).maxValue() ); + double y1 = theYMap.transform( iData.at(i).interval.minValue() ); + double y2 = theYMap.transform( iData.at(i).interval.maxValue() ); if ( y1 > y2 ) qSwap( y1, y2 ); if ( i < (int)iData.size() - 2 ) { - const int yy1 = theYMap.transform( iData.interval(i+1).minValue() ); - const int yy2 = theYMap.transform( iData.interval(i+1).maxValue() ); + const double yy1 = theYMap.transform( iData.at( i+1 ).interval.minValue() ); + const double yy2 = theYMap.transform( iData.at( i+1 ). interval.maxValue() ); if ( y2 == qwtMin( yy1, yy2 ) ) { - const int xx2 = theXMap.transform( iData.interval(i+1).minValue() ); + const double xx2 = theXMap.transform( iData.at( i+1 ).interval.minValue() ); if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) || ( xx2 > x0 && x2 > x0 ) ) ) { // One pixel distance between neighboured bars @@ -213,19 +215,19 @@ void Plot2d_HistogramQwtItem::draw( QPainter *thePainter, drawBar( thePainter, Qt::Horizontal, QRect( x0, y1, x2 - x0, y2 - y1 ) ); } else { - const int y2 = theYMap.transform( iData.value( i ) ); + const double y2 = theYMap.transform( iData.at(i).value ); if ( y2 == y0 ) continue; - int x1 = theXMap.transform( iData.interval( i ).minValue() ); - int x2 = theXMap.transform( iData.interval( i ).maxValue() ); + double x1 = theXMap.transform( iData.at( i ).interval.minValue() ); + double x2 = theXMap.transform( iData.at( i ).interval.maxValue() ); if ( x1 > x2 ) qSwap( x1, x2 ); if ( i < (int)iData.size() - 2 ) { - const int xx1 = theXMap.transform( iData.interval(i+1).minValue() ); - const int xx2 = theXMap.transform( iData.interval(i+1).maxValue() ); + const double xx1 = theXMap.transform( iData.at( i+1 ).interval.minValue() ); + const double xx2 = theXMap.transform( iData.at( i+1 ).interval.maxValue() ); if ( x2 == qwtMin( xx1, xx2 ) ) { - const int yy2 = theYMap.transform( iData.value(i+1) ); + const double yy2 = theYMap.transform( iData.at( i+1 ).value ); if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) || ( yy2 > y0 && y2 > y0 ) ) ) { // One pixel distance between neighboured bars @@ -349,9 +351,12 @@ void Plot2d_HistogramItem::updateLegend( QwtLegend* theLegend ) const int aSize = aFMetrics.height(); QwtSymbol aSymbol( QwtSymbol::Rect, QBrush( color() ), QPen( color() ), QSize( aSize, aSize ) ); - anItem->setSymbol( aSymbol ); - anItem->setIdentifierMode( theLegend->identifierMode() - | QwtLegendItem::ShowSymbol ); + //anItem->setSymbol( aSymbol ); + //anItem->setIdentifierMode( theLegend->identifierMode() + // | QwtLegendItem::ShowSymbol ); + QPixmap aPixMap( 8, 8); + aPixMap.fill( color() ); + anItem->setIdentifier( aPixMap ); anItem->update(); } @@ -367,26 +372,25 @@ void Plot2d_HistogramItem::draw( QPainter *thePainter, Plot2d_HistogramItem* anItem = (Plot2d_HistogramItem*)this; anItem->m_BarItems.clear(); - const QwtIntervalData &iData = m_pData->data; thePainter->setPen( QPen( m_pData->color ) ); - const int x0 = theXMap.transform( baseline() ); - const int y0 = theYMap.transform( baseline() ); - + const double x0 = theXMap.transform( baseline() ); + const double y0 = theYMap.transform( baseline() ); + const QVector& iData = m_pData->data; for ( int i = 0; i < (int)iData.size(); i++ ) { if ( m_pData->attributes & Plot2d_HistogramItem::Xfy ) { - const int x2 = theXMap.transform( iData.value( i ) ); + const double x2 = theXMap.transform( iData.at(i).value ); if ( x2 == x0 ) continue; - int y1 = theYMap.transform( iData.interval( i ).minValue() ); - int y2 = theYMap.transform( iData.interval( i ).maxValue() ); + double y1 = theYMap.transform( iData.at(i).interval.minValue() ); + double y2 = theYMap.transform( iData.at(i).interval.maxValue() ); if ( y1 > y2 ) qSwap( y1, y2 ); if ( i < (int)iData.size() - 2 ) { - const int yy1 = theYMap.transform( iData.interval(i+1).minValue() ); - const int yy2 = theYMap.transform( iData.interval(i+1).maxValue() ); + const double yy1 = theYMap.transform( iData.at( i+1 ).interval.minValue() ); + const double yy2 = theYMap.transform( iData.at( i+1 ).interval.maxValue() ); if ( y2 == qwtMin( yy1, yy2 ) ) { - const int xx2 = theXMap.transform( iData.interval(i+1).minValue() ); + const double xx2 = theXMap.transform( iData.at( i+1 ).interval.minValue() ); if ( xx2 != x0 && ( ( xx2 < x0 && x2 < x0 ) || ( xx2 > x0 && x2 > x0 ) ) ) { // One pixel distance between neighboured bars @@ -400,19 +404,19 @@ void Plot2d_HistogramItem::draw( QPainter *thePainter, anItem->m_BarItems.append( aRect ); } else { - const int y2 = theYMap.transform( iData.value( i ) ); + const double y2 = theYMap.transform( iData.at( i ).value ); if ( y2 == y0 ) continue; - int x1 = theXMap.transform( iData.interval( i ).minValue() ); - int x2 = theXMap.transform( iData.interval( i ).maxValue() ); + double x1 = theXMap.transform( iData.at( i ).interval.minValue() ); + double x2 = theXMap.transform( iData.at( i ).interval.maxValue() ); if ( x1 > x2 ) qSwap( x1, x2 ); if ( i < (int)iData.size() - 2 ) { - const int xx1 = theXMap.transform( iData.interval(i+1).minValue() ); - const int xx2 = theXMap.transform( iData.interval(i+1).maxValue() ); + const double xx1 = theXMap.transform( iData.at( i+1 ).interval.minValue() ); + const double xx2 = theXMap.transform( iData.at( i+1 ).interval.maxValue() ); if ( x2 == qwtMin( xx1, xx2 ) ) { - const int yy2 = theYMap.transform( iData.value(i+1) ); + const double yy2 = theYMap.transform(iData.at( i+1 ).value ); if ( yy2 != y0 && ( ( yy2 < y0 && y2 < y0 ) || ( yy2 > y0 && y2 > y0 ) ) ) { // One pixel distance between neighboured bars diff --git a/src/Plot2d/Plot2d_HistogramItem.h b/src/Plot2d/Plot2d_HistogramItem.h index e5be0e0a1..6188e16d9 100644 --- a/src/Plot2d/Plot2d_HistogramItem.h +++ b/src/Plot2d/Plot2d_HistogramItem.h @@ -14,12 +14,13 @@ #include #include #include "qwt_plot_item.h" -#include "qwt_interval_data.h" +#include "qwt_series_data.h" +#include "qwt_compat.h" #include "QColor" #include -class QwtIntervalData; +class QwtIntervalSeriesData; class QwtLegend; class QString; @@ -29,7 +30,7 @@ protected: class PrivateData { public: int attributes; - QwtIntervalData data; + QVector data; QColor color; double reference; }; @@ -38,8 +39,8 @@ public: explicit Plot2d_HistogramQwtItem( const QwtText& ); virtual ~Plot2d_HistogramQwtItem(); - void setData( const QwtIntervalData& ); - const QwtIntervalData& data() const; + void setData( const QwtIntervalSeriesData& ); + const QwtIntervalSeriesData& data() const; void setColor( const QColor & ); QColor color() const; @@ -47,7 +48,7 @@ public: virtual QwtDoubleRect boundingRect() const; virtual int rtti() const; virtual void draw( QPainter *, const QwtScaleMap &xMap, - const QwtScaleMap &yMap, const QRect & ) const; + const QwtScaleMap &yMap, const QRectF & ) const; void setBaseline( double ); double baseline() const; diff --git a/src/Plot2d/Plot2d_Object.cxx b/src/Plot2d/Plot2d_Object.cxx index 8de33b353..5beb397d6 100755 --- a/src/Plot2d/Plot2d_Object.cxx +++ b/src/Plot2d/Plot2d_Object.cxx @@ -79,7 +79,7 @@ void Plot2d_Object::updatePlotItem( QwtPlotItem* theItem ) return; if ( theItem->yAxis() != getYAxis() || theItem->xAxis() != getXAxis() ) { - theItem->setAxis( getXAxis(), getYAxis() ); + theItem->setAxes( getXAxis(), getYAxis() ); QwtPlot* aPlot = theItem->plot(); theItem->detach(); diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index d8957f229..f4fd4af14 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -54,6 +54,8 @@ #include #include #include +#include +#include #include #include @@ -911,25 +913,27 @@ int Plot2d_ViewFrame::testOperation( const QMouseEvent& me ) const int zoomBtn = Qt::ControlModifier | Qt::LeftButton; const int panBtn = Qt::ControlModifier | Qt::MidButton; const int fitBtn = Qt::ControlModifier | Qt::RightButton; - - switch (btn) - { - case zoomBtn: + + if( btn == zoomBtn) { QPixmap zoomPixmap (imageZoomCursor); QCursor zoomCursor (zoomPixmap); myPlot->canvas()->setCursor( zoomCursor ); return ZoomId; } - case panBtn: + else if( btn == panBtn ) + { myPlot->canvas()->setCursor( QCursor( Qt::SizeAllCursor ) ); return PanId; - case fitBtn: + } + else if(btn == fitBtn) + { myPlot->canvas()->setCursor( QCursor( Qt::PointingHandCursor ) ); return FitAreaId; - default : + } + else return NoOpId; - } + } /*! @@ -1178,9 +1182,10 @@ void Plot2d_ViewFrame::setMarkerSize( const int size, bool update ) QwtPlotCurve* crv = it.key(); if ( crv ) { - QwtSymbol aSymbol = crv->symbol(); - aSymbol.setSize( myMarkerSize, myMarkerSize ); - crv->setSymbol( aSymbol ); + const QwtSymbol* aSymbol = crv->symbol(); + QwtSymbol* aSymbolNew = new QwtSymbol( aSymbol->style(), aSymbol->brush(), aSymbol->pen(), aSymbol->size() ); + aSymbolNew->setSize( myMarkerSize, myMarkerSize ); + crv->setSymbol( aSymbolNew ); } } if ( update ) @@ -1734,7 +1739,7 @@ Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent ) myIsPolished( false ) { myPlotZoomer = new Plot2d_QwtPlotZoomer( QwtPlot::xBottom, QwtPlot::yLeft, canvas() ); - myPlotZoomer->setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner ); + //myPlotZoomer->setSelectionFlags( QwtPicker::DragSelection | QwtPicker::CornerToCorner ); myPlotZoomer->setTrackerMode( QwtPicker::AlwaysOff ); myPlotZoomer->setRubberBand( QwtPicker::RectRubberBand ); myPlotZoomer->setRubberBandPen( QColor( Qt::green ) ); @@ -1984,7 +1989,8 @@ bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const if( pd ) { - myPlot->print( *pd ); + QwtPlotRenderer aRend; + aRend.renderTo( myPlot, *pd ); res = true; delete pd; } @@ -1996,10 +2002,10 @@ bool Plot2d_ViewFrame::print( const QString& file, const QString& format ) const /** * Print Plot2d window */ -void Plot2d_ViewFrame::printPlot( QPainter* p, const QRect& rect, - const QwtPlotPrintFilter& filter ) const +void Plot2d_ViewFrame::printPlot( QPainter* p, const QRectF& rect) const { - myPlot->print( p, rect, filter ); + QwtPlotRenderer aRend; + aRend.render( myPlot, p, rect ); } /*! diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 40335b34a..a1b793774 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -142,8 +142,7 @@ public: void setEnableAxis( const QwtPlot::Axis&, const bool& ); virtual bool print( const QString& file, const QString& format ) const; - void printPlot( QPainter* p, const QRect& rect, - const QwtPlotPrintFilter& = QwtPlotPrintFilter() ) const; + void printPlot( QPainter* p, const QRectF& rect) const; QString getVisualParameters(); void setVisualParameters( const QString& parameters ); diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 2e78b7a19..baeee50e6 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -716,7 +716,7 @@ void Plot2d_ViewWindow::onPrintView() } QMap< QwtPlotCurve*, QPen > aCurvToPen; - QMap< QwtPlotCurve*, QwtSymbol > aCurvToSymbol; + QMap< QwtPlotCurve*, const QwtSymbol* > aCurvToSymbol; if ( needColorCorrection ) { @@ -741,14 +741,12 @@ void Plot2d_ViewWindow::onPrintView() aCurve->setPen( aPen ); // symbol - QwtSymbol aSymbol = aCurve->symbol(); + const QwtSymbol* aSymbol = aCurve->symbol(); aCurvToSymbol[ aCurve ] = aSymbol; - aPen = aSymbol.pen(); + aPen = aSymbol->pen(); aPen.setColor( QColor( 0, 0, 0 ) ); aPen.setWidthF( 1.5 ); - aSymbol.setPen( aPen ); - - aCurve->setSymbol( aSymbol ); + aCurve->setSymbol( new QwtSymbol( aSymbol->style(), aSymbol->brush(), aPen, aSymbol->size() ) ); } }