QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgs3dsymbolwidget.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgs3dsymbolwidget.cpp
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 #include "qgs3dsymbolwidget.h"
17 #include "qgsapplication.h"
18 #include "qgs3dsymbolregistry.h"
19 #include "qgsabstract3dsymbol.h"
20 #include "qgsgui.h"
21 #include <QVBoxLayout>
22 #include <QDialogButtonBox>
23 
25  : QWidget( parent )
26 {}
27 
29  : QDialog( parent )
30 {
31  Q_ASSERT( symbol );
32 
34 
35  QVBoxLayout *vLayout = new QVBoxLayout();
36 
37  if ( Qgs3DSymbolAbstractMetadata *metadata = QgsApplication::symbol3DRegistry()->symbolMetadata( symbol->type() ) )
38  {
39  mWidget = metadata->createSymbolWidget( nullptr );
40  vLayout->addWidget( mWidget );
41  mWidget->setSymbol( symbol, nullptr );
42  }
43 
44  mButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Ok, Qt::Horizontal );
45  connect( mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
46  connect( mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
47  vLayout->addStretch();
48  vLayout->addWidget( mButtonBox );
49  setLayout( vLayout );
50  setWindowTitle( tr( "3D Symbol" ) );
51 }
52 
54 {
55  return mWidget ? mWidget->symbol() : nullptr;
56 }
57 
58 QDialogButtonBox *Qgs3DSymbolDialog::buttonBox() const
59 {
60  return mButtonBox;
61 }
Qgs3DSymbolDialog::Qgs3DSymbolDialog
Qgs3DSymbolDialog(const QgsAbstract3DSymbol *symbol, QWidget *parent=nullptr)
Constructor for Qgs3DSymbolDialog, initially showing the specified symbol.
Definition: qgs3dsymbolwidget.cpp:28
Qgs3DSymbolAbstractMetadata
Stores metadata about one 3D symbol class.
Definition: qgs3dsymbolregistry.h:42
qgsgui.h
Qgs3DSymbolDialog::symbol
QgsAbstract3DSymbol * symbol() const
Returns a new instance of the symbol defined by the dialog.
Definition: qgs3dsymbolwidget.cpp:53
QgsApplication::symbol3DRegistry
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
Definition: qgsapplication.cpp:2288
qgsabstract3dsymbol.h
qgs3dsymbolregistry.h
Qgs3DSymbolWidget::Qgs3DSymbolWidget
Qgs3DSymbolWidget(QWidget *parent)
Constructor for Qgs3DSymbolWidget with the specified parent widget.
Definition: qgs3dsymbolwidget.cpp:24
qgsapplication.h
Qgs3DSymbolWidget::symbol
virtual QgsAbstract3DSymbol * symbol()=0
Returns a new instance of the symbol defined by the widget.
QgsGui::enableAutoGeometryRestore
static void enableAutoGeometryRestore(QWidget *widget, const QString &key=QString())
Register the widget to allow its position to be automatically saved and restored when open and closed...
Definition: qgsgui.cpp:139
QgsAbstract3DSymbol
3 Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
Definition: qgsabstract3dsymbol.h:46
Qgs3DSymbolWidget::setSymbol
virtual void setSymbol(const QgsAbstract3DSymbol *symbol, QgsVectorLayer *layer)=0
Sets the symbol to show in the widget.
QgsAbstract3DSymbol::type
virtual QString type() const =0
Returns identifier of symbol type. Each 3D symbol implementation should return a different type.
Qgs3DSymbolDialog::buttonBox
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Definition: qgs3dsymbolwidget.cpp:58
qgs3dsymbolwidget.h