Skip to content
Permalink
Browse files
add identify results graph for rasters using qwt5 (qwt6 not supported…
… yet)
  • Loading branch information
etiennesky authored and NathanW2 committed May 19, 2014
1 parent 4620513 commit 1012d3dd687673b5227cdbe2f76e91b4fbefc0b7
Showing with 64 additions and 0 deletions.
  1. +57 −0 src/app/qgsidentifyresultsdialog.cpp
  2. +7 −0 src/app/qgsidentifyresultsdialog.h
@@ -52,6 +52,13 @@
#include <QComboBox>
#include <QWebFrame>

//graph
#if defined(QWT_VERSION) && QWT_VERSION<0x060000
#include <qwt_plot.h>
#include <qwt_plot_curve.h>
#include <qwt_symbol.h>
#endif

QgsIdentifyResultsWebView::QgsIdentifyResultsWebView( QWidget *parent ) : QWebView( parent )
{
setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Minimum );
@@ -291,6 +298,30 @@ QgsIdentifyResultsDialog::QgsIdentifyResultsDialog( QgsMapCanvas *canvas, QWidge
cmbIdentifyMode->setCurrentIndex( cmbIdentifyMode->findData( identifyMode ) );
cbxAutoFeatureForm->setChecked( mySettings.value( "/Map/identifyAutoFeatureForm", false ).toBool() );

// graph
mPlot->setVisible( false );
#if defined(QWT_VERSION) && QWT_VERSION<0x060000
mPlot->setAutoFillBackground( false );
mPlot->setAutoDelete( true );
QSizePolicy sizePolicy = QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
sizePolicy.setHeightForWidth( mPlot->sizePolicy().hasHeightForWidth() );
mPlot->setSizePolicy( sizePolicy );
mPlot->updateGeometry();

mPlotCurve = new QwtPlotCurve( "" );
mPlotCurve->setSymbol( QwtSymbol( QwtSymbol::Ellipse, QBrush( Qt::white ),
QPen( Qt::red, 2 ), QSize( 9, 9 ) ) );
mPlotCurve->attach( mPlot );
#else
delete mPlot;
mPlot = 0;
tabWidget->removeTab( 2 );
#endif

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

connect( lstResults, SIGNAL( itemExpanded( QTreeWidgetItem* ) ),
this, SLOT( itemExpanded( QTreeWidgetItem* ) ) );

@@ -315,6 +346,9 @@ QgsIdentifyResultsDialog::~QgsIdentifyResultsDialog()

if ( mActionPopup )
delete mActionPopup;
#if defined(QWT_VERSION) && QWT_VERSION<0x060000
delete mPlotCurve;
#endif
}

QTreeWidgetItem *QgsIdentifyResultsDialog::layerItem( QObject *object )
@@ -705,6 +739,23 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
}
tblResults->resizeColumnToContents( 1 );

// graph
#if defined(QWT_VERSION) && QWT_VERSION<0x060000
i = mPlotCurveXData.count();
for ( QMap<QString, QString>::const_iterator it = attributes.begin(); it != attributes.end(); ++it )
{
mPlotCurveXData.append( double( ++i ) );
mPlotCurveYData.append( double( it.value().toDouble() ) );
}
mPlotCurve->setData( mPlotCurveXData, mPlotCurveYData );

mPlot->setAxisMaxMinor( QwtPlot::xBottom, 0 );
//mPlot->setAxisScale( QwtPlot::xBottom, 1, mPlotCurve->dataSize());
//mPlot->setAxisScale( QwtPlot::yLeft, ymin, ymax );

mPlot->replot();
mPlot->setVisible( mPlotCurveXData.count() > 0 );
#endif
}

void QgsIdentifyResultsDialog::editingToggled()
@@ -978,6 +1029,12 @@ void QgsIdentifyResultsDialog::clear()
tblResults->clearContents();
tblResults->setRowCount( 0 );

#if defined(QWT_VERSION) && QWT_VERSION<0x060000
mPlot->setVisible( false );
mPlotCurveXData.clear();
mPlotCurveYData.clear();
#endif

// keep it visible but disabled, it can switch from disabled/enabled
// after raster format change
mPrintToolButton->setDisabled( true );
@@ -43,6 +43,8 @@ class QgsHighlight;
class QgsMapCanvas;
class QDockWidget;

class QwtPlotCurve;

/**
*@author Gary E.Sherman
*/
@@ -226,6 +228,11 @@ class APP_EXPORT QgsIdentifyResultsDialog: public QDialog, private Ui::QgsIdenti
void doMapLayerAction( QTreeWidgetItem *item, QgsMapLayerAction* action );

QDockWidget *mDock;

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

class QgsIdentifyResultsDialogMapLayerAction : public QAction

0 comments on commit 1012d3d

Please sign in to comment.