929 changes: 20 additions & 909 deletions src/app/qgsrasterlayerproperties.cpp

Large diffs are not rendered by default.

61 changes: 2 additions & 59 deletions src/app/qgsrasterlayerproperties.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,12 @@ class QgsRasterLayer;
class QgsMapToolEmitPoint;
class QgsRasterRenderer;
class QgsRasterRendererWidget;
class QwtPlotPicker;
class QwtPlotMarker;
class QwtPlotZoomer;
class QgsRasterHistogramWidget;

/**Property sheet for a raster map layer
*@author Tim Sutton
*/

// fix for qwt5/qwt6 QwtDoublePoint vs. QPointF
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
typedef QPointF QwtDoublePoint;
#endif

class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPropertiesBase
{
Q_OBJECT
Expand All @@ -59,9 +52,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
/** synchronize state with associated raster layer */
void sync();

/** Save the histogram as an image to disk */
void histoSaveAsImage( const QString& theFilename );

public slots:
//TODO: Verify that these all need to be public
/** \brief Applies the settings made in the dialog without closing the box */
Expand All @@ -80,8 +70,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
void on_pbnExportTransparentPixelValues_clicked();
/** \brief auto slot executed when the active page in the main widget stack is changed */
void on_tabBar_currentChanged( int theTab );
/** \brief slot executed when user wishes to refresh raster histogram */
void refreshHistogram();
/** \brief slow executed when user wishes to import transparency values */
void on_pbnImportTransparentPixelValues_clicked();
/** \brief slot executed when user presses "Remove Selected Row" button on the transparency page */
Expand All @@ -106,32 +94,9 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
void on_pbnSaveStyleAs_clicked();
/** Help button */
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
/** This slot lets you save the histogram as an image to disk */
void on_mSaveAsImageButton_clicked();
/**Enable or disable Build pyramids button depending on selection in pyramids list*/
void toggleBuildPyramidsButton();

// histogram

/** Used when the histogram band selector changes, or when tab is loaded. */
void on_cboHistoBand_currentIndexChanged( int );
/** Applies the selected min/max values to the renderer widget. */
void applyHistoMin( );
void applyHistoMax( );
/** Button to activate picking of the min/max value on the graph. */
void on_btnHistoMin_toggled();
void on_btnHistoMax_toggled();
/** Called when a selection has been made using the plot picker. */
void histoPickerSelected( const QPointF & );
/** Called when a selection has been made using the plot picker (for qwt5 only). */
void histoPickerSelectedQwt5( const QwtDoublePoint & );
/** Various actions that are stored in btnHistoActions. */
void histoActionTriggered( QAction* );
/** Draw the min/max markers on the histogram plot. */
void updateHistoMarkers();
/** Button to compute the histogram, appears when no cached histogram is available. */
void on_btnHistoCompute_clicked();

signals:
/** emitted when changes to layer were saved to update legend */
void refreshLegend( QString layerID, bool expandItem );
Expand Down Expand Up @@ -187,28 +152,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
QgsMapCanvas* mMapCanvas;
QgsMapToolEmitPoint* mPixelSelectorTool;

// histogram

QwtPlotPicker* mHistoPicker;
QwtPlotZoomer* mHistoZoomer;
QwtPlotMarker* mHistoMarkerMin;
QwtPlotMarker* mHistoMarkerMax;
double mHistoMin;
double mHistoMax;
QVector<QColor> mHistoColors;
bool mHistoShowMarkers;
bool mHistoLoadApplyAll;
enum HistoShowBands
{
ShowAll = 0,
ShowSelected = 1,
ShowRGB = 2
};
HistoShowBands mHistoShowBands;

/** \brief Compute the histogram on demand. */
bool computeHistogram( bool forceComputeFlag );
/** \brief Returns a list of selected bands - or empty if there is no selection restriction. */
QList< int > histoSelectedBands();
QgsRasterHistogramWidget* mHistogramWidget;
};
#endif
8 changes: 8 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ raster/qgsmultibandcolorrendererwidget.cpp
raster/qgspalettedrendererwidget.cpp
raster/qgssinglebandgrayrendererwidget.cpp
raster/qgssinglebandpseudocolorrendererwidget.cpp
raster/qgsrasterhistogramwidget.cpp

symbology-ng/qgsbrushstylecombobox.cpp
symbology-ng/qgscolorrampcombobox.cpp
Expand Down Expand Up @@ -100,6 +101,7 @@ raster/qgspalettedrendererwidget.h
raster/qgsmultibandcolorrendererwidget.h
raster/qgssinglebandgrayrendererwidget.h
raster/qgssinglebandpseudocolorrendererwidget.h
raster/qgsrasterhistogramwidget.h

symbology-ng/qgsdashspacedialog.h
symbology-ng/qgssymbollayerv2widget.h
Expand Down Expand Up @@ -251,6 +253,7 @@ INCLUDE_DIRECTORIES(
../core/symbology-ng
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../ui
${QWT_INCLUDE_DIR}
)
IF (WITH_INTERNAL_SPATIALITE)
INCLUDE_DIRECTORIES(../core/spatialite/headers)
Expand Down Expand Up @@ -316,13 +319,18 @@ ADD_DEPENDENCIES(qgis_gui ui)
TARGET_LINK_LIBRARIES(qgis_gui
qgis_core
${QT_QTUITOOLS_LIBRARY}
${QWT_LIBRARY}
#${QT_QTTEST_LIBRARY} # for ModelTest
)

