Skip to content

Commit 200c44e

Browse files
committedNov 22, 2011
Merge branch 'master' of github.com:qgis/Quantum-GIS
2 parents 6191319 + 376adc4 commit 200c44e

15 files changed

+1454
-186
lines changed
 

‎src/app/main.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -474,13 +474,17 @@ int main( int argc, char *argv[] )
474474
}
475475
#endif
476476

477-
#ifdef Q_WS_WIN
478-
//for windows lets use plastique style!
479-
QApplication::setStyle( new QPlastiqueStyle );
480-
#endif
481-
482477
QSettings mySettings;
483478

479+
// Set the application style. If it's not set QT will use the platform style except on Windows
480+
// as it looks really ugly so we use QPlastiqueStyle.
481+
QString style = mySettings.value("/qgis/style").toString();
482+
if ( !style.isNull() )
483+
QApplication::setStyle( style );
484+
#ifdef Q_WS_WIN
485+
else
486+
QApplication::setStyle( new QPlastiqueStyle );
487+
#endif
484488

485489
/* Translation file for QGIS.
486490
*/

‎src/app/qgsoptions.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <QLocale>
3131
#include <QToolBar>
3232
#include <QSize>
33+
#include <QStyleFactory>
3334

3435
#if QT_VERSION >= 0x40500
3536
#include <QNetworkDiskCache>
@@ -58,12 +59,19 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
5859
connect( cmbSize, SIGNAL( activated( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
5960
connect( cmbSize, SIGNAL( highlighted( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
6061
connect( cmbSize, SIGNAL( textChanged( const QString& ) ), this, SLOT( iconSizeChanged( const QString& ) ) );
62+
6163
connect( this, SIGNAL( accepted() ), this, SLOT( saveOptions() ) );
6264

6365
cmbSize->addItem( "16" );
6466
cmbSize->addItem( "24" );
6567
cmbSize->addItem( "32" );
6668

69+
QStringList styles = QStyleFactory::keys();
70+
foreach(QString style, styles )
71+
{
72+
cmbStyle->addItem( style );
73+
}
74+
6775
cmbIdentifyMode->addItem( tr( "Current layer" ), 0 );
6876
cmbIdentifyMode->addItem( tr( "Top down, stop at first" ), 1 );
6977
cmbIdentifyMode->addItem( tr( "Top down" ), 2 );
@@ -270,6 +278,8 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WFlags fl ) :
270278
// set the theme combo
271279
cmbTheme->setCurrentIndex( cmbTheme->findText( settings.value( "/Themes", "default" ).toString() ) );
272280
cmbSize->setCurrentIndex( cmbSize->findText( settings.value( "/IconSize", 24 ).toString() ) );
281+
QString name = QApplication::style()->objectName();
282+
cmbStyle->setCurrentIndex( cmbStyle->findText( name, Qt::MatchFixedString ) );
273283
//set the state of the checkboxes
274284
//Changed to default to true as of QGIS 1.7
275285
chkAntiAliasing->setChecked( settings.value( "/qgis/enable_anti_aliasing", true ).toBool() );
@@ -589,6 +599,7 @@ void QgsOptions::saveOptions()
589599
settings.setValue( "/qgis/askToSaveProjectChanges", chbAskToSaveProjectChanges->isChecked() );
590600
settings.setValue( "/qgis/warnOldProjectVersion", chbWarnOldProjectVersion->isChecked() );
591601
settings.setValue( "/qgis/nullValue", leNullValue->text() );
602+
settings.setValue( "/qgis/style", cmbStyle->currentText() );
592603

593604
//overlay placement method
594605
int overlayIndex = mOverlayAlgorithmComboBox->currentIndex();

‎src/core/symbology-ng/qgspointdisplacementrenderer.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
#include "qgspointdisplacementrenderer.h"
1919
#include "qgsgeometry.h"
2020
#include "qgslogger.h"
21-
#include "qgsrendererv2registry.h"
2221
#include "qgsspatialindex.h"
2322
#include "qgssymbolv2.h"
2423
#include "qgssymbollayerv2utils.h"
@@ -276,12 +275,7 @@ QgsFeatureRendererV2* QgsPointDisplacementRenderer::create( QDomElement& symbolo
276275
QDomElement embeddedRendererElem = symbologyElem.firstChildElement( "renderer-v2" );
277276
if ( !embeddedRendererElem.isNull() )
278277
{
279-
QString rendererName = embeddedRendererElem.attribute( "type" );
280-
QgsRendererV2AbstractMetadata* metaData = QgsRendererV2Registry::instance()->rendererMetadata( rendererName );
281-
if ( metaData )
282-
{
283-
r->setEmbeddedRenderer( metaData->createRenderer( embeddedRendererElem ) );
284-
}
278+
r->setEmbeddedRenderer( QgsFeatureRendererV2::load( embeddedRendererElem ) );
285279
}
286280

287281
//center symbol

‎src/gui/qgsprojectionselector.cpp

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,25 @@ QgsProjectionSelector::QgsProjectionSelector( QWidget* parent, const char *name,
5252
lstCoordinateSystems->header()->setResizeMode( AUTHID_COLUMN, QHeaderView::Stretch );
5353
lstCoordinateSystems->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
5454
lstCoordinateSystems->header()->setResizeMode( QGIS_CRS_ID_COLUMN, QHeaderView::Fixed );
55+
// Hide (internal) ID column
56+
lstCoordinateSystems->setColumnHidden(QGIS_CRS_ID_COLUMN, true);
5557

5658
lstRecent->header()->setResizeMode( AUTHID_COLUMN, QHeaderView::Stretch );
5759
lstRecent->header()->resizeSection( QGIS_CRS_ID_COLUMN, 0 );
5860
lstRecent->header()->setResizeMode( QGIS_CRS_ID_COLUMN, QHeaderView::Fixed );
61+
// Hide (internal) ID column
62+
lstRecent->setColumnHidden(QGIS_CRS_ID_COLUMN, true);
5963

6064
cbxAuthority->addItem( tr( "All" ) );
6165
cbxAuthority->addItems( authorities() );
6266

67+
// TEMP? hide buttons, we now implemented filter
68+
cbxAuthority->hide();
69+
cbxMode->hide();
70+
label->hide();
71+
label_2->hide();
72+
pbnFind->hide();
73+
6374
// Read settings from persistent storage
6475
QSettings settings;
6576
mRecentProjections = settings.value( "/UI/recentProjections" ).toStringList();
@@ -189,7 +200,6 @@ QString QgsProjectionSelector::ogcWmsCrsFilterAsSqlExpression( QSet<QString> * c
189200
{
190201
return sqlExpression;
191202
}
192-
193203
/*
194204
Ref: WMS 1.3.0, section 6.7.3 "Layer CRS":
195205
@@ -794,7 +804,8 @@ void QgsProjectionSelector::loadCrsList( QSet<QString> *crsFilter )
794804
newItem->setText( AUTHID_COLUMN, QString::fromUtf8(( char * )sqlite3_column_text( ppStmt, 2 ) ) );
795805
// display the qgis srs_id (field 1) in the third column of the list view
796806
newItem->setText( QGIS_CRS_ID_COLUMN, QString::fromUtf8(( char * )sqlite3_column_text( ppStmt, 1 ) ) );
797-
807+
// expand also parent node
808+
newItem->parent()->setExpanded(true);
798809
}
799810

800811
// display the qgis deprecated in the user data of the item
@@ -982,6 +993,65 @@ void QgsProjectionSelector::on_pbnFind_clicked()
982993
teProjection->setText( "" );
983994
}
984995

996+
void QgsProjectionSelector::on_leSearch_textChanged( const QString & theFilterTxt)
997+
{
998+
// filter recent crs's
999+
QTreeWidgetItemIterator itr(lstRecent);
1000+
while (*itr) {
1001+
if ( (*itr)->childCount() == 0 ) // it's an end node aka a projection
1002+
{
1003+
if ( (*itr)->text( NAME_COLUMN ).contains( theFilterTxt, Qt::CaseInsensitive )
1004+
|| (*itr)->text( AUTHID_COLUMN ).contains( theFilterTxt, Qt::CaseInsensitive )
1005+
)
1006+
{
1007+
(*itr)->setHidden(false);
1008+
QTreeWidgetItem * parent = (*itr)->parent();
1009+
while (parent != NULL)
1010+
{
1011+
parent->setExpanded(true);
1012+
parent->setHidden(false);
1013+
parent = parent->parent();
1014+
}
1015+
}
1016+
else{
1017+
(*itr)->setHidden(true);
1018+
}
1019+
}
1020+
else{
1021+
(*itr)->setHidden(true);
1022+
}
1023+
++itr;
1024+
}
1025+
// filter crs's
1026+
QTreeWidgetItemIterator it(lstCoordinateSystems);
1027+
while (*it) {
1028+
if ( (*it)->childCount() == 0 ) // it's an end node aka a projection
1029+
{
1030+
if ( (*it)->text( NAME_COLUMN ).contains( theFilterTxt, Qt::CaseInsensitive )
1031+
|| (*it)->text( AUTHID_COLUMN ).contains( theFilterTxt, Qt::CaseInsensitive )
1032+
)
1033+
{
1034+
(*it)->setHidden(false);
1035+
QTreeWidgetItem * parent = (*it)->parent();
1036+
while (parent != NULL)
1037+
{
1038+
parent->setExpanded(true);
1039+
parent->setHidden(false);
1040+
parent = parent->parent();
1041+
}
1042+
}
1043+
else{
1044+
(*it)->setHidden(true);
1045+
}
1046+
}
1047+
else{
1048+
(*it)->setHidden(true);
1049+
}
1050+
++it;
1051+
}
1052+
}
1053+
1054+
9851055
long QgsProjectionSelector::getLargestCRSIDMatch( QString theSql )
9861056
{
9871057
long mySrsId = 0;
@@ -1094,7 +1164,7 @@ QStringList QgsProjectionSelector::authorities()
10941164
return authorities;
10951165
}
10961166

1097-
/*!
1167+
/*!linfinity qtcreator qgis
10981168
* \brief Make the string safe for use in SQL statements.
10991169
* This involves escaping single quotes, double quotes, backslashes,
11001170
* and optionally, percentage symbols. Percentage symbols are used

‎src/gui/qgsprojectionselector.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class GUI_EXPORT QgsProjectionSelector: public QWidget, private Ui::QgsProjectio
117117
void on_pbnFind_clicked();
118118
void on_lstRecent_currentItemChanged( QTreeWidgetItem *, QTreeWidgetItem * );
119119
void on_cbxHideDeprecated_stateChanged();
120+
void on_leSearch_textChanged(const QString &);
120121

121122
protected:
122123
/** Used to ensure the projection list view is actually populated */

‎src/plugins/roadgraph/linevectorlayerwidget.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ RgLineVectorLayerSettingsWidget::RgLineVectorLayerSettingsWidget( RgLineVectorLa
132132
QgsVectorLayer* vl = dynamic_cast<QgsVectorLayer*>( layer_it.value() );
133133
if ( !vl )
134134
continue;
135-
// if ( vl->geometryType() != QGis::Line )
136-
// continue;
135+
if ( vl->geometryType() != QGis::Line )
136+
continue;
137137
mcbLayers->insertItem( 0, vl->name() );
138138
}
139139

‎src/providers/ogr/qgsogrprovider.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,14 @@ QgsOgrProvider::QgsOgrProvider( QString const & uri )
294294
}
295295

296296
ogrLayer = ogrOrigLayer;
297-
setSubsetString( mSubsetString );
297+
if (ogrLayer != NULL )
298+
{
299+
setSubsetString( mSubsetString );
300+
}
301+
else
302+
{
303+
valid = false;
304+
}
298305
}
299306
else
300307
{

‎src/ui/qgsoptionsbase.ui

Lines changed: 74 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,6 @@
127127
</property>
128128
</widget>
129129
</item>
130-
<item row="1" column="2">
131-
<spacer>
132-
<property name="orientation">
133-
<enum>Qt::Horizontal</enum>
134-
</property>
135-
<property name="sizeHint" stdset="0">
136-
<size>
137-
<width>40</width>
138-
<height>20</height>
139-
</size>
140-
</property>
141-
</spacer>
142-
</item>
143130
<item row="1" column="3">
144131
<widget class="QgsColorButton" name="pbnCanvasColor">
145132
<property name="minimumSize">
@@ -153,7 +140,20 @@
153140
</property>
154141
</widget>
155142
</item>
156-
<item row="0" column="2">
143+
<item row="0" column="4">
144+
<spacer>
145+
<property name="orientation">
146+
<enum>Qt::Horizontal</enum>
147+
</property>
148+
<property name="sizeHint" stdset="0">
149+
<size>
150+
<width>40</width>
151+
<height>20</height>
152+
</size>
153+
</property>
154+
</spacer>
155+
</item>
156+
<item row="1" column="4">
157157
<spacer>
158158
<property name="orientation">
159159
<enum>Qt::Horizontal</enum>
@@ -176,22 +176,22 @@
176176
</property>
177177
<layout class="QVBoxLayout" name="verticalLayout_2">
178178
<item>
179-
<layout class="QHBoxLayout" name="horizontalLayout_3">
179+
<layout class="QHBoxLayout" name="horizontalLayout_9">
180+
<property name="topMargin">
181+
<number>0</number>
182+
</property>
180183
<item>
181-
<widget class="QLabel" name="textLabel1_4">
182-
<property name="sizePolicy">
183-
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
184-
<horstretch>0</horstretch>
185-
<verstretch>0</verstretch>
186-
</sizepolicy>
187-
</property>
184+
<widget class="QLabel" name="label_18">
188185
<property name="text">
189-
<string>Icon theme</string>
186+
<string>Style &lt;i&gt;(QGIS restart required)&lt;/i&gt;</string>
190187
</property>
191188
</widget>
192189
</item>
193190
<item>
194-
<spacer name="horizontalSpacer_2">
191+
<widget class="QComboBox" name="cmbStyle"/>
192+
</item>
193+
<item>
194+
<spacer name="horizontalSpacer_7">
195195
<property name="orientation">
196196
<enum>Qt::Horizontal</enum>
197197
</property>
@@ -203,6 +203,23 @@
203203
</property>
204204
</spacer>
205205
</item>
206+
</layout>
207+
</item>
208+
<item>
209+
<layout class="QHBoxLayout" name="horizontalLayout_3">
210+
<item>
211+
<widget class="QLabel" name="textLabel1_4">
212+
<property name="sizePolicy">
213+
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
214+
<horstretch>0</horstretch>
215+
<verstretch>0</verstretch>
216+
</sizepolicy>
217+
</property>
218+
<property name="text">
219+
<string>Icon theme</string>
220+
</property>
221+
</widget>
222+
</item>
206223
<item>
207224
<widget class="QComboBox" name="cmbTheme">
208225
<property name="duplicatesEnabled">
@@ -215,6 +232,19 @@
215232
</item>
216233
</widget>
217234
</item>
235+
<item>
236+
<spacer name="horizontalSpacer_2">
237+
<property name="orientation">
238+
<enum>Qt::Horizontal</enum>
239+
</property>
240+
<property name="sizeHint" stdset="0">
241+
<size>
242+
<width>40</width>
243+
<height>20</height>
244+
</size>
245+
</property>
246+
</spacer>
247+
</item>
218248
</layout>
219249
</item>
220250
<item>
@@ -232,6 +262,13 @@
232262
</property>
233263
</widget>
234264
</item>
265+
<item>
266+
<widget class="QComboBox" name="cmbSize">
267+
<property name="duplicatesEnabled">
268+
<bool>false</bool>
269+
</property>
270+
</widget>
271+
</item>
235272
<item>
236273
<spacer name="horizontalSpacer_5">
237274
<property name="orientation">
@@ -245,13 +282,6 @@
245282
</property>
246283
</spacer>
247284
</item>
248-
<item>
249-
<widget class="QComboBox" name="cmbSize">
250-
<property name="duplicatesEnabled">
251-
<bool>false</bool>
252-
</property>
253-
</widget>
254-
</item>
255285
</layout>
256286
</item>
257287
<item>
@@ -263,19 +293,6 @@
263293
</property>
264294
</widget>
265295
</item>
266-
<item>
267-
<spacer name="horizontalSpacer_6">
268-
<property name="orientation">
269-
<enum>Qt::Horizontal</enum>
270-
</property>
271-
<property name="sizeHint" stdset="0">
272-
<size>
273-
<width>40</width>
274-
<height>20</height>
275-
</size>
276-
</property>
277-
</spacer>
278-
</item>
279296
<item>
280297
<widget class="QComboBox" name="cmbLegendDoubleClickAction">
281298
<item>
@@ -290,6 +307,19 @@
290307
</item>
291308
</widget>
292309
</item>
310+
<item>
311+
<spacer name="horizontalSpacer_6">
312+
<property name="orientation">
313+
<enum>Qt::Horizontal</enum>
314+
</property>
315+
<property name="sizeHint" stdset="0">
316+
<size>
317+
<width>40</width>
318+
<height>20</height>
319+
</size>
320+
</property>
321+
</spacer>
322+
</item>
293323
</layout>
294324
</item>
295325
<item>

‎src/ui/qgsprojectionselectorbase.ui

Lines changed: 149 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>590</width>
10-
<height>358</height>
9+
<width>574</width>
10+
<height>389</height>
1111
</rect>
1212
</property>
1313
<property name="sizePolicy">
@@ -31,69 +31,7 @@
3131
<property name="margin">
3232
<number>3</number>
3333
</property>
34-
<item row="1" column="0">
35-
<widget class="QTextEdit" name="teProjection">
36-
<property name="sizePolicy">
37-
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
38-
<horstretch>0</horstretch>
39-
<verstretch>0</verstretch>
40-
</sizepolicy>
41-
</property>
42-
<property name="minimumSize">
43-
<size>
44-
<width>0</width>
45-
<height>30</height>
46-
</size>
47-
</property>
48-
<property name="maximumSize">
49-
<size>
50-
<width>16777215</width>
51-
<height>50</height>
52-
</size>
53-
</property>
54-
<property name="baseSize">
55-
<size>
56-
<width>0</width>
57-
<height>50</height>
58-
</size>
59-
</property>
60-
<property name="autoFormatting">
61-
<set>QTextEdit::AutoBulletList</set>
62-
</property>
63-
<property name="readOnly">
64-
<bool>true</bool>
65-
</property>
66-
</widget>
67-
</item>
6834
<item row="0" column="0">
69-
<widget class="QTreeWidget" name="lstCoordinateSystems">
70-
<property name="alternatingRowColors">
71-
<bool>true</bool>
72-
</property>
73-
<property name="uniformRowHeights">
74-
<bool>true</bool>
75-
</property>
76-
<property name="columnCount">
77-
<number>3</number>
78-
</property>
79-
<column>
80-
<property name="text">
81-
<string>Coordinate Reference System</string>
82-
</property>
83-
</column>
84-
<column>
85-
<property name="text">
86-
<string>Authority ID</string>
87-
</property>
88-
</column>
89-
<column>
90-
<property name="text">
91-
<string>ID</string>
92-
</property>
93-
</column>
94-
</widget>
95-
</item>
96-
<item row="2" column="0">
9735
<widget class="QGroupBox" name="groupBox">
9836
<property name="sizePolicy">
9937
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
@@ -102,64 +40,9 @@
10240
</sizepolicy>
10341
</property>
10442
<property name="title">
105-
<string>Search</string>
43+
<string>Filter</string>
10644
</property>
10745
<layout class="QVBoxLayout" name="verticalLayout">
108-
<item>
109-
<layout class="QHBoxLayout" name="horizontalLayout_2">
110-
<item>
111-
<widget class="QLabel" name="label">
112-
<property name="text">
113-
<string>Authority</string>
114-
</property>
115-
</widget>
116-
</item>
117-
<item>
118-
<widget class="QComboBox" name="cbxAuthority"/>
119-
</item>
120-
<item>
121-
<widget class="QLabel" name="label_2">
122-
<property name="text">
123-
<string>Search for</string>
124-
</property>
125-
</widget>
126-
</item>
127-
<item>
128-
<widget class="QComboBox" name="cbxMode">
129-
<item>
130-
<property name="text">
131-
<string>ID</string>
132-
</property>
133-
</item>
134-
<item>
135-
<property name="text">
136-
<string>Name</string>
137-
</property>
138-
</item>
139-
</widget>
140-
</item>
141-
<item>
142-
<spacer name="horizontalSpacer">
143-
<property name="orientation">
144-
<enum>Qt::Horizontal</enum>
145-
</property>
146-
<property name="sizeHint" stdset="0">
147-
<size>
148-
<width>40</width>
149-
<height>20</height>
150-
</size>
151-
</property>
152-
</spacer>
153-
</item>
154-
<item>
155-
<widget class="QCheckBox" name="cbxHideDeprecated">
156-
<property name="text">
157-
<string>Hide deprecated CRSs</string>
158-
</property>
159-
</widget>
160-
</item>
161-
</layout>
162-
</item>
16346
<item>
16447
<layout class="QHBoxLayout" name="horizontalLayout">
16548
<item>
@@ -196,7 +79,7 @@
19679
<item row="4" column="0">
19780
<widget class="QTreeWidget" name="lstRecent">
19881
<property name="sizePolicy">
199-
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
82+
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
20083
<horstretch>0</horstretch>
20184
<verstretch>0</verstretch>
20285
</sizepolicy>
@@ -210,7 +93,7 @@
21093
<property name="maximumSize">
21194
<size>
21295
<width>16777215</width>
213-
<height>105</height>
96+
<height>200</height>
21497
</size>
21598
</property>
21699
<property name="alternatingRowColors">
@@ -242,6 +125,150 @@
242125
</column>
243126
</widget>
244127
</item>
128+
<item row="7" column="0" rowspan="5">
129+
<layout class="QHBoxLayout" name="horizontalLayout_3">
130+
<property name="topMargin">
131+
<number>15</number>
132+
</property>
133+
<item>
134+
<widget class="QLabel" name="label_4">
135+
<property name="text">
136+
<string>Coordinate reference systems of the world</string>
137+
</property>
138+
</widget>
139+
</item>
140+
<item>
141+
<spacer name="horizontalSpacer_2">
142+
<property name="orientation">
143+
<enum>Qt::Horizontal</enum>
144+
</property>
145+
<property name="sizeHint" stdset="0">
146+
<size>
147+
<width>40</width>
148+
<height>20</height>
149+
</size>
150+
</property>
151+
</spacer>
152+
</item>
153+
<item>
154+
<widget class="QCheckBox" name="cbxHideDeprecated">
155+
<property name="text">
156+
<string>Hide deprecated CRSs</string>
157+
</property>
158+
</widget>
159+
</item>
160+
</layout>
161+
</item>
162+
<item row="15" column="0">
163+
<widget class="QTreeWidget" name="lstCoordinateSystems">
164+
<property name="alternatingRowColors">
165+
<bool>true</bool>
166+
</property>
167+
<property name="uniformRowHeights">
168+
<bool>true</bool>
169+
</property>
170+
<property name="columnCount">
171+
<number>3</number>
172+
</property>
173+
<column>
174+
<property name="text">
175+
<string>Coordinate Reference System</string>
176+
</property>
177+
</column>
178+
<column>
179+
<property name="text">
180+
<string>Authority ID</string>
181+
</property>
182+
</column>
183+
<column>
184+
<property name="text">
185+
<string>ID</string>
186+
</property>
187+
</column>
188+
</widget>
189+
</item>
190+
<item row="19" column="0">
191+
<widget class="QTextEdit" name="teProjection">
192+
<property name="sizePolicy">
193+
<sizepolicy hsizetype="Expanding" vsizetype="Minimum">
194+
<horstretch>0</horstretch>
195+
<verstretch>0</verstretch>
196+
</sizepolicy>
197+
</property>
198+
<property name="minimumSize">
199+
<size>
200+
<width>0</width>
201+
<height>30</height>
202+
</size>
203+
</property>
204+
<property name="maximumSize">
205+
<size>
206+
<width>16777215</width>
207+
<height>50</height>
208+
</size>
209+
</property>
210+
<property name="baseSize">
211+
<size>
212+
<width>0</width>
213+
<height>50</height>
214+
</size>
215+
</property>
216+
<property name="autoFormatting">
217+
<set>QTextEdit::AutoBulletList</set>
218+
</property>
219+
<property name="readOnly">
220+
<bool>true</bool>
221+
</property>
222+
</widget>
223+
</item>
224+
<item row="16" column="0">
225+
<layout class="QHBoxLayout" name="horizontalLayout_2">
226+
<item>
227+
<widget class="QLabel" name="label">
228+
<property name="text">
229+
<string>Authority</string>
230+
</property>
231+
</widget>
232+
</item>
233+
<item>
234+
<widget class="QComboBox" name="cbxAuthority"/>
235+
</item>
236+
<item>
237+
<widget class="QLabel" name="label_2">
238+
<property name="text">
239+
<string>Search for</string>
240+
</property>
241+
</widget>
242+
</item>
243+
<item>
244+
<widget class="QComboBox" name="cbxMode">
245+
<item>
246+
<property name="text">
247+
<string>ID</string>
248+
</property>
249+
</item>
250+
<item>
251+
<property name="text">
252+
<string>Name</string>
253+
</property>
254+
</item>
255+
</widget>
256+
</item>
257+
<item>
258+
<spacer name="horizontalSpacer">
259+
<property name="orientation">
260+
<enum>Qt::Horizontal</enum>
261+
</property>
262+
<property name="sizeHint" stdset="0">
263+
<size>
264+
<width>40</width>
265+
<height>20</height>
266+
</size>
267+
</property>
268+
</spacer>
269+
</item>
270+
</layout>
271+
</item>
245272
</layout>
246273
</widget>
247274
<layoutdefault spacing="6" margin="11"/>
@@ -250,10 +277,8 @@
250277
<tabstop>teProjection</tabstop>
251278
<tabstop>cbxAuthority</tabstop>
252279
<tabstop>cbxMode</tabstop>
253-
<tabstop>cbxHideDeprecated</tabstop>
254280
<tabstop>leSearch</tabstop>
255281
<tabstop>pbnFind</tabstop>
256-
<tabstop>lstRecent</tabstop>
257282
</tabstops>
258283
<resources/>
259284
<connections/>

‎tests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
IF (ENABLE_TESTS)
22
ADD_SUBDIRECTORY(src)
3+
ADD_SUBDIRECTORY(bench)
34
ENDIF (ENABLE_TESTS)

‎tests/bench/CMakeLists.txt

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
########################################################
2+
# Files
3+
4+
SET (BENCH_SRCS
5+
main.cpp
6+
qgsbench.cpp
7+
)
8+
9+
SET (BENCH_MOC_HDRS
10+
qgsbench.h
11+
)
12+
13+
########################################################
14+
# Build
15+
16+
QT4_WRAP_CPP (BENCH_MOC_SRCS ${BENCH_MOC_HDRS})
17+
18+
ADD_EXECUTABLE (qgis_bench MACOSX_BUNDLE WIN32 ${BENCH_SRCS} ${BENCH_MOC_SRCS} )
19+
20+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
21+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/core
22+
${CMAKE_CURRENT_SOURCE_DIR}/../../src/core/raster
23+
${CMAKE_CURRENT_BINARY_DIR}
24+
# ${GDAL_INCLUDE_DIR} # remove once raster layer is cleaned up
25+
)
26+
27+
IF (WITH_INTERNAL_SPATIALITE)
28+
INCLUDE_DIRECTORIES(../../src/core/spatialite/headers/spatialite)
29+
ELSE (WITH_INTERNAL_SPATIALITE)
30+
INCLUDE_DIRECTORIES(${SQLITE3_INCLUDE_DIR})
31+
ENDIF (WITH_INTERNAL_SPATIALITE)
32+
33+
TARGET_LINK_LIBRARIES(qgis_bench qgis_core)
34+
35+
IF (NOT WITH_INTERNAL_SPATIALITE)
36+
TARGET_LINK_LIBRARIES(qgis_bench ${SQLITE3_LIBRARY})
37+
ENDIF (NOT WITH_INTERNAL_SPATIALITE)
38+
39+
TARGET_LINK_LIBRARIES(qgis_bench
40+
${QT_QTCORE_LIBRARY}
41+
${QT_QTNETWORK_LIBRARY}
42+
${QT_QTSVG_LIBRARY}
43+
${QT_QTXML_LIBRARY}
44+
${QT_QTWEBKIT_LIBRARY}
45+
${QT_QTMAIN_LIBRARY}
46+
${QT_QTTEST_LIBRARY}
47+
)
48+
49+
SET_TARGET_PROPERTIES(qgis_bench PROPERTIES
50+
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/${QGIS_LIB_DIR}
51+
INSTALL_RPATH_USE_LINK_PATH true
52+
)
53+
54+
########################################################
55+
# Install
56+
57+
INSTALL (TARGETS qgis_bench
58+
BUNDLE DESTINATION ${QGIS_BIN_DIR}
59+
RUNTIME DESTINATION ${QGIS_BIN_DIR}
60+
)
61+
IF (APPLE)
62+
INSTALL (CODE "EXECUTE_PROCESS(COMMAND ln -sfh ../../../${QGIS_FW_SUBDIR} \"$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/${QGIS_BIN_DIR}/qgis_bench.app/Contents/Frameworks\")")
63+
ENDIF (APPLE)
64+

‎tests/bench/README

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
Time measurement
2+
------------------
3+
4+
For usable benchmarking we need a precise, reliable and repeatable time measurement. It seems to be easy? We are on computer right? Unfortunetly I found it almost impossible! Hopefully I am totaly wrong.
5+
6+
Several "kind of time" exist: real (wall clock), user CPU time, system CPU time. What I believe we have to use is task user + system CPU time.
7+
8+
There are varions commands/functions which can be used to measure time, e.g.:
9+
10+
1) time command (real, user, sys time):
11+
12+
time COMMAND
13+
14+
2) getrusage function (user, sys time):
15+
16+
#include <sys/time.h>
17+
#include <sys/resource.h>
18+
struct rusage usage;
19+
getrusage( RUSAGE_SELF, &start);
20+
// measured code
21+
getrusage( RUSAGE_SELF, &end);
22+
double user_elapsed = end.ru_utime.tv_sec + end.ru_utime.tv_usec/1000000. - start.ru_utime.tv_sec - start.ru_utime.tv_usec/1000000.;
23+
double sys_elapsed = end.ru_stime.tv_sec + end.rs_utime.tv_usec/1000000. - start.ru_stime.tv_sec -start.ru_stime.tv_usec/1000000.;
24+
25+
26+
3) times function (user, sys time):
27+
28+
#include <sys/times.h>
29+
struct tms start, end;
30+
times(&start);
31+
// measured code
32+
times(&end);
33+
double user_elapsed = ((double)(end.tms_utime - start.tms_utime))/sysconf(_SC_CLK_TCK);
34+
double sys_elapsed = ((double)(end.tms_stime - start.tms_stime))/sysconf(_SC_CLK_TCK);
35+
36+
4) clock function (user + sys time ?):
37+
38+
#include <time.h>
39+
clock_t start = clock();
40+
// measured code
41+
clock_t end = clock();
42+
double elapsed = ((double) (end - start)) / CLOCKS_PER_SEC;
43+
44+
5) clock_gettime functions (user + sys time ?):
45+
46+
#include <time.h>
47+
struct timespec start, end;
48+
clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &start );
49+
// measured code
50+
clock_gettime( CLOCK_PROCESS_CPUTIME_ID, &end );
51+
double elapsed = end.tv_sec + end.tv_nsec / 1000000000. - start.tv_sec - start.tv_nsec / 1000000000.;
52+
53+
6) QTime class (QElapsedTimer Qt >= 4.7) (real time):
54+
55+
QTime time;
56+
time.start();
57+
// measured code
58+
double elapsed = time.elapsed() / 1000.;
59+
60+
I tried all of them and all are giving the same mostly useless values. If the same piece of code is measured more times, the results differ. It seems that all those functions read user time from the same place, kernel task_struct.utime. The problem is, if I understand correctly, how the task_struct.utime is updated. Whenever timer interrupt comes (every 1/HZ) to scheduler, it calls update_process_times->account_process_tick->irqtime_account_process_tick->account_user_time and increases task_struct.utime by cputime_one_jiffy (1/HZ). See kernel/sched.c and kernel/timer.c. It means, that utime is not increased by pure time when the the task code is running, but by fixed interval which includes some task switching overhead??? In a simple test, I could observe 30% increas of utime if another application was running at the same time.
61+
62+
Unfortunately I don't see anything better than user time + sys time, running test with highest priority and avoiding other use of computer when tests are running, e.g.:
63+
64+
sudo chrt -f 99 COMMAND
65+
66+
To be sure that the measured values are correct, it is necessary to run more cycles and check some standard deviation or so.
67+
68+
There is also high level benchmark support available in QTestLib, it is possible to use QBENCHMARK macro + QTEST_MAIN to create easily test executable. Such test may be run with various options, some notes on modes/options:
69+
70+
-tickcounter - reads rdtsc register (on Linux), thus it counts real time, result is not constant
71+
72+
-callgrind - reruns the command with callgrind, number of 'instr. loads' is constant for constant number of iterations, number of instructions per iterarion decreases with number of iterarions (for small numbers of iterations) for a simple function the number of instractions of the second iteration may be 40% of the first one - cache, prediction??? Callgrind is realy very slow. I am not sure what 'instr. loads' exactly means and if it can be somehow converted to time, but I don't believe so. AFAIK each instruction need a different number of cycles and it may be different even for the same instruction because of CPU cache, then there are instruction pipelines etc.
73+
74+
75+
Build options
76+
-------------
77+
78+
CMAKE_BUILD_TYPE should be RelWithDebInfo so that it compiles with optimisations but also adds debug information so that it can be profiled with callgrind and visualized with kcachegrind.

