Skip to content

Commit 1c41b40

Browse files
author
stopa85
committed
fix: #3688
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@15656 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 5f7561c commit 1c41b40

File tree

2 files changed

+9
-44
lines changed

2 files changed

+9
-44
lines changed

src/app/qgsrasterlayerproperties.cpp

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
#include "qgsmaptopixel.h"
2121
#include "qgsmapcanvas.h"
22+
#include "qgsmaprenderer.h"
2223
#include "qgslogger.h"
2324
#include "qgsapplication.h"
2425
#include "qgisapp.h"
@@ -33,6 +34,7 @@
3334
#include "qgsmaplayerregistry.h"
3435
#include "qgscontrastenhancement.h"
3536
#include "qgsrastertransparency.h"
37+
#include "qgsmaptoolemitpoint.h"
3638

3739
#include <QTableWidgetItem>
3840
#include <QHeaderView>
@@ -205,8 +207,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
205207
mPixelSelectorTool = 0;
206208
if ( mMapCanvas )
207209
{
208-
mPixelSelectorTool = new QgsPixelSelectorTool( theCanvas );
209-
connect( mPixelSelectorTool, SIGNAL( pixelSelected( int, int ) ), this, SLOT( pixelSelected( int, int ) ) );
210+
mPixelSelectorTool = new QgsMapToolEmitPoint( theCanvas );
211+
connect( mPixelSelectorTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ), this, SLOT( pixelSelected( const QgsPoint& ) ) );
210212
}
211213
else
212214
{
@@ -2230,7 +2232,7 @@ void QgsRasterLayerProperties::on_rbtnThreeBandStdDev_toggled( bool theState )
22302232
sboxThreeBandStdDev->setValue( mDefaultStandardDeviation );
22312233
}
22322234

2233-
void QgsRasterLayerProperties::pixelSelected( int x, int y )
2235+
void QgsRasterLayerProperties::pixelSelected( const QgsPoint& canvasPoint )
22342236
{
22352237
//PixelSelectorTool has registered a mouse click on the canvas, so bring the dialog back to the front
22362238
raise();
@@ -2242,7 +2244,7 @@ void QgsRasterLayerProperties::pixelSelected( int x, int y )
22422244
{
22432245
QMap< QString, QString > myPixelMap;
22442246
mMapCanvas->unsetMapTool( mPixelSelectorTool );
2245-
mRasterLayer->identify( mMapCanvas->getCoordinateTransform( )->toMapCoordinates( x, y ), myPixelMap );
2247+
mRasterLayer->identify( mMapCanvas->mapRenderer()->mapToLayerCoordinates( mRasterLayer, canvasPoint ), myPixelMap );
22462248
if ( tableTransparency->columnCount() == 2 )
22472249
{
22482250
QString myValue = myPixelMap[ mRasterLayer->grayBandName()];
@@ -3002,20 +3004,6 @@ void QgsRasterLayerProperties::on_pbnSaveStyleAs_clicked()
30023004
}
30033005
}
30043006

3005-
QgsPixelSelectorTool::QgsPixelSelectorTool( QgsMapCanvas* theCanvas ) : QgsMapTool( theCanvas )
3006-
{
3007-
mMapCanvas = theCanvas;
3008-
}
3009-
3010-
QgsPixelSelectorTool::~QgsPixelSelectorTool()
3011-
{
3012-
}
3013-
3014-
void QgsPixelSelectorTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
3015-
{
3016-
emit pixelSelected( theMouseEvent->x( ), theMouseEvent->y( ) );
3017-
}
3018-
30193007
void QgsRasterLayerProperties::on_btnResetNull_clicked( )
30203008
{
30213009
//If reset NoDataValue is checked do this first, will ignore what ever is in the LineEdit

src/app/qgsrasterlayerproperties.h

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
class QgsMapLayer;
3030
class QgsMapCanvas;
3131
class QgsRasterLayer;
32-
class QgsPixelSelectorTool;
32+
class QgsMapToolEmitPoint;
3333

3434
/**Property sheet for a raster map layer
3535
*@author Tim Sutton
@@ -89,7 +89,7 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
8989
/** \brief slot executed when the reset null value to file default icon is selected */
9090
void on_btnResetNull_clicked( );
9191

92-
void pixelSelected( int x, int y );
92+
void pixelSelected( const QgsPoint& );
9393
/** \brief this slot clears min max values from gui */
9494
void sboxSingleBandStdDev_valueChanged( double );
9595
/** \brief this slot clears min max values from gui */
@@ -213,29 +213,6 @@ class QgsRasterLayerProperties : public QDialog, private Ui::QgsRasterLayerPrope
213213
qreal mGradientWidth;
214214

215215
QgsMapCanvas* mMapCanvas;
216-
QgsPixelSelectorTool* mPixelSelectorTool;
216+
QgsMapToolEmitPoint* mPixelSelectorTool;
217217
};
218-
219-
/**
220-
*Simple map tool for selecting pixels, specific to QgsRasterLayerProperties
221-
*/
222-
class QgsPixelSelectorTool: public QgsMapTool
223-
{
224-
Q_OBJECT
225-
226-
public:
227-
QgsPixelSelectorTool( QgsMapCanvas* );
228-
~QgsPixelSelectorTool( );
229-
230-
/** \brief Method to handle mouse release, i.e., select, event */
231-
void canvasReleaseEvent( QMouseEvent* theMouseEvent );
232-
233-
signals:
234-
/** \brief Alter the listener ( raster properties dialog ) that a mouse click was registered */
235-
void pixelSelected( int x, int y );
236-
237-
private:
238-
QgsMapCanvas * mMapCanvas;
239-
};
240-
241218
#endif

0 commit comments

Comments
 (0)