Skip to content

Commit 29c8ef7

Browse files
committedJul 17, 2012
move raster histogram widget to separate class, fix paletted+pseudo
1 parent 008592b commit 29c8ef7

7 files changed

+1595
-1427
lines changed
 

‎src/app/qgsrasterlayerproperties.cpp

Lines changed: 20 additions & 909 deletions
Large diffs are not rendered by default.

‎src/app/qgsrasterlayerproperties.h

Lines changed: 2 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,12 @@ class QgsRasterLayer;
3131
class QgsMapToolEmitPoint;
3232
class QgsRasterRenderer;
3333
class QgsRasterRendererWidget;
34-
class QwtPlotPicker;
35-
class QwtPlotMarker;
36-
class QwtPlotZoomer;
34+
class QgsRasterHistogramWidget;
3735

3836
/**Property sheet for a raster map layer
3937
*@author Tim Sutton
4038
*/
4139

42-
// fix for qwt5/qwt6 QwtDoublePoint vs. QPointF
43-
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
44-
typedef QPointF QwtDoublePoint;
45-
#endif
46-
4740
class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPropertiesBase
4841
{
4942
Q_OBJECT
@@ -59,9 +52,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
5952
/** synchronize state with associated raster layer */
6053
void sync();
6154

62-
/** Save the histogram as an image to disk */
63-
void histoSaveAsImage( const QString& theFilename );
64-
6555
public slots:
6656
//TODO: Verify that these all need to be public
6757
/** \brief Applies the settings made in the dialog without closing the box */
@@ -80,8 +70,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
8070
void on_pbnExportTransparentPixelValues_clicked();
8171
/** \brief auto slot executed when the active page in the main widget stack is changed */
8272
void on_tabBar_currentChanged( int theTab );
83-
/** \brief slot executed when user wishes to refresh raster histogram */
84-
void refreshHistogram();
8573
/** \brief slow executed when user wishes to import transparency values */
8674
void on_pbnImportTransparentPixelValues_clicked();
8775
/** \brief slot executed when user presses "Remove Selected Row" button on the transparency page */
@@ -106,32 +94,9 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
10694
void on_pbnSaveStyleAs_clicked();
10795
/** Help button */
10896
void on_buttonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
109-
/** This slot lets you save the histogram as an image to disk */
110-
void on_mSaveAsImageButton_clicked();
11197
/**Enable or disable Build pyramids button depending on selection in pyramids list*/
11298
void toggleBuildPyramidsButton();
11399

114-
// histogram
115-
116-
/** Used when the histogram band selector changes, or when tab is loaded. */
117-
void on_cboHistoBand_currentIndexChanged( int );
118-
/** Applies the selected min/max values to the renderer widget. */
119-
void applyHistoMin( );
120-
void applyHistoMax( );
121-
/** Button to activate picking of the min/max value on the graph. */
122-
void on_btnHistoMin_toggled();
123-
void on_btnHistoMax_toggled();
124-
/** Called when a selection has been made using the plot picker. */
125-
void histoPickerSelected( const QPointF & );
126-
/** Called when a selection has been made using the plot picker (for qwt5 only). */
127-
void histoPickerSelectedQwt5( const QwtDoublePoint & );
128-
/** Various actions that are stored in btnHistoActions. */
129-
void histoActionTriggered( QAction* );
130-
/** Draw the min/max markers on the histogram plot. */
131-
void updateHistoMarkers();
132-
/** Button to compute the histogram, appears when no cached histogram is available. */
133-
void on_btnHistoCompute_clicked();
134-
135100
signals:
136101
/** emitted when changes to layer were saved to update legend */
137102
void refreshLegend( QString layerID, bool expandItem );
@@ -187,28 +152,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
187152
QgsMapCanvas* mMapCanvas;
188153
QgsMapToolEmitPoint* mPixelSelectorTool;
189154

190-
// histogram
191-
192-
QwtPlotPicker* mHistoPicker;
193-
QwtPlotZoomer* mHistoZoomer;
194-
QwtPlotMarker* mHistoMarkerMin;
195-
QwtPlotMarker* mHistoMarkerMax;
196-
double mHistoMin;
197-
double mHistoMax;
198-
QVector<QColor> mHistoColors;
199-
bool mHistoShowMarkers;
200-
bool mHistoLoadApplyAll;
201-
enum HistoShowBands
202-
{
203-
ShowAll = 0,
204-
ShowSelected = 1,
205-
ShowRGB = 2
206-
};
207-
HistoShowBands mHistoShowBands;
208-
209-
/** \brief Compute the histogram on demand. */
210-
bool computeHistogram( bool forceComputeFlag );
211-
/** \brief Returns a list of selected bands - or empty if there is no selection restriction. */
212-
QList< int > histoSelectedBands();
155+
QgsRasterHistogramWidget* mHistogramWidget;
213156
};
214157
#endif