‎tests/bench/main.cpp

Lines changed: 550 additions & 0 deletions
Large diffs are not rendered by default.

‎tests/bench/qgsbench.cpp

Lines changed: 339 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,339 @@
1+
/***************************************************************************
2+
qgsbench.cpp - Benchmark
3+
-------------------
4+
begin : 2011-11-15
5+
copyright : (C) 2011 Radim Blazek
6+
email : radim dot blazek at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
#include <QtGlobal>
18+
19+
#include <cmath>
20+
#include <ctime>
21+
#include <iostream>
22+
#include <stdio.h>
23+
#ifndef Q_OS_WIN
24+
#include <sys/resource.h>
25+
#endif
26+
#include <time.h>
27+
#include <math.h>
28+
29+
#include <QFile>
30+
#include <QFileInfo>
31+
#include <QPainter>
32+
#include <QSettings>
33+
#include <QString>
34+
#include <QTextStream>
35+
#include <QTime>
36+
37+
#include "qgsbench.h"
38+
#include "qgslogger.h"
39+
#include "qgsmaplayerregistry.h"
40+
#include "qgsproject.h"
41+
42+
#ifdef Q_OS_WIN
43+
// slightly adapted from http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/port/getrusage.c?rev=1.18;content-type=text%2Fplain
44+
45+
#include <winsock2.h>
46+
#include <errno.h>
47+
48+
#define RUSAGE_SELF 0
49+
50+
struct rusage
51+
{
52+
struct timeval ru_utime; /* user time used */
53+
struct timeval ru_stime; /* system time used */
54+
};
55+
56+
/*-------------------------------------------------------------------------
57+
*
58+
* getrusage.c
59+
* get information about resource utilisation
60+
*
61+
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
62+
* Portions Copyright (c) 1994, Regents of the University of California
63+
*
64+
*
65+
* IDENTIFICATION
66+
* $PostgreSQL: pgsql/src/port/getrusage.c,v 1.18 2010-01-02 16:58:13 momjian Exp $
67+
*
68+
*-------------------------------------------------------------------------
69+
*/
70+
71+
72+
int getrusage( int who, struct rusage * rusage )
73+
{
74+
FILETIME starttime;
75+
FILETIME exittime;
76+
FILETIME kerneltime;
77+
FILETIME usertime;
78+
ULARGE_INTEGER li;
79+
80+
if ( who != RUSAGE_SELF )
81+
{
82+
/* Only RUSAGE_SELF is supported in this implementation for now */
83+
errno = EINVAL;
84+
return -1;
85+
}
86+
87+
if ( rusage == ( struct rusage * ) NULL )
88+
{
89+
errno = EFAULT;
90+
return -1;
91+
}
92+
memset( rusage, 0, sizeof( struct rusage ) );
93+
if ( GetProcessTimes( GetCurrentProcess(),
94+
&starttime, &exittime, &kerneltime, &usertime ) == 0 )
95+
{
96+
// _dosmaperr(GetLastError());
97+
return -1;
98+
}
99+
100+
/* Convert FILETIMEs (0.1 us) to struct timeval */
101+
memcpy( &li, &kerneltime, sizeof( FILETIME ) );
102+
li.QuadPart /= 10L; /* Convert to microseconds */
103+
rusage->ru_stime.tv_sec = li.QuadPart / 1000000L;
104+
rusage->ru_stime.tv_usec = li.QuadPart % 1000000L;
105+
106+
memcpy( &li, &usertime, sizeof( FILETIME ) );
107+
li.QuadPart /= 10L; /* Convert to microseconds */
108+
rusage->ru_utime.tv_sec = li.QuadPart / 1000000L;
109+
rusage->ru_utime.tv_usec = li.QuadPart % 1000000L;
110+
111+
return 0;
112+
}
113+
#endif
114+
115+
QgsBench::QgsBench( int theWidth, int theHeight, int theIterations )
116+
: QObject(), mWidth( theWidth ), mHeight( theHeight ), mIterations( theIterations ), mSetExtent( false )
117+
{
118+
QgsDebugMsg( "entered" );
119+
120+
QgsDebugMsg( QString( "mIterations = %1" ).arg( mIterations ) );
121+
122+
mMapRenderer = new QgsMapRenderer;
123+
124+
connect( QgsProject::instance(), SIGNAL( readProject( const QDomDocument & ) ),
125+
this, SLOT( readProject( const QDomDocument & ) ) );
126+
}
127+
128+
QgsBench::~QgsBench()
129+
{
130+
}
131+
132+
bool QgsBench::openProject( const QString & theFileName )
133+
{
134+
QgsDebugMsg( "entered" );
135+
// QgsProject loads layers to QgsMapLayerRegistry singleton
136+
QFileInfo file( theFileName );
137+
if ( ! QgsProject::instance()->read( file ) )
138+
{
139+
return false;
140+
}
141+
mLogMap.insert( "project", theFileName );
142+
return true;
143+
}
144+
145+
void QgsBench::readProject( const QDomDocument &doc )
146+
{
147+
QgsDebugMsg( "entered" );
148+
QDomNodeList nodes = doc.elementsByTagName( "mapcanvas" );
149+
if ( nodes.count() )
150+
{
151+
QDomNode node = nodes.item( 0 );
152+
mMapRenderer->readXML( node );
153+
}
154+
else
155+
{
156+
fprintf( stderr, "Cannot read mapcanvas from project\n" );
157+
}
158+
}
159+
160+
void QgsBench::setExtent( const QgsRectangle & extent )
161+
{
162+
mExtent = extent;
163+
mSetExtent = true;
164+
}
165+
166+
void QgsBench::render()
167+
{
168+
QgsDebugMsg( "entered" );
169+
170+
QgsDebugMsg( "extent: " + mMapRenderer->extent().toString() );
171+
172+
QMap<QString, QgsMapLayer*> layersMap = QgsMapLayerRegistry::instance()->mapLayers();
173+
174+
QStringList layers( layersMap.keys() );
175+
176+
mMapRenderer->setLayerSet( layers );
177+
178+
if ( mSetExtent )
179+
{
180+
mMapRenderer->setExtent( mExtent );
181+
}
182+
183+
// Maybe in future
184+
//outputCRS = QgsCRSCache::instance()->crsByAuthId( crsId );
185+
//mMapRenderer->setMapUnits( outputCRS.mapUnits() );
186+
//mMapRenderer->setDestinationCrs( outputCRS );
187+
188+
// TODO: this should be probably set according to project
189+
mMapRenderer->setProjectionsEnabled( true );
190+
191+
// Necessary?
192+
//mMapRenderer->setLabelingEngine( new QgsPalLabeling() );
193+
194+
mImage = new QImage( mWidth, mHeight, QImage::Format_ARGB32_Premultiplied );
195+
mImage->fill( 0 );
196+
197+
mMapRenderer->setOutputSize( QSize( mWidth, mHeight ), mImage->logicalDpiX() );
198+
199+
QPainter painter( mImage );
200+
201+
painter.setRenderHints( mRendererHints );
202+
203+
for ( int i = 0; i < mIterations; i++ )
204+
{
205+
start();
206+
mMapRenderer->render( &painter );
207+
elapsed();
208+
}
209+
210+
mLogMap.insert( "iterations", mTimes.size() );
211+
212+
// Calc stats: user, sys, total
213+
double avg[3], min[3], max[3];
214+
double stdev[3] = {0.};
215+
double maxdev[3] = {0.};
216+
217+
for ( int t = 0; t < 3; t++ )
218+
{
219+
for ( int i = 0; i < mTimes.size(); i++ )
220+
{
221+
avg[t] += mTimes[i][t];
222+
223+
if ( i == 0 || mTimes[i][t] < min[t] ) min[t] = mTimes[i][t];
224+
if ( i == 0 || mTimes[i][t] > max[t] ) max[t] = mTimes[i][t];
225+
}
226+
avg[t] /= mTimes.size();
227+
}
228+
229+
QMap<QString, QVariant> timesMap;
230+
for ( int t = 0; t < 3; t++ )
231+
{
232+
if ( mIterations > 1 )
233+
{
234+
for ( int i = 0; i < mTimes.size(); i++ )
235+
{
236+
double d = fabs( avg[t] - mTimes[i][t] );
237+
stdev[t] += pow( d, 2 );
238+
if ( i == 0 || d > maxdev[t] ) maxdev[t] = d;
239+
}
240+
241+
stdev[t] = sqrt( stdev[t] / mTimes.size() );
242+
}
243+
244+
const char *pre[] = { "user", "sys", "total" } ;
245+
246+
QMap<QString, QVariant> map;
247+
248+
map.insert( "min", min[t] );
249+
map.insert( "max", max[t] );
250+
map.insert( "avg", avg[t] );
251+
map.insert( "stdev", stdev[t] );
252+
map.insert( "maxdev", maxdev[t] );
253+
254+
timesMap.insert( pre[t], map );
255+
}
256+
mLogMap.insert( "times", timesMap );
257+
}
258+
259+
void QgsBench::saveSnapsot( const QString & fileName )
260+
{
261+
// If format is 0, QImage will attempt to guess the format by looking at fileName's suffix.
262+
mImage->save( fileName );
263+
}
264+
265+
void QgsBench::printLog()
266+
{
267+
std::cout << "iterations: " << mLogMap["iterations"].toString().toAscii().constData() << std::endl;
268+
269+
QMap<QString, QVariant> timesMap = mLogMap["times"].toMap();
270+
QMap<QString, QVariant> totalMap = timesMap["total"].toMap();
271+
QMap<QString, QVariant>::iterator i = totalMap.begin();
272+
while ( i != totalMap.end() )
273+
{
274+
QString s = "total_" + i.key() + ": " + i.value().toString();
275+
std::cout << s.toAscii().constData() << std::endl;
276+
++i;
277+
}
278+
}
279+
280+
QString QgsBench::serialize( QMap<QString, QVariant> theMap, int level )
281+
{
282+
QStringList list;
283+
QString space = QString( " " ).repeated( level * 2 );
284+
QString space2 = QString( " " ).repeated( level * 2 + 2 );
285+
QMap<QString, QVariant>::const_iterator i = theMap.constBegin();
286+
while ( i != theMap.constEnd() )
287+
{
288+
switch ( i.value().type() )
289+
{
290+
case QMetaType::Int:
291+
list.append( space2 + "\"" + i.key() + "\": " + QString( "%1" ).arg( i.value().toInt() ) );
292+
break;
293+
case QMetaType::Double:
294+
list.append( space2 + "\"" + i.key() + "\": " + QString( "%1" ).arg( i.value().toDouble(), 0, 'f', 3 ) );
295+
break;
296+
case QMetaType::QString:
297+
list.append( space2 + "\"" + i.key() + "\": \"" + i.value().toString() + "\"" );
298+
break;
299+
//case QMetaType::QMap: QMap is not in QMetaType
300+
default:
301+
list.append( space2 + "\"" + i.key() + "\": " + serialize( i.value().toMap(), level + 1 ) );
302+
break;
303+
}
304+
++i;
305+
}
306+
return space + "{\n" + list.join( ",\n" ) + "\n" + space + "}";
307+
}
308+
309+
void QgsBench::saveLog( const QString & fileName )
310+
{
311+
QFile file( fileName );
312+
file.open( QIODevice::WriteOnly | QIODevice::Text );
313+
QTextStream out( &file );
314+
out << serialize( mLogMap ).toAscii().constData() << "\n";
315+
file.close();
316+
}
317+
318+
void QgsBench::start()
319+
{
320+
struct rusage usage;
321+
getrusage( RUSAGE_SELF, &usage );
322+
mUserStart = usage.ru_utime.tv_sec + usage.ru_utime.tv_usec / 1000000.;
323+
mSysStart = usage.ru_stime.tv_sec + usage.ru_stime.tv_usec / 1000000.;
324+
}
325+
326+
void QgsBench::elapsed()
327+
{
328+
struct rusage usage;
329+
getrusage( RUSAGE_SELF, &usage );
330+
331+
double userEnd = usage.ru_utime.tv_sec + usage.ru_utime.tv_usec / 1000000.;
332+
double sysEnd = usage.ru_stime.tv_sec + usage.ru_stime.tv_usec / 1000000.;
333+
334+
double *t = new double[3];
335+
t[0] = userEnd - mUserStart;
336+
t[1] = sysEnd - mSysStart;
337+
t[2] = t[0] + t[1];
338+
mTimes.append( t );
339+
}

