Skip to content

Commit 91f00be

Browse files
author
jef
committed
fix warning, indentation and little cleanup
git-svn-id: http://svn.osgeo.org/qgis/trunk@13989 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent d237cb2 commit 91f00be

File tree

4 files changed

+53
-64
lines changed

4 files changed

+53
-64
lines changed

src/plugins/georeferencer/qgsgcplistmodel.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,23 @@ class QgsStandardItem : public QStandardItem
3030
QgsStandardItem( QString text ) : QStandardItem( text )
3131
{
3232
// In addition to the DisplayRole, also set the user role, which is used for sorting.
33-
setData( QVariant( text ), Qt::UserRole);
33+
setData( QVariant( text ), Qt::UserRole );
3434
setTextAlignment( Qt::AlignRight );
3535
}
3636

3737
QgsStandardItem( int value ) : QStandardItem( QString::number( value ) )
3838
{
3939
// In addition to the DisplayRole, also set the user role, which is used for sorting.
4040
// This is needed for numerical sorting to work corretly (otherwise sorting is lexicographic).
41-
setData( QVariant( value ), Qt::UserRole);
41+
setData( QVariant( value ), Qt::UserRole );
4242
setTextAlignment( Qt::AlignCenter );
4343
}
44-
44+
4545
QgsStandardItem( double value ) : QStandardItem( QString::number( value, 'f', 2 ) )
4646
{
4747
// In addition to the DisplayRole, also set the user role, which is used for sorting.
4848
// This is needed for numerical sorting to work corretly (otherwise sorting is lexicographic).
49-
setData( QVariant( value ), Qt::UserRole);
49+
setData( QVariant( value ), Qt::UserRole );
5050
setTextAlignment( Qt::AlignRight );
5151
}
5252
};

src/plugins/georeferencer/qgsgcplistwidget.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ QgsGCPListWidget::QgsGCPListWidget( QWidget *parent )
4343
proxyModel->setSortRole( Qt::UserRole );
4444
setModel( proxyModel );
4545
setSortingEnabled( true );
46-
46+
4747
setContextMenuPolicy( Qt::CustomContextMenu );
4848
setFocusPolicy( Qt::NoFocus );
4949

