Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
User-configurable update interval
  • Loading branch information
wonder-sk committed Dec 11, 2013
1 parent 90b10f7 commit d3b5fb0
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 7 deletions.
8 changes: 8 additions & 0 deletions python/gui/qgsmapcanvas.sip
Expand Up @@ -91,6 +91,14 @@ class QgsMapCanvas : QGraphicsView
//! @note added in 2.1
bool isParallelRenderingEnabled() const;

//! Set how often map preview should be updated while it is being rendered (in miliseconds)
//! @note added in 2.1
void setMapUpdateInterval( int timeMiliseconds );

//! Find out how often map preview should be updated while it is being rendered (in miliseconds)
//! @note added in 2.1
int mapUpdateInterval() const;

//! @deprecated since 2.1 - there could be more than just one "map" items
QgsMapCanvasMap* map();

Expand Down
4 changes: 4 additions & 0 deletions src/app/qgisapp.cpp
Expand Up @@ -2073,6 +2073,8 @@ void QgisApp::createOverview()
mMapCanvas->setCachingEnabled( mySettings.value( "/qgis/enable_render_caching", false ).toBool() );

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

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

void QgisApp::addDockWidget( Qt::DockWidgetArea theArea, QDockWidget * thepDockWidget )
Expand Down Expand Up @@ -6607,6 +6609,8 @@ void QgisApp::options()

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

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

//do we need this? TS
mMapCanvas->refresh();

Expand Down
2 changes: 2 additions & 0 deletions src/app/qgsoptions.cpp
Expand Up @@ -499,6 +499,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
chkAntiAliasing->setChecked( settings.value( "/qgis/enable_anti_aliasing", true ).toBool() );
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
chkParallelRendering->setChecked( settings.value( "/qgis/parallel_rendering", false ).toBool() );
spinMapUpdateInterval->setValue( settings.value( "/qgis/map_update_interval", 250 ).toInt() );

// Slightly awkard here at the settings value is true to use QImage,
// but the checkbox is true to use QPixmap
Expand Down Expand Up @@ -934,6 +935,7 @@ void QgsOptions::saveOptions()
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
settings.setValue( "/qgis/enable_render_caching", chkUseRenderCaching->isChecked() );
settings.setValue( "/qgis/parallel_rendering", chkParallelRendering->isChecked() );
settings.setValue( "/qgis/map_update_interval", spinMapUpdateInterval->value() );
settings.setValue( "/qgis/legendDoubleClickAction", cmbLegendDoubleClickAction->currentIndex() );
bool legendLayersCapitalise = settings.value( "/qgis/capitaliseLayerName", false ).toBool();
settings.setValue( "/qgis/capitaliseLayerName", capitaliseCheckBox->isChecked() );
Expand Down
12 changes: 11 additions & 1 deletion src/gui/qgsmapcanvas.cpp
Expand Up @@ -208,7 +208,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
moveCanvasContents( true );

connect(&mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) );
mMapUpdateTimer.setInterval( 400 );
mMapUpdateTimer.setInterval( 250 );

#ifdef Q_OS_WIN
// Enable touch event on Windows.
Expand Down Expand Up @@ -525,6 +525,16 @@ bool QgsMapCanvas::isParallelRenderingEnabled() const
return mUseParallelRendering;
}

void QgsMapCanvas::setMapUpdateInterval( int timeMiliseconds )
{
mMapUpdateTimer.setInterval( timeMiliseconds );
}

int QgsMapCanvas::mapUpdateInterval() const
{
return mMapUpdateTimer.interval();
}


void QgsMapCanvas::updateOverview()
{
Expand Down
8 changes: 8 additions & 0 deletions src/gui/qgsmapcanvas.h
Expand Up @@ -162,6 +162,14 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
//! @note added in 2.1
bool isParallelRenderingEnabled() const;

//! Set how often map preview should be updated while it is being rendered (in miliseconds)
//! @note added in 2.1
void setMapUpdateInterval( int timeMiliseconds );

//! Find out how often map preview should be updated while it is being rendered (in miliseconds)
//! @note added in 2.1
int mapUpdateInterval() const;

//! @deprecated since 2.1 - there could be more than just one "map" items
QgsMapCanvasMap* map();

Expand Down
52 changes: 46 additions & 6 deletions src/ui/qgsoptionsbase.ui
Expand Up @@ -236,7 +236,7 @@
<item>
<widget class="QStackedWidget" name="mOptionsStackedWidget">
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="mOptionsPage_01">
<layout class="QVBoxLayout" name="verticalLayout_3">
Expand Down Expand Up @@ -1578,7 +1578,7 @@
<x>0</x>
<y>0</y>
<width>670</width>
<height>631</height>
<height>666</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_29">
Expand All @@ -1587,28 +1587,68 @@
<property name="title">
<string>Rendering behavior</string>
</property>
<layout class="QGridLayout" name="_4">
<item row="0" column="0">
<layout class="QVBoxLayout" name="verticalLayout_9">
<item>
<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="1" column="0" colspan="2">
<item>
<widget class="QCheckBox" name="chkUseRenderCaching">
<property name="text">
<string>Use render caching where possible to speed up redraws</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item>
<widget class="QCheckBox" name="chkParallelRendering">
<property name="text">
<string>Render layers in parallel using all available CPU cores</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QLabel" name="label_56">
<property name="text">
<string>Map update interval</string>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="spinMapUpdateInterval">
<property name="suffix">
<string> ms</string>
</property>
<property name="maximum">
<number>999999</number>
</property>
<property name="singleStep">
<number>50</number>
</property>
<property name="value">
<number>250</number>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_38">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout>
</widget>
</item>
Expand Down

0 comments on commit d3b5fb0

Please sign in to comment.