Skip to content

Commit 2f93ef1

Browse files
committedOct 4, 2018
add 2.5D screenshot
1 parent 046f915 commit 2f93ef1

File tree

5 files changed

+60
-8
lines changed

5 files changed

+60
-8
lines changed
 

‎src/app/main.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void usage( const QString &appName )
143143
<< QStringLiteral( "\t[--dxf-encoding encoding]\tencoding to use for dxf output\n" )
144144
<< QStringLiteral( "\t[--dxf-map-theme maptheme]\tmap theme to use for dxf output\n" )
145145
<< QStringLiteral( "\t[--take-screenshots output_path]\ttake screen shots for the user documentation\n" )
146+
<< QStringLiteral( "\t[--screenshots-categories categories]\tspecify the categories of screenshot to be used (see QgsAppScreenShots::Categories).\n" )
146147
<< QStringLiteral( "\t[--profile name]\tload a named profile from the users profiles folder.\n" )
147148
<< QStringLiteral( "\t[--profiles-path path]\tpath to store user profile folders. Will create profiles inside a {path}\\profiles folder \n" )
148149
<< QStringLiteral( "\t[--version-migration]\tforce the settings migration from older version if found\n" )
@@ -532,6 +533,7 @@ int main( int argc, char *argv[] )
532533

533534
bool takeScreenShots = false;
534535
QString screenShotsPath;
536+
int screenShotsCategories = 0;
535537