@@ -99,7 +99,7 @@ void QgsGCPListWidget::updateGCPList()
9999
void QgsGCPListWidget::itemDoubleClicked( QModelIndex index )
100100
{
101101
index = static_cast<const QSortFilterProxyModel*>( model() )->mapToSource( index );
102-
QStandardItem *item = mGCPListModel->item( index.row(), 1);
102+
QStandardItem *item = mGCPListModel->item( index.row(), 1 );
103103
bool ok;
104104
int id = item->text().toInt( &ok );
105105

@@ -193,7 +193,7 @@ void QgsGCPListWidget::showContextMenu( QPoint p )
193193
connect( removeAction, SIGNAL( triggered() ), this, SLOT( removeRow() ) );
194194
m.addAction( removeAction );
195195
m.exec( QCursor::pos(), removeAction );
196-
196+
197197
index = static_cast<const QSortFilterProxyModel*>( model() )->mapToSource( index );
198198
mPrevRow = index.row();
199199
mPrevColumn = index.column();

src/plugins/georeferencer/qgsgeorefplugingui.cpp

+23-34
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
#include "qgstransformsettingsdialog.h"
6262

6363
#include "qgsgeorefplugingui.h"
64-
#include <assert.h>
6564

6665

6766
QgsGeorefDockWidget::QgsGeorefDockWidget( const QString & title, QWidget * parent, Qt::WindowFlags flags )
@@ -85,9 +84,9 @@ QgsGeorefPluginGui::QgsGeorefPluginGui( QgisInterface* theQgisInterface, QWidget
8584
, mTransformParam( QgsGeorefTransform::InvalidTransform )
8685
, mIface( theQgisInterface )
8786
, mLayer( 0 )
88-
, mAgainAddRaster ( false )
87+
, mAgainAddRaster( false )
8988
, mMovingPoint( 0 )
90-
, mMovingPointQgis ( 0 )
89+
, mMovingPointQgis( 0 )
9190
, mMapCoordsDialog( 0 )
9291
, mUseZeroForTrans( false )
9392
, mLoadInQgis( false )
@@ -254,7 +253,7 @@ void QgsGeorefPluginGui::openRaster()
254253
QgsMapLayerRegistry::instance()->removeMapLayer( mLayer->getLayerID(), false );
255254

256255
// Add raster
257-
addRaster(mRasterFileName);
256+
addRaster( mRasterFileName );
258257

259258
// load previously added points
260259
mGCPpointsFileName = mRasterFileName + ".points";
@@ -487,7 +486,7 @@ void QgsGeorefPluginGui::deleteDataPoint( const QPoint &coords )
487486
delete *it;
488487
mPoints.erase( it );
489488
mGCPListWidget->updateGCPList();
490-
489+
491490
mCanvas->refresh();
492491
break;
493492
}
@@ -497,7 +496,7 @@ void QgsGeorefPluginGui::deleteDataPoint( const QPoint &coords )
497496

498497
void QgsGeorefPluginGui::deleteDataPoint( int theGCPIndex )
499498
{
500-
assert( theGCPIndex >= 0 );
499+
Q_ASSERT( theGCPIndex >= 0 );
501500
delete mPoints.takeAt( theGCPIndex );
502501
mGCPListWidget->updateGCPList();
503502
updateGeorefTransform();
@@ -506,34 +505,24 @@ void QgsGeorefPluginGui::deleteDataPoint( int theGCPIndex )
506505
void QgsGeorefPluginGui::selectPoint( const QPoint &p )
507506
{
508507
// Get Map Sender
509-
QObject *tool = sender();
510-
if ( tool == 0)
511-
{
512-
return;
513-
}
514-
bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false;
508+
bool isMapPlugin = sender() == mToolMovePoint;
509+
QgsGeorefDataPoint *&mvPoint = isMapPlugin ? mMovingPoint : mMovingPointQgis;
515510

516511
for ( QgsGCPList::iterator it = mPoints.begin(); it != mPoints.end(); ++it )
517512
{
518-
if ( ( *it )->contains( p, isMapPlugin ) )
513+
if (( *it )->contains( p, isMapPlugin ) )
519514
{
520-
isMapPlugin ? mMovingPoint = *it : mMovingPointQgis = *it;
515+
mvPoint = *it;
521516
break;
522517
}
523518
}
524-
525519
}
526520

527521
void QgsGeorefPluginGui::movePoint( const QPoint &p )
528522
{
529523
// Get Map Sender
530-
QObject *tool = sender();
531-
if ( tool == 0)
532-
{
533-
return;
534-
}
535-
bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false;
536-
QgsGeorefDataPoint *mvPoint = (isMapPlugin ? mMovingPoint : mMovingPointQgis);
524+
bool isMapPlugin = sender() == mToolMovePoint;
525+
QgsGeorefDataPoint *mvPoint = isMapPlugin ? mMovingPoint : mMovingPointQgis;
537526

538527
if ( mvPoint )
539528
{
@@ -546,13 +535,14 @@ void QgsGeorefPluginGui::movePoint( const QPoint &p )
546535
void QgsGeorefPluginGui::releasePoint( const QPoint &p )
547536
{
548537
// Get Map Sender
549-
QObject *tool = sender();
550-
if ( tool == 0)
538+
if ( sender() == mToolMovePoint )
551539
{
552-
return;
540+
mMovingPoint = 0;
541+
}
542+
else
543+
{
544+
mMovingPointQgis = 0;
553545
}
554-
bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false;
555-
isMapPlugin ? mMovingPoint = 0 : mMovingPointQgis = 0;
556546
}
557547

558548
void QgsGeorefPluginGui::showCoordDialog( const QgsPoint &pixelCoords )
@@ -770,7 +760,7 @@ void QgsGeorefPluginGui::extentsChanged()
770760
{
771761
if ( QFile::exists( mRasterFileName ) )
772762
{
773-
addRaster(mRasterFileName);
763+
addRaster( mRasterFileName );
774764
}
775765
else
776766
{
@@ -781,10 +771,9 @@ void QgsGeorefPluginGui::extentsChanged()
781771
}
782772

783773
// Registry layer QGis
784-
void QgsGeorefPluginGui::layerWillBeRemoved ( QString theLayerId )
774+
void QgsGeorefPluginGui::layerWillBeRemoved( QString theLayerId )
785775
{
786-
mAgainAddRaster = ( mLayer && mLayer->getLayerID().compare(theLayerId) == 0 )
787-
? true : false;
776+
mAgainAddRaster = mLayer && mLayer->getLayerID().compare( theLayerId ) == 0;
788777
}
789778

790779
// ------------------------------ private ---------------------------------- //
@@ -1032,15 +1021,15 @@ void QgsGeorefPluginGui::setupConnections()
10321021
connect( mCanvas, SIGNAL( zoomLastStatusChanged( bool ) ), mActionZoomLast, SLOT( setEnabled( bool ) ) );
10331022
connect( mCanvas, SIGNAL( zoomNextStatusChanged( bool ) ), mActionZoomNext, SLOT( setEnabled( bool ) ) );
10341023
// Connect when one Layer is removed - Case where change the Projetct in QGIS
1035-
connect( QgsMapLayerRegistry::instance() , SIGNAL( layerWillBeRemoved (QString) ), this, SLOT( layerWillBeRemoved (QString) ) );
1024+
connect( QgsMapLayerRegistry::instance() , SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( layerWillBeRemoved( QString ) ) );
10361025

10371026
// Connect extents changed - Use for need add again Raster
1038-
connect( mCanvas, SIGNAL( extentsChanged () ), this, SLOT( extentsChanged() ) );
1027+
connect( mCanvas, SIGNAL( extentsChanged() ), this, SLOT( extentsChanged() ) );
10391028

10401029
}
10411030

10421031
// Mapcanvas Plugin
1043-
void QgsGeorefPluginGui::addRaster(QString file)
1032+
void QgsGeorefPluginGui::addRaster( QString file )
10441033
{
10451034
mLayer = new QgsRasterLayer( file, "Raster" );
10461035

src/plugins/georeferencer/qgsleastsquares.cpp

+23-23
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,12 @@ void QgsLeastSquares::projective( std::vector<QgsPoint> mapCoords,
187187

188188
// GSL does not support a full SVD, so we artificially add a linear dependent row
189189
// to the matrix in case the system is underconstrained.
190-
uint m = std::max(9u, (uint)mapCoords.size()*2u);
190+
uint m = std::max( 9u, ( uint )mapCoords.size() * 2u );
191191
uint n = 9;
192-
gsl_matrix *S = gsl_matrix_alloc ( m, n );
192+
gsl_matrix *S = gsl_matrix_alloc( m, n );
193193

194-
for ( uint i = 0; i < mapCoords.size(); i++ ) {
194+
for ( uint i = 0; i < mapCoords.size(); i++ )
195+
{
195196
gsl_matrix_set( S, i*2, 0, pixelCoords[i].x() );
196197
gsl_matrix_set( S, i*2, 1, -pixelCoords[i].y() );
197198
gsl_matrix_set( S, i*2, 2, 1.0 );
@@ -201,51 +202,50 @@ void QgsLeastSquares::projective( std::vector<QgsPoint> mapCoords,
201202
gsl_matrix_set( S, i*2, 5, 0.0 );
202203

203204
gsl_matrix_set( S, i*2, 6, -mapCoords[i].x()* pixelCoords[i].x() );
204-
gsl_matrix_set( S, i*2, 7, -mapCoords[i].x()*-pixelCoords[i].y() );
205+
gsl_matrix_set( S, i*2, 7, -mapCoords[i].x()* -pixelCoords[i].y() );
205206
gsl_matrix_set( S, i*2, 8, -mapCoords[i].x()*1.0 );
206207

207-
gsl_matrix_set( S, i*2+1, 0, 0.0 );
208-
gsl_matrix_set( S, i*2+1, 1, 0.0 );
209-
gsl_matrix_set( S, i*2+1, 2, 0.0 );
208+
gsl_matrix_set( S, i*2 + 1, 0, 0.0 );
209+
gsl_matrix_set( S, i*2 + 1, 1, 0.0 );
210+
gsl_matrix_set( S, i*2 + 1, 2, 0.0 );
210211

211-
gsl_matrix_set( S, i*2+1, 3, pixelCoords[i].x() );
212-
gsl_matrix_set( S, i*2+1, 4, -pixelCoords[i].y() );
213-
gsl_matrix_set( S, i*2+1, 5, 1.0 );
212+
gsl_matrix_set( S, i*2 + 1, 3, pixelCoords[i].x() );
213+
gsl_matrix_set( S, i*2 + 1, 4, -pixelCoords[i].y() );
214+
gsl_matrix_set( S, i*2 + 1, 5, 1.0 );
214215

215-
gsl_matrix_set( S, i*2+1, 6, -mapCoords[i].y()* pixelCoords[i].x() );
216-
gsl_matrix_set( S, i*2+1, 7, -mapCoords[i].y()*-pixelCoords[i].y() );
217-
gsl_matrix_set( S, i*2+1, 8, -mapCoords[i].y()*1.0 );
216+
gsl_matrix_set( S, i*2 + 1, 6, -mapCoords[i].y()* pixelCoords[i].x() );
217+
gsl_matrix_set( S, i*2 + 1, 7, -mapCoords[i].y()* -pixelCoords[i].y() );
218+
gsl_matrix_set( S, i*2 + 1, 8, -mapCoords[i].y()*1.0 );
218219
}
219220

220-
if (mapCoords.size() == 4)
221+
if ( mapCoords.size() == 4 )
221222
{
222223
// The GSL SVD routine only supports matrices with rows >= columns (m >= n)
223224
// Unfortunately, we can't use the SVD of the transpose (i.e. S^T = (U D V^T)^T = V D U^T)
224-
// to work around this, because the solution lies in the right nullspace of S, and
225+
// to work around this, because the solution lies in the right nullspace of S, and
225226
// gsl only supports a thin SVD of S^T, which does not return these vectors.
226227

227228
// HACK: duplicate last row to get a 9x9 equation system
228-
for (int j = 0; j < 9; j++)
229+
for ( int j = 0; j < 9; j++ )
229230
{
230-
gsl_matrix_set( S, 8, j, gsl_matrix_get( S, 7, j) );
231+
gsl_matrix_set( S, 8, j, gsl_matrix_get( S, 7, j ) );
231232
}
232233
}
233234

234235
// Solve Sh = 0 in the total least squares sense, i.e.
235236
// with Sh = min and |h|=1. The solution "h" is given by the
236237
// right singular eigenvector of S corresponding, to the smallest
237238
// singular value (via SVD).
238-
gsl_matrix *V = gsl_matrix_alloc (n, n);
239-
gsl_vector *singular_values = gsl_vector_alloc(n);
240-
gsl_vector *work = gsl_vector_alloc(n);
239+
gsl_matrix *V = gsl_matrix_alloc( n, n );
240+
gsl_vector *singular_values = gsl_vector_alloc( n );
241+
gsl_vector *work = gsl_vector_alloc( n );
241242

242243
// V = n x n
243244
// U = m x n (thin SVD) U D V^T
244-
gsl_linalg_SV_decomp(S, V, singular_values, work);
245+
gsl_linalg_SV_decomp( S, V, singular_values, work );
245246

246-
double eigen[9];
247247
// Columns of V store the right singular vectors of S
248-
for (int i = 0; i < n; i++)
248+
for ( unsigned int i = 0; i < n; i++ )
249249
{
250250
H[i] = gsl_matrix_get( V, i, n - 1 );
251251
}

0 commit comments

Comments
 (0)