‎tests/bench/qgsbench.h

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/***************************************************************************
2+
qgsbench.h - Benchmark
3+
-------------------
4+
begin : 2011-11-15
5+
copyright : (C) 2011 Radim Blazek
6+
email : radim dot blazek at gmail dot com
7+
***************************************************************************/
8+
9+
/***************************************************************************
10+
* *
11+
* This program is free software; you can redistribute it and/or modify *
12+
* it under the terms of the GNU General Public License as published by *
13+
* the Free Software Foundation; either version 2 of the License, or *
14+
* (at your option) any later version. *
15+
* *
16+
***************************************************************************/
17+
#ifndef QGSBENCH_H
18+
#define QGSBENCH_H
19+
20+
#include <QCoreApplication>
21+
#include <QDomDocument>
22+
#include <QDomNode>
23+
#include <QMap>
24+
#include <QPainter>
25+
#include <QString>
26+
#include <QVariant>
27+
#include <QVector>
28+
29+
#include "qgsmaprenderer.h"
30+
31+
class QgsBench : public QObject
32+
{
33+
Q_OBJECT
34+
public:
35+
QgsBench( int theWidth, int theHeight, int theCycles );
36+
~QgsBench();
37+
38+
// start time counter
39+
void start();
40+
41+
// save elapsed time since last start() in list and restarts counter
42+
void elapsed();
43+
44+
void render();
45+
46+
void printLog();
47+
48+
bool openProject( const QString & fileName );
49+
50+
void setExtent( const QgsRectangle & extent );
51+
52+
void saveSnapsot( const QString & fileName );
53+
54+
void saveLog( const QString & fileName );
55+
56+
QString serialize( QMap<QString, QVariant> theMap, int level = 0 );
57+
58+
void setRenderHints( QPainter::RenderHints hints ) { mRendererHints = hints; }
59+
60+
public slots:
61+
void readProject( const QDomDocument &doc );
62+
63+
private:
64+
// snapshot image width
65+
int mWidth;
66+
67+
// snapshot image height
68+
int mHeight;
69+
70+
// Number of rendering cycles
71+
int mIterations;
72+
73+
74+
QgsRectangle mExtent;
75+
bool mSetExtent;
76+
77+
QPainter::RenderHints mRendererHints;
78+
79+
// log map
80+
QMap<QString, QVariant> mLogMap;
81+
82+
double mUserStart;
83+
double mSysStart;
84+
85+
// user, sys, total times
86+
QVector<double*> mTimes;
87+
88+
QImage* mImage;
89+
90+
QgsMapRenderer *mMapRenderer;
91+
};
92+
93+
#endif // QGSBENCH_H
94+

0 commit comments

Comments
 (0)
Please sign in to comment.