Skip to content

Commit

Permalink
reindent georeferencer plugin
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@13041 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Mar 10, 2010
1 parent 4e23117 commit 9da13b6
Show file tree
Hide file tree
Showing 38 changed files with 1,747 additions and 1,715 deletions.
61 changes: 31 additions & 30 deletions src/plugins/georeferencer/qgsgcpcanvasitem.cpp
Expand Up @@ -16,35 +16,35 @@

#include "qgsgcpcanvasitem.h"

QgsGCPCanvasItem::QgsGCPCanvasItem(QgsMapCanvas* mapCanvas, const QgsPoint& rasterCoords,
const QgsPoint& worldCoords, bool isGCPSource )
: QgsMapCanvasItem( mapCanvas )
, mPointBrush(Qt::red)
, mLabelBrush(Qt::yellow)
, mRasterCoords(rasterCoords)
, mWorldCoords(worldCoords)
, mId(-1)
, mIsGCPSource(isGCPSource)
, mEnabled(true)
QgsGCPCanvasItem::QgsGCPCanvasItem( QgsMapCanvas* mapCanvas, const QgsPoint& rasterCoords,
const QgsPoint& worldCoords, bool isGCPSource )
: QgsMapCanvasItem( mapCanvas )
, mPointBrush( Qt::red )
, mLabelBrush( Qt::yellow )
, mRasterCoords( rasterCoords )
, mWorldCoords( worldCoords )
, mId( -1 )
, mIsGCPSource( isGCPSource )
, mEnabled( true )
{
setFlags(QGraphicsItem::ItemIsMovable);
setFlags( QGraphicsItem::ItemIsMovable );

updatePosition();
}

void QgsGCPCanvasItem::paint( QPainter* p )
{
p->setRenderHint(QPainter::Antialiasing);
p->setOpacity(mEnabled ? 1.0 : 0.3);
p->setRenderHint( QPainter::Antialiasing );
p->setOpacity( mEnabled ? 1.0 : 0.3 );

// draw the point
p->setPen( Qt::black );
p->setBrush( mPointBrush );
p->drawEllipse( -2, -2, 5, 5 );

QSettings s;
bool showIDs = s.value("/Plugin-GeoReferencer/Config/ShowId").toBool();
if (!showIDs && mIsGCPSource)
bool showIDs = s.value( "/Plugin-GeoReferencer/Config/ShowId" ).toBool();
if ( !showIDs && mIsGCPSource )
{
QString msg = QString( "X %1\nY %2" ).arg( QString::number( mWorldCoords.x(), 'f' ) ).
arg( QString::number( mWorldCoords.y(), 'f' ) );
Expand All @@ -53,17 +53,17 @@ void QgsGCPCanvasItem::paint( QPainter* p )
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);
mTextBounds = QSizeF( textBounds.width() + 4, textBounds.height() + 4 );
}
else if (showIDs)
else if ( showIDs )
{
p->setFont( QFont( "helvetica", 12 ) );
QString msg = QString::number(mId);
QString msg = QString::number( mId );
p->setBrush( mLabelBrush );
p->drawRect( 5, 4, p->fontMetrics().width(msg) + 2, 14 );
p->drawText(6, 16, msg);
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);
mTextBounds = QSize( fm.width( msg ) + 4, fm.height() + 4 );
}
// else
// mTextBounds = QSizeF(0, 0);
Expand All @@ -77,36 +77,37 @@ QRectF QgsGCPCanvasItem::boundingRect() const
QPainterPath QgsGCPCanvasItem::shape() const
{
QPainterPath p;
p.addEllipse(-2, -2, 5, 5);
p.addRect(6, 6, mTextBounds.width(), mTextBounds.height());
p.addEllipse( -2, -2, 5, 5 );
p.addRect( 6, 6, mTextBounds.width(), mTextBounds.height() );

return p;
}

void QgsGCPCanvasItem::setEnabled(bool enabled)
void QgsGCPCanvasItem::setEnabled( bool enabled )
{
mEnabled = enabled;
mPointBrush = enabled ? QBrush(Qt::red) : QBrush(Qt::gray);
mLabelBrush = enabled ? QBrush(Qt::yellow) : QBrush(Qt::gray);
mPointBrush = enabled ? QBrush( Qt::red ) : QBrush( Qt::gray );
mLabelBrush = enabled ? QBrush( Qt::yellow ) : QBrush( Qt::gray );
update();
}

void QgsGCPCanvasItem::setRasterCoords(QgsPoint p)
void QgsGCPCanvasItem::setRasterCoords( QgsPoint p )
{
mRasterCoords = p;
}

void QgsGCPCanvasItem::setWorldCoords(QgsPoint p)
void QgsGCPCanvasItem::setWorldCoords( QgsPoint p )
{
mWorldCoords = p;
}

void QgsGCPCanvasItem::setId(int id) {
void QgsGCPCanvasItem::setId( int id )
{
mId = id;
update();
}

void QgsGCPCanvasItem::updatePosition()
{
setPos( toCanvasCoordinates( mIsGCPSource ? mRasterCoords : mWorldCoords) );
setPos( toCanvasCoordinates( mIsGCPSource ? mRasterCoords : mWorldCoords ) );
}
49 changes: 25 additions & 24 deletions src/plugins/georeferencer/qgsgcpcanvasitem.h
Expand Up @@ -20,39 +20,40 @@
#include "qgsmapcanvas.h"
#include "qgsmapcanvasitem.h"

class QgsGCPCanvasItem : public QgsMapCanvasItem {
public:
QgsGCPCanvasItem( QgsMapCanvas* mapCanvas, const QgsPoint& rasterCoords,
const QgsPoint& worldCoords, bool isGCPSource/* = true*/ );
class QgsGCPCanvasItem : public QgsMapCanvasItem
{
public:
QgsGCPCanvasItem( QgsMapCanvas* mapCanvas, const QgsPoint& rasterCoords,
const QgsPoint& worldCoords, bool isGCPSource/* = true*/ );

//! draws point information
void paint( QPainter* p );
//! draws point information
void paint( QPainter* p );

//! handler for manual updating of position and size
QRectF boundingRect() const;
//! handler for manual updating of position and size
QRectF boundingRect() const;

QPainterPath shape() const;
QPainterPath shape() const;

void setEnabled(bool enabled);
void setEnabled( bool enabled );

void setRasterCoords(QgsPoint p);
void setWorldCoords(QgsPoint p);
void setRasterCoords( QgsPoint p );
void setWorldCoords( QgsPoint p );

int id() { return mId; }
void setId(int id);
int id() { return mId; }
void setId( int id );

void updatePosition();
void updatePosition();

private:
QSizeF mTextBounds;
QBrush mPointBrush;
QBrush mLabelBrush;
QgsPoint mRasterCoords;
QgsPoint mWorldCoords;
private:
QSizeF mTextBounds;
QBrush mPointBrush;
QBrush mLabelBrush;
QgsPoint mRasterCoords;
QgsPoint mWorldCoords;

int mId;
bool mIsGCPSource;
bool mEnabled;
int mId;
bool mIsGCPSource;
bool mEnabled;
};

#endif // QGSGCPCANVASITEM_H
38 changes: 19 additions & 19 deletions src/plugins/georeferencer/qgsgcplist.cpp
Expand Up @@ -20,30 +20,30 @@
#include "qgsgcplist.h"

QgsGCPList::QgsGCPList()
: QList<QgsGeorefDataPoint *>()
: QList<QgsGeorefDataPoint *>()
{
}

QgsGCPList::QgsGCPList(const QgsGCPList &list)
QgsGCPList::QgsGCPList( const QgsGCPList &list )
{
clear();
QgsGCPList::const_iterator it = list.constBegin();
for (; it != list.constEnd(); ++it)
for ( ; it != list.constEnd(); ++it )
{
QgsGeorefDataPoint *pt = new QgsGeorefDataPoint(**it);
append(pt);
QgsGeorefDataPoint *pt = new QgsGeorefDataPoint( **it );
append( pt );
}
}

void QgsGCPList::createGCPVectors(std::vector<QgsPoint> &mapCoords,
std::vector<QgsPoint> &pixelCoords)
void QgsGCPList::createGCPVectors( std::vector<QgsPoint> &mapCoords,
std::vector<QgsPoint> &pixelCoords )
{
mapCoords = std::vector<QgsPoint>(size());
pixelCoords = std::vector<QgsPoint>(size());
for (int i = 0, j = 0; i < sizeAll(); i++)
mapCoords = std::vector<QgsPoint>( size() );
pixelCoords = std::vector<QgsPoint>( size() );
for ( int i = 0, j = 0; i < sizeAll(); i++ )
{
QgsGeorefDataPoint *pt = at(i);
if (pt->isEnabled())
QgsGeorefDataPoint *pt = at( i );
if ( pt->isEnabled() )
{
mapCoords[j] = pt->mapCoords();
pixelCoords[j] = pt->pixelCoords();
Expand All @@ -54,14 +54,14 @@ void QgsGCPList::createGCPVectors(std::vector<QgsPoint> &mapCoords,

int QgsGCPList::size() const
{
if (QList<QgsGeorefDataPoint *>::isEmpty())
if ( QList<QgsGeorefDataPoint *>::isEmpty() )
return 0;

int s = 0;
const_iterator it = begin();
while (it != end())
while ( it != end() )
{
if ((*it)->isEnabled()) s++;
if (( *it )->isEnabled() ) s++;
it++;
}
return s;
Expand All @@ -72,14 +72,14 @@ int QgsGCPList::sizeAll() const
return QList<QgsGeorefDataPoint *>::size();
}

QgsGCPList &QgsGCPList::operator =(const QgsGCPList &list)
QgsGCPList &QgsGCPList::operator =( const QgsGCPList & list )
{
clear();
QgsGCPList::const_iterator it = list.constBegin();
for (; it != list.constEnd(); ++it)
for ( ; it != list.constEnd(); ++it )
{
QgsGeorefDataPoint *pt = new QgsGeorefDataPoint(**it);
append(pt);
QgsGeorefDataPoint *pt = new QgsGeorefDataPoint( **it );
append( pt );
}
return *this;
}
16 changes: 8 additions & 8 deletions src/plugins/georeferencer/qgsgcplist.h
Expand Up @@ -26,16 +26,16 @@ class QgsPoint;
// what is better use inherid or agrigate QList?
class QgsGCPList : public QList<QgsGeorefDataPoint *>
{
public:
QgsGCPList();
QgsGCPList(const QgsGCPList &list);
public:
QgsGCPList();
QgsGCPList( const QgsGCPList &list );

void createGCPVectors(std::vector<QgsPoint> &mapCoords,
std::vector<QgsPoint> &pixelCoords);
int size() const;
int sizeAll() const;
void createGCPVectors( std::vector<QgsPoint> &mapCoords,
std::vector<QgsPoint> &pixelCoords );
int size() const;
int sizeAll() const;

QgsGCPList &operator =(const QgsGCPList &list);
QgsGCPList &operator =( const QgsGCPList &list );
};

//typedef std::vector<QgsGeorefDataPoint *> QgsGCPList;
Expand Down

0 comments on commit 9da13b6

Please sign in to comment.