Skip to content
Permalink
Browse files
add support for qwt6 for identify results graph
  • Loading branch information
etiennesky authored and NathanW2 committed May 19, 2014
1 parent 3fc1585 commit fe2435c745e008e62522308346630799d5cb9f99
Showing with 26 additions and 25 deletions.
  1. +26 −18 src/app/qgsidentifyresultsdialog.cpp
  2. +0 −7 src/app/qgsidentifyresultsdialog.h
@@ -53,13 +53,12 @@
#include <QWebFrame>

//graph
#if defined(QWT_VERSION) && QWT_VERSION<0x060000
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_symbol.h>
#include <qwt_legend.h>
#include "qgsvectorcolorrampv2.h" // for random colors
#endif


QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QWebView( parent )
{
@@ -302,7 +301,6 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge

// graph
mPlot->setVisible( false );
#if defined(QWT_VERSION) && QWT_VERSION<0x060000
mPlot->setAutoFillBackground( false );
mPlot->setAutoDelete( true );
mPlot->insertLegend( new QwtLegend(), QwtPlot::TopLegend );
@@ -312,11 +310,6 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
sizePolicy.setHeightForWidth( mPlot->sizePolicy().hasHeightForWidth() );
mPlot->setSizePolicy( sizePolicy );
mPlot->updateGeometry();
#else
delete mPlot;
mPlot = 0;
tabWidget->removeTab( 2 );
#endif

connect( buttonBox, SIGNAL( rejected() ), this, SLOT( close() ) );

@@ -344,11 +337,9 @@ QgsIdentifyResultsDialog::~QgsIdentifyResultsDialog()

if ( mActionPopup )
delete mActionPopup;
#if defined(QWT_VERSION) && QWT_VERSION<0x060000
foreach ( QgsIdentifyPlotCurve *curve, mPlotCurves )
delete curve;
mPlotCurves.clear();
#endif
}

QTreeWidgetItem *QgsIdentifyResultsDialog::layerItem( QObject *object )
@@ -610,17 +601,39 @@ QgsIdentifyPlotCurve::QgsIdentifyPlotCurve( const QMap<QString, QString> &attrib
{
color = QgsVectorRandomColorRampV2::randomColors( 1 )[0];
}
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
mPlotCurve->setSymbol( new QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::white ),
QPen( color, 2 ), QSize( 9, 9 ) ) );
mPlotCurve->setPen( QPen( color, 2 ) ); // needed for legend
#else
mPlotCurve->setSymbol( QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::white ),
QPen( color, 2 ), QSize( 9, 9 ) ) );
mPlotCurve->setPen( QPen( color, 2 ) );
#endif

#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
QVector<QPointF> myData;
#else
QVector<double> myX2Data;
QVector<double> myY2Data;
#endif
int i = 1;

for ( QMap<QString, QString>::const_iterator it = attributes.begin();
it != attributes.end(); ++it )
{
mPlotCurveXData.append( double( i++ ) );
mPlotCurveYData.append( double( it.value().toDouble() ) );
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
myData << QPointF( double( i++ ), it.value().toDouble() );
#else
myX2Data.append( double( i++ ) );
myY2Data.append( it.value().toDouble() );
#endif
}
mPlotCurve->setData( mPlotCurveXData, mPlotCurveYData );
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
mPlotCurve->setSamples( myData );
#else
mPlotCurve->setData( myX2Data, myY2Data );
#endif

mPlotCurve->attach( plot );

@@ -640,7 +653,6 @@ QgsIdentifyPlotCurve::~QgsIdentifyPlotCurve()
delete mPlotCurve;
}
}
#endif

void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
QString label,
@@ -782,12 +794,10 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
tblResults->resizeColumnToContents( 1 );

// graph
#if defined(QWT_VERSION) && QWT_VERSION<0x060000
if ( attributes.count() > 0 )
{
mPlotCurves.append( new QgsIdentifyPlotCurve( attributes, mPlot, layer->name() ) );
}
#endif
}

void QgsIdentifyResultsDialog::editingToggled()
@@ -1061,12 +1071,10 @@ void QgsIdentifyResultsDialog::clear()
tblResults->clearContents();
tblResults->setRowCount( 0 );

#if defined(QWT_VERSION) && QWT_VERSION<0x060000
mPlot->setVisible( false );
foreach ( QgsIdentifyPlotCurve *curve, mPlotCurves )
delete curve;
mPlotCurves.clear();
#endif

// keep it visible but disabled, it can switch from disabled/enabled
// after raster format change
@@ -94,7 +94,6 @@ class APP_EXPORT QgsIdentifyResultsWebViewItem: public QObject, public QTreeWidg
QgsIdentifyResultsWebView *mWebView;
};

#if defined(QWT_VERSION) && QWT_VERSION<0x060000
class APP_EXPORT QgsIdentifyPlotCurve
{
public:
@@ -106,9 +105,7 @@ class APP_EXPORT QgsIdentifyPlotCurve

private:
QwtPlotCurve* mPlotCurve;
QVector<double> mPlotCurveXData, mPlotCurveYData;
};
#endif

class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdentifyResultsBase
{
@@ -245,11 +242,7 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti

QDockWidget *mDock;

#if defined(QWT_VERSION) && QWT_VERSION<0x060000
/* QwtPlotCurve* mPlotCurve; */
/* QVector<double> mPlotCurveXData, mPlotCurveYData; */
QVector<QgsIdentifyPlotCurve *> mPlotCurves;
#endif
};

class QgsIdentifyResultsDialogMapLayerAction : public QAction

0 comments on commit fe2435c

Please sign in to comment.