QGIS API Documentation 3.99.0-Master (d270888f95f)
Loading...
Searching...
No Matches
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
18#include "qgs3dsymbolregistry.h"
19#include "qgsabstract3dsymbol.h"
20#include "qgsapplication.h"
21#include "qgsgui.h"
22#include "qgshelp.h"
23
24#include <QDialogButtonBox>
25#include <QString>
26#include <QVBoxLayout>
27
28#include "moc_qgs3dsymbolwidget.cpp"
29
30using namespace Qt::StringLiterals;
31
33 : QWidget( parent )
34{}
35
37 : QDialog( parent )
38{
39 Q_ASSERT( symbol );
40
42
43 QVBoxLayout *vLayout = new QVBoxLayout();
44
45 if ( Qgs3DSymbolAbstractMetadata *metadata = QgsApplication::symbol3DRegistry()->symbolMetadata( symbol->type() ) )
46 {
47 mWidget = metadata->createSymbolWidget( nullptr );
48 vLayout->addWidget( mWidget );
49 mWidget->setSymbol( symbol, nullptr );
50 }
51
52 mButtonBox = new QDialogButtonBox( QDialogButtonBox::Cancel | QDialogButtonBox::Help | QDialogButtonBox::Ok, Qt::Horizontal );
53 connect( mButtonBox, &QDialogButtonBox::accepted, this, &QDialog::accept );
54 connect( mButtonBox, &QDialogButtonBox::rejected, this, &QDialog::reject );
55 connect( mButtonBox, &QDialogButtonBox::helpRequested, this, [] {
56 QgsHelp::openHelp( u"style_library/3d_symbols.html"_s );
57 } );
58 vLayout->addStretch();
59 vLayout->addWidget( mButtonBox );
60 setLayout( vLayout );
61 setWindowTitle( tr( "3D Symbol" ) );
62}
63
65{
66 return mWidget ? mWidget->symbol() : nullptr;
67}
68
69QDialogButtonBox *Qgs3DSymbolDialog::buttonBox() const
70{
71 return mButtonBox;
72}
Stores metadata about one 3D symbol class.
QgsAbstract3DSymbol * symbol() const
Returns a new instance of the symbol defined by the dialog.
QDialogButtonBox * buttonBox() const
Returns a reference to the dialog's button box.
Qgs3DSymbolDialog(const QgsAbstract3DSymbol *symbol, QWidget *parent=nullptr)
Constructor for Qgs3DSymbolDialog, initially showing the specified symbol.
Qgs3DSymbolWidget(QWidget *parent)
Constructor for Qgs3DSymbolWidget with the specified parent widget.
Abstract base class for 3D symbols that are used by VectorLayer3DRenderer objects.
static Qgs3DSymbolRegistry * symbol3DRegistry()
Returns registry of available 3D symbols.
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:224
static void openHelp(const QString &key)
Opens help topic for the given help key using default system web browser.
Definition qgshelp.cpp:41