Skip to content

Commit

Permalink
Split simple line material out from phong material
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Aug 3, 2020
1 parent c87a8f6 commit 4d55185
Show file tree
Hide file tree
Showing 18 changed files with 628 additions and 14 deletions.
1 change: 1 addition & 0 deletions images/images.qrc
Expand Up @@ -882,6 +882,7 @@
<file>themes/default/mIconAlignVCenter.svg</file>
<file>themes/default/mIconPhongMaterial.svg</file>
<file>themes/default/mIconGoochMaterial.svg</file>
<file>themes/default/mIconSimpleLineMaterial.svg</file>
</qresource>
<qresource prefix="/images/tips">
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
Expand Down
77 changes: 77 additions & 0 deletions images/themes/default/mIconSimpleLineMaterial.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions python/3d/3d_auto.sip
Expand Up @@ -14,6 +14,7 @@
%Include auto_generated/materials/qgsgoochmaterialsettings.sip
%Include auto_generated/materials/qgsmaterialregistry.sip
%Include auto_generated/materials/qgsphongmaterialsettings.sip
%Include auto_generated/materials/qgssimplelinematerialsettings.sip
%Include auto_generated/symbols/qgsline3dsymbol.sip
%Include auto_generated/symbols/qgspoint3dsymbol.sip
%Include auto_generated/symbols/qgspolygon3dsymbol.sip
Expand Down
@@ -0,0 +1,85 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/materials/qgssimplelinematerialsettings.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/






class QgsSimpleLineMaterialSettings : QgsAbstractMaterialSettings
{
%Docstring
Basic shading material used for rendering simple lines as solid line components.

.. warning::

This is not considered stable API, and may change in future QGIS releases. It is
exposed to the Python bindings as a tech preview only.

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgssimplelinematerialsettings.h"
%End
public:

QgsSimpleLineMaterialSettings();
%Docstring
Constructor for QgsSimpleLineMaterialSettings.
%End

virtual QString type() const;


static bool supportsTechnique( QgsMaterialSettingsRenderingTechnique technique );
%Docstring
Returns ``True`` if the specified ``technique`` is suppored by the material.
%End

static QgsAbstractMaterialSettings *create() /Factory/;
%Docstring
Returns a new instance of QgsSimpleLineMaterialSettings.
%End

virtual QgsSimpleLineMaterialSettings *clone() const /Factory/;


QColor ambient() const;
%Docstring
Returns the ambient color component.

.. seealso:: :py:func:`setAmbient`
%End

void setAmbient( const QColor &ambient );
%Docstring
Sets the ``ambient`` color component.

.. seealso:: :py:func:`ambient`
%End

virtual QMap<QString, QString> toExportParameters() const;

virtual void readXml( const QDomElement &elem, const QgsReadWriteContext &context );

virtual void writeXml( QDomElement &elem, const QgsReadWriteContext &context ) const;


bool operator==( const QgsSimpleLineMaterialSettings &other ) const;

};


/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/materials/qgssimplelinematerialsettings.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
106 changes: 106 additions & 0 deletions python/3d/auto_generated/qgs3dmapexportsettings.sip.in
@@ -0,0 +1,106 @@
/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/qgs3dmapexportsettings.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/




class Qgs3DMapExportSettings
{
%Docstring
The Qgs3DMapExportSettings class
Manages the various settings the user can choose from when exporting a 3D scene

.. versionadded:: 3.16
%End

%TypeHeaderCode
#include "qgs3dmapexportsettings.h"
%End
public:
Qgs3DMapExportSettings();
%Docstring
Constructor
%End

~Qgs3DMapExportSettings();

QString sceneName() const;
%Docstring
Returns the scene name
%End
QString sceneFolderPath() const;
%Docstring
Returns the scene folder path
%End
int terrrainResolution() const;
%Docstring
Returns the terrain resolution
%End
bool smoothEdges() const;
%Docstring
Returns whether triangles edges will look smooth
%End
bool exportNormals() const;
%Docstring
Returns whether normals will be exported
%End
bool exportTextures() const;
%Docstring
Returns whether textures will be exported
%End
int terrainTextureResolution() const;
%Docstring
Returns the terrain texture resolution
%End
float scale() const;
%Docstring
Returns the scale of the exported model
%End

void setSceneName( const QString &sceneName );
%Docstring
Sets the scene name
%End
void setSceneFolderPath( const QString &sceneFolderPath );
%Docstring
Sets the scene's .obj file folder path
%End
void setTerrainResolution( int resolution );
%Docstring
Sets the terrain resolution
%End
void setSmoothEdges( bool smoothEdges );
%Docstring
Sets whether triangles edges will look smooth
%End
void setExportNormals( bool exportNormals );
%Docstring
Sets whether normals should be exported
%End
void setExportTextures( bool exportTextures );
%Docstring
Sets whether textures will be exported
%End
void setTerrainTextureResolution( int resolution );
%Docstring
Sets the terrain texture resolution
%End
void setScale( float scale );
%Docstring
Sets the scale of exported model
%End

};

/************************************************************************
* This file has been generated automatically from *
* *
* src/3d/qgs3dmapexportsettings.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2 changes: 2 additions & 0 deletions src/3d/CMakeLists.txt
Expand Up @@ -40,6 +40,7 @@ SET(QGIS_3D_SRCS
materials/qgsgoochmaterialsettings.cpp
materials/qgsmaterialregistry.cpp
materials/qgsphongmaterialsettings.cpp
materials/qgssimplelinematerialsettings.cpp

processing/qgs3dalgorithms.cpp
processing/qgsalgorithmtessellate.cpp
Expand Down Expand Up @@ -106,6 +107,7 @@ SET(QGIS_3D_HDRS
materials/qgsgoochmaterialsettings.h
materials/qgsmaterialregistry.h
materials/qgsphongmaterialsettings.h
materials/qgssimplelinematerialsettings.h

symbols/qgsbillboardgeometry.h
symbols/qgsline3dsymbol.h
Expand Down
17 changes: 5 additions & 12 deletions src/3d/materials/qgsphongmaterialsettings.cpp
Expand Up @@ -16,7 +16,6 @@
#include "qgsphongmaterialsettings.h"

#include "qgssymbollayerutils.h"
#include "qgslinematerial_p.h"
#include "qgsapplication.h"
#include "qgsimagecache.h"
#include <Qt3DExtras/QDiffuseMapMaterial>
Expand All @@ -38,11 +37,13 @@ bool QgsPhongMaterialSettings::supportsTechnique( QgsMaterialSettingsRenderingTe
switch ( technique )
{
case QgsMaterialSettingsRenderingTechnique::Triangles:
case QgsMaterialSettingsRenderingTechnique::Lines:
case QgsMaterialSettingsRenderingTechnique::InstancedPoints:
case QgsMaterialSettingsRenderingTechnique::Points:
case QgsMaterialSettingsRenderingTechnique::TrianglesWithFixedTexture:
return true;

case QgsMaterialSettingsRenderingTechnique::Lines:
return false;
}
return false;
}
Expand Down Expand Up @@ -173,16 +174,8 @@ Qt3DRender::QMaterial *QgsPhongMaterialSettings::toMaterial( QgsMaterialSettings
}

case QgsMaterialSettingsRenderingTechnique::Lines:
{
QgsLineMaterial *mat = new QgsLineMaterial;
mat->setLineColor( mAmbient );
if ( context.isSelected() )
{
// update the material with selection colors
mat->setLineColor( context.selectionColor() );
}
return mat;
}
return nullptr;

}
return nullptr;
}
Expand Down

0 comments on commit 4d55185

Please sign in to comment.