Skip to content

Commit

Permalink
[georef] Modernise georeferencer UI
Browse files Browse the repository at this point in the history
- Standardise capitalisation and formatting of strings
- Remove use of old style icons
- Use QgsDoubleSpinBox and QgsProjectionSelectionWidgets
- Rework dialogs for usability
  • Loading branch information
nyalldawson committed Jun 17, 2015
1 parent d3df4ed commit 049436e
Show file tree
Hide file tree
Showing 10 changed files with 411 additions and 372 deletions.
2 changes: 1 addition & 1 deletion src/plugins/georeferencer/CMakeLists.txt
Expand Up @@ -75,7 +75,7 @@ INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
../../core ../../core/geometry ../../core/raster ../../core/composer
../../gui
../../gui ../../gui/editorwidgets
..
${GSL_INCLUDE_DIR}
${QGIS_INCLUDE_DIR}
Expand Down
46 changes: 41 additions & 5 deletions src/plugins/georeferencer/qgsgeorefconfigdialogbase.ui
Expand Up @@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>309</width>
<height>468</height>
<height>443</height>
</rect>
</property>
<property name="windowTitle">
Expand All @@ -30,7 +30,7 @@
<item row="1" column="0">
<widget class="QCheckBox" name="mShowCoordsCheckBox">
<property name="text">
<string>Show coords</string>
<string>Show coordinates</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -76,13 +76,16 @@
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="mLeftMarginSpinBox">
<widget class="QgsDoubleSpinBox" name="mLeftMarginSpinBox">
<property name="prefix">
<string/>
</property>
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
Expand All @@ -97,10 +100,13 @@
</widget>
</item>
<item>
<widget class="QDoubleSpinBox" name="mRightMarginSpinBox">
<widget class="QgsDoubleSpinBox" name="mRightMarginSpinBox">
<property name="suffix">
<string> mm</string>
</property>
<property name="showClearButton" stdset="0">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
Expand All @@ -115,7 +121,7 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
Expand Down Expand Up @@ -148,8 +154,38 @@
</layout>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>QgsDoubleSpinBox</class>
<extends>QDoubleSpinBox</extends>
<header location="global">qgsdoublespinbox.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>mShowIDsCheckBox</tabstop>
<tabstop>mShowCoordsCheckBox</tabstop>
<tabstop>mPixelsButton</tabstop>
<tabstop>mMapUnitsButton</tabstop>
<tabstop>mLeftMarginSpinBox</tabstop>
<tabstop>mRightMarginSpinBox</tabstop>
<tabstop>mPaperSizeComboBox</tabstop>
<tabstop>mShowDockedCheckBox</tabstop>
</tabstops>
<resources/>
<connections/>
</ui>
3 changes: 2 additions & 1 deletion src/plugins/georeferencer/qgsgeorefplugingui.h
Expand Up @@ -19,6 +19,7 @@
#include "qgsgcplist.h"
#include "qgsmapcoordsdialog.h"
#include "qgsimagewarper.h"
#include "qgscoordinatereferencesystem.h"

#include <QPointer>

Expand Down Expand Up @@ -216,7 +217,7 @@ class QgsGeorefPluginGui : public QMainWindow, private Ui::QgsGeorefPluginGuiBas
QString mWorldFileName;
QString mTranslatedRasterFileName;
QString mGCPpointsFileName;
QString mProjection;
QgsCoordinateReferenceSystem mProjection;
QString mPdfOutputFile;
QString mPdfOutputMapFile;
double mUserResX, mUserResY; // User specified target scale
Expand Down
31 changes: 17 additions & 14 deletions src/plugins/georeferencer/qgsgeorefpluginguibase.ui
Expand Up @@ -179,7 +179,7 @@
</widget>
<action name="mActionOpenRaster">
<property name="text">
<string>Open raster</string>
<string>Open Raster...</string>
</property>
<property name="statusTip">
<string>Open raster</string>
Expand Down Expand Up @@ -231,15 +231,15 @@
</action>
<action name="mActionTransformSettings">
<property name="text">
<string>Transformation settings</string>
<string>Transformation Settings...</string>
</property>
<property name="statusTip">
<string>Transformation settings</string>
</property>
</action>
<action name="mActionAddPoint">
<property name="text">
<string>Add point</string>
<string>Add Point</string>
</property>
<property name="statusTip">
<string>Add point</string>
Expand All @@ -250,7 +250,7 @@
</action>
<action name="mActionDeletePoint">
<property name="text">
<string>Delete point</string>
<string>Delete Point</string>
</property>
<property name="statusTip">
<string>Delete point</string>
Expand All @@ -261,15 +261,18 @@
</action>
<action name="mActionQuit">
<property name="text">
<string>Quit</string>
<string>Close Georeferencer</string>
</property>
<property name="toolTip">
<string>Close georeferencer</string>
</property>
<property name="statusTip">
<string>Quit</string>
</property>
</action>
<action name="mActionStartGeoref">
<property name="text">
<string>Start georeferencing</string>
<string>Start Georeferencing</string>
</property>
<property name="statusTip">
<string>Start georeferencing</string>
Expand All @@ -280,7 +283,7 @@
</action>
<action name="mActionGDALScript">
<property name="text">
<string>Generate GDAL script</string>
<string>Generate GDAL Script</string>
</property>
<property name="statusTip">
<string>Generate GDAL script</string>
Expand Down Expand Up @@ -313,7 +316,7 @@
</action>
<action name="mActionSaveGCPpoints">
<property name="text">
<string>Save GCP points as...</string>
<string>Save GCP Points as...</string>
</property>
<property name="statusTip">
<string>Save GCP points as...</string>
Expand All @@ -324,7 +327,7 @@
</action>
<action name="mActionLoadGCPpoints">
<property name="text">
<string>Load GCP points</string>
<string>Load GCP Points...</string>
</property>
<property name="statusTip">
<string>Load GCP points</string>
Expand All @@ -335,20 +338,20 @@
</action>
<action name="mActionGeorefConfig">
<property name="text">
<string>Configure Georeferencer</string>
<string>Configure Georeferencer...</string>
</property>
<property name="shortcut">
<string>Ctrl+P</string>
</property>
</action>
<action name="mActionRasterProperties">
<property name="text">
<string>Raster properties</string>
<string>Raster Properties...</string>
</property>
</action>
<action name="mActionMoveGCPPoint">
<property name="text">
<string>Move GCP point</string>
<string>Move GCP Point</string>
</property>
<property name="statusTip">
<string>Move GCP point</string>
Expand All @@ -366,12 +369,12 @@
</action>
<action name="mActionLocalHistogramStretch">
<property name="text">
<string>Local histogram stretch</string>
<string>Local Histogram Stretch</string>
</property>
</action>
<action name="mActionFullHistogramStretch">
<property name="text">
<string>Full histogram stretch</string>
<string>Full Histogram Stretch</string>
</property>
</action>
</widget>
Expand Down
23 changes: 7 additions & 16 deletions src/plugins/georeferencer/qgsimagewarper.cpp
Expand Up @@ -72,10 +72,9 @@ bool QgsImageWarper::openSrcDSAndGetWarpOpt( const QString &input, const Resampl
return true;
}

