summaryrefslogtreecommitdiffstats
path: root/src/Runtime/ogl-runtime/src/dm/systems/SlideSystem.h
blob: 1ea3f81653a9fe4acee90f9721abc81ae2a740ba (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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
/****************************************************************************
**
** 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 SLIDESYSTEMH
#define SLIDESYSTEMH
#include "Qt3DSDMDataCore.h"
#include "Qt3DSDMSlideCore.h"
#include "Qt3DSDMSlideGraphCore.h"
#include "Qt3DSDMTransactions.h"
#include "Qt3DSDMSlides.h"
#include "Qt3DSDMAnimation.h"
#include "StudioPropertySystem.h"
#include "SignalsImpl.h"

/**
 *	The systems aggregate the various cores and provide further information or
 *	integrity checking taking the various cores into account.
 */

namespace qt3dsdm {

typedef std::pair<Qt3DSDMPropertyHandle, TPropertyInstanceInfoPtr> TPropertyHandlePropertyInfoPair;
typedef std::vector<TPropertyHandlePropertyInfoPair> TPropertyHandlePropertyInfoPairList;
/**
 *	Provides more thorough checking and will return an appropriate
 *	slide graph when calling GetSlideGraph
 */
struct SSlideSystem : public ISlideSystem
{
    Q_DISABLE_COPY(SSlideSystem)

    TDataCorePtr m_DataCore; // TODO: We might want to throw this away and use the PropertySystem,
                             // unless we have a clean seperate of IPropertySystem and IDataCore
    TPropertySystemPtr m_PropertySystem;
    TSlideCorePtr m_SlideCore;
    TSlideGraphCorePtr m_SlideGraphCore;
    TAnimationCorePtr m_AnimationCore;
    Qt3DSDMInstanceHandle m_SlideInstance;
    Qt3DSDMPropertyHandle m_ComponentGuid;
    std::shared_ptr<ISignalItem> m_Signaller;
    TPropertyHandlePropertyInfoPairList m_PropertyInfoPairList;
    typedef std::unordered_map<int, int> TIntIntMap;
    TIntIntMap m_SlideSelectedInstances;

    SSlideSystem(TDataCorePtr inDataCore, TSlideCorePtr inSlideCore,
                 TSlideGraphCorePtr inSlideGraphCore, TAnimationCorePtr inAnimationCore,
                 Qt3DSDMInstanceHandle inSlideInstance,
                 Qt3DSDMPropertyHandle inComponentGuidProperty);

    void SetPropertySystem(TPropertySystemPtr inPropertySystem);

    Qt3DSDMSlideHandle CreateMasterSlide() override;
    Qt3DSDMSlideHandle CreateSlide(Qt3DSDMSlideHandle inMaster, int inIndex = -1) override;
    Qt3DSDMSlideHandle DuplicateSlide(Qt3DSDMSlideHandle inSourceSlide, int inDestIndex = -1) override;
    Qt3DSDMSlideHandle GetMasterSlide(Qt3DSDMSlideHandle inSlide) const override;
    bool IsMasterSlide(Qt3DSDMSlideHandle inSlide) const override;
    Qt3DSDMSlideHandle GetMasterSlideByComponentGuid(SLong4 inGuid) const override;
    // Indexes are 1 based.  Index 0 refers to the master slide; you can't delete this.
    void DeleteSlideByIndex(Qt3DSDMSlideHandle inMaster, size_t inIndex) override;
    void GetSlideReferencedInstances(Qt3DSDMSlideHandle inMaster, size_t inIndex,
                                             TInstanceHandleList &outReferencedInstances) override;
    Qt3DSDMSlideHandle GetSlideByIndex(Qt3DSDMSlideHandle inMaster, size_t inIndex) const override;
    void SetActiveSlide(Qt3DSDMSlideHandle inMaster, size_t inIndex) override;
    size_t GetSlideCount(Qt3DSDMSlideHandle inMaster) const override;
    void RearrangeSlide(Qt3DSDMSlideHandle inMaster, size_t inOldIndex, size_t inNewIndex) override;

    void SetComponentSeconds(Qt3DSDMSlideHandle inSlide, float inSeconds) override;
    float GetComponentSeconds(Qt3DSDMSlideHandle inSlide) const override;
    long GetComponentSecondsLong(Qt3DSDMSlideHandle inSlide) const override;
    // For any given instance, find the current seconds via backtracking to the graph, finding the
    // active
    // slide, and return.
    long GetComponentSecondsLong(Qt3DSDMInstanceHandle inInstance) const override;
    virtual SInstanceSlideInformation
    GetInstanceSlideInformation(Qt3DSDMInstanceHandle inInstance) const override;
    /**
     * Use the instance for storing information such as name, or the GUID of the object
     * this slide links to.
     */
    Qt3DSDMInstanceHandle GetSlideInstance(Qt3DSDMSlideHandle inInstance) const override;
    /**
     *	Reverse lookup into the slide system so you can match slides to instances.
     */
    Qt3DSDMSlideHandle GetSlideByInstance(Qt3DSDMInstanceHandle inInstance) const override;

    /**
     *	Slide may be either a master slide or a normal slide.  This will associate this instance
     *	with this set of slides.  Property lookups (using the above IInstancePropertyCore interface)
     *	will now run through the slide set before hitting the main data core database.
     */
    void AssociateInstanceWithSlide(Qt3DSDMSlideHandle inSlide,
                                            Qt3DSDMInstanceHandle inInstance) override;
    Qt3DSDMSlideHandle GetAssociatedSlide(Qt3DSDMInstanceHandle inInstance) const override;
    void GetAssociatedInstances(
        Qt3DSDMSlideHandle inMaster,
        std::vector<std::pair<Qt3DSDMSlideHandle, Qt3DSDMInstanceHandle>> &outAssociations) const override;
    void GetAssociatedInstances(Qt3DSDMSlideHandle inSlide,
                                        TInstanceHandleList &outAssociations) const override;
    void LinkProperty(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) override;
    void UnlinkProperty(Qt3DSDMInstanceHandle inInstance, Qt3DSDMPropertyHandle inProperty) override;
    bool IsPropertyLinked(Qt3DSDMInstanceHandle inInstance,
                                  Qt3DSDMPropertyHandle inProperty) const override;
    bool CanPropertyBeLinked(Qt3DSDMInstanceHandle inInstance,
                                     Qt3DSDMPropertyHandle inProperty) const override;
    bool GetSlidePropertyValue(size_t inSlide, Qt3DSDMInstanceHandle inInstance,
                                       Qt3DSDMPropertyHandle inProperty, SValue &outValue) override;
    void GetUnionOfProperties(Qt3DSDMSlideHandle inSlide1, Qt3DSDMSlideHandle inSlide,
                                      TInstancePropertyPairList &outProperties) const override;

    void SetActiveSlide(Qt3DSDMSlideHandle inSlide) override;
    Qt3DSDMSlideHandle GetAssociatedSlide(Qt3DSDMInstanceHandle inInstance,
                                                 Qt3DSDMPropertyHandle inProperty) const override;

    bool SlideValid(Qt3DSDMSlideHandle inSlide) const override;
    int GetSlideIndex(Qt3DSDMSlideHandle inSlide) const override;
    int GetActiveSlideIndex(Qt3DSDMSlideHandle inMaster) const override;
    Qt3DSDMSlideHandle GetActiveSlide(Qt3DSDMSlideHandle inMaster) const override;
    Qt3DSDMInstanceHandle GetSlideSelectedInstance(Qt3DSDMSlideHandle inSlide) const override;
    void SetSlideSelectedInstance(Qt3DSDMSlideHandle inSlide, Qt3DSDMInstanceHandle inInstance) override;

    Qt3DSDMSlideHandle GetApplicableSlide(Qt3DSDMInstanceHandle inHandle) override;
    Qt3DSDMSlideHandle GetApplicableSlide(Qt3DSDMInstanceHandle inHandle,
                                                 Qt3DSDMPropertyHandle inProperty) override;

    bool GetInstancePropertyValue(Qt3DSDMSlideHandle inSlide,
                                          Qt3DSDMInstanceHandle inInstance,
                                          Qt3DSDMPropertyHandle inProperty, SValue &outValue) const override;
    bool GetCanonicalInstancePropertyValue(Qt3DSDMInstanceHandle inInstance,
                                                   Qt3DSDMPropertyHandle inProperty,
                                                   SValue &outValue) const override;
    void ForceSetInstancePropertyValue(Qt3DSDMSlideHandle inSlide,
                                               Qt3DSDMInstanceHandle inInstance,
                                               Qt3DSDMPropertyHandle inProperty,
                                               const SValue &inValue) override;

    void RegisterPropertyInstance(Qt3DSDMPropertyHandle inPropertyHandle,
                                          TPropertyInstanceInfoPtr inPropertyInfo) override;

    virtual ISlideSystemSignalProvider *GetSignalProvider();

private:
    virtual ISlideSystemSignalSender *GetSignalSender();
    // helper method
    void InsertEntryAndPropertyInstance(const TSlideEntry &inEntry,
                                        TInstanceHandleList &inInstances,
                                        Qt3DSDMSlideHandle inSlide);
    void DeleteReferencedInstances(Qt3DSDMSlideHandle inSlide);
    void GetReferencedInstances(Qt3DSDMSlideHandle inSlide,
                                TInstanceHandleList &outReferencedInstances);
};
}

#endif