Skip to content

Commit

Permalink
indentation update
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 23, 2014
1 parent bc87d51 commit 5a25570
Show file tree
Hide file tree
Showing 75 changed files with 1,508 additions and 1,507 deletions.
68 changes: 34 additions & 34 deletions src/app/composer/qgscomposermapwidget.cpp
Expand Up @@ -296,41 +296,41 @@ void QgsComposerMapWidget::on_mSetToMapCanvasExtentButton_clicked()
{
if ( mComposerMap )
{
QgsRectangle newExtent = mComposerMap->composition()->mapSettings().visibleExtent();

//Make sure the width/height ratio is the same as in current composer map extent.
//This is to keep the map item frame and the page layout fixed
QgsRectangle currentMapExtent = *( mComposerMap->currentMapExtent() );
double currentWidthHeightRatio = currentMapExtent.width() / currentMapExtent.height();
double newWidthHeightRatio = newExtent.width() / newExtent.height();

if ( currentWidthHeightRatio < newWidthHeightRatio )
{
//enlarge height of new extent, ensuring the map center stays the same
double newHeight = newExtent.width() / currentWidthHeightRatio;
double deltaHeight = newHeight - newExtent.height();
newExtent.setYMinimum( newExtent.yMinimum() - deltaHeight / 2 );
newExtent.setYMaximum( newExtent.yMaximum() + deltaHeight / 2 );
}
else
{
//enlarge width of new extent, ensuring the map center stays the same
double newWidth = currentWidthHeightRatio * newExtent.height();
double deltaWidth = newWidth - newExtent.width();
newExtent.setXMinimum( newExtent.xMinimum() - deltaWidth / 2 );
newExtent.setXMaximum( newExtent.xMaximum() + deltaWidth / 2 );
}

//fill text into line edits
mXMinLineEdit->setText( QString::number( newExtent.xMinimum() ) );
mXMaxLineEdit->setText( QString::number( newExtent.xMaximum() ) );
mYMinLineEdit->setText( QString::number( newExtent.yMinimum() ) );
mYMaxLineEdit->setText( QString::number( newExtent.yMaximum() ) );

mComposerMap->beginCommand( tr( "Map extent changed" ) );
mComposerMap->setNewExtent( newExtent );
mComposerMap->endCommand();
QgsRectangle newExtent = mComposerMap->composition()->mapSettings().visibleExtent();

//Make sure the width/height ratio is the same as in current composer map extent.
//This is to keep the map item frame and the page layout fixed
QgsRectangle currentMapExtent = *( mComposerMap->currentMapExtent() );
double currentWidthHeightRatio = currentMapExtent.width() / currentMapExtent.height();
double newWidthHeightRatio = newExtent.width() / newExtent.height();

if ( currentWidthHeightRatio < newWidthHeightRatio )
{
//enlarge height of new extent, ensuring the map center stays the same
double newHeight = newExtent.width() / currentWidthHeightRatio;
double deltaHeight = newHeight - newExtent.height();
newExtent.setYMinimum( newExtent.yMinimum() - deltaHeight / 2 );
newExtent.setYMaximum( newExtent.yMaximum() + deltaHeight / 2 );
}
else
{
//enlarge width of new extent, ensuring the map center stays the same
double newWidth = currentWidthHeightRatio * newExtent.height();
double deltaWidth = newWidth - newExtent.width();
newExtent.setXMinimum( newExtent.xMinimum() - deltaWidth / 2 );
newExtent.setXMaximum( newExtent.xMaximum() + deltaWidth / 2 );
}

//fill text into line edits
mXMinLineEdit->setText( QString::number( newExtent.xMinimum() ) );
mXMaxLineEdit->setText( QString::number( newExtent.xMaximum() ) );
mYMinLineEdit->setText( QString::number( newExtent.yMinimum() ) );
mYMaxLineEdit->setText( QString::number( newExtent.yMaximum() ) );

mComposerMap->beginCommand( tr( "Map extent changed" ) );
mComposerMap->setNewExtent( newExtent );
mComposerMap->endCommand();
}
}

void QgsComposerMapWidget::on_mXMinLineEdit_editingFinished()
Expand Down
38 changes: 19 additions & 19 deletions src/app/maprenderertest.cpp
Expand Up @@ -13,31 +13,31 @@
#include "qgsmapoverviewcanvas.h"
#include "qgsmaptoolpan.h"

int main(int argc, char* argv[])
int main( int argc, char* argv[] )
{
QApplication app(argc, argv);
QApplication app( argc, argv );

QgsApplication::setPrefixPath("/home/martin/qgis/git-master/creator/output", true);
QgsApplication::setPrefixPath( "/home/martin/qgis/git-master/creator/output", true );
QgsApplication::initQgis();

QString uri = "dbname='/data/gis/praha.osm.db' table=\"praha_polygons\" (geometry) sql=";
QString uri2 = "dbname='/data/gis/praha.osm.db' table=\"praha_polylines\" (geometry) sql=";
//QString uri = "/data/gis/cr-shp-wgs84/plochy/kraje_pseudo.shp";
QgsVectorLayer* layer = new QgsVectorLayer(uri, "praha", "spatialite");
if (!layer->isValid())
QgsVectorLayer* layer = new QgsVectorLayer( uri, "praha", "spatialite" );
if ( !layer->isValid() )
{
qDebug("invalid layer");
qDebug( "invalid layer" );
return 1;
}
QgsMapLayerRegistry::instance()->addMapLayer(layer);
QgsMapLayerRegistry::instance()->addMapLayer( layer );

QgsVectorLayer* layer2 = new QgsVectorLayer(uri2, "praha", "spatialite");
if (!layer2->isValid())
QgsVectorLayer* layer2 = new QgsVectorLayer( uri2, "praha", "spatialite" );
if ( !layer2->isValid() )
{
qDebug("invalid layer");
qDebug( "invalid layer" );
return 1;
}
QgsMapLayerRegistry::instance()->addMapLayer(layer2);
QgsMapLayerRegistry::instance()->addMapLayer( layer2 );

// open a window and do the rendering!
/*TestWidget l(layer);
Expand All @@ -46,23 +46,23 @@ int main(int argc, char* argv[])


QgsMapCanvas canvas;
canvas.setCanvasColor(Qt::white);
canvas.setExtent(layer->extent());
canvas.setCanvasColor( Qt::white );
canvas.setExtent( layer->extent() );
canvas.show();

// test overview
QgsMapOverviewCanvas overview( 0, &canvas );
overview.resize(200,200);
overview.resize( 200, 200 );
canvas.enableOverviewMode( &overview );
overview.show();

QList<QgsMapCanvasLayer> layers;
layers.append(QgsMapCanvasLayer(layer2, true, true));
layers.append(QgsMapCanvasLayer(layer));
canvas.setLayerSet(layers);
layers.append( QgsMapCanvasLayer( layer2, true, true ) );
layers.append( QgsMapCanvasLayer( layer ) );
canvas.setLayerSet( layers );

QgsMapTool* pan = new QgsMapToolPan(&canvas);
canvas.setMapTool(pan);
QgsMapTool* pan = new QgsMapToolPan( &canvas );
canvas.setMapTool( pan );

return app.exec();
}
118 changes: 59 additions & 59 deletions src/app/maprenderertest.h
Expand Up @@ -13,81 +13,81 @@

class TestWidget : public QLabel
{
Q_OBJECT
public:
TestWidget(QgsMapLayer* layer)
{
job = 0;

// init renderer
ms.setLayers(QStringList(layer->id()));
ms.setExtent(layer->extent());
ms.setOutputSize(size());

if (ms.hasValidSettings())
qDebug("map renderer settings valid");

connect(&timer, SIGNAL(timeout()), SLOT(onMapUpdateTimeout()));
timer.setInterval(100);
}

void mousePressEvent(QMouseEvent * event)
{
if (event->button() == Qt::RightButton)
Q_OBJECT
public:
TestWidget( QgsMapLayer* layer )
{
qDebug("cancelling!");
job = 0;

if (job)
{
job->cancel();
delete job;
job = 0;
}
// init renderer
ms.setLayers( QStringList( layer->id() ) );
ms.setExtent( layer->extent() );
ms.setOutputSize( size() );

if ( ms.hasValidSettings() )
qDebug( "map renderer settings valid" );

connect( &timer, SIGNAL( timeout() ), SLOT( onMapUpdateTimeout() ) );
timer.setInterval( 100 );
}
else
{
qDebug("starting!");

if (job)
void mousePressEvent( QMouseEvent * event )
{
if ( event->button() == Qt::RightButton )
{
qDebug("need to cancel first!");
job->cancel();
delete job;
job = 0;
qDebug( "cancelling!" );

if ( job )
{
job->cancel();
delete job;
job = 0;
}
}
else
{
qDebug( "starting!" );

job = new QgsMapRendererSequentialJob(ms);
connect(job, SIGNAL(finished()), SLOT(f()));
if ( job )
{
qDebug( "need to cancel first!" );
job->cancel();
delete job;
job = 0;
}

job->start();
job = new QgsMapRendererSequentialJob( ms );
connect( job, SIGNAL( finished() ), SLOT( f() ) );

timer.start();
job->start();

timer.start();
}
}
}

protected slots:
void f()
{
qDebug("finished!");
protected slots:
void f()
{
qDebug( "finished!" );

timer.stop();
timer.stop();

if (job)
setPixmap(QPixmap::fromImage( job->renderedImage() ));
}
if ( job )
setPixmap( QPixmap::fromImage( job->renderedImage() ) );
}

void onMapUpdateTimeout()
{
qDebug("update timer!");
void onMapUpdateTimeout()
{
qDebug( "update timer!" );

if (job)
setPixmap(QPixmap::fromImage( job->renderedImage() ));
}
if ( job )
setPixmap( QPixmap::fromImage( job->renderedImage() ) );
}

protected:
QgsMapSettings ms;
QgsMapRendererQImageJob* job;
QTimer timer;
protected:
QgsMapSettings ms;
QgsMapRendererQImageJob* job;
QTimer timer;
};


Expand Down
4 changes: 2 additions & 2 deletions src/app/qgisapp.cpp
Expand Up @@ -2094,7 +2094,7 @@ void QgisApp::createOverview()

mMapCanvas->setCachingEnabled( mySettings.value( "/qgis/enable_render_caching", false ).toBool() );

mMapCanvas->setParallelRenderingEnabled( mySettings.value( "/qgis/parallel_rendering", false).toBool() );
mMapCanvas->setParallelRenderingEnabled( mySettings.value( "/qgis/parallel_rendering", false ).toBool() );

mMapCanvas->setMapUpdateInterval( mySettings.value( "/qgis/map_update_interval", 250 ).toInt() );
}
Expand Down Expand Up @@ -6849,7 +6849,7 @@ void QgisApp::showOptionsDialog( QWidget *parent, QString currentPage )

mMapCanvas->setCachingEnabled( mySettings.value( "/qgis/enable_render_caching", false ).toBool() );

mMapCanvas->setParallelRenderingEnabled( mySettings.value( "/qgis/parallel_rendering", false).toBool() );
mMapCanvas->setParallelRenderingEnabled( mySettings.value( "/qgis/parallel_rendering", false ).toBool() );

mMapCanvas->setMapUpdateInterval( mySettings.value( "/qgis/map_update_interval", 250 ).toInt() );

Expand Down
4 changes: 2 additions & 2 deletions src/app/qgslabelengineconfigdialog.cpp
Expand Up @@ -57,8 +57,8 @@ void QgsLabelEngineConfigDialog::onOK()
lbl.setSearchMethod(( QgsPalLabeling::Search ) cboSearchMethod->currentIndex() );

lbl.setNumCandidatePositions( spinCandPoint->value(),
spinCandLine->value(),
spinCandPolygon->value() );
spinCandLine->value(),
spinCandPolygon->value() );

lbl.setShowingCandidates( chkShowCandidates->isChecked() );
lbl.setShowingShadowRectangles( mShadowDebugRectChkBox->isChecked() );
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsmaptoollabel.cpp
Expand Up @@ -26,7 +26,7 @@
#include <QMouseEvent>

QgsMapToolLabel::QgsMapToolLabel( QgsMapCanvas* canvas ): QgsMapTool( canvas ), mLabelRubberBand( 0 ), mFeatureRubberBand( 0 ), mFixPointRubberBand( 0 )
, mCurrentLayer( 0 )
, mCurrentLayer( 0 )
{
}

Expand Down Expand Up @@ -138,7 +138,7 @@ QgsPalLayerSettings& QgsMapToolLabel::currentLabelSettings( bool* ok )
mCurrentSettings = QgsPalLayerSettings::fromLayer( vlayer );

if ( ok )
*ok = true;
*ok = true;

return mCurrentSettings;
}
Expand Down
14 changes: 7 additions & 7 deletions src/core/composer/qgscomposermap.cpp
Expand Up @@ -184,13 +184,13 @@ void QgsComposerMap::draw( QPainter *painter, const QgsRectangle& extent, const
jobMapSettings.setDestinationCrs( ms.destinationCrs() );
jobMapSettings.setCrsTransformEnabled( ms.hasCrsTransformEnabled() );
jobMapSettings.setFlags( ms.flags() );
/* TODO[MD] fix after merge
if ( mComposition->plotStyle() == QgsComposition::Print ||
mComposition->plotStyle() == QgsComposition::Postscript )
{
//if outputing composer, disable optimisations like layer simplification
theRendererContext->setUseRenderingOptimization( false );
}*/
/* TODO[MD] fix after merge
if ( mComposition->plotStyle() == QgsComposition::Print ||
mComposition->plotStyle() == QgsComposition::Postscript )
{
//if outputing composer, disable optimisations like layer simplification
theRendererContext->setUseRenderingOptimization( false );
}*/

//update $map variable. Use QgsComposerItem's id since that is user-definable
QgsExpression::setSpecialColumn( "$map", QgsComposerItem::id() );
Expand Down
10 changes: 5 additions & 5 deletions src/core/composer/qgscomposition.cpp
Expand Up @@ -60,10 +60,10 @@ QgsComposition::QgsComposition( QgsMapRenderer* mapRenderer )
}

QgsComposition::QgsComposition( const QgsMapSettings& mapSettings )
: QGraphicsScene( 0 )
, mMapRenderer( 0 )
, mMapSettings( mapSettings )
, mAtlasComposition( this )
: QGraphicsScene( 0 )
, mMapRenderer( 0 )
, mMapSettings( mapSettings )
, mAtlasComposition( this )
{
init();
}
Expand Down Expand Up @@ -98,7 +98,7 @@ void QgsComposition::init()

setBackgroundBrush( QColor( 215, 215, 215 ) );
createDefaultPageStyleSymbol();

addPaperItem();

updateBounds();
Expand Down
2 changes: 1 addition & 1 deletion src/core/pal/pal.cpp
Expand Up @@ -819,7 +819,7 @@ namespace pal
return solution;
}

void Pal::registerCancellationCallback(Pal::FnIsCancelled fnCancelled, void *context)
void Pal::registerCancellationCallback( Pal::FnIsCancelled fnCancelled, void *context )
{
fnIsCancelled = fnCancelled;
fnIsCancelledContext = context;
Expand Down

0 comments on commit 5a25570

Please sign in to comment.