IF (NOT WITH_INTERNAL_SPATIALITE)
TARGET_LINK_LIBRARIES(qgis_gui ${SQLITE3_LIBRARIES})
ENDIF (NOT WITH_INTERNAL_SPATIALITE)

IF(WIN32)
ADD_DEFINITIONS(-DQWT_DLL)
ENDIF(WIN32)

IF (APPLE)
SET_TARGET_PROPERTIES(qgis_gui PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
ENDIF (APPLE)
Expand Down
980 changes: 980 additions & 0 deletions src/gui/raster/qgsrasterhistogramwidget.cpp

Large diffs are not rendered by default.

117 changes: 117 additions & 0 deletions src/gui/raster/qgsrasterhistogramwidget.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/***************************************************************************
qgsrasterrendererwidget.h
---------------------------
begin : July 2012
copyright : (C) 2012 by Etienne Tourigny
email : etourigny dot dev at gmail dot com
***************************************************************************/

/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSRASTERHISTOGRAMWIDGET_H
#define QGSRASTERHISTOGRAMWIDGET_H

#include "ui_qgsrasterhistogramwidgetbase.h"

class QgsRasterLayer;
class QgsRasterRendererWidget;
class QwtPlotPicker;
class QwtPlotMarker;
class QwtPlotZoomer;

// fix for qwt5/qwt6 QwtDoublePoint vs. QPointF
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
typedef QPointF QwtDoublePoint;
#endif

/** Histogram widget
*@author Etienne Tourigny
*/

class QgsRasterHistogramWidget : public QWidget, private Ui::QgsRasterHistogramWidgetBase
{
Q_OBJECT

public:
QgsRasterHistogramWidget( QgsRasterLayer *lyr, QWidget *parent = 0 );
~QgsRasterHistogramWidget();

/** Save the histogram as an image to disk */
void histoSaveAsImage( const QString& theFilename );

/** Set the renderer widget (or just its name if there is no widget) */
void setRendererWidget( const QString& name, QgsRasterRendererWidget* rendererWidget = NULL );

/** Activate the histogram widget */
void setActive( bool theActiveFlag );

/** \brief Compute the histogram on demand. */
bool computeHistogram( bool forceComputeFlag );

public slots:
/** \brief slot executed when user wishes to refresh raster histogramwidget */
void refreshHistogram();
/** This slot lets you save the histogram as an image to disk */
void on_mSaveAsImageButton_clicked();

private slots:
/** Used when the histogram band selector changes, or when tab is loaded. */
void on_cboHistoBand_currentIndexChanged( int );
/** Applies the selected min/max values to the renderer widget. */
void applyHistoMin( );
void applyHistoMax( );
/** Button to activate picking of the min/max value on the graph. */
void on_btnHistoMin_toggled();
void on_btnHistoMax_toggled();
/** Called when a selection has been made using the plot picker. */
void histoPickerSelected( const QPointF & );
/** Called when a selection has been made using the plot picker (for qwt5 only). */
void histoPickerSelectedQwt5( const QwtDoublePoint & );
/** Various actions that are stored in btnHistoActions. */
void histoActionTriggered( QAction* );
/** Draw the min/max markers on the histogram plot. */
void updateHistoMarkers();
/** Button to compute the histogram, appears when no cached histogram is available. */
void on_btnHistoCompute_clicked();

//signals:

private:

enum HistoShowBands
{
ShowAll = 0,
ShowSelected = 1,
ShowRGB = 2
};

/** \brief Pointer to the raster layer that this property dilog changes the behaviour of. */
QgsRasterLayer * mRasterLayer;
/** \brief Pointer to the renderer widget, to get/set min/max. */
QgsRasterRendererWidget* mRendererWidget;
/** \brief Name of the renderer widget (see QgsRasterRendererRegistry). */
QString mRendererName;

QwtPlotPicker* mHistoPicker;
QwtPlotZoomer* mHistoZoomer;
QwtPlotMarker* mHistoMarkerMin;
QwtPlotMarker* mHistoMarkerMax;
double mHistoMin;
double mHistoMax;
QVector<QColor> mHistoColors;
bool mHistoShowMarkers;
bool mHistoLoadApplyAll;
HistoShowBands mHistoShowBands;
/** \brief Returns a list of selected bands in the histogram widget- or empty if there is no selection restriction. */
QList< int > histoSelectedBands();
/** \brief Returns a list of selected bands in the renderer widget. */
QList< int > rendererSelectedBands();
QPair< QString, QString > rendererMinMax( int theBandNo );
};
#endif
441 changes: 441 additions & 0 deletions src/ui/qgsrasterhistogramwidgetbase.ui

Large diffs are not rendered by default.

486 changes: 27 additions & 459 deletions src/ui/qgsrasterlayerpropertiesbase.ui

Large diffs are not rendered by default.