QGIS API Documentation 4.3.0-Master (dfb0041329c)
Loading...
Searching...
No Matches
qgsmaterialwidget.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsmaterialwidget.h
3 --------------------------------------
4 Date : July 2020
5 Copyright : (C) 2020 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
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
16#ifndef QGSMATERIALWIDGET_H
17#define QGSMATERIALWIDGET_H
18
19#include "ui_materialwidget.h"
20
21#include <memory>
22
23#include "qgis.h"
24#include "qgis_gui.h"
25
26#include <QDialog>
27#include <QPointer>
28#include <QWidget>
29
30#define SIP_NO_FILE
31
33class QgsVectorLayer;
34class QDialogButtonBox;
35
45class GUI_EXPORT QgsMaterialWidget : public QgsPanelWidget, private Ui::MaterialWidgetBase
46{
47 Q_OBJECT
48 public:
52 explicit QgsMaterialWidget( QWidget *parent = nullptr );
54
66
77 Qgis::MaterialRenderingTechnique technique() const { return mTechnique; }
78
85 void setFilterByTechnique( bool enabled );
86
93 bool filterByTechnique() const { return mFilterByTechnique; }
94
98 void setSettings( const QgsAbstractMaterialSettings *settings, QgsVectorLayer *layer );
99
103 std::unique_ptr< QgsAbstractMaterialSettings > settings();
104
108 void setType( const QString &type );
109
110 void setDockMode( bool dockMode ) override;
111
122 void setMode( Qgis::MaterialWidgetMode mode );
123
124 public slots:
125
129 void setPreviewVisible( bool visible );
130
131 signals:
132
136 void changed();
137
138 private slots:
139 void materialTypeChanged();
140 void materialWidgetChanged();
141
142 private:
143 void updateMaterialWidget();
144 void rebuildAvailableTypes();
145 bool mPreviewVisible = false;
146 QPointer< QgsVectorLayer > mLayer;
147
148 std::unique_ptr<QgsAbstractMaterialSettings> mCurrentSettings;
149
150 bool mFilterByTechnique = false;
153};
154
155
163class GUI_EXPORT QgsMaterialWidgetDialog : public QDialog
164{
165 Q_OBJECT
166
167 public:
172
185
193 void setFilterByTechnique( bool enabled );
194
198 std::unique_ptr< QgsAbstractMaterialSettings > settings();
199
203 QDialogButtonBox *buttonBox();
204
205 private:
206 QgsMaterialWidget *mWidget = nullptr;
207 QDialogButtonBox *mButtonBox = nullptr;
208};
209
210
211#endif // QGSMATERIALWIDGET_H
MaterialWidgetMode
Modes for material settings widgets.
Definition qgis.h:4429
@ Full
Shows all material settings.
Definition qgis.h:4431
MaterialRenderingTechnique
Material rendering techniques.
Definition qgis.h:4411
@ Triangles
Triangle based rendering (default).
Definition qgis.h:4412
Abstract base class for material settings.
void setFilterByTechnique(bool enabled)
Sets whether available materials should be filtered by technique.
void setTechnique(Qgis::MaterialRenderingTechnique technique)
Sets the required rendering technique which the material must support.
std::unique_ptr< QgsAbstractMaterialSettings > settings()
Returns the current settings defined by the dialog.
QDialogButtonBox * buttonBox()
Returns the dialog's button box.
QgsMaterialWidgetDialog(const QgsAbstractMaterialSettings *settings, QWidget *parent=nullptr)
Constructor for QgsMaterialWidgetDialog, initially showing the specified material settings.
A widget allowing users to customize a 3d material.
bool filterByTechnique() const
Returns whether available materials are filtered by technique.
QgsMaterialWidget(QWidget *parent=nullptr)
Constructor for QgsMaterialWidget.
void changed()
Emitted when the material defined by the widget is changed.
void setTechnique(Qgis::MaterialRenderingTechnique technique)
Sets the required rendering technique which the material must support.
Qgis::MaterialRenderingTechnique technique() const
Returns the required rendering technique which the material must support.
~QgsMaterialWidget() override
QgsPanelWidget(QWidget *parent=nullptr)
Base class for any widget that can be shown as an inline panel.
virtual void setDockMode(bool dockMode)
Set the widget in dock mode which tells the widget to emit panel widgets and not open dialogs.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52