Skip to content
Permalink
Browse files
Add option to show canvas refresh event in Log Message panel
- In Options at bottom of Rendering tab
- Useful for debugging excessive refreshes from userspace without having to build with debug and filter logs
- Records time taken for refresh and any resolvable sender class
  • Loading branch information
dakcarto committed Feb 9, 2013
1 parent 92cbf8f commit d4fcc6d
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 22 deletions.
@@ -358,6 +358,10 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :

// set the display update threshold
spinBoxUpdateThreshold->setValue( settings.value( "/Map/updateThreshold" ).toInt() );

// log rendering events, for userspace debugging
mLogCanvasRefreshChkBx->setChecked( settings.value( "/Map/logCanvasRefreshEvent", false ).toBool() );

//set the default projection behaviour radio buttongs
if ( settings.value( "/Projections/defaultBehaviour", "prompt" ).toString() == "prompt" )
{
@@ -1140,6 +1144,10 @@ void QgsOptions::saveOptions()

settings.setValue( "/Map/enableBackbuffer", chkEnableBackbuffer->isChecked() );
settings.setValue( "/Map/updateThreshold", spinBoxUpdateThreshold->value() );

// log rendering events, for userspace debugging
settings.setValue( "/Map/logCanvasRefreshEvent", mLogCanvasRefreshChkBx->isChecked() );

//check behaviour so default projection when new layer is added with no
//projection defined...
if ( radPromptForProjection->isChecked() )
@@ -47,6 +47,7 @@ email : sherman at mrcc.com
#include "qgsmaptopixel.h"
#include "qgsmapoverviewcanvas.h"
#include "qgsmaprenderer.h"
#include "qgsmessagelog.h"
#include "qgsmessageviewer.h"
#include "qgsproject.h"
#include "qgsrubberband.h"
@@ -368,6 +369,13 @@ void QgsMapCanvas::refresh()
return;

QSettings settings;
bool logRefresh = settings.value( "/Map/logCanvasRefreshEvent", false ).toBool();
QTime t;
if ( logRefresh )
{
t.start();
}

#ifdef Q_WS_X11
bool enableBackbufferSetting = settings.value( "/Map/enableBackbuffer", 1 ).toBool();
#endif
@@ -428,6 +436,17 @@ void QgsMapCanvas::refresh()
// Done refreshing
emit mapCanvasRefreshed();

if ( logRefresh )
{
QString logMsg = tr( "Canvas refresh: %1 ms" ).arg( t.elapsed() );
QObject* senderObj = QObject::sender();
if ( senderObj )
{
logMsg += tr( ", sender '%1'" ).arg( senderObj->metaObject()->className() );
}
QgsMessageLog::logMessage( logMsg, tr( "Rendering" ) );
}

} // refresh

void QgsMapCanvas::updateMap()
@@ -901,7 +901,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>611</width>
<width>654</width>
<height>808</height>
</rect>
</property>
@@ -1231,8 +1231,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>559</width>
<height>417</height>
<width>669</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_27">
@@ -1549,9 +1549,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>615</width>
<height>681</height>
<y>-291</y>
<width>654</width>
<height>781</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_29">
@@ -1561,7 +1561,7 @@
<string>Rendering behavior</string>
</property>
<layout class="QGridLayout" name="_4">
<item row="2" column="0">
<item row="1" column="0">
<widget class="QCheckBox" name="chkEnableBackbuffer">
<property name="toolTip">
<string>Better graphics performance at the cost of loosing the possibility to cancel rendering and incremental feature drawing</string>
@@ -1571,21 +1571,21 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="0" column="0">
<widget class="QCheckBox" name="chkAddedVisibility">
<property name="text">
<string>By default new la&amp;yers added to the map should be displayed</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<item row="4" column="0" colspan="2">
<widget class="QCheckBox" name="chkUseRenderCaching">
<property name="text">
<string>Use render caching where possible to speed up redraws</string>
</property>
</widget>
</item>
<item row="3" column="0">
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_26">
<item>
<widget class="QLabel" name="labelUpdateThreshold">
@@ -1615,7 +1615,7 @@
</item>
</layout>
</item>
<item row="4" column="0" colspan="3">
<item row="3" column="0" colspan="2">
<widget class="QLabel" name="textLabel3">
<property name="text">
<string>&lt;b&gt;Note:&lt;/b&gt; Use zero to prevent display updates until all features have been rendered</string>
@@ -1991,6 +1991,49 @@
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="groupBox_22">
<property name="title">
<string>Debugging</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_35">
<item>
<widget class="QLabel" name="label_55">
<property name="text">
<string>Show these events in the Log Message panel (under Rendering tab)</string>
</property>
</widget>
</item>
<item>
<layout class="QGridLayout" name="gridLayout_6">
<item row="0" column="0">
<spacer name="horizontalSpacer_37">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Fixed</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>8</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="mLogCanvasRefreshChkBx">
<property name="text">
<string>Map canvas refresh</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer_6">
<property name="orientation">
@@ -2038,8 +2081,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>498</width>
<height>396</height>
<width>669</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_25">
@@ -2349,7 +2392,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>556</width>
<width>654</width>
<height>718</height>
</rect>
</property>
@@ -2729,7 +2772,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>517</width>
<width>654</width>
<height>643</height>
</rect>
</property>
@@ -3218,8 +3261,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>537</width>
<height>361</height>
<width>669</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_6">
@@ -3358,8 +3401,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>614</width>
<height>393</height>
<width>669</width>
<height>490</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_15">
@@ -3539,8 +3582,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>300</width>
<height>248</height>
<width>669</width>
<height>490</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_32">
@@ -3639,7 +3682,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>521</width>
<width>654</width>
<height>650</height>
</rect>
</property>

0 comments on commit d4fcc6d

Please sign in to comment.