536538
// This behavior will set initial extent of map canvas, but only if
537539
// there are no command line arguments. This gives a usable map
@@ -754,6 +756,10 @@ int main( int argc, char *argv[] )
754756
takeScreenShots = true;
755757
screenShotsPath = args[++i];
756758
}
759+
else if ( arg == QLatin1String( "--screenshots-categories" ) )
760+
{
761+
screenShotsCategories = args[++i].toInt();
762+
}
757763
#ifdef HAVE_OPENCL
758764
else if ( arg == QLatin1String( "--openclprogramfolder" ) )
759765
{
@@ -1242,7 +1248,7 @@ int main( int argc, char *argv[] )
12421248
int h = 300 * qApp->desktop()->logicalDpiY() / 96;
12431249

12441250
QSplashScreen *mypSplash = new QSplashScreen( myPixmap.scaled( w, h, Qt::KeepAspectRatio, Qt::SmoothTransformation ) );
1245-
if ( !myHideSplash && !settings.value( QStringLiteral( "qgis/hideSplash" ) ).toBool() )
1251+
if ( !takeScreenShots && !myHideSplash && !settings.value( QStringLiteral( "qgis/hideSplash" ) ).toBool() )
12461252
{
12471253
//for win and linux we can just automask and png transparency areas will be used
12481254
mypSplash->setMask( myPixmap.mask() );
@@ -1468,7 +1474,7 @@ int main( int argc, char *argv[] )
14681474

14691475
if ( takeScreenShots )
14701476
{
1471-
qgis->takeAppScreenShots( screenShotsPath );
1477+
qgis->takeAppScreenShots( screenShotsPath, screenShotsCategories );
14721478
}
14731479

14741480
/////////////////////////////////////////////////////////////////////

‎src/app/qgsappscreenshots.cpp

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#include <QWindow>
1919
#include <QScreen>
2020
#include <QImageWriter>
21-
#include <QTransform>
21+
#include <QIcon>
2222

2323
#include "qgsappscreenshots.h"
2424

@@ -27,13 +27,22 @@
2727
#include "qgsproject.h"
2828
#include "qgsmessagelog.h"
2929
#include "qgisapp.h"
30+
#include "qgsrendererpropertiesdialog.h"
31+
#include "qgs25drendererwidget.h"
32+
#include "qgsapplication.h"
33+
3034

3135
QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
3236
: mSaveDirectory( saveDirectory )
3337
{
3438
QString layerDef = QStringLiteral( "Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=my_integer:integer&field=my_double:double&key=pk" );
35-
mVectorLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Layer" ), QStringLiteral( "memory" ) );
36-
QgsProject::instance()->addMapLayer( mVectorLayer );
39+
mLineLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Line Layer" ), QStringLiteral( "memory" ) );
40+
layerDef = QStringLiteral( "Polygon?crs=epsg:2056&field=pk:integer&field=my_text:string&field=my_integer:integer&field=height:double&key=pk" );
41+
mPolygonLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Polygon Layer" ), QStringLiteral( "memory" ) );
42+
43+
QgsProject::instance()->addMapLayers( QList<QgsMapLayer *>()
44+
<< mLineLayer
45+
<< mPolygonLayer );
3746
}
3847

3948
void QgsAppScreenShots::saveScreenshot( const QString &name, QWidget *widget, GrabMode mode )
@@ -117,6 +126,9 @@ QScreen *QgsAppScreenShots::screen( QWidget *widget )
117126

118127
void QgsAppScreenShots::takePicturesOf( Categories categories )
119128
{
129+
if ( !categories || categories.testFlag( Symbol25D ) )
130+
take25dSymbol();
131+
120132
if ( !categories || categories.testFlag( VectorLayerProperties ) )
121133
takeVectorLayerProperties();
122134
}
@@ -128,7 +140,7 @@ void QgsAppScreenShots::takePicturesOf( Categories categories )
128140
void QgsAppScreenShots::takeVectorLayerProperties()
129141
{
130142
QString rootName = QLatin1String( "vectorlayerproperties_" );
131-
QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties( mVectorLayer, QgisApp::instance() );
143+
QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties( mLineLayer, QgisApp::instance() );
132144
dlg->show();
133145
// ----------------
134146
// do all the pages
@@ -159,3 +171,28 @@ void QgsAppScreenShots::takeVectorLayerProperties()
159171
dlg->deleteLater();
160172
}
161173

174+
void QgsAppScreenShots::take25dSymbol()
175+
{
176+
QString rootName = QLatin1String( "vectorlayerproperties_" );
177+
QgsVectorLayerProperties *dlg = new QgsVectorLayerProperties( mPolygonLayer, QgisApp::instance() );
178+
dlg->show();
179+
dlg->mOptionsListWidget->setCurrentRow( 2 );
180+
Q_ASSERT( dlg->mOptionsListWidget->currentItem()->icon().pixmap( 24, 24 ).toImage()
181+
== QgsApplication::getThemeIcon( QStringLiteral( "/propertyicons/symbology.svg" ) ).pixmap( 24, 24 ).toImage() );
182+
int idx = dlg->mRendererDialog->cboRenderers->findData( QLatin1String( "25dRenderer" ) );
183+
Q_ASSERT( idx >= 0 );
184+
dlg->mRendererDialog->cboRenderers->setCurrentIndex( idx );
185+
QCoreApplication::processEvents();
186+
Qgs25DRendererWidget *w = dynamic_cast<Qgs25DRendererWidget *>( dlg->mRendererDialog->mActiveWidget );
187+
w->mHeightWidget->setField( QLatin1String( "height" ) );
188+
Q_ASSERT( w->mHeightWidget->expression() == QLatin1String( "\"height\"" ) );
189+
QCoreApplication::processEvents();
190+
dlg->adjustSize();
191+
QCoreApplication::processEvents();
192+
saveScreenshot( rootName + QLatin1String( "25dsymbol" ), dlg );
193+
194+
// exit properly
195+
dlg->close();
196+
dlg->deleteLater();
197+
}
198+

‎src/app/qgsappscreenshots.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,12 @@ class QgsAppScreenShots
4141
Screen
4242
};
4343

44+
//! Not part of the API to avoid cluttering
4445
enum Category
4546
{
46-
VectorLayerProperties = 1,
47+
All = 0,
48+
Symbol25D,
49+
VectorLayerProperties,
4750
};
4851
Q_ENUM( Category )
4952
Q_DECLARE_FLAGS( Categories, Category )
@@ -60,9 +63,11 @@ class QgsAppScreenShots
6063
void saveScreenshot( const QString &name, QWidget *widget = nullptr, GrabMode mode = GrabWidgetAndFrame );
6164

6265
void takeVectorLayerProperties();
66+
void take25dSymbol();
6367

6468
QString mSaveDirectory;
65-
QgsVectorLayer *mVectorLayer = nullptr;
69+
QgsVectorLayer *mLineLayer = nullptr;
70+
QgsVectorLayer *mPolygonLayer = nullptr;
6671
};
6772

6873
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsAppScreenShots::Categories )

‎src/gui/symbology/qgs25drendererwidget.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ class GUI_EXPORT Qgs25DRendererWidget : public QgsRendererWidget, protected Ui::
5858
void apply() override SIP_FORCE;
5959

6060
Qgs25DRenderer *mRenderer = nullptr;
61+
62+
friend class QgsAppScreenShots;
6163
};
6264

6365
#endif // QGS25DRENDERERWIDGET_H

‎src/gui/symbology/qgsrendererpropertiesdialog.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ class GUI_EXPORT QgsRendererPropertiesDialog : public QDialog, private Ui::QgsRe
153153

154154
private:
155155
bool mDockMode;
156+
157+
friend class QgsAppScreenShots;
156158
};
157159

158160

0 commit comments

Comments
 (0)
Please sign in to comment.