‎src/gui/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ raster/qgsmultibandcolorrendererwidget.cpp
66
raster/qgspalettedrendererwidget.cpp
77
raster/qgssinglebandgrayrendererwidget.cpp
88
raster/qgssinglebandpseudocolorrendererwidget.cpp
9+
raster/qgsrasterhistogramwidget.cpp
910

1011
symbology-ng/qgsbrushstylecombobox.cpp
1112
symbology-ng/qgscolorrampcombobox.cpp
@@ -100,6 +101,7 @@ raster/qgspalettedrendererwidget.h
100101
raster/qgsmultibandcolorrendererwidget.h
101102
raster/qgssinglebandgrayrendererwidget.h
102103
raster/qgssinglebandpseudocolorrendererwidget.h
104+
raster/qgsrasterhistogramwidget.h
103105

104106
symbology-ng/qgsdashspacedialog.h
105107
symbology-ng/qgssymbollayerv2widget.h
@@ -251,6 +253,7 @@ INCLUDE_DIRECTORIES(
251253
../core/symbology-ng
252254
${CMAKE_CURRENT_BINARY_DIR}
253255
${CMAKE_CURRENT_BINARY_DIR}/../ui
256+
${QWT_INCLUDE_DIR}
254257
)
255258
IF (WITH_INTERNAL_SPATIALITE)
256259
INCLUDE_DIRECTORIES(../core/spatialite/headers)
@@ -316,13 +319,18 @@ ADD_DEPENDENCIES(qgis_gui ui)
316319
TARGET_LINK_LIBRARIES(qgis_gui
317320
qgis_core
318321
${QT_QTUITOOLS_LIBRARY}
322+
${QWT_LIBRARY}
319323
#${QT_QTTEST_LIBRARY} # for ModelTest
320324
)
321325

322326
IF (NOT WITH_INTERNAL_SPATIALITE)
323327
TARGET_LINK_LIBRARIES(qgis_gui ${SQLITE3_LIBRARIES})
324328
ENDIF (NOT WITH_INTERNAL_SPATIALITE)
325329

330+
IF(WIN32)
331+
ADD_DEFINITIONS(-DQWT_DLL)
332+
ENDIF(WIN32)
333+
326334
IF (APPLE)
327335
SET_TARGET_PROPERTIES(qgis_gui PROPERTIES BUILD_WITH_INSTALL_RPATH TRUE)
328336
ENDIF (APPLE)

‎src/gui/raster/qgsrasterhistogramwidget.cpp

Lines changed: 980 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/***************************************************************************
2+
qgsrasterrendererwidget.h
3+
---------------------------
4+
begin : July 2012
5+
copyright : (C) 2012 by Etienne Tourigny
6+
email : etourigny dot dev at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
#ifndef QGSRASTERHISTOGRAMWIDGET_H
18+
#define QGSRASTERHISTOGRAMWIDGET_H
19+
20+
#include "ui_qgsrasterhistogramwidgetbase.h"
21+
22+
class QgsRasterLayer;
23+
class QgsRasterRendererWidget;
24+
class QwtPlotPicker;
25+
class QwtPlotMarker;
26+
class QwtPlotZoomer;
27+
28+
// fix for qwt5/qwt6 QwtDoublePoint vs. QPointF
29+
#if defined(QWT_VERSION) && QWT_VERSION>=0x060000
30+
typedef QPointF QwtDoublePoint;
31+
#endif
32+
33+
/** Histogram widget
34+
*@author Etienne Tourigny
35+
*/
36+
37+
class QgsRasterHistogramWidget : public QWidget, private Ui::QgsRasterHistogramWidgetBase
38+
{
39+
Q_OBJECT
40+
41+
public:
42+
QgsRasterHistogramWidget( QgsRasterLayer *lyr, QWidget *parent = 0 );
43+
~QgsRasterHistogramWidget();
44+
45+
/** Save the histogram as an image to disk */
46+
void histoSaveAsImage( const QString& theFilename );
47+
48+
/** Set the renderer widget (or just its name if there is no widget) */
49+
void setRendererWidget( const QString& name, QgsRasterRendererWidget* rendererWidget = NULL );
50+
51+
/** Activate the histogram widget */
52+
void setActive( bool theActiveFlag );
53+
54+
/** \brief Compute the histogram on demand. */
55+
bool computeHistogram( bool forceComputeFlag );
56+
57+
public slots:
58+
/** \brief slot executed when user wishes to refresh raster histogramwidget */
59+
void refreshHistogram();
60+
/** This slot lets you save the histogram as an image to disk */
61+
void on_mSaveAsImageButton_clicked();
62+
63+
private slots:
64+
/** Used when the histogram band selector changes, or when tab is loaded. */
65+
void on_cboHistoBand_currentIndexChanged( int );
66+
/** Applies the selected min/max values to the renderer widget. */
67+
void applyHistoMin( );
68+
void applyHistoMax( );
69+
/** Button to activate picking of the min/max value on the graph. */
70+
void on_btnHistoMin_toggled();
71+
void on_btnHistoMax_toggled();
72+
/** Called when a selection has been made using the plot picker. */
73+
void histoPickerSelected( const QPointF & );
74+
/** Called when a selection has been made using the plot picker (for qwt5 only). */
75+
void histoPickerSelectedQwt5( const QwtDoublePoint & );
76+
/** Various actions that are stored in btnHistoActions. */
77+
void histoActionTriggered( QAction* );
78+
/** Draw the min/max markers on the histogram plot. */
79+
void updateHistoMarkers();
80+
/** Button to compute the histogram, appears when no cached histogram is available. */
81+
void on_btnHistoCompute_clicked();
82+
83+
//signals:
84+
85+
private:
86+
87+
enum HistoShowBands
88+
{
89+
ShowAll = 0,
90+
ShowSelected = 1,
91+
ShowRGB = 2
92+
};
93+
94+
/** \brief Pointer to the raster layer that this property dilog changes the behaviour of. */
95+
QgsRasterLayer * mRasterLayer;
96+
/** \brief Pointer to the renderer widget, to get/set min/max. */
97+
QgsRasterRendererWidget* mRendererWidget;
98+
/** \brief Name of the renderer widget (see QgsRasterRendererRegistry). */
99+
QString mRendererName;
100+
101+
QwtPlotPicker* mHistoPicker;
102+
QwtPlotZoomer* mHistoZoomer;
103+
QwtPlotMarker* mHistoMarkerMin;
104+
QwtPlotMarker* mHistoMarkerMax;
105+
double mHistoMin;
106+
double mHistoMax;
107+
QVector<QColor> mHistoColors;
108+
bool mHistoShowMarkers;
109+
bool mHistoLoadApplyAll;
110+
HistoShowBands mHistoShowBands;
111+
/** \brief Returns a list of selected bands in the histogram widget- or empty if there is no selection restriction. */
112+
QList< int > histoSelectedBands();
113+
/** \brief Returns a list of selected bands in the renderer widget. */
114+
QList< int > rendererSelectedBands();
115+
QPair< QString, QString > rendererMinMax( int theBandNo );
116+
};
117+
#endif

‎src/ui/qgsrasterhistogramwidgetbase.ui

Lines changed: 441 additions & 0 deletions
Large diffs are not rendered by default.

‎src/ui/qgsrasterlayerpropertiesbase.ui

Lines changed: 27 additions & 459 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.