mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Add an icon in the 3d material combo box
This commit is contained in:
parent
c1e91425b6
commit
d85228654b
@ -880,6 +880,7 @@
|
||||
<file>themes/default/mIconAlignBottom.svg</file>
|
||||
<file>themes/default/mIconAlignTop.svg</file>
|
||||
<file>themes/default/mIconAlignVCenter.svg</file>
|
||||
<file>themes/default/mIconPhongMaterial.svg</file>
|
||||
</qresource>
|
||||
<qresource prefix="/images/tips">
|
||||
<file alias="symbol_levels.png">qgis_tips/symbol_levels.png</file>
|
||||
|
83
images/themes/default/mIconPhongMaterial.svg
Normal file
83
images/themes/default/mIconPhongMaterial.svg
Normal file
@ -0,0 +1,83 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
viewBox="0 0 16 16"
|
||||
version="1.1"
|
||||
id="svg14"
|
||||
sodipodi:docname="mIconPhongMaterial.svg"
|
||||
inkscape:version="1.0 (4035a4fb49, 2020-05-01)">
|
||||
<metadata
|
||||
id="metadata18">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<sodipodi:namedview
|
||||
inkscape:document-rotation="0"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1043"
|
||||
id="namedview16"
|
||||
showgrid="false"
|
||||
inkscape:zoom="18.981398"
|
||||
inkscape:cx="-1.0328911"
|
||||
inkscape:cy="10.253336"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="svg14" />
|
||||
<defs
|
||||
id="defs10">
|
||||
<linearGradient
|
||||
id="a">
|
||||
<stop
|
||||
offset="0"
|
||||
stop-color="#ffebeb"
|
||||
id="stop3" />
|
||||
<stop
|
||||
offset=".516"
|
||||
stop-color="#be0f0f"
|
||||
id="stop5" />
|
||||
<stop
|
||||
offset="1"
|
||||
stop-color="#280000"
|
||||
id="stop7" />
|
||||
</linearGradient>
|
||||
<radialGradient
|
||||
inkscape:collect="always"
|
||||
xlink:href="#a"
|
||||
id="radialGradient869"
|
||||
cx="6.1088824"
|
||||
cy="6.2365189"
|
||||
fx="6.1088824"
|
||||
fy="6.2365189"
|
||||
r="6"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
gradientTransform="matrix(1.1139103,1.0868262,-1.085359,1.1124067,5.3465552,-7.847367)" />
|
||||
</defs>
|
||||
<circle
|
||||
r="7"
|
||||
style="fill:url(#radialGradient869);fill-opacity:1;stroke:none;stroke-width:2.11621;stroke-linecap:round;paint-order:stroke fill markers"
|
||||
id="path843"
|
||||
cx="8"
|
||||
cy="8" />
|
||||
</svg>
|
After Width: | Height: | Size: 2.3 KiB |
@ -29,9 +29,11 @@ Stores metadata about one 3D material settings class.
|
||||
%End
|
||||
public:
|
||||
|
||||
QgsMaterialSettingsAbstractMetadata( const QString &type, const QString &visibleName );
|
||||
QgsMaterialSettingsAbstractMetadata( const QString &type, const QString &visibleName, const QIcon &icon = QIcon() );
|
||||
%Docstring
|
||||
Constructor for QgsMaterialSettingsAbstractMetadata, with the specified ``type`` and ``visibleName``.
|
||||
|
||||
An optional ``icon`` can be specified to represent the material type.
|
||||
%End
|
||||
|
||||
virtual ~QgsMaterialSettingsAbstractMetadata();
|
||||
@ -44,6 +46,11 @@ Returns the unique material type string.
|
||||
QString visibleName() const;
|
||||
%Docstring
|
||||
Returns the material's visible (translated) name.
|
||||
%End
|
||||
|
||||
QIcon icon() const;
|
||||
%Docstring
|
||||
Returns an icon representing the material type, if available.
|
||||
%End
|
||||
|
||||
virtual QgsAbstractMaterialSettings *create() = 0 /Factory/;
|
||||
|
@ -66,7 +66,7 @@ void Qgs3D::initialize()
|
||||
&QgsPolygon3DSymbol::create, nullptr, Qgs3DSymbolImpl::handlerForPolygon3DSymbol ) );
|
||||
|
||||
instance()->materialRegistry()->addMaterialSettingsType( new QgsMaterialSettingsMetadata( QStringLiteral( "phong" ), QObject::tr( "Realistic (Phong)" ),
|
||||
QgsPhongMaterialSettings::create, nullptr ) );
|
||||
QgsPhongMaterialSettings::create, nullptr, QgsApplication::getThemeIcon( QStringLiteral( "/mIconPhongMaterial.svg" ) ) ) );
|
||||
|
||||
// because we are usually populating the 3d registry AFTER QgsApplication initialisation, we need to defer creation
|
||||
// of 3d symbols in the default style until now
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include <QDomElement>
|
||||
#include <QMap>
|
||||
#include <QIcon>
|
||||
|
||||
class QgsAbstractMaterialSettings;
|
||||
class QgsReadWriteContext;
|
||||
@ -41,10 +42,13 @@ class _3D_EXPORT QgsMaterialSettingsAbstractMetadata
|
||||
|
||||
/**
|
||||
* Constructor for QgsMaterialSettingsAbstractMetadata, with the specified \a type and \a visibleName.
|
||||
*
|
||||
* An optional \a icon can be specified to represent the material type.
|
||||
*/
|
||||
QgsMaterialSettingsAbstractMetadata( const QString &type, const QString &visibleName )
|
||||
QgsMaterialSettingsAbstractMetadata( const QString &type, const QString &visibleName, const QIcon &icon = QIcon() )
|
||||
: mType( type )
|
||||
, mVisibleName( visibleName )
|
||||
, mIcon( icon )
|
||||
{}
|
||||
|
||||
virtual ~QgsMaterialSettingsAbstractMetadata() = default;
|
||||
@ -59,6 +63,11 @@ class _3D_EXPORT QgsMaterialSettingsAbstractMetadata
|
||||
*/
|
||||
QString visibleName() const { return mVisibleName; }
|
||||
|
||||
/**
|
||||
* Returns an icon representing the material type, if available.
|
||||
*/
|
||||
QIcon icon() const { return mIcon; }
|
||||
|
||||
/**
|
||||
* Creates a new instance of this material settings type.
|
||||
*
|
||||
@ -81,6 +90,7 @@ class _3D_EXPORT QgsMaterialSettingsAbstractMetadata
|
||||
private:
|
||||
QString mType;
|
||||
QString mVisibleName;
|
||||
QIcon mIcon;
|
||||
};
|
||||
|
||||
//! Material settings creation function
|
||||
@ -108,11 +118,14 @@ class _3D_EXPORT QgsMaterialSettingsMetadata : public QgsMaterialSettingsAbstrac
|
||||
*
|
||||
* The \a pfCreate and \a pfWidget arguments are used to specify
|
||||
* static functions for creating the material settings type and configuration widget.
|
||||
*
|
||||
* An optional \a icon can be specified to represent the material type.
|
||||
*/
|
||||
QgsMaterialSettingsMetadata( const QString &type, const QString &visibleName,
|
||||
QgsMaterialSettingsCreateFunc pfCreate,
|
||||
QgsMaterialSettingsWidgetFunc pfWidget = nullptr )
|
||||
: QgsMaterialSettingsAbstractMetadata( type, visibleName )
|
||||
QgsMaterialSettingsWidgetFunc pfWidget = nullptr,
|
||||
const QIcon &icon = QIcon() )
|
||||
: QgsMaterialSettingsAbstractMetadata( type, visibleName, icon )
|
||||
, mCreateFunc( pfCreate )
|
||||
, mWidgetFunc( pfWidget )
|
||||
{}
|
||||
|
@ -30,7 +30,8 @@ QgsMaterialWidget::QgsMaterialWidget( QWidget *parent )
|
||||
const QStringList materialTypes = Qgs3D::materialRegistry()->materialSettingsTypes();
|
||||
for ( const QString &type : materialTypes )
|
||||
{
|
||||
mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type );
|
||||
mMaterialTypeComboBox->addItem( Qgs3D::materialRegistry()->materialSettingsMetadata( type )->icon(),
|
||||
Qgs3D::materialRegistry()->materialSettingsMetadata( type )->visibleName(), type );
|
||||
}
|
||||
|
||||
connect( mMaterialTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsMaterialWidget::materialTypeChanged );
|
||||
|
Loading…
x
Reference in New Issue
Block a user