summaryrefslogtreecommitdiffstats
path: root/src/dm/systems/StudioPropertySystem.h
blob: 67abcf98792030091fd39a04300dcf4e35d4e790 (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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/****************************************************************************
**
** Copyright (C) 1993-2009 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/
#pragma once
#ifndef INSTANCEPROPERTYCORESYSTEMH
#define INSTANCEPROPERTYCORESYSTEMH

#include "Qt3DSDMSlides.h"
#include "Qt3DSDMAnimation.h"
#include "Qt3DSDMSignals.h"
#include "Qt3DSDMDataCore.h"

namespace qt3dsdm {

typedef std::tuple<Qt3DSDMInstanceHandle, Qt3DSDMPropertyHandle, SValue> TTemporaryPropertyValue;
typedef std::vector<TTemporaryPropertyValue> TTemporaryPropertyValueList;

/**
 *	Get/set instance properties taking the slide and slide graph, and animation systems into
 *account.
 *	Also takes care of notifying external entities when a property changes.
 */
class CStudioPropertySystem : public IPropertySystem
{
    std::shared_ptr<IMetaData> m_MetaData;
    TDataCorePtr m_DataCore;

    TSlideSystemPtr m_SlideSystem;
    TStudioAnimationSystemPtr m_StudioAnimationSystem;

    TSignalItemPtr m_PropertyCoreSignaller;
    TSignalItemPtr m_ImmediateModePropertyCoreSignaller;

public:
    CStudioPropertySystem(std::shared_ptr<IMetaData> inMetaData, TDataCorePtr inDataCore,
                          TSlideSystemPtr inSlideSystem,
                          TStudioAnimationSystemPtr inStudioAnimationSystem);

    IInstancePropertyCoreSignalProvider *GetPropertyCoreSignalProvider()
    {
        return dynamic_cast<IInstancePropertyCoreSignalProvider *>(m_PropertyCoreSignaller.get());
    }
    // The immediate signaller is used before changes have been committed for very live feedback.
    IInstancePropertyCoreSignalProvider *GetImmediatePropertyCoreSignalProvider()
    {
        return dynamic_cast<IInstancePropertyCoreSignalProvider *>(
            m_ImmediateModePropertyCoreSignaller.get());
    }

    IInstancePropertyCoreSignalSender *GetPropertyCoreSignalSender()
    {
        return dynamic_cast<IInstancePropertyCoreSignalSender *>(m_PropertyCoreSignaller.get());
    }

    DataModelDataType::Value GetDataType(Qt3DSDMPropertyHandle inProperty) const override;
    TCharStr GetName(Qt3DSDMPropertyHandle inProperty) const override;
    TCharStr GetFormalName(Qt3DSDMInstanceHandle inInstance,
                                   Qt3DSDMPropertyHandle inProperty) const override;
    virtual AdditionalMetaDataType::Value
    GetAdditionalMetaDataType(Qt3DSDMInstanceHandle inInstance,
                              Qt3DSDMPropertyHandle inProperty) const override;
    TMetaDataData GetAdditionalMetaDataData(Qt3DSDMInstanceHandle inInstance,
                                                    Qt3DSDMPropertyHandle inProperty) const override;
    Qt3DSDMInstanceHandle GetPropertyOwner(Qt3DSDMPropertyHandle inProperty) const override;

    Qt3DSDMPropertyHandle GetAggregateInstancePropertyByName(Qt3DSDMInstanceHandle inInstance,
                                                                    const TCharStr &inStr) const override;
    void GetAggregateInstanceProperties(Qt3DSDMInstanceHandle inInstance,
                                                TPropertyHandleList &outProperties) const override;
    bool HasAggregateInstanceProperty(Qt3DSDMInstanceHandle inInstance,
                                              Qt3DSDMPropertyHandle inProperty) const override;

    bool GetInstancePropertyValue(Qt3DSDMInstanceHandle inInstance,
                                          Qt3DSDMPropertyHandle inProperty, SValue &outValue) const override;
    void SetInstancePropertyValue(Qt3DSDMInstanceHandle inInstance,
                                          Qt3DSDMPropertyHandle inProperty, const SValue &inValue) override;

    Qt3DSDMInstanceHandle CreateInstance() override;
    void GetInstances(TInstanceHandleList &outInstances) const override;
    void DeleteInstance(Qt3DSDMInstanceHandle inHandle) override;

    void DeriveInstance(Qt3DSDMInstanceHandle inInstance, Qt3DSDMInstanceHandle inParent) override;
    bool IsInstanceOrDerivedFrom(Qt3DSDMInstanceHandle inInstance,
                                         Qt3DSDMInstanceHandle inParent) const override;

    Qt3DSDMPropertyHandle AddProperty(Qt3DSDMInstanceHandle inInstance, TCharPtr inName,
                                             DataModelDataType::Value inPropType) override;
    bool HandleValid(int inHandle) const override;

    // Get the instance property value from the slide that owns the instance or the data core if the
    // slide doesn't have the value
    bool GetCanonicalInstancePropertyValue(Qt3DSDMInstanceHandle inInstance,
                                           Qt3DSDMPropertyHandle inProperty, SValue &outValue) const;

    QVector<Qt3DSDMPropertyHandle> GetControllableProperties(
            Qt3DSDMInstanceHandle inInst) const override;

private:
    static bool DerivedGuidMatches(qt3dsdm::IDataCore &inDataCore,
                                   qt3dsdm::Qt3DSDMInstanceHandle inInstance,
                                   qt3dsdm::Qt3DSDMPropertyHandle inProperty, qt3dsdm::SLong4 inGuid);
    CStudioPropertySystem(const CStudioPropertySystem&) = delete;
    CStudioPropertySystem& operator=(const CStudioPropertySystem&) = delete;
};
}

#endif