QGIS API Documentation 4.1.0-Master (376402f9aeb)
Loading...
Searching...
No Matches
qgs3dmapexportsettings.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgs3dmapexportsettings.cpp
3 --------------------------------------
4 Date : July 2020
5 Copyright : (C) 2020 by Belgacem Nedjima
6 Email : gb underscore nedjima at esi dot dz
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
18#include "qgssettings.h"
19
20#include <QString>
21#include <QUrl>
22
23using namespace Qt::StringLiterals;
24
26{
27 const QgsSettings settings;
28 mSceneName = settings.value( u"UI/last3DSceneExportName"_s, u"Scene"_s ).toString();
29 mSceneFolderPath = settings.value( u"UI/last3DSceneExportDir"_s, QDir::homePath() ).toString();
30 mTerrainResolution = settings.value( u"UI/last3DSceneExportTerrainResolution"_s, 128 ).toInt();
31 mTerrainTextureResolution = settings.value( u"UI/last3DSceneExportTerrainTextureResolution"_s, 512 ).toInt();
32 mScale = settings.value( u"UI/last3DSceneExportModelScale"_s, 1.0f ).toFloat();
33 mSmoothEdges = settings.value( u"UI/last3DSceneExportSmoothEdges"_s, false ).toBool();
34 mExportNormals = settings.value( u"UI/last3DSceneExportExportNormals"_s, true ).toBool();
35 mExportTextures = settings.value( u"UI/last3DSceneExportExportTextures"_s, true ).toBool();
36}
37
39{
40 QgsSettings settings;
41 settings.setValue( u"UI/last3DSceneExportName"_s, mSceneName );
42 settings.setValue( u"UI/last3DSceneExportDir"_s, mSceneFolderPath );
43 settings.setValue( u"UI/last3DSceneExportTerrainResolution"_s, mTerrainResolution );
44 settings.setValue( u"UI/last3DSceneExportTerrainTextureResolution"_s, mTerrainTextureResolution );
45 settings.setValue( u"UI/last3DSceneExportModelScale"_s, mScale );
46 settings.setValue( u"UI/last3DSceneExportSmoothEdges"_s, mSmoothEdges );
47 settings.setValue( u"UI/last3DSceneExportExportNormals"_s, mExportNormals );
48 settings.setValue( u"UI/last3DSceneExportExportTextures"_s, mExportTextures );
49}
50
52{
53 QString extension;
54 switch ( mExportFormat )
55 {
57 extension = u"obj"_s;
58 break;
60 extension = u"stl"_s;
61 break;
62 }
63
64 const QString path = QDir( sceneFolderPath() ).filePath( sceneName() + u"."_s + extension );
65 return QUrl::fromLocalFile( path ).toString();
66}
@ StlAscii
STL ascii format.
Definition qgis.h:4440
@ Obj
Wavefront OBJ format.
Definition qgis.h:4439
QString sceneFolderPath() const
Returns the scene folder path.
QString exportFileUri() const
Returns the full file uri where the 3D scene will be exported.
~Qgs3DMapExportSettings()
destructor (save the export settings before deallocation)
QString sceneName() const
Returns the scene name.
Stores settings for use within QGIS.
Definition qgssettings.h:68
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void setValue(const QString &key, const QVariant &value, QgsSettings::Section section=QgsSettings::NoSection)
Sets the value of setting key to value.