Skip to content

Commit d3b5fb0

Browse files
committed
User-configurable update interval
1 parent 90b10f7 commit d3b5fb0

File tree

6 files changed

+79
-7
lines changed

6 files changed

+79
-7
lines changed

python/gui/qgsmapcanvas.sip

+8
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,14 @@ class QgsMapCanvas : QGraphicsView
9191
//! @note added in 2.1
9292
bool isParallelRenderingEnabled() const;
9393

94+
//! Set how often map preview should be updated while it is being rendered (in miliseconds)
95+
//! @note added in 2.1
96+
void setMapUpdateInterval( int timeMiliseconds );
97+
98+
//! Find out how often map preview should be updated while it is being rendered (in miliseconds)
99+
//! @note added in 2.1
100+
int mapUpdateInterval() const;
101+
94102
//! @deprecated since 2.1 - there could be more than just one "map" items
95103
QgsMapCanvasMap* map();
96104

src/app/qgisapp.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -2073,6 +2073,8 @@ void QgisApp::createOverview()
20732073
mMapCanvas->setCachingEnabled( mySettings.value( "/qgis/enable_render_caching", false ).toBool() );
20742074

20752075
mMapCanvas->setParallelRenderingEnabled( mySettings.value( "/qgis/parallel_rendering", false).toBool() );
2076+
2077+
mMapCanvas->setMapUpdateInterval( mySettings.value( "/qgis/map_update_interval", 250 ).toInt() );
20762078
}
20772079

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

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

6612+
mMapCanvas->setMapUpdateInterval( mySettings.value( "/qgis/map_update_interval", 250 ).toInt() );
6613+
66106614
//do we need this? TS
66116615
mMapCanvas->refresh();
66126616

src/app/qgsoptions.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
499499
chkAntiAliasing->setChecked( settings.value( "/qgis/enable_anti_aliasing", true ).toBool() );
500500
chkUseRenderCaching->setChecked( settings.value( "/qgis/enable_render_caching", false ).toBool() );
501501
chkParallelRendering->setChecked( settings.value( "/qgis/parallel_rendering", false ).toBool() );
502+
spinMapUpdateInterval->setValue( settings.value( "/qgis/map_update_interval", 250 ).toInt() );
502503

503504
// Slightly awkard here at the settings value is true to use QImage,
504505
// but the checkbox is true to use QPixmap
@@ -934,6 +935,7 @@ void QgsOptions::saveOptions()
934935
settings.setValue( "/qgis/enable_anti_aliasing", chkAntiAliasing->isChecked() );
935936
settings.setValue( "/qgis/enable_render_caching", chkUseRenderCaching->isChecked() );
936937
settings.setValue( "/qgis/parallel_rendering", chkParallelRendering->isChecked() );
938+
settings.setValue( "/qgis/map_update_interval", spinMapUpdateInterval->value() );
937939
settings.setValue( "/qgis/legendDoubleClickAction", cmbLegendDoubleClickAction->currentIndex() );
938940
bool legendLayersCapitalise = settings.value( "/qgis/capitaliseLayerName", false ).toBool();
939941
settings.setValue( "/qgis/capitaliseLayerName", capitaliseCheckBox->isChecked() );

src/gui/qgsmapcanvas.cpp

+11-1
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ QgsMapCanvas::QgsMapCanvas( QWidget * parent, const char *name )
208208
moveCanvasContents( true );
209209

210210
connect(&mMapUpdateTimer, SIGNAL( timeout() ), SLOT( mapUpdateTimeout() ) );
211-
mMapUpdateTimer.setInterval( 400 );
211+
mMapUpdateTimer.setInterval( 250 );
212212

213213
#ifdef Q_OS_WIN
214214
// Enable touch event on Windows.
@@ -525,6 +525,16 @@ bool QgsMapCanvas::isParallelRenderingEnabled() const
525525
return mUseParallelRendering;
526526
}
527527

528+
void QgsMapCanvas::setMapUpdateInterval( int timeMiliseconds )
529+
{
530+
mMapUpdateTimer.setInterval( timeMiliseconds );
531+
}
532+
533+
int QgsMapCanvas::mapUpdateInterval() const
534+
{
535+
return mMapUpdateTimer.interval();
536+
}
537+
528538