bool QgsImageWarper::createDestinationDataset(
const QString &outputName, GDALDatasetH hSrcDS, GDALDatasetH &hDstDS,
uint resX, uint resY, double *adfGeoTransform, bool useZeroAsTrans,
const QString& compression, const QString &projection )
bool QgsImageWarper::createDestinationDataset( const QString &outputName, GDALDatasetH hSrcDS, GDALDatasetH &hDstDS,
uint resX, uint resY, double *adfGeoTransform, bool useZeroAsTrans,
const QString& compression, const QgsCoordinateReferenceSystem& crs )
{
// create the output file
GDALDriverH driver = GDALGetDriverByName( "GTiff" );
Expand All @@ -100,18 +99,10 @@ bool QgsImageWarper::createDestinationDataset(
return false;
}

if ( !projection.isEmpty() )
if ( crs.isValid() )
{
OGRSpatialReference oTargetSRS;
if ( projection.startsWith( "EPSG", Qt::CaseInsensitive ) )
{
QString epsg = projection.mid( projection.indexOf( ":" ) + 1 );
oTargetSRS.importFromEPSG( epsg.toInt() );
}
else
{
oTargetSRS.importFromProj4( projection.toLatin1().data() );
}
oTargetSRS.importFromProj4( crs.toProj4().toLatin1().data() );

char *wkt = NULL;
OGRErr err = oTargetSRS.exportToWkt( &wkt );
Expand Down Expand Up @@ -155,7 +146,7 @@ int QgsImageWarper::warpFile( const QString& input,
ResamplingMethod resampling,
bool useZeroAsTrans,
const QString& compression,
const QString &projection,
const QgsCoordinateReferenceSystem& crs,
double destResX, double destResY )
{
if ( !georefTransform.parametersInitialized() )
Expand Down Expand Up @@ -221,7 +212,7 @@ int QgsImageWarper::warpFile( const QString& input,

if ( !createDestinationDataset( output, hSrcDS, hDstDS, destPixels, destLines,
adfGeoTransform, useZeroAsTrans, compression,
projection ) )
crs ) )
{
GDALClose( hSrcDS );
GDALDestroyWarpOptions( psWarpOptions );
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/georeferencer/qgsimagewarper.h
Expand Up @@ -21,6 +21,7 @@
#include <gdalwarper.h>
#include <vector>
#include "qgspoint.h"
#include "qgscoordinatereferencesystem.h"

class QgsGeorefTransform;
class QProgressDialog;
Expand Down Expand Up @@ -56,7 +57,7 @@ class QgsImageWarper
ResamplingMethod resampling,
bool useZeroAsTrans,
const QString& compression,
const QString& projection,
const QgsCoordinateReferenceSystem& crs,
double destResX = 0.0, double destResY = 0.0 );
private:
struct TransformChain
Expand Down Expand Up @@ -87,7 +88,7 @@ class QgsImageWarper
GDALWarpOptions *&psWarpOptions );

bool createDestinationDataset( const QString &outputName, GDALDatasetH hSrcDS, GDALDatasetH &hDstDS, uint resX, uint resY,
double *adfGeoTransform, bool useZeroAsTrans, const QString& compression, const QString &projection );
double *adfGeoTransform, bool useZeroAsTrans, const QString& compression, const QgsCoordinateReferenceSystem& crs );

QWidget *mParent;
void *createWarpProgressArg( QProgressDialog *progressDialog ) const;
Expand Down

0 comments on commit 049436e

Please sign in to comment.