diff options
Diffstat (limited to 'src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h')
-rw-r--r-- | src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h b/src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h index 0d99aa7f..c07170c2 100644 --- a/src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h +++ b/src/Authoring/Client/Code/Core/Commands/CmdDataModelInsertKeyframe.h @@ -28,13 +28,8 @@ ****************************************************************************/ #ifndef INCLUDED_CMD_DATAMODEL_INSERTKEYFRAME_H -#define INCLUDED_CMD_DATAMODEL_INSERTKEYFRAME_H 1 +#define INCLUDED_CMD_DATAMODEL_INSERTKEYFRAME_H -#pragma once - -//============================================================================== -// Include -//============================================================================== #include "Cmd.h" #include "CmdDataModel.h" #include "Doc.h" @@ -51,74 +46,60 @@ public: struct STimeKeyframeData { qt3dsdm::Qt3DSDMPropertyHandle m_Property; - float m_KeyframeTime; - qt3dsdm::SGetOrSetKeyframeInfo m_Infos[3]; + long m_KeyframeTime; + qt3dsdm::SGetOrSetKeyframeInfo m_Infos[4]; size_t m_ValidInfoCount; - STimeKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, float inKeyframeTime, + STimeKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, long inKeyframeTime, qt3dsdm::SGetOrSetKeyframeInfo *inInfos, size_t inInfoCount) : m_Property(inProperty) , m_KeyframeTime(inKeyframeTime) { - m_ValidInfoCount = inInfoCount <= 3 ? inInfoCount : 3; - for (size_t idx = 0, end = m_ValidInfoCount; idx < end; ++idx) { + m_ValidInfoCount = inInfoCount <= 4 ? inInfoCount : 4; + for (size_t idx = 0, end = m_ValidInfoCount; idx < end; ++idx) m_Infos[idx] = inInfos[idx]; - } } }; protected: typedef std::vector<STimeKeyframeData> TKeyframeDataList; -protected: // Members CDoc *m_Doc; qt3dsdm::Qt3DSDMInstanceHandle m_Instance; TKeyframeDataList m_KeyframeDataList; -public: // Construction - //@param inTime is in secs - CCmdDataModelInsertKeyframe(CDoc *inDoc, qt3dsdm::Qt3DSDMInstanceHandle inInstance, - qt3dsdm::Qt3DSDMPropertyHandle inProperty, float inKeyframeTime, - qt3dsdm::SGetOrSetKeyframeInfo *inInfos, size_t inInfoCount) +public: + CCmdDataModelInsertKeyframe(CDoc *inDoc, qt3dsdm::Qt3DSDMInstanceHandle inInstance) : qt3dsdm::CmdDataModel(*inDoc) , m_Doc(inDoc) - , m_Instance(inInstance) - { - AddKeyframeData(inProperty, inKeyframeTime, inInfos, inInfoCount); - } + , m_Instance(inInstance) {} ~CCmdDataModelInsertKeyframe() {} - void AddKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, float inTime, + void AddKeyframeData(qt3dsdm::Qt3DSDMPropertyHandle inProperty, long inTime, qt3dsdm::SGetOrSetKeyframeInfo *inInfos, size_t inInfoCount) { m_KeyframeDataList.push_back(STimeKeyframeData(inProperty, inTime, inInfos, inInfoCount)); } - //====================================================================== - // Do/Redo - //====================================================================== unsigned long Do() override { if (!ConsumerExists()) { qt3dsdm::SScopedDataModelConsumer __scopedConsumer(*this); qt3dsdm::IStudioAnimationSystem *theAnimationSystem = m_Doc->GetStudioSystem()->GetAnimationSystem(); - // if there are existing keyframes exist at the same times, the values are overridden. ( - // That's how it always work in studio anyways ) - for (size_t i = 0; i < m_KeyframeDataList.size(); ++i) + // Keyframes at same time are overridden (only 1 keyframe allowed at a point in time) + for (size_t i = 0; i < m_KeyframeDataList.size(); ++i) { theAnimationSystem->SetOrCreateKeyframe( m_Instance, m_KeyframeDataList[i].m_Property, m_KeyframeDataList[i].m_KeyframeTime, m_KeyframeDataList[i].m_Infos, m_KeyframeDataList[i].m_ValidInfoCount); + } } else { DataModelRedo(); } return 0; } - //====================================================================== - // Undo - //====================================================================== unsigned long Undo() override { if (ConsumerExists()) { @@ -127,9 +108,6 @@ public: // Construction return 0; } - //====================================================================== - // ToString - //====================================================================== QString ToString() override { return QObject::tr("Insert Keyframe"); |