529539
void QgsMapCanvas::updateOverview()
530540
{

src/gui/qgsmapcanvas.h

+8
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ class GUI_EXPORT QgsMapCanvas : public QGraphicsView
162162
//! @note added in 2.1
163163
bool isParallelRenderingEnabled() const;
164164

165+
//! Set how often map preview should be updated while it is being rendered (in miliseconds)
166+
//! @note added in 2.1
167+
void setMapUpdateInterval( int timeMiliseconds );
168+
169+
//! Find out how often map preview should be updated while it is being rendered (in miliseconds)
170+
//! @note added in 2.1
171+
int mapUpdateInterval() const;
172+
165173
//! @deprecated since 2.1 - there could be more than just one "map" items
166174
QgsMapCanvasMap* map();
167175

src/ui/qgsoptionsbase.ui

+46-6
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@
236236
<item>
237237
<widget class="QStackedWidget" name="mOptionsStackedWidget">
238238
<property name="currentIndex">
239-
<number>0</number>
239+
<number>3</number>
240240
</property>
241241
<widget class="QWidget" name="mOptionsPage_01">
242242
<layout class="QVBoxLayout" name="verticalLayout_3">
@@ -1578,7 +1578,7 @@
15781578
<x>0</x>
15791579
<y>0</y>
15801580
<width>670</width>
1581-
<height>631</height>
1581+
<height>666</height>
15821582
</rect>
15831583
</property>
15841584
<layout class="QVBoxLayout" name="verticalLayout_29">
@@ -1587,28 +1587,68 @@
15871587
<property name="title">
15881588
<string>Rendering behavior</string>
15891589
</property>
1590-
<layout class="QGridLayout" name="_4">
1591-
<item row="0" column="0">
1590+
<layout class="QVBoxLayout" name="verticalLayout_9">
1591+
<item>
15921592
<widget class="QCheckBox" name="chkAddedVisibility">
15931593
<property name="text">
15941594
<string>By default new la&amp;yers added to the map should be displayed</string>
15951595
</property>
15961596
</widget>
15971597
</item>
1598-
<item row="1" column="0" colspan="2">
1598+
<item>
15991599
<widget class="QCheckBox" name="chkUseRenderCaching">
16001600
<property name="text">
16011601
<string>Use render caching where possible to speed up redraws</string>
16021602
</property>
16031603
</widget>
16041604
</item>
1605-
<item row="2" column="0" colspan="2">
1605+
<item>
16061606
<widget class="QCheckBox" name="chkParallelRendering">
16071607
<property name="text">
16081608
<string>Render layers in parallel using all available CPU cores</string>
16091609
</property>
16101610
</widget>
16111611
</item>
1612+
<item>
1613+
<layout class="QHBoxLayout" name="horizontalLayout_4">
1614+
<item>
1615+
<widget class="QLabel" name="label_56">
1616+
<property name="text">
1617+
<string>Map update interval</string>
1618+
</property>
1619+
</widget>
1620+
</item>
1621+
<item>
1622+
<widget class="QSpinBox" name="spinMapUpdateInterval">
1623+
<property name="suffix">
1624+
<string> ms</string>
1625+
</property>
1626+
<property name="maximum">
1627+
<number>999999</number>
1628+
</property>
1629+
<property name="singleStep">
1630+
<number>50</number>
1631+
</property>
1632+
<property name="value">
1633+
<number>250</number>
1634+
</property>
1635+
</widget>
1636+
</item>
1637+
<item>
1638+
<spacer name="horizontalSpacer_38">
1639+
<property name="orientation">
1640+
<enum>Qt::Horizontal</enum>
1641+
</property>
1642+
<property name="sizeHint" stdset="0">
1643+
<size>
1644+
<width>40</width>
1645+
<height>20</height>
1646+
</size>
1647+
</property>
1648+
</spacer>
1649+
</item>
1650+
</layout>
1651+
</item>
16121652
</layout>
16131653
</widget>
16141654
</item>

0 commit comments

Comments
 (0)