13 changes: 10 additions & 3 deletions src/app/legend/qgslegendlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include "qgscategorizedsymbolrendererv2.h"
#include "qgsgraduatedsymbolrendererv2.h"

#include <iostream>
#include <QAction>
#include <QCoreApplication>
#include <QIcon>
Expand All @@ -54,8 +53,10 @@


QgsLegendLayer::QgsLegendLayer( QgsMapLayer* layer )
: QgsLegendItem( ),
mLyr( layer ), mShowFeatureCount( false )
: QgsLegendItem( )
, mLyr( layer )
, mDrawingOrder( -1 )
, mShowFeatureCount( false )
{
mType = LEGEND_LAYER;

Expand Down Expand Up @@ -711,3 +712,9 @@ void QgsLegendLayer::setShowFeatureCount( bool show, bool update )
}
}
}

void QgsLegendLayer::setDrawingOrder( int order )
{
QgsDebugMsg( QString( "order %1: %2=>%3" ).arg( mLyr.layer()->name() ).arg( mDrawingOrder ).arg( order ) );
mDrawingOrder = order;
}
6 changes: 6 additions & 0 deletions src/app/legend/qgslegendlayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ class QgsLegendLayer : public QgsLegendItem
/** set check state, but only if user checkable */
void setCheckState( int column, Qt::CheckState state );

void setDrawingOrder( int order );
int drawingOrder() const { return mDrawingOrder; }

public slots:

/**Toggle show in overview*/
Expand Down Expand Up @@ -127,6 +130,9 @@ class QgsLegendLayer : public QgsLegendItem
/** layer identified by its layer id */
QgsMapCanvasLayer mLyr;

/** drawing order */
int mDrawingOrder;

/**True if number of features per legend class should is shown in the legend items*/
bool mShowFeatureCount;
};
Expand Down
16 changes: 16 additions & 0 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
#include "qgsgpsinformationwidget.h"
#include "qgslabelinggui.h"
#include "qgslegend.h"
#include "qgslayerorder.h"
#include "qgslegendlayer.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
Expand Down Expand Up @@ -428,6 +429,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
// "theMapLegend" used to find this canonical instance later
mMapLegend = new QgsLegend( mMapCanvas, this, "theMapLegend" );

mMapLayerOrder = new QgsLayerOrder( mMapLegend, this, "theMapLayerOrder" );

// create undo widget
mUndoWidget = new QgsUndoWidget( NULL, mMapCanvas );
mUndoWidget->setObjectName( "Undo" );
Expand Down Expand Up @@ -495,6 +498,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,
QString caption = tr( "Quantum GIS - %1 ('%2')" ).arg( QGis::QGIS_VERSION ).arg( QGis::QGIS_RELEASE_NAME );
setWindowTitle( caption );

QgsMessageLog::logMessage( tr( "QGIS starting..." ) );

// set QGIS specific srs validation
QgsCoordinateReferenceSystem::setCustomSrsValidation( customSrsValidation_ );

Expand Down Expand Up @@ -575,6 +580,8 @@ QgisApp::QgisApp( QSplashScreen *splash, bool restorePlugins, QWidget * parent,

mSplash->showMessage( tr( "QGIS Ready!" ), Qt::AlignHCenter | Qt::AlignBottom );

QgsMessageLog::logMessage( tr( "QGIS Ready!" ) );

mMapTipsVisible = false;

// setup drag drop
Expand Down Expand Up @@ -1714,8 +1721,17 @@ void QgisApp::initLegend()
mLegendDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mLegendDock->setWidget( mMapLegend );
addDockWidget( Qt::LeftDockWidgetArea, mLegendDock );

// add to the Panel submenu
mPanelMenu->addAction( mLegendDock->toggleViewAction() );

mMapLayerOrder->setWhatsThis( tr( "Map layer list that displays all layers in drawing order." ) );
mLayerOrderDock = new QDockWidget( tr( "Layerorder" ), this );
mLayerOrderDock->setObjectName( "Legend" );
mLayerOrderDock->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
mLayerOrderDock->setWidget( mMapLayerOrder );
addDockWidget( Qt::LeftDockWidgetArea, mLayerOrderDock );

return;
}

Expand Down
4 changes: 4 additions & 0 deletions src/app/qgisapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ class QgsGeometry;
class QgsFeature;

class QgsLegend;
class QgsLayerOrder;
class QgsMapCanvas;
class QgsMapLayer;
class QgsMapTip;
Expand Down Expand Up @@ -906,6 +907,7 @@ class QgisApp : public QMainWindow, private Ui::MainWindow

// docks ------------------------------------------
QDockWidget *mLegendDock;
QDockWidget *mLayerOrderDock;
QDockWidget *mOverviewDock;
QDockWidget *mpTileScaleDock;
QDockWidget *mpGpsDock;
Expand Down Expand Up @@ -991,6 +993,8 @@ class QgisApp : public QMainWindow, private Ui::MainWindow
QgsMapCanvas *mMapCanvas;
//! Table of contents (legend) for the map
QgsLegend *mMapLegend;
//! Table of contents (legend) to order layers of the map
QgsLayerOrder *mMapLayerOrder;
//! Cursor for the overview map
QCursor *mOverviewMapCursor;
//! scale factor
Expand Down
17 changes: 10 additions & 7 deletions src/core/qgsmaprenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,13 @@ void QgsMapRenderer::render( QPainter* painter )
continue;
}

QgsDebugMsg( "Rendering layer " + ml->name() );
QgsDebugMsg( " Layer minscale " + QString( "%1" ).arg( ml->minimumScale() ) );
QgsDebugMsg( " Layer maxscale " + QString( "%1" ).arg( ml->maximumScale() ) );
QgsDebugMsg( " Scale dep. visibility enabled? " + QString( "%1" ).arg( ml->hasScaleBasedVisibility() ) );
QgsDebugMsg( " Input extent: " + ml->extent().toString() );
QgsDebugMsg( QString( "layer %1: minscale:%2 maxscale:%3 scaledepvis:%4 extent:%5" )
.arg( ml->name() )
.arg( ml->minimumScale() )
.arg( ml->maximumScale() )
.arg( ml->hasScaleBasedVisibility() )
.arg( ml->extent().toString() )
);

if ( !ml->hasScaleBasedVisibility() || ( ml->minimumScale() < mScale && mScale < ml->maximumScale() ) || mOverview )
{
Expand Down Expand Up @@ -455,7 +457,7 @@ void QgsMapRenderer::render( QPainter* painter )
{
if ( !mySameAsLastFlag || ml->cacheImage() == 0 )
{
QgsDebugMsg( "\n\n\nCaching enabled but layer redraw forced by extent change or empty cache\n\n\n" );
QgsDebugMsg( "Caching enabled but layer redraw forced by extent change or empty cache" );
QImage * mypImage = new QImage( mRenderContext.painter()->device()->width(),
mRenderContext.painter()->device()->height(), QImage::Format_ARGB32 );
mypImage->fill( 0 );
Expand All @@ -471,7 +473,7 @@ void QgsMapRenderer::render( QPainter* painter )
else if ( mySameAsLastFlag )
{
//draw from cached image
QgsDebugMsg( "\n\n\nCaching enabled --- drawing layer from cached image\n\n\n" );
QgsDebugMsg( "Caching enabled --- drawing layer from cached image" );
mypContextPainter->drawImage( 0, 0, *( ml->cacheImage() ) );
disconnect( ml, SIGNAL( drawingProgress( int, int ) ), this, SLOT( onDrawingProgress( int, int ) ) );
//short circuit as there is nothing else to do...
Expand Down Expand Up @@ -899,6 +901,7 @@ QgsRectangle QgsMapRenderer::fullExtent()

void QgsMapRenderer::setLayerSet( const QStringList& layers )
{
QgsDebugMsg( QString( "Entering: %1" ).arg( layers.join( ", " ) ) );
mLayerSet = layers;
updateFullExtent();
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void QgsVectorLayer::drawLabels( QgsRenderContext& rendererContext )
if ( !hasGeometryType() )
return;

QgsDebugMsg( "Starting draw of labels" );
QgsDebugMsg( "Starting draw of labels: " + id() );

if (( mRenderer || mRendererV2 ) && mLabelOn &&
( !mLabel->scaleBasedVisibility() ||
Expand Down
4 changes: 4 additions & 0 deletions src/gui/qgsmapcanvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
{
if ( mDrawing )
{
QgsDebugMsg( "NOT updating layer set while drawing" );
return;
}

Expand All @@ -255,6 +256,7 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
{
layerSet.push_back( lyr.layer()->id() );
}

if ( lyr.isInOverview() )
{
layerSetOverview.push_back( lyr.layer()->id() );
Expand All @@ -268,6 +270,8 @@ void QgsMapCanvas::setLayerSet( QList<QgsMapCanvasLayer> &layers )
// update only if needed
if ( layerSetChanged )
{
QgsDebugMsg( "Layer changed to: " + layerSet.join( ", " ) );

for ( i = 0; i < layerCount(); i++ )
{
// Add check if vector layer when disconnecting from selectionChanged slot
Expand Down