summaryrefslogtreecommitdiffstats
path: root/src/core/aspect/coresettings.cpp
blob: df64fd614cb0f47fa1976cef40e111666712fa59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Copyright (C) 2020 Klaralvdalens Datakonsult AB (KDAB).
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "coresettings_p.h"
#include <Qt3DCore/private/qcoreaspect_p.h>

QT_BEGIN_NAMESPACE

namespace Qt3DCore {

CoreSettings::CoreSettings()
    : QBackendNode()
{
}

void CoreSettings::syncFromFrontEnd(const Qt3DCore::QNode *frontEnd, bool firstTime)
{
    Q_UNUSED(firstTime);

    const QCoreSettings *node = qobject_cast<const QCoreSettings *>(frontEnd);
    if (!node)
        return;

    Q_ASSERT(m_aspect);
    auto daspect = QCoreAspectPrivate::get(m_aspect);
    daspect->m_boundingVolumesEnabled = node->boundingVolumesEnabled();
}

CoreSettingsFunctor::CoreSettingsFunctor(QCoreAspect *aspect)
    : m_aspect(aspect)
    , m_settings(nullptr)
{
}

Qt3DCore::QBackendNode *CoreSettingsFunctor::create(Qt3DCore::QNodeId) const
{
    if (m_settings != nullptr) {
        qWarning() << "Core settings already exists";
        return nullptr;
    }

    m_settings = new CoreSettings;
    m_settings->setAspect(m_aspect);
    return m_settings;
}

Qt3DCore::QBackendNode *CoreSettingsFunctor::get(Qt3DCore::QNodeId id) const
{
    Q_UNUSED(id);
    return m_settings;
}

void CoreSettingsFunctor::destroy(Qt3DCore::QNodeId id) const
{
    Q_UNUSED(id);
    delete m_settings;
    m_settings = nullptr;
}

} // namespace Qt3DCore

QT_END_NAMESPACE