[QGIS Commit] r13989 - trunk/qgis/src/plugins/georeferencer
svn_qgis at osgeo.org
svn_qgis at osgeo.org
Sat Jul 31 21:45:34 EDT 2010
Author: jef
Date: 2010-08-01 01:45:34 +0000 (Sun, 01 Aug 2010)
New Revision: 13989
Modified:
trunk/qgis/src/plugins/georeferencer/qgsgcplistmodel.cpp
trunk/qgis/src/plugins/georeferencer/qgsgcplistwidget.cpp
trunk/qgis/src/plugins/georeferencer/qgsgeorefplugingui.cpp
trunk/qgis/src/plugins/georeferencer/qgsleastsquares.cpp
Log:
fix warning, indentation and little cleanup
Modified: trunk/qgis/src/plugins/georeferencer/qgsgcplistmodel.cpp
===================================================================
--- trunk/qgis/src/plugins/georeferencer/qgsgcplistmodel.cpp 2010-08-01 00:57:43 UTC (rev 13988)
+++ trunk/qgis/src/plugins/georeferencer/qgsgcplistmodel.cpp 2010-08-01 01:45:34 UTC (rev 13989)
@@ -30,7 +30,7 @@
QgsStandardItem( QString text ) : QStandardItem( text )
{
// In addition to the DisplayRole, also set the user role, which is used for sorting.
- setData( QVariant( text ), Qt::UserRole);
+ setData( QVariant( text ), Qt::UserRole );
setTextAlignment( Qt::AlignRight );
}
@@ -38,15 +38,15 @@
{
// In addition to the DisplayRole, also set the user role, which is used for sorting.
// This is needed for numerical sorting to work corretly (otherwise sorting is lexicographic).
- setData( QVariant( value ), Qt::UserRole);
+ setData( QVariant( value ), Qt::UserRole );
setTextAlignment( Qt::AlignCenter );
}
-
+
QgsStandardItem( double value ) : QStandardItem( QString::number( value, 'f', 2 ) )
{
// In addition to the DisplayRole, also set the user role, which is used for sorting.
// This is needed for numerical sorting to work corretly (otherwise sorting is lexicographic).
- setData( QVariant( value ), Qt::UserRole);
+ setData( QVariant( value ), Qt::UserRole );
setTextAlignment( Qt::AlignRight );
}
};
Modified: trunk/qgis/src/plugins/georeferencer/qgsgcplistwidget.cpp
===================================================================
--- trunk/qgis/src/plugins/georeferencer/qgsgcplistwidget.cpp 2010-08-01 00:57:43 UTC (rev 13988)
+++ trunk/qgis/src/plugins/georeferencer/qgsgcplistwidget.cpp 2010-08-01 01:45:34 UTC (rev 13989)
@@ -43,7 +43,7 @@
proxyModel->setSortRole( Qt::UserRole );
setModel( proxyModel );
setSortingEnabled( true );
-
+
setContextMenuPolicy( Qt::CustomContextMenu );
setFocusPolicy( Qt::NoFocus );
@@ -99,7 +99,7 @@
void QgsGCPListWidget::itemDoubleClicked( QModelIndex index )
{
index = static_cast<const QSortFilterProxyModel*>( model() )->mapToSource( index );
- QStandardItem *item = mGCPListModel->item( index.row(), 1);
+ QStandardItem *item = mGCPListModel->item( index.row(), 1 );
bool ok;
int id = item->text().toInt( &ok );
@@ -193,7 +193,7 @@
connect( removeAction, SIGNAL( triggered() ), this, SLOT( removeRow() ) );
m.addAction( removeAction );
m.exec( QCursor::pos(), removeAction );
-
+
index = static_cast<const QSortFilterProxyModel*>( model() )->mapToSource( index );
mPrevRow = index.row();
mPrevColumn = index.column();
Modified: trunk/qgis/src/plugins/georeferencer/qgsgeorefplugingui.cpp
===================================================================
--- trunk/qgis/src/plugins/georeferencer/qgsgeorefplugingui.cpp 2010-08-01 00:57:43 UTC (rev 13988)
+++ trunk/qgis/src/plugins/georeferencer/qgsgeorefplugingui.cpp 2010-08-01 01:45:34 UTC (rev 13989)
@@ -61,7 +61,6 @@
#include "qgstransformsettingsdialog.h"
#include "qgsgeorefplugingui.h"
-#include <assert.h>
QgsGeorefDockWidget::QgsGeorefDockWidget( const QString & title, QWidget * parent, Qt::WindowFlags flags )
@@ -85,9 +84,9 @@
, mTransformParam( QgsGeorefTransform::InvalidTransform )
, mIface( theQgisInterface )
, mLayer( 0 )
- , mAgainAddRaster ( false )
+ , mAgainAddRaster( false )
, mMovingPoint( 0 )
- , mMovingPointQgis ( 0 )
+ , mMovingPointQgis( 0 )
, mMapCoordsDialog( 0 )
, mUseZeroForTrans( false )
, mLoadInQgis( false )
@@ -254,7 +253,7 @@
QgsMapLayerRegistry::instance()->removeMapLayer( mLayer->getLayerID(), false );
// Add raster
- addRaster(mRasterFileName);
+ addRaster( mRasterFileName );
// load previously added points
mGCPpointsFileName = mRasterFileName + ".points";
@@ -487,7 +486,7 @@
delete *it;
mPoints.erase( it );
mGCPListWidget->updateGCPList();
-
+
mCanvas->refresh();
break;
}
@@ -497,7 +496,7 @@
void QgsGeorefPluginGui::deleteDataPoint( int theGCPIndex )
{
- assert( theGCPIndex >= 0 );
+ Q_ASSERT( theGCPIndex >= 0 );
delete mPoints.takeAt( theGCPIndex );
mGCPListWidget->updateGCPList();
updateGeorefTransform();
@@ -506,34 +505,24 @@
void QgsGeorefPluginGui::selectPoint( const QPoint &p )
{
// Get Map Sender
- QObject *tool = sender();
- if ( tool == 0)
- {
- return;
- }
- bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false;
+ bool isMapPlugin = sender() == mToolMovePoint;
+ QgsGeorefDataPoint *&mvPoint = isMapPlugin ? mMovingPoint : mMovingPointQgis;
for ( QgsGCPList::iterator it = mPoints.begin(); it != mPoints.end(); ++it )
{
- if ( ( *it )->contains( p, isMapPlugin ) )
+ if (( *it )->contains( p, isMapPlugin ) )
{
- isMapPlugin ? mMovingPoint = *it : mMovingPointQgis = *it;
+ mvPoint = *it;
break;
}
}
-
}
void QgsGeorefPluginGui::movePoint( const QPoint &p )
{
// Get Map Sender
- QObject *tool = sender();
- if ( tool == 0)
- {
- return;
- }
- bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false;
- QgsGeorefDataPoint *mvPoint = (isMapPlugin ? mMovingPoint : mMovingPointQgis);
+ bool isMapPlugin = sender() == mToolMovePoint;
+ QgsGeorefDataPoint *mvPoint = isMapPlugin ? mMovingPoint : mMovingPointQgis;
if ( mvPoint )
{
@@ -546,13 +535,14 @@
void QgsGeorefPluginGui::releasePoint( const QPoint &p )
{
// Get Map Sender
- QObject *tool = sender();
- if ( tool == 0)
+ if ( sender() == mToolMovePoint )
{
- return;
+ mMovingPoint = 0;
}
- bool isMapPlugin = ( (void *)tool == (void *)mToolMovePoint ) ? true : false;
- isMapPlugin ? mMovingPoint = 0 : mMovingPointQgis = 0;
+ else
+ {
+ mMovingPointQgis = 0;
+ }
}
void QgsGeorefPluginGui::showCoordDialog( const QgsPoint &pixelCoords )
@@ -770,7 +760,7 @@
{
if ( QFile::exists( mRasterFileName ) )
{
- addRaster(mRasterFileName);
+ addRaster( mRasterFileName );
}
else
{
@@ -781,10 +771,9 @@
}
// Registry layer QGis
-void QgsGeorefPluginGui::layerWillBeRemoved ( QString theLayerId )
+void QgsGeorefPluginGui::layerWillBeRemoved( QString theLayerId )
{
- mAgainAddRaster = ( mLayer && mLayer->getLayerID().compare(theLayerId) == 0 )
- ? true : false;
+ mAgainAddRaster = mLayer && mLayer->getLayerID().compare( theLayerId ) == 0;
}
// ------------------------------ private ---------------------------------- //
@@ -1032,15 +1021,15 @@
connect( mCanvas, SIGNAL( zoomLastStatusChanged( bool ) ), mActionZoomLast, SLOT( setEnabled( bool ) ) );
connect( mCanvas, SIGNAL( zoomNextStatusChanged( bool ) ), mActionZoomNext, SLOT( setEnabled( bool ) ) );
// Connect when one Layer is removed - Case where change the Projetct in QGIS
- connect( QgsMapLayerRegistry::instance() , SIGNAL( layerWillBeRemoved (QString) ), this, SLOT( layerWillBeRemoved (QString) ) );
+ connect( QgsMapLayerRegistry::instance() , SIGNAL( layerWillBeRemoved( QString ) ), this, SLOT( layerWillBeRemoved( QString ) ) );
// Connect extents changed - Use for need add again Raster
- connect( mCanvas, SIGNAL( extentsChanged () ), this, SLOT( extentsChanged() ) );
+ connect( mCanvas, SIGNAL( extentsChanged() ), this, SLOT( extentsChanged() ) );
}
// Mapcanvas Plugin
-void QgsGeorefPluginGui::addRaster(QString file)
+void QgsGeorefPluginGui::addRaster( QString file )
{
mLayer = new QgsRasterLayer( file, "Raster" );
Modified: trunk/qgis/src/plugins/georeferencer/qgsleastsquares.cpp
===================================================================
--- trunk/qgis/src/plugins/georeferencer/qgsleastsquares.cpp 2010-08-01 00:57:43 UTC (rev 13988)
+++ trunk/qgis/src/plugins/georeferencer/qgsleastsquares.cpp 2010-08-01 01:45:34 UTC (rev 13989)
@@ -187,11 +187,12 @@
// GSL does not support a full SVD, so we artificially add a linear dependent row
// to the matrix in case the system is underconstrained.
- uint m = std::max(9u, (uint)mapCoords.size()*2u);
+ uint m = std::max( 9u, ( uint )mapCoords.size() * 2u );
uint n = 9;
- gsl_matrix *S = gsl_matrix_alloc ( m, n );
+ gsl_matrix *S = gsl_matrix_alloc( m, n );
- for ( uint i = 0; i < mapCoords.size(); i++ ) {
+ for ( uint i = 0; i < mapCoords.size(); i++ )
+ {
gsl_matrix_set( S, i*2, 0, pixelCoords[i].x() );
gsl_matrix_set( S, i*2, 1, -pixelCoords[i].y() );
gsl_matrix_set( S, i*2, 2, 1.0 );
@@ -201,33 +202,33 @@
gsl_matrix_set( S, i*2, 5, 0.0 );
gsl_matrix_set( S, i*2, 6, -mapCoords[i].x()* pixelCoords[i].x() );
- gsl_matrix_set( S, i*2, 7, -mapCoords[i].x()*-pixelCoords[i].y() );
+ gsl_matrix_set( S, i*2, 7, -mapCoords[i].x()* -pixelCoords[i].y() );
gsl_matrix_set( S, i*2, 8, -mapCoords[i].x()*1.0 );
- gsl_matrix_set( S, i*2+1, 0, 0.0 );
- gsl_matrix_set( S, i*2+1, 1, 0.0 );
- gsl_matrix_set( S, i*2+1, 2, 0.0 );
+ gsl_matrix_set( S, i*2 + 1, 0, 0.0 );
+ gsl_matrix_set( S, i*2 + 1, 1, 0.0 );
+ gsl_matrix_set( S, i*2 + 1, 2, 0.0 );
- gsl_matrix_set( S, i*2+1, 3, pixelCoords[i].x() );
- gsl_matrix_set( S, i*2+1, 4, -pixelCoords[i].y() );
- gsl_matrix_set( S, i*2+1, 5, 1.0 );
+ gsl_matrix_set( S, i*2 + 1, 3, pixelCoords[i].x() );
+ gsl_matrix_set( S, i*2 + 1, 4, -pixelCoords[i].y() );
+ gsl_matrix_set( S, i*2 + 1, 5, 1.0 );
- gsl_matrix_set( S, i*2+1, 6, -mapCoords[i].y()* pixelCoords[i].x() );
- gsl_matrix_set( S, i*2+1, 7, -mapCoords[i].y()*-pixelCoords[i].y() );
- gsl_matrix_set( S, i*2+1, 8, -mapCoords[i].y()*1.0 );
+ gsl_matrix_set( S, i*2 + 1, 6, -mapCoords[i].y()* pixelCoords[i].x() );
+ gsl_matrix_set( S, i*2 + 1, 7, -mapCoords[i].y()* -pixelCoords[i].y() );
+ gsl_matrix_set( S, i*2 + 1, 8, -mapCoords[i].y()*1.0 );
}
- if (mapCoords.size() == 4)
+ if ( mapCoords.size() == 4 )
{
// The GSL SVD routine only supports matrices with rows >= columns (m >= n)
// Unfortunately, we can't use the SVD of the transpose (i.e. S^T = (U D V^T)^T = V D U^T)
- // to work around this, because the solution lies in the right nullspace of S, and
+ // to work around this, because the solution lies in the right nullspace of S, and
// gsl only supports a thin SVD of S^T, which does not return these vectors.
// HACK: duplicate last row to get a 9x9 equation system
- for (int j = 0; j < 9; j++)
+ for ( int j = 0; j < 9; j++ )
{
- gsl_matrix_set( S, 8, j, gsl_matrix_get( S, 7, j) );
+ gsl_matrix_set( S, 8, j, gsl_matrix_get( S, 7, j ) );
}
}
@@ -235,17 +236,16 @@
// with Sh = min and |h|=1. The solution "h" is given by the
// right singular eigenvector of S corresponding, to the smallest
// singular value (via SVD).
- gsl_matrix *V = gsl_matrix_alloc (n, n);
- gsl_vector *singular_values = gsl_vector_alloc(n);
- gsl_vector *work = gsl_vector_alloc(n);
+ gsl_matrix *V = gsl_matrix_alloc( n, n );
+ gsl_vector *singular_values = gsl_vector_alloc( n );
+ gsl_vector *work = gsl_vector_alloc( n );
// V = n x n
// U = m x n (thin SVD) U D V^T
- gsl_linalg_SV_decomp(S, V, singular_values, work);
+ gsl_linalg_SV_decomp( S, V, singular_values, work );
- double eigen[9];
// Columns of V store the right singular vectors of S
- for (int i = 0; i < n; i++)
+ for ( unsigned int i = 0; i < n; i++ )
{
H[i] = gsl_matrix_get( V, i, n - 1 );
}
More information about the QGIS-commit
mailing list