2018-10-25 00:19:38 +00:00
|
|
|
#ifndef DUST3D_SNAPSHOT_H
|
|
|
|
#define DUST3D_SNAPSHOT_H
|
2018-03-26 12:41:46 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
#include <QString>
|
|
|
|
#include <QRectF>
|
|
|
|
#include <QSizeF>
|
2018-10-25 06:27:59 +00:00
|
|
|
extern "C" {
|
|
|
|
#include <crc64.h>
|
|
|
|
}
|
2018-03-26 12:41:46 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
class Snapshot
|
2018-03-26 12:41:46 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::map<QString, QString> canvas;
|
|
|
|
std::map<QString, std::map<QString, QString>> nodes;
|
|
|
|
std::map<QString, std::map<QString, QString>> edges;
|
2018-04-07 08:44:39 +00:00
|
|
|
std::map<QString, std::map<QString, QString>> parts;
|
2018-08-27 08:50:40 +00:00
|
|
|
std::map<QString, std::map<QString, QString>> components;
|
|
|
|
std::map<QString, QString> rootComponent;
|
2018-11-09 03:20:48 +00:00
|
|
|
std::vector<std::pair<std::map<QString, QString>, std::vector<std::pair<std::map<QString, QString>, std::map<QString, std::map<QString, QString>>>>>> poses; // std::pair<Pose attributes, frames> frame: std::pair<Frame attributes, Frame parameters>
|
2018-10-23 14:57:47 +00:00
|
|
|
std::vector<std::pair<std::map<QString, QString>, std::vector<std::map<QString, QString>>>> motions; // std::pair<Motion attributes, clips>
|
2018-10-09 02:19:12 +00:00
|
|
|
std::vector<std::pair<std::map<QString, QString>, std::vector<std::pair<std::map<QString, QString>, std::vector<std::map<QString, QString>>>>>> materials; // std::pair<Material attributes, layers> layer: std::pair<Layer attributes, maps>
|
2018-10-25 06:27:59 +00:00
|
|
|
|
|
|
|
uint64_t hash() const
|
|
|
|
{
|
|
|
|
std::vector<unsigned char> buffer;
|
|
|
|
auto addQStringToBuffer = [&buffer](const QString &str) {
|
|
|
|
auto byteArray = str.toUtf8();
|
|
|
|
for (const auto &byte: byteArray)
|
|
|
|
buffer.push_back(byte);
|
|
|
|
};
|
|
|
|
for (const auto &item: canvas) {
|
|
|
|
addQStringToBuffer(item.first);
|
|
|
|
addQStringToBuffer(item.second);
|
|
|
|
}
|
|
|
|
for (const auto &item: nodes) {
|
|
|
|
addQStringToBuffer(item.first);
|
|
|
|
for (const auto &subItem: item.second) {
|
|
|
|
addQStringToBuffer(subItem.first);
|
|
|
|
addQStringToBuffer(subItem.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const auto &item: edges) {
|
|
|
|
addQStringToBuffer(item.first);
|
|
|
|
for (const auto &subItem: item.second) {
|
|
|
|
addQStringToBuffer(subItem.first);
|
|
|
|
addQStringToBuffer(subItem.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const auto &item: parts) {
|
|
|
|
addQStringToBuffer(item.first);
|
|
|
|
for (const auto &subItem: item.second) {
|
|
|
|
addQStringToBuffer(subItem.first);
|
|
|
|
addQStringToBuffer(subItem.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const auto &item: components) {
|
|
|
|
addQStringToBuffer(item.first);
|
|
|
|
for (const auto &subItem: item.second) {
|
|
|
|
addQStringToBuffer(subItem.first);
|
|
|
|
addQStringToBuffer(subItem.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const auto &item: rootComponent) {
|
|
|
|
addQStringToBuffer(item.first);
|
|
|
|
addQStringToBuffer(item.second);
|
|
|
|
}
|
|
|
|
for (const auto &item: poses) {
|
|
|
|
for (const auto &subItem: item.first) {
|
|
|
|
addQStringToBuffer(subItem.first);
|
|
|
|
addQStringToBuffer(subItem.second);
|
|
|
|
}
|
|
|
|
for (const auto &subItem: item.second) {
|
2018-11-09 03:20:48 +00:00
|
|
|
for (const auto &subSubItem: subItem.first) {
|
2018-10-25 06:27:59 +00:00
|
|
|
addQStringToBuffer(subSubItem.first);
|
|
|
|
addQStringToBuffer(subSubItem.second);
|
|
|
|
}
|
2018-11-09 03:20:48 +00:00
|
|
|
for (const auto &subSubItem: subItem.second) {
|
|
|
|
addQStringToBuffer(subSubItem.first);
|
|
|
|
for (const auto &subSubSubItem: subSubItem.second) {
|
|
|
|
addQStringToBuffer(subSubSubItem.first);
|
|
|
|
addQStringToBuffer(subSubSubItem.second);
|
|
|
|
}
|
|
|
|
}
|
2018-10-25 06:27:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const auto &item: motions) {
|
|
|
|
for (const auto &subItem: item.first) {
|
|
|
|
addQStringToBuffer(subItem.first);
|
|
|
|
addQStringToBuffer(subItem.second);
|
|
|
|
}
|
|
|
|
for (const auto &subItem: item.second) {
|
|
|
|
for (const auto &subSubItem: subItem) {
|
|
|
|
addQStringToBuffer(subSubItem.first);
|
|
|
|
addQStringToBuffer(subSubItem.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const auto &item: materials) {
|
|
|
|
for (const auto &subItem: item.first) {
|
|
|
|
addQStringToBuffer(subItem.first);
|
|
|
|
addQStringToBuffer(subItem.second);
|
|
|
|
}
|
|
|
|
for (const auto &subItem: item.second) {
|
|
|
|
for (const auto &subSubItem: subItem.first) {
|
|
|
|
addQStringToBuffer(subSubItem.first);
|
|
|
|
addQStringToBuffer(subSubItem.second);
|
|
|
|
}
|
|
|
|
for (const auto &subSubItem: subItem.second) {
|
|
|
|
for (const auto &subSubSubItem: subSubItem) {
|
|
|
|
addQStringToBuffer(subSubSubItem.first);
|
|
|
|
addQStringToBuffer(subSubSubItem.second);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return crc64(0, buffer.data(), buffer.size());
|
|
|
|
}
|
|
|
|
|
|
|
|
void resolveBoundingBox(QRectF *mainProfile, QRectF *sideProfile, const QString &partId=QString()) const;
|
2018-03-26 12:41:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|