Skip to content

Commit 6b474fe

Browse files
committed
add histogram zoom in/out
1 parent 4a53350 commit 6b474fe

File tree

4 files changed

+23
-1
lines changed

4 files changed

+23
-1
lines changed

images/images.qrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
<file>themes/default/mIconWms.png</file>
200200
<file>themes/default/mIconWmsLayer.png</file>
201201
<file>themes/default/mIconWarn.png</file>
202+
<file>themes/default/mIconZoom.png</file>
202203
<file>themes/default/mIconZip.png</file>
203204
<file>themes/default/mMapserverExport.png</file>
204205
<file>themes/default/plugin.png</file>

images/themes/default/mIconZoom.png

3.39 KB
Loading

src/app/qgsrasterlayerproperties.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
#include <qwt_plot_marker.h>
7272
#include <qwt_plot_picker.h>
7373
#include <qwt_picker_machine.h>
74+
#include <qwt_plot_zoomer.h>
7475

7576
QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanvas* theCanvas, QWidget *parent, Qt::WFlags fl )
7677
: QDialog( parent, fl ),
@@ -299,6 +300,7 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
299300

300301
// histogram
301302
mHistoPicker = NULL;
303+
mHistoZoomer = NULL;
302304
mHistoMarkerMin = NULL;
303305
mHistoMarkerMax = NULL;
304306
if ( tabPageHistogram->isEnabled() )
@@ -1392,10 +1394,21 @@ void QgsRasterLayerProperties::refreshHistogram()
13921394
connect( mHistoPicker, SIGNAL( selected( const QwtDoublePoint & ) ), this, SLOT( histoPickerSelected( const QwtDoublePoint & ) ) );
13931395
}
13941396

1397+
// plot zoomer
1398+
if ( ! mHistoZoomer )
1399+
{
1400+
mHistoZoomer = new QwtPlotZoomer( mpPlot->canvas() );
1401+
mHistoZoomer->setSelectionFlags( QwtPicker::RectSelection | QwtPicker::DragSelection );
1402+
mHistoZoomer->setTrackerMode( QwtPicker::AlwaysOff );
1403+
mHistoZoomer->setEnabled( true );
1404+
}
1405+
13951406
disconnect( mRasterLayer, SIGNAL( progressUpdate( int ) ), mHistogramProgress, SLOT( setValue( int ) ) );
13961407
// mHistogramProgress->hide();
13971408
stackedWidget2->setCurrentIndex( 0 );
1398-
mpPlot->canvas()->setCursor( Qt::ArrowCursor );
1409+
// mpPlot->canvas()->setCursor( Qt::ArrowCursor );
1410+
// icon from http://findicons.com/icon/169577/14_zoom?id=171427
1411+
mpPlot->canvas()->setCursor( QCursor( QgisApp::getThemePixmap( "/mIconZoom.png" ) ) );
13991412
on_cboHistoBand_currentIndexChanged( -1 );
14001413
QApplication::restoreOverrideCursor();
14011414
}
@@ -1777,6 +1790,8 @@ void QgsRasterLayerProperties::on_cboHistoBand_currentIndexChanged( int index )
17771790
mHistoPicker->setEnabled( false );
17781791
mHistoPicker->setRubberBandPen( QPen( mHistoColors.at( index + 1 ) ) );
17791792
}
1793+
if ( mHistoZoomer != NULL )
1794+
mHistoZoomer->setEnabled( true );
17801795
btnHistoMin->setEnabled( true );
17811796
btnHistoMax->setEnabled( true );
17821797

@@ -1989,6 +2004,8 @@ void QgsRasterLayerProperties::on_btnHistoMin_toggled()
19892004
btnHistoMax->setChecked( false );
19902005
QApplication::setOverrideCursor( Qt::PointingHandCursor );
19912006
}
2007+
if ( mHistoZoomer != NULL )
2008+
mHistoZoomer->setEnabled( ! btnHistoMax->isChecked() );
19922009
mHistoPicker->setEnabled( btnHistoMin->isChecked() );
19932010
}
19942011
}
@@ -2004,6 +2021,8 @@ void QgsRasterLayerProperties::on_btnHistoMax_toggled()
20042021
btnHistoMin->setChecked( false );
20052022
QApplication::setOverrideCursor( Qt::PointingHandCursor );
20062023
}
2024+
if ( mHistoZoomer != NULL )
2025+
mHistoZoomer->setEnabled( ! btnHistoMax->isChecked() );
20072026
mHistoPicker->setEnabled( btnHistoMax->isChecked() );
20082027
}
20092028
}

src/app/qgsrasterlayerproperties.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class QgsRasterRenderer;
3333
class QgsRasterRendererWidget;
3434
class QwtPlotPicker;
3535
class QwtPlotMarker;
36+
class QwtPlotZoomer;
3637

3738
/**Property sheet for a raster map layer
3839
*@author Tim Sutton
@@ -176,6 +177,7 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
176177

177178
// histogram
178179
QwtPlotPicker* mHistoPicker;
180+
QwtPlotZoomer* mHistoZoomer;
179181
QwtPlotMarker* mHistoMarkerMin;
180182
QwtPlotMarker* mHistoMarkerMax;
181183
double mHistoMin;

0 commit comments

Comments
 (0)