53
53
#include < QWebFrame>
54
54
55
55
// graph
56
- #if defined(QWT_VERSION) && QWT_VERSION<0x060000
57
56
#include < qwt_plot.h>
58
57
#include < qwt_plot_curve.h>
59
58
#include < qwt_symbol.h>
60
59
#include < qwt_legend.h>
61
60
#include " qgsvectorcolorrampv2.h" // for random colors
62
- # endif
61
+
63
62
64
63
QgsIdentifyResultsWebView::QgsIdentifyResultsWebView ( QWidget *parent ) : QWebView( parent )
65
64
{
@@ -302,7 +301,6 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
302
301
303
302
// graph
304
303
mPlot ->setVisible ( false );
305
- #if defined(QWT_VERSION) && QWT_VERSION<0x060000
306
304
mPlot ->setAutoFillBackground ( false );
307
305
mPlot ->setAutoDelete ( true );
308
306
mPlot ->insertLegend ( new QwtLegend (), QwtPlot::TopLegend );
@@ -312,11 +310,6 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
312
310
sizePolicy.setHeightForWidth ( mPlot ->sizePolicy ().hasHeightForWidth () );
313
311
mPlot ->setSizePolicy ( sizePolicy );
314
312
mPlot ->updateGeometry ();
315
- #else
316
- delete mPlot ;
317
- mPlot = 0 ;
318
- tabWidget->removeTab ( 2 );
319
- #endif
320
313
321
314
connect ( buttonBox, SIGNAL ( rejected () ), this , SLOT ( close () ) );
322
315
@@ -344,11 +337,9 @@ QgsIdentifyResultsDialog::~QgsIdentifyResultsDialog()
344
337
345
338
if ( mActionPopup )
346
339
delete mActionPopup ;
347
- #if defined(QWT_VERSION) && QWT_VERSION<0x060000
348
340
foreach ( QgsIdentifyPlotCurve *curve, mPlotCurves )
349
341
delete curve;
350
342
mPlotCurves .clear ();
351
- #endif
352
343
}
353
344
354
345
QTreeWidgetItem *QgsIdentifyResultsDialog::layerItem ( QObject *object )
@@ -610,17 +601,39 @@ QgsIdentifyPlotCurve::QgsIdentifyPlotCurve( const QMap<QString, QString> &attrib
610
601
{
611
602
color = QgsVectorRandomColorRampV2::randomColors ( 1 )[0 ];
612
603
}
604
+ #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
605
+ mPlotCurve ->setSymbol ( new QwtSymbol ( QwtSymbol::Ellipse, QBrush ( Qt::white ),
606
+ QPen ( color, 2 ), QSize ( 9 , 9 ) ) );
607
+ mPlotCurve ->setPen ( QPen ( color, 2 ) ); // needed for legend
608
+ #else
613
609
mPlotCurve ->setSymbol ( QwtSymbol ( QwtSymbol::Ellipse, QBrush ( Qt::white ),
614
610
QPen ( color, 2 ), QSize ( 9 , 9 ) ) );
611
+ mPlotCurve ->setPen ( QPen ( color, 2 ) );
612
+ #endif
615
613
614
+ #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
615
+ QVector<QPointF> myData;
616
+ #else
617
+ QVector<double > myX2Data;
618
+ QVector<double > myY2Data;
619
+ #endif
616
620
int i = 1 ;
621
+
617
622
for ( QMap<QString, QString>::const_iterator it = attributes.begin ();
618
623
it != attributes.end (); ++it )
619
624
{
620
- mPlotCurveXData .append ( double ( i++ ) );
621
- mPlotCurveYData .append ( double ( it.value ().toDouble () ) );
625
+ #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
626
+ myData << QPointF ( double ( i++ ), it.value ().toDouble () );
627
+ #else
628
+ myX2Data.append ( double ( i++ ) );
629
+ myY2Data.append ( it.value ().toDouble () );
630
+ #endif
622
631
}
623
- mPlotCurve ->setData ( mPlotCurveXData , mPlotCurveYData );
632
+ #if defined(QWT_VERSION) && QWT_VERSION>=0x060000
633
+ mPlotCurve ->setSamples ( myData );
634
+ #else
635
+ mPlotCurve ->setData ( myX2Data, myY2Data );
636
+ #endif
624
637
625
638
mPlotCurve ->attach ( plot );
626
639
@@ -640,7 +653,6 @@ QgsIdentifyPlotCurve::~QgsIdentifyPlotCurve()
640
653
delete mPlotCurve ;
641
654
}
642
655
}
643
- #endif
644
656
645
657
void QgsIdentifyResultsDialog::addFeature ( QgsRasterLayer *layer,
646
658
QString label,
@@ -782,12 +794,10 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
782
794
tblResults->resizeColumnToContents ( 1 );
783
795
784
796
// graph
785
- #if defined(QWT_VERSION) && QWT_VERSION<0x060000
786
797
if ( attributes.count () > 0 )
787
798
{
788
799
mPlotCurves .append ( new QgsIdentifyPlotCurve ( attributes, mPlot , layer->name () ) );
789
800
}
790
- #endif
791
801
}
792
802
793
803
void QgsIdentifyResultsDialog::editingToggled ()
@@ -1061,12 +1071,10 @@ void QgsIdentifyResultsDialog::clear()
1061
1071
tblResults->clearContents ();
1062
1072
tblResults->setRowCount ( 0 );
1063
1073
1064
- #if defined(QWT_VERSION) && QWT_VERSION<0x060000
1065
1074
mPlot ->setVisible ( false );
1066
1075
foreach ( QgsIdentifyPlotCurve *curve, mPlotCurves )
1067
1076
delete curve;
1068
1077
mPlotCurves .clear ();
1069
- #endif
1070
1078
1071
1079
// keep it visible but disabled, it can switch from disabled/enabled
1072
1080
// after raster format change
0 commit comments