Skip to content

Commit

Permalink
fix: #3688
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@15656 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
stopa85 committed Apr 1, 2011
1 parent 71f19c1 commit 297475f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 44 deletions.
24 changes: 6 additions & 18 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -19,6 +19,7 @@

#include "qgsmaptopixel.h"
#include "qgsmapcanvas.h"
#include "qgsmaprenderer.h"
#include "qgslogger.h"
#include "qgsapplication.h"
#include "qgisapp.h"
Expand All @@ -33,6 +34,7 @@
#include "qgsmaplayerregistry.h"
#include "qgscontrastenhancement.h"
#include "qgsrastertransparency.h"
#include "qgsmaptoolemitpoint.h"

#include <QTableWidgetItem>
#include <QHeaderView>
Expand Down Expand Up @@ -205,8 +207,8 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
mPixelSelectorTool = 0;
if ( mMapCanvas )
{
mPixelSelectorTool = new QgsPixelSelectorTool( theCanvas );
connect( mPixelSelectorTool, SIGNAL( pixelSelected( int, int ) ), this, SLOT( pixelSelected( int, int ) ) );
mPixelSelectorTool = new QgsMapToolEmitPoint( theCanvas );
connect( mPixelSelectorTool, SIGNAL( canvasClicked( const QgsPoint&, Qt::MouseButton ) ), this, SLOT( pixelSelected( const QgsPoint& ) ) );
}
else
{
Expand Down Expand Up @@ -2230,7 +2232,7 @@ void QgsRasterLayerProperties::on_rbtnThreeBandStdDev_toggled( bool theState )
sboxThreeBandStdDev->setValue( mDefaultStandardDeviation );
}

void QgsRasterLayerProperties::pixelSelected( int x, int y )
void QgsRasterLayerProperties::pixelSelected( const QgsPoint& canvasPoint )
{
//PixelSelectorTool has registered a mouse click on the canvas, so bring the dialog back to the front
raise();
Expand All @@ -2242,7 +2244,7 @@ void QgsRasterLayerProperties::pixelSelected( int x, int y )
{
QMap< QString, QString > myPixelMap;
mMapCanvas->unsetMapTool( mPixelSelectorTool );
mRasterLayer->identify( mMapCanvas->getCoordinateTransform( )->toMapCoordinates( x, y ), myPixelMap );
mRasterLayer->identify( mMapCanvas->mapRenderer()->mapToLayerCoordinates( mRasterLayer, canvasPoint ), myPixelMap );
if ( tableTransparency->columnCount() == 2 )
{
QString myValue = myPixelMap[ mRasterLayer->grayBandName()];
Expand Down Expand Up @@ -3002,20 +3004,6 @@ void QgsRasterLayerProperties::on_pbnSaveStyleAs_clicked()
}
}

QgsPixelSelectorTool::QgsPixelSelectorTool( QgsMapCanvas* theCanvas ) : QgsMapTool( theCanvas )
{
mMapCanvas = theCanvas;
}

QgsPixelSelectorTool::~QgsPixelSelectorTool()
{
}

void QgsPixelSelectorTool::canvasReleaseEvent( QMouseEvent* theMouseEvent )
{
emit pixelSelected( theMouseEvent->x( ), theMouseEvent->y( ) );
}

void QgsRasterLayerProperties::on_btnResetNull_clicked( )
{
//If reset NoDataValue is checked do this first, will ignore what ever is in the LineEdit
Expand Down
29 changes: 3 additions & 26 deletions src/app/qgsrasterlayerproperties.h
Expand Up @@ -29,7 +29,7 @@
class QgsMapLayer;
class QgsMapCanvas;
class QgsRasterLayer;
class QgsPixelSelectorTool;
class QgsMapToolEmitPoint;

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

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

QgsMapCanvas* mMapCanvas;
QgsPixelSelectorTool* mPixelSelectorTool;
QgsMapToolEmitPoint* mPixelSelectorTool;
};

/**
*Simple map tool for selecting pixels, specific to QgsRasterLayerProperties
*/
class QgsPixelSelectorTool: public QgsMapTool
{
Q_OBJECT

public:
QgsPixelSelectorTool( QgsMapCanvas* );
~QgsPixelSelectorTool( );

/** \brief Method to handle mouse release, i.e., select, event */
void canvasReleaseEvent( QMouseEvent* theMouseEvent );

signals:
/** \brief Alter the listener ( raster properties dialog ) that a mouse click was registered */
void pixelSelected( int x, int y );

private:
QgsMapCanvas * mMapCanvas;
};

#endif

0 comments on commit 297475f

Please sign in to comment.