Skip to content

Commit

Permalink
indentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Dec 8, 2014
1 parent e27d809 commit 28c3443
Show file tree
Hide file tree
Showing 13 changed files with 98 additions and 91 deletions.
8 changes: 4 additions & 4 deletions python/gui/editorwidgets/qgsspinbox.sip
Expand Up @@ -10,15 +10,15 @@ class QgsSpinBox : QSpinBox
MinimumValue,
MaximumValue,
CustomValue
};
};

explicit QgsSpinBox( QWidget *parent /TransferThis/ = 0 );

//! determines if the widget will show a clear button
//! @note the clear button will set the widget to its minimum value
void setShowClearButton( const bool showClearButton );
bool showClearButton() const;

/**Sets if the widget will allow entry of simple expressions, which are
* evaluated and then discarded.
* @param enabled set to true to allow expression entry
Expand Down Expand Up @@ -53,7 +53,7 @@ class QgsSpinBox : QSpinBox

virtual int valueFromText( const QString & text ) const;
virtual QValidator::State validate( QString & input, int & pos ) const;

protected:
virtual void resizeEvent( QResizeEvent* event );
virtual void changeEvent( QEvent* event );
Expand Down
2 changes: 1 addition & 1 deletion python/gui/qgsnewmemorylayerdialog.sip
Expand Up @@ -25,6 +25,6 @@ class QgsNewMemoryLayerDialog : QDialog
QString layerName() const;

protected slots:

void on_mChangeSrsButton_clicked();
};
14 changes: 7 additions & 7 deletions src/app/qgisapp.cpp
Expand Up @@ -1750,16 +1750,16 @@ void QgisApp::createStatusBar()
mRotationEdit->setObjectName( "mRotationEdit" );
mRotationEdit->setMaximumWidth( 100 );
mRotationEdit->setMaximumHeight( 20 );
mRotationEdit->setRange(-180, 180);
mRotationEdit->setWrapping(true);
mRotationEdit->setSingleStep(5.0);
mRotationEdit->setRange( -180, 180 );
mRotationEdit->setWrapping( true );
mRotationEdit->setSingleStep( 5.0 );
mRotationEdit->setFont( myFont );
mRotationEdit->setWhatsThis( tr( "Shows the current map clockwise rotation "
"in degrees. It also allows editing to set "
"the rotation") );
"in degrees. It also allows editing to set "
"the rotation" ) );
mRotationEdit->setToolTip( tr( "Current clockwise map rotation in degrees" ) );
statusBar()->addPermanentWidget( mRotationEdit, 0 );
connect( mRotationEdit, SIGNAL( valueChanged(int) ), this, SLOT( userRotation() ) );
connect( mRotationEdit, SIGNAL( valueChanged( int ) ), this, SLOT( userRotation() ) );

showRotation();

Expand Down Expand Up @@ -6900,7 +6900,7 @@ void QgisApp::userCenter()
void QgisApp::userRotation()
{
double degrees = mRotationEdit->value();
mMapCanvas->setRotation(degrees);
mMapCanvas->setRotation( degrees );
mMapCanvas->refresh();
}

Expand Down
26 changes: 14 additions & 12 deletions src/core/qgsmapsettings.cpp
Expand Up @@ -161,15 +161,16 @@ void QgsMapSettings::updateDerived()
mMapToPixel.setMapRotation( mRotation, visibleExtent().center().x(), visibleExtent().center().y() );

#if 1 // set visible extent taking rotation in consideration
if ( mRotation ) {
QgsPoint p1 = mMapToPixel.toMapCoordinates( QPoint(0,0) );
QgsPoint p2 = mMapToPixel.toMapCoordinates( QPoint(0,myHeight) );
QgsPoint p3 = mMapToPixel.toMapCoordinates( QPoint(myWidth,0) );
QgsPoint p4 = mMapToPixel.toMapCoordinates( QPoint(myWidth,myHeight) );
dxmin = std::min(p1.x(), std::min(p2.x(), std::min(p3.x(), p4.x())));
dymin = std::min(p1.y(), std::min(p2.y(), std::min(p3.y(), p4.y())));
dxmax = std::max(p1.x(), std::max(p2.x(), std::max(p3.x(), p4.x())));
dymax = std::max(p1.y(), std::max(p2.y(), std::max(p3.y(), p4.y())));
if ( mRotation )
{
QgsPoint p1 = mMapToPixel.toMapCoordinates( QPoint( 0, 0 ) );
QgsPoint p2 = mMapToPixel.toMapCoordinates( QPoint( 0, myHeight ) );
QgsPoint p3 = mMapToPixel.toMapCoordinates( QPoint( myWidth, 0 ) );
QgsPoint p4 = mMapToPixel.toMapCoordinates( QPoint( myWidth, myHeight ) );
dxmin = std::min( p1.x(), std::min( p2.x(), std::min( p3.x(), p4.x() ) ) );
dymin = std::min( p1.y(), std::min( p2.y(), std::min( p3.y(), p4.y() ) ) );
dxmax = std::max( p1.x(), std::max( p2.x(), std::max( p3.x(), p4.x() ) ) );
dymax = std::max( p1.y(), std::max( p2.y(), std::max( p3.y(), p4.y() ) ) );
mVisibleExtent.set( dxmin, dymin, dxmax, dymax );
}
#endif
Expand Down Expand Up @@ -547,7 +548,8 @@ void QgsMapSettings::readXML( QDomNode& theNode )
// set rotation
QDomNode rotationNode = theNode.namedItem( "rotation" );
QString rotationVal = rotationNode.toElement().text();
if ( ! rotationVal.isEmpty() ) {
if ( ! rotationVal.isEmpty() )
{
double rot = rotationVal.toDouble();
setRotation( rot );
}
Expand All @@ -568,9 +570,9 @@ void QgsMapSettings::writeXML( QDomNode& theNode, QDomDocument& theDoc )
// Write current view rotation
QDomElement rotNode = theDoc.createElement( "rotation" );
rotNode.appendChild(
theDoc.createTextNode( qgsDoubleToString( rotation() ) )
theDoc.createTextNode( qgsDoubleToString( rotation() ) )
);
theNode.appendChild(rotNode);
theNode.appendChild( rotNode );

// projections enabled
QDomElement projNode = theDoc.createElement( "projections" );
Expand Down
35 changes: 18 additions & 17 deletions src/core/qgsmaptopixel.cpp
Expand Up @@ -46,48 +46,49 @@ int QgsMapToPixel::mapHeight() const

int QgsMapToPixel::mapWidth() const
{
return ((xCenter-xMin)*2)/mMapUnitsPerPixel;
return (( xCenter -xMin )*2 ) / mMapUnitsPerPixel;
}

QTransform QgsMapToPixel::getMatrix() const
{
double cy = mapHeight()/2.0;
double cx = mapWidth()/2.0;
double cy = mapHeight() / 2.0;
double cx = mapWidth() / 2.0;
double rotation = mapRotation();

#if 0 // debugging
QgsDebugMsg(QString("XXX %7 -- xCent:%1 yCent:%2 mWidth:%3 mHeight:%4 uPP:%5 rot:%6")
.arg(xCenter).arg(yCenter).arg(mWidth).arg(mHeight)
.arg(mMapUnitsPerPixel).arg(rotation).arg((quintptr)this,QT_POINTER_SIZE *2, 15, QChar('0')));
QgsDebugMsg( QString( "XXX %7 -- xCent:%1 yCent:%2 mWidth:%3 mHeight:%4 uPP:%5 rot:%6" )
.arg( xCenter ).arg( yCenter ).arg( mWidth ).arg( mHeight )
.arg( mMapUnitsPerPixel ).arg( rotation ).arg(( quintptr )this, QT_POINTER_SIZE *2, 15, QChar( '0' ) ) );
#endif

// NOTE: operations are done in the reverse order in which
// they are configured, so translation to geographical
// center happens first, then scaling, then rotation
// and finally translation to output viewport center

if ( ! rotation ) {
if ( ! rotation )
{
// Returning a simplified matrix in hope it'll give expected
// results from an existing test, see
// https://travis-ci.org/qgis/QGIS/builds/42508945
return QTransform::fromScale( 1.0/mMapUnitsPerPixel, -1.0/mMapUnitsPerPixel )
.translate( -xMin, - ( yMin + mHeight*mMapUnitsPerPixel ) );
return QTransform::fromScale( 1.0 / mMapUnitsPerPixel, -1.0 / mMapUnitsPerPixel )
.translate( -xMin, - ( yMin + mHeight*mMapUnitsPerPixel ) );
}

return QTransform::fromTranslate( cx, cy )
.rotate( rotation )
.scale( 1/mMapUnitsPerPixel, -1/mMapUnitsPerPixel )
.translate ( -xCenter, -yCenter )
.scale( 1 / mMapUnitsPerPixel, -1 / mMapUnitsPerPixel )
.translate( -xCenter, -yCenter )
;
}

QgsPoint QgsMapToPixel::toMapPoint( double x, double y ) const
{
bool invertible;
QTransform matrix = getMatrix().inverted(&invertible);
assert(invertible);
QTransform matrix = getMatrix().inverted( &invertible );
assert( invertible );
double mx, my;
matrix.map(x, y, &mx, &my);
matrix.map( x, y, &mx, &my );
QgsPoint ret( mx, my );

//QgsDebugMsg(QString("XXX toMapPoint x:%1 y:%2 -> x:%3 y:%4").arg(x).arg(y).arg(mx).arg(my));
Expand Down Expand Up @@ -126,8 +127,8 @@ void QgsMapToPixel::setMapRotation( double degrees, double cx, double cy )
mMapRotation = degrees;
xCenter = cx;
yCenter = cy;
assert(xCenter >= xMin);
assert(yCenter >= yMin);
assert( xCenter >= xMin );
assert( yCenter >= yMin );
//assert(yCenter <= yMin + mHeight*mMapUnitsPerPixel;
}

Expand Down Expand Up @@ -206,7 +207,7 @@ void QgsMapToPixel::transformInPlace( qreal& x, qreal& y ) const

QTransform matrix = getMatrix();
double mx, my;
matrix.map(x, y, &mx, &my);
matrix.map( x, y, &mx, &my );
//QgsDebugMsg(QString("XXX transformInPlace X : %1-->%2, Y: %3 -->%4").arg(x).arg(mx).arg(y).arg(my));
x = mx; y = my;
}
5 changes: 3 additions & 2 deletions src/core/qgsmaptopixel.h
Expand Up @@ -74,7 +74,8 @@ class CORE_EXPORT QgsMapToPixel
@note not available in python bindings
*/
template <class T>
void transformInPlace( QVector<T>& x, QVector<T>& y ) const {
void transformInPlace( QVector<T>& x, QVector<T>& y ) const
{
assert( x.size() == y.size() );
for ( int i = 0; i < x.size(); ++i )
transformInPlace( x[i], y[i] );
Expand Down Expand Up @@ -120,7 +121,7 @@ class CORE_EXPORT QgsMapToPixel
//! Set maximum y value
// @deprecated in 2.8, use setViewportHeight
// @note this really sets the viewport height, not ymax
void setYMaximum( double yMax ) { setViewportHeight(yMax); }
void setYMaximum( double yMax ) { setViewportHeight( yMax ); }
//! Set viewport height
//! @note added in 2.8
void setViewportHeight( double height );
Expand Down
26 changes: 14 additions & 12 deletions src/core/raster/qgsrasterdrawer.cpp
Expand Up @@ -115,12 +115,14 @@ void QgsRasterDrawer::drawImage( QPainter* p, QgsRasterViewPort* viewPort, const
int w = theQgsMapToPixel->mapWidth();
int h = theQgsMapToPixel->mapHeight();

if ( theQgsMapToPixel ) {
if ( theQgsMapToPixel )
{
double rotation = theQgsMapToPixel->mapRotation();
if ( rotation ) {
if ( rotation )
{
// both viewPort and image sizes are dependent on scale
double cx = w/2.0;
double cy = h/2.0;
double cx = w / 2.0;
double cy = h / 2.0;
p->translate( cx, cy );
p->rotate( rotation );
p->translate( -cx, -cy );
Expand All @@ -131,19 +133,19 @@ void QgsRasterDrawer::drawImage( QPainter* p, QgsRasterViewPort* viewPort, const

#if 0
// For debugging:
QRectF br = QRectF(tlPoint, img.size());
QRectF br = QRectF( tlPoint, img.size() );
QPointF c = br.center();
double rad = std::max(br.width(),br.height())/10;
double rad = std::max( br.width(), br.height() ) / 10;
p->drawRoundedRect( br, rad, rad );
p->drawLine( QLineF(br.x(), br.y(), br.x()+br.width(), br.y()+br.height()) );
p->drawLine( QLineF(br.x()+br.width(), br.y(), br.x(), br.y()+br.height()) );
p->drawLine( QLineF( br.x(), br.y(), br.x() + br.width(), br.y() + br.height() ) );
p->drawLine( QLineF( br.x() + br.width(), br.y(), br.x(), br.y() + br.height() ) );

double nw = br.width()*0.5; double nh = br.height()*0.5;
br = QRectF(c-QPointF(nw/2,nh/2), QSize(nw, nh));
double nw = br.width() * 0.5; double nh = br.height() * 0.5;
br = QRectF( c - QPointF( nw / 2, nh / 2 ), QSize( nw, nh ) );
p->drawRoundedRect( br, rad, rad );

nw = br.width()*0.5; nh = br.height()*0.5;
br = QRectF(c-QPointF(nw/2,nh/2), QSize(nw, nh));
nw = br.width() * 0.5; nh = br.height() * 0.5;
br = QRectF( c - QPointF( nw / 2, nh / 2 ), QSize( nw, nh ) );
p->drawRoundedRect( br, rad, rad );
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgsrasterdrawer.h
Expand Up @@ -46,7 +46,7 @@ class CORE_EXPORT QgsRasterDrawer
@param topLeftCol Left position relative to left border of viewport
@param topLeftRow Top position relative to top border of viewport
@param mapToPixel map to device coordinate transformation info */
void drawImage( QPainter* p, QgsRasterViewPort* viewPort, const QImage& img, int topLeftCol, int topLeftRow, const QgsMapToPixel* mapToPixel=0 ) const;
void drawImage( QPainter* p, QgsRasterViewPort* viewPort, const QImage& img, int topLeftCol, int topLeftRow, const QgsMapToPixel* mapToPixel = 0 ) const;

private:
QgsRasterIterator* mIterator;
Expand Down
15 changes: 8 additions & 7 deletions src/core/raster/qgsrasterlayerrenderer.cpp
Expand Up @@ -32,16 +32,17 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer* layer, QgsRender
mMapToPixel = &theQgsMapToPixel;

QgsMapToPixel mapToPixel = theQgsMapToPixel;
if ( mapToPixel.mapRotation() ) {
if ( mapToPixel.mapRotation() )
{
// unset rotation for the sake of local computations.
// Rotation will be handled by QPainter later
// TODO: provide a method of QgsMapToPixel to fetch map center
// in geographical units
QgsPoint center = mapToPixel.toMapCoordinates(
mapToPixel.mapWidth()/2.0,
mapToPixel.mapHeight()/2.0
);
mapToPixel.setMapRotation(0, center.x(), center.y());
mapToPixel.mapWidth() / 2.0,
mapToPixel.mapHeight() / 2.0
);
mapToPixel.setMapRotation( 0, center.x(), center.y() );
}

QgsRectangle myProjectedViewExtent;
Expand Down Expand Up @@ -133,9 +134,9 @@ QgsRasterLayerRenderer::QgsRasterLayerRenderer( QgsRasterLayer* layer, QgsRender
// recalc myRasterExtent to aligned values
myRasterExtent.set(
mapToPixel.toMapCoordinatesF( mRasterViewPort->mTopLeftPoint.x(),
mRasterViewPort->mBottomRightPoint.y() ),
mRasterViewPort->mBottomRightPoint.y() ),
mapToPixel.toMapCoordinatesF( mRasterViewPort->mBottomRightPoint.x(),
mRasterViewPort->mTopLeftPoint.y() )
mRasterViewPort->mTopLeftPoint.y() )
);

//raster viewport top left / bottom right are already rounded to int
Expand Down
8 changes: 4 additions & 4 deletions src/gui/qgsmapcanvasitem.cpp
Expand Up @@ -73,10 +73,10 @@ QRectF QgsMapCanvasItem::toCanvasCoordinates( const QRectF& rect )
QPointF bl( toCanvasCoordinates( rect.bottomLeft() ) );
QPointF br( toCanvasCoordinates( rect.bottomRight() ) );
QPointF tr( toCanvasCoordinates( rect.topRight() ) );
double xmin = std::min(tl.x(), std::min(bl.x(), std::min(br.x(), tr.x())));
double ymin = std::min(tl.y(), std::min(bl.y(), std::min(br.y(), tr.y())));
double xmax = std::max(tl.x(), std::max(bl.x(), std::max(br.x(), tr.x())));
double ymax = std::max(tl.y(), std::max(bl.y(), std::max(br.y(), tr.y())));
double xmin = std::min( tl.x(), std::min( bl.x(), std::min( br.x(), tr.x() ) ) );
double ymin = std::min( tl.y(), std::min( bl.y(), std::min( br.y(), tr.y() ) ) );
double xmax = std::max( tl.x(), std::max( bl.x(), std::max( br.x(), tr.x() ) ) );
double ymax = std::max( tl.y(), std::max( bl.y(), std::max( br.y(), tr.y() ) ) );
return QRectF( QPointF( xmin, ymin ), QPointF( xmax, ymax ) );
}

Expand Down
20 changes: 10 additions & 10 deletions src/gui/qgsmapcanvasmap.cpp
Expand Up @@ -50,13 +50,13 @@ void QgsMapCanvasMap::paint( QPainter* painter )
if ( mImage.size() != QSize( w, h ) )
{
QgsDebugMsg( QString( "map paint DIFFERENT SIZE: img %1,%2 item %3,%4" ).arg( mImage.width() ).arg( mImage.height() ).arg( w ).arg( h ) );
int tX = (w-mImage.width())/2.0;
int tY = (h-mImage.height())/2.0;
int tX = ( w - mImage.width() ) / 2.0;
int tY = ( h - mImage.height() ) / 2.0;
int fX = 0;
int fY = 0;
int fW = w;
int fH = h;
painter->drawImage(tX, tY, mImage, fX, fY, fW, fH);
painter->drawImage( tX, tY, mImage, fX, fY, fW, fH );
}
else
{
Expand All @@ -67,17 +67,17 @@ void QgsMapCanvasMap::paint( QPainter* painter )
#if 0
QRectF br = boundingRect();
QPointF c = br.center();
double rad = std::max(br.width(),br.height())/10;
double rad = std::max( br.width(), br.height() ) / 10;
painter->drawRoundedRect( br, rad, rad );
painter->drawLine( QLineF(0, 0, br.width(), br.height()) );
painter->drawLine( QLineF(br.width(), 0, 0, br.height()) );
painter->drawLine( QLineF( 0, 0, br.width(), br.height() ) );
painter->drawLine( QLineF( br.width(), 0, 0, br.height() ) );

double nw = br.width()*0.5; double nh = br.height()*0.5;
br = QRectF(c-QPointF(nw/2,nh/2), QSize(nw, nh));
double nw = br.width() * 0.5; double nh = br.height() * 0.5;
br = QRectF( c - QPointF( nw / 2, nh / 2 ), QSize( nw, nh ) );
painter->drawRoundedRect( br, rad, rad );

nw = br.width()*0.5; nh = br.height()*0.5;
br = QRectF(c-QPointF(nw/2,nh/2), QSize(nw, nh));
nw = br.width() * 0.5; nh = br.height() * 0.5;
br = QRectF( c - QPointF( nw / 2, nh / 2 ), QSize( nw, nh ) );
painter->drawRoundedRect( br, rad, rad );
#endif
}
Expand Down

0 comments on commit 28c3443

Please sign in to comment.