Skip to content
Permalink
Browse files
Partial patch #2673 by mhugent:
-Configurable GCP labeling
-Ability to generate PDF report of residuals and transform parameters
-Allow resampling to output file even for linear transforms

git-svn-id: http://svn.osgeo.org/qgis/trunk@13436 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mmassing committed May 7, 2010
1 parent cca4b0c commit a9f345f05f77014f21ca9cace3fc372e919a251a
@@ -15,6 +15,7 @@ SET (GEOREF_SRCS
qgsgeorefvalidators.cpp
qgsleastsquares.cpp
qgsmapcoordsdialog.cpp
qgsresidualplotitem.cpp
qgstransformsettingsdialog.cpp

qgsgcplist.cpp
@@ -67,7 +68,7 @@ ADD_LIBRARY (georefplugin MODULE ${GEOREF_SRCS} ${GEOREF_MOC_SRCS} ${GEOREF_RCC_
INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
../../core ../../core/raster ../../core/renderer ../../core/symbology
../../core ../../core/raster ../../core/renderer ../../core/symbology ../../core/composer
../../gui
..
${GSL_INCLUDE_DIR}
@@ -35,6 +35,12 @@ QgsGCPCanvasItem::QgsGCPCanvasItem( QgsMapCanvas* mapCanvas, const QgsGeorefData

void QgsGCPCanvasItem::paint( QPainter* p )
{
QgsRenderContext context;
if ( !setRenderContextVariables( p, context ) )
{
return;
}

p->setRenderHint( QPainter::Antialiasing );

bool enabled = true;
@@ -57,29 +63,39 @@ void QgsGCPCanvasItem::paint( QPainter* p )

QSettings s;
bool showIDs = s.value( "/Plugin-GeoReferencer/Config/ShowId" ).toBool();
if ( !showIDs && mIsGCPSource )
bool showCoords = s.value( "/Plugin-GeoReferencer/Config/ShowCoords" ).toBool();

QString msg;
if ( showIDs && showCoords )
{
QString msg = QString( "X %1\nY %2" ).arg( QString::number( worldCoords.x(), 'f' ) ).
arg( QString::number( worldCoords.y(), 'f' ) );
p->setFont( QFont( "helvetica", 9 ) );
QRect textBounds = p->boundingRect( 6, 6, 10, 10, Qt::AlignLeft, msg );
p->setBrush( mLabelBrush );
p->drawRect( textBounds.x() - 2, textBounds.y() - 2, textBounds.width() + 4, textBounds.height() + 4 );
p->drawText( textBounds, Qt::AlignLeft, msg );
mTextBounds = QSizeF( textBounds.width() + 4, textBounds.height() + 4 );
msg = QString( "%1\nX %2\nY %3" ).arg( QString::number( id ) ).arg( QString::number( worldCoords.x(), 'f' ) ).arg( QString::number( worldCoords.y(), 'f' ) );
}
else if ( showIDs )
{
p->setFont( QFont( "helvetica", 12 ) );
QString msg = QString::number( id );
msg = msg = QString::number( id );
}
else if ( showCoords )
{
msg = QString( "X %1\nY %2" ).arg( QString::number( worldCoords.x(), 'f' ) ).arg( QString::number( worldCoords.y(), 'f' ) );
}

if ( !msg.isEmpty() )
{
p->setBrush( mLabelBrush );
p->drawRect( 5, 4, p->fontMetrics().width( msg ) + 2, 14 );
p->drawText( 6, 16, msg );
QFontMetrics fm = p->fontMetrics();
mTextBounds = QSize( fm.width( msg ) + 4, fm.height() + 4 );
QFont textFont( "helvetica" );
textFont.setPixelSize( fontSizePainterUnits( 12, context ) );
p->setFont( textFont );
QRectF textBounds = p->boundingRect( 3 * context.scaleFactor(), 3 * context.scaleFactor(), 5 * context.scaleFactor(), 5 * context.scaleFactor(), Qt::AlignLeft, msg );
mTextBoxRect = QRectF( textBounds.x() - context.scaleFactor() * 1, textBounds.y() - context.scaleFactor() * 1, \
textBounds.width() + 2 * context.scaleFactor(), textBounds.height() + 2 * context.scaleFactor() );
p->drawRect( mTextBoxRect );
p->drawText( textBounds, Qt::AlignLeft, msg );
}

drawResidualArrow( p );
if ( data( 0 ) != "composer" ) //draw residuals only on screen
{
drawResidualArrow( p, context );
}
}

QRectF QgsGCPCanvasItem::boundingRect() const
@@ -91,6 +107,8 @@ QRectF QgsGCPCanvasItem::boundingRect() const
{
residual = mDataPoint->residual();
}

//only considering screen resolution is ok for the bounding box function
double rf = residualToScreenFactor();

if ( residual.x() > 0 )
@@ -116,7 +134,12 @@ QRectF QgsGCPCanvasItem::boundingRect() const

QRectF residualArrowRect( QPointF( residualLeft, residualTop ), QPointF( residualRight, residualBottom ) );
QRectF markerRect( -2, -2, mTextBounds.width() + 6, mTextBounds.height() + 6 );
return residualArrowRect.united( markerRect );
QRectF boundingRect = residualArrowRect.united( markerRect );
if ( !mTextBoxRect.isNull() )
{
boundingRect = boundingRect.united( mTextBoxRect );
}
return boundingRect;
}

QPainterPath QgsGCPCanvasItem::shape() const
@@ -138,9 +161,9 @@ void QgsGCPCanvasItem::updatePosition()
setPos( toCanvasCoordinates( mIsGCPSource ? mDataPoint->pixelCoords() : mDataPoint->mapCoords() ) );
}

void QgsGCPCanvasItem::drawResidualArrow( QPainter* p )
void QgsGCPCanvasItem::drawResidualArrow( QPainter* p, const QgsRenderContext& context )
{
if ( !mDataPoint || !mIsGCPSource )
if ( !mDataPoint || !mIsGCPSource || !mMapCanvas )
{
return;
}
@@ -188,3 +211,9 @@ void QgsGCPCanvasItem::checkBoundingRectChange()
{
prepareGeometryChange();
}

double QgsGCPCanvasItem::fontSizePainterUnits( double points, const QgsRenderContext& c )
{
return points * 0.3527 * c.scaleFactor();
}

@@ -49,9 +49,14 @@ class QgsGCPCanvasItem : public QgsMapCanvasItem
bool mIsGCPSource;
QPen mResidualPen;

void drawResidualArrow( QPainter* p );
//text box rect for bounding rect calculation (updated in the paint event)
QRectF mTextBoxRect;

void drawResidualArrow( QPainter* p, const QgsRenderContext& context );
/**Calculates scale factor for residual display*/
double residualToScreenFactor() const;
/**Calculates pixel size for a font point size*/
double fontSizePainterUnits( double points, const QgsRenderContext& c );
};

#endif // QGSGCPCANVASITEM_H
@@ -54,13 +54,27 @@ void QgsGeorefConfigDialog::readSettings()
{
QSettings s;
if ( s.value( "/Plugin-GeoReferencer/Config/ShowId" ).toBool() )
mShowIDsRadioButton->setChecked( true );
{
mShowIDsCheckBox->setChecked( true );
}
else
{
mShowIDsCheckBox->setChecked( false );
}

if ( s.value( "/Plugin-GeoReferencer/Config/ShowCoords" ).toBool() )
{
mShowCoordsCheckBox->setChecked( true );
}
else
mShowCoordsRadioButton->setChecked( true );
{
mShowCoordsCheckBox->setChecked( false );
}
}

void QgsGeorefConfigDialog::writeSettings()
{
QSettings s;
s.setValue( "/Plugin-GeoReferencer/Config/ShowId", mShowIDsRadioButton->isChecked() );
s.setValue( "/Plugin-GeoReferencer/Config/ShowId", mShowIDsCheckBox->isChecked() );
s.setValue( "/Plugin-GeoReferencer/Config/ShowCoords", mShowCoordsCheckBox->isChecked() );
}
@@ -6,32 +6,29 @@
<rect>
<x>0</x>
<y>0</y>
<width>221</width>
<height>102</height>
<width>219</width>
<height>162</height>
</rect>
</property>
<property name="windowTitle">
<string>Configure Georeferencer</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="mPointTipGroupBox">
<property name="title">
<string>Point tip</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="mShowIDsRadioButton">
<widget class="QCheckBox" name="mShowIDsCheckBox">
<property name="text">
<string>Show IDs</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="mShowCoordsRadioButton">
<widget class="QCheckBox" name="mShowCoordsCheckBox">
<property name="text">
<string>Show coords</string>
</property>
@@ -47,6 +47,8 @@ QgsGeorefDataPoint::QgsGeorefDataPoint( const QgsGeorefDataPoint &p )
mPixelCoords = p.pixelCoords();
mMapCoords = p.mapCoords();
mEnabled = p.isEnabled();
mResidual = p.residual();
mId = p.id();
}

QgsGeorefDataPoint::~QgsGeorefDataPoint()
@@ -13,6 +13,10 @@
* *
***************************************************************************/
/* $Id$ */

#ifndef QGSGEOREFDATAPOINT_H
#define QGSGEOREFDATAPOINT_H

#include "qgsmapcanvasitem.h"

class QgsGCPCanvasItem;
@@ -66,3 +70,5 @@ class QgsGeorefDataPoint : public QObject
bool mEnabled;
QPointF mResidual;
};

#endif //QGSGEOREFDATAPOINT_H

0 comments on commit a9f345f

Please sign in to comment.