@@ -238,6 +238,7 @@ void QgsGeorefPluginGui::openRaster()
238238 s.setValue ( " /Plugin-GeoReferencer/lastusedfilter" , lastUsedFilter );
239239
240240 mGeorefTransform .selectTransformParametrisation ( mTransformParam );
241+ mGeorefTransform .setRasterChangeCoords ( mRasterFileName );
241242 statusBar ()->showMessage ( tr ( " Raster loaded: %1" ).arg ( mRasterFileName ) );
242243 setWindowTitle ( tr ( " Georeferencer - %1" ).arg ( fileInfo.fileName () ) );
243244
@@ -628,6 +629,23 @@ void QgsGeorefPluginGui::showGeorefConfigDialog()
628629 }
629630}
630631
632+ // Histogram stretch slots
633+ void QgsGeorefPluginGui::fullHistogramStretch ()
634+ {
635+ mLayer ->setContrastEnhancementAlgorithm ( " StretchToMinimumMaximum" );
636+ mLayer ->setMinimumMaximumUsingDataset ();
637+ mLayer ->setCacheImage ( NULL );
638+ mCanvas ->refresh ();
639+ }
640+
641+ void QgsGeorefPluginGui::localHistogramStretch ()
642+ {
643+ mLayer ->setContrastEnhancementAlgorithm ( " StretchToMinimumMaximum" );
644+ mLayer ->setMinimumMaximumUsingLastExtent ();
645+ mLayer ->setCacheImage ( NULL );
646+ mCanvas ->refresh ();
647+ }
648+
631649// Info slots
632650void QgsGeorefPluginGui::contextHelp ()
633651{
@@ -673,7 +691,8 @@ void QgsGeorefPluginGui::extentsChangedGeorefCanvas()
673691 }
674692
675693 // Reproject the georeference plugin canvas into world coordinates and fit axis aligned bounding box
676- QgsRectangle boundingBox = transformViewportBoundingBox ( mCanvas ->extent (), mGeorefTransform , true );
694+ QgsRectangle rectMap = mGeorefTransform .hasCrs () ? mGeorefTransform .getBoundingBox ( mCanvas ->extent (), true ) : mCanvas ->extent ();
695+ QgsRectangle boundingBox = transformViewportBoundingBox ( rectMap, mGeorefTransform , true );
677696
678697 mExtentsChangedRecursionGuard = true ;
679698 // Just set the whole extent for now
@@ -703,11 +722,12 @@ void QgsGeorefPluginGui::extentsChangedQGisCanvas()
703722
704723 // Reproject the canvas into raster coordinates and fit axis aligned bounding box
705724 QgsRectangle boundingBox = transformViewportBoundingBox ( mIface ->mapCanvas ()->extent (), mGeorefTransform , false );
725+ QgsRectangle rectMap = mGeorefTransform .hasCrs () ? mGeorefTransform .getBoundingBox ( boundingBox, false ) : boundingBox;
706726
707727 mExtentsChangedRecursionGuard = true ;
708728 // Just set the whole extent for now
709729 // TODO: better fitting function which acounts for differing aspect ratios etc.
710- mCanvas ->setExtent ( boundingBox );
730+ mCanvas ->setExtent ( rectMap );
711731 mCanvas ->refresh ();
712732 mExtentsChangedRecursionGuard = false ;
713733 }
@@ -840,6 +860,15 @@ void QgsGeorefPluginGui::createActions()
840860 mActionGeorefConfig ->setIcon ( getThemeIcon ( " /mActionGeorefConfig.png" ) );
841861 connect ( mActionGeorefConfig , SIGNAL ( triggered () ), this , SLOT ( showGeorefConfigDialog () ) );
842862
863+ // Histogram stretch
864+ mActionLocalHistogramStretch ->setIcon ( getThemeIcon ( " /mActionLocalHistogramStretch.png" ) );
865+ connect ( mActionLocalHistogramStretch , SIGNAL ( triggered () ), this , SLOT ( localHistogramStretch () ) );
866+ mActionLocalHistogramStretch ->setEnabled (false );
867+
868+ mActionFullHistogramStretch ->setIcon ( getThemeIcon ( " /mActionFullHistogramStretch.png" ) );
869+ connect ( mActionFullHistogramStretch , SIGNAL ( triggered () ), this , SLOT ( fullHistogramStretch () ) );
870+ mActionFullHistogramStretch ->setEnabled (false );
871+
843872 // Help actions
844873 mActionHelp = new QAction ( tr ( " Help" ), this );
845874 connect ( mActionHelp , SIGNAL ( triggered () ), this , SLOT ( contextHelp () ) );
@@ -985,32 +1014,35 @@ void QgsGeorefPluginGui::createDockWidgets()
9851014 connect ( mGCPListWidget , SIGNAL ( pointEnabled ( QgsGeorefDataPoint*, int ) ), this , SLOT ( updateGeorefTransform () ) );
9861015}
9871016
988- void QgsGeorefPluginGui::createStatusBar ()
1017+ QLabel* QgsGeorefPluginGui::createBaseLabelStatus ()
9891018{
9901019 QFont myFont ( " Arial" , 9 );
1020+ QLabel* label = new QLabel ( statusBar () );
1021+ label->setFont ( myFont );
1022+ label->setMinimumWidth ( 10 );
1023+ label->setMaximumHeight ( 20 );
1024+ label->setMargin ( 3 );
1025+ label->setAlignment ( Qt::AlignCenter );
1026+ label->setFrameStyle ( QFrame::NoFrame );
1027+ return label;
1028+ }
9911029
992- mTransformParamLabel = new QLabel ( statusBar () );
993- mTransformParamLabel ->setFont ( myFont );
994- mTransformParamLabel ->setMinimumWidth ( 10 );
995- mTransformParamLabel ->setMaximumHeight ( 20 );
996- mTransformParamLabel ->setMargin ( 3 );
997- mTransformParamLabel ->setAlignment ( Qt::AlignCenter );
998- mTransformParamLabel ->setFrameStyle ( QFrame::NoFrame );
1030+ void QgsGeorefPluginGui::createStatusBar ()
1031+ {
1032+ mTransformParamLabel = createBaseLabelStatus ();
9991033 mTransformParamLabel ->setText ( tr ( " Transform: " ) + convertTransformEnumToString ( mTransformParam ) );
10001034 mTransformParamLabel ->setToolTip ( tr ( " Current transform parametrisation" ) );
10011035 statusBar ()->addPermanentWidget ( mTransformParamLabel , 0 );
10021036
1003- mCoordsLabel = new QLabel ( QString (), statusBar () );
1004- mCoordsLabel ->setFont ( myFont );
1005- mCoordsLabel ->setMinimumWidth ( 10 );
1006- mCoordsLabel ->setMaximumHeight ( 20 );
1037+ mCoordsLabel = createBaseLabelStatus ();
10071038 mCoordsLabel ->setMaximumWidth ( 100 );
1008- mCoordsLabel ->setMargin ( 3 );
1009- mCoordsLabel ->setAlignment ( Qt::AlignCenter );
1010- mCoordsLabel ->setFrameStyle ( QFrame::NoFrame );
10111039 mCoordsLabel ->setText ( tr ( " Coordinate: " ) );
10121040 mCoordsLabel ->setToolTip ( tr ( " Current map coordinate" ) );
10131041 statusBar ()->addPermanentWidget ( mCoordsLabel , 0 );
1042+
1043+ mEPSG = createBaseLabelStatus ();
1044+ mEPSG ->setText (" EPSG:" );
1045+ statusBar ()->addPermanentWidget ( mEPSG , 0 );
10141046}
10151047
10161048void QgsGeorefPluginGui::setupConnections ()
@@ -1088,6 +1120,23 @@ void QgsGeorefPluginGui::addRaster( QString file )
10881120 mCanvas ->setLayerSet ( layers );
10891121
10901122 mAgainAddRaster = false ;
1123+
1124+ mActionLocalHistogramStretch ->setEnabled (true );
1125+ mActionFullHistogramStretch ->setEnabled (true );
1126+
1127+ // Status Bar
1128+ QString sEpsg (" ESPG: %1" );
1129+ if ( mGeorefTransform .hasCrs () )
1130+ {
1131+ long epsg = mLayer ->crs ().epsg ();
1132+ mEPSG ->setText ( sEpsg .arg ( epsg ) );
1133+ mEPSG ->setToolTip ( mLayer ->crs ().toProj4 () );
1134+ }
1135+ else
1136+ {
1137+ mEPSG ->setText ( sEpsg .arg ( tr (" None" ) ) );
1138+ mEPSG ->setToolTip ( tr (" Coordinate of image(column/line)" ) );
1139+ }
10911140}
10921141
10931142// Settings
@@ -1894,7 +1943,7 @@ bool QgsGeorefPluginGui::updateGeorefTransform()
18941943// Samples the given rectangle at numSamples per edge.
18951944// Returns an axis aligned bounding box which contains the transformed samples.
18961945QgsRectangle QgsGeorefPluginGui::transformViewportBoundingBox ( const QgsRectangle &canvasExtent,
1897- const QgsGeorefTransform &t,
1946+ QgsGeorefTransform &t,
18981947 bool rasterToWorld, uint numSamples )
18991948{
19001949 double minX, minY;
0 commit comments