2018-11-05 15:47:21 +00:00
|
|
|
#ifndef DUST3D_POSE_DOCUMENT_H
|
|
|
|
#define DUST3D_POSE_DOCUMENT_H
|
|
|
|
#include <map>
|
|
|
|
#include <QString>
|
|
|
|
#include <deque>
|
|
|
|
#include "skeletondocument.h"
|
|
|
|
#include "rigger.h"
|
|
|
|
|
|
|
|
struct PoseHistoryItem
|
|
|
|
{
|
|
|
|
std::map<QString, std::map<QString, QString>> parameters;
|
|
|
|
};
|
|
|
|
|
|
|
|
class PoseDocument : public SkeletonDocument
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
signals:
|
|
|
|
void turnaroundChanged();
|
|
|
|
void cleanup();
|
|
|
|
void nodeAdded(QUuid nodeId);
|
|
|
|
void edgeAdded(QUuid edgeId);
|
|
|
|
void nodeOriginChanged(QUuid nodeId);
|
|
|
|
void parametersChanged();
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool undoable() const override;
|
|
|
|
bool redoable() const override;
|
|
|
|
bool hasPastableNodesInClipboard() const override;
|
|
|
|
bool originSettled() const override;
|
|
|
|
bool isNodeEditable(QUuid nodeId) const override;
|
|
|
|
bool isEdgeEditable(QUuid edgeId) const override;
|
2019-03-03 00:05:13 +00:00
|
|
|
bool isNodeDeactivated(QUuid nodeId) const override;
|
|
|
|
bool isEdgeDeactivated(QUuid edgeId) const override;
|
2018-11-05 15:47:21 +00:00
|
|
|
void copyNodes(std::set<QUuid> nodeIdSet) const override;
|
|
|
|
|
|
|
|
void updateTurnaround(const QImage &image);
|
2019-03-03 00:05:13 +00:00
|
|
|
void updateOtherFramesParameters(const std::vector<std::map<QString, std::map<QString, QString>>> &otherFramesParameters);
|
2018-11-05 15:47:21 +00:00
|
|
|
void reset();
|
|
|
|
|
2018-11-09 03:20:48 +00:00
|
|
|
void toParameters(std::map<QString, std::map<QString, QString>> ¶meters, const std::set<QUuid> &limitNodeIds=std::set<QUuid>()) const;
|
2018-11-05 15:47:21 +00:00
|
|
|
void fromParameters(const std::vector<RiggerBone> *rigBones,
|
|
|
|
const std::map<QString, std::map<QString, QString>> ¶meters);
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void saveHistoryItem();
|
2018-11-09 03:20:48 +00:00
|
|
|
void clearHistories();
|
2018-11-05 15:47:21 +00:00
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
|
|
|
void paste() override;
|
|
|
|
|
|
|
|
void moveNodeBy(QUuid nodeId, float x, float y, float z);
|
|
|
|
void setNodeOrigin(QUuid nodeId, float x, float y, float z);
|
2018-11-09 23:56:58 +00:00
|
|
|
void switchChainSide(const std::set<QUuid> nodeIds);
|
2018-11-05 15:47:21 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static const float m_nodeRadius;
|
|
|
|
static const float m_groundPlaneHalfThickness;
|
2018-11-07 08:02:55 +00:00
|
|
|
static const bool m_hideRootAndVirtual;
|
2018-11-07 14:48:24 +00:00
|
|
|
static const float m_outcomeScaleFactor;
|
2018-11-05 15:47:21 +00:00
|
|
|
|
|
|
|
private:
|
2018-11-09 23:56:58 +00:00
|
|
|
QString findBoneNameByNodeId(const QUuid &nodeId);
|
2018-11-10 16:05:49 +00:00
|
|
|
float findFootBottomY() const;
|
2019-03-03 00:05:13 +00:00
|
|
|
void parametersToNodes(const std::vector<RiggerBone> *rigBones,
|
|
|
|
std::map<QString, std::pair<QUuid, QUuid>> *boneNameToIdsMap,
|
|
|
|
QUuid *bonesPartId,
|
|
|
|
bool isOther=false);
|
2019-06-10 09:25:35 +00:00
|
|
|
void updateBonesFromParameters(std::vector<RiggerBone> *bones,
|
|
|
|
const std::map<QString, std::map<QString, QString>> ¶meters,
|
|
|
|
float firstSpineBoneLength,
|
|
|
|
QVector3D firstSpineBonePosition);
|
2018-11-09 23:56:58 +00:00
|
|
|
|
2018-11-05 15:47:21 +00:00
|
|
|
std::map<QString, std::pair<QUuid, QUuid>> m_boneNameToIdsMap;
|
|
|
|
QUuid m_bonesPartId;
|
|
|
|
std::deque<PoseHistoryItem> m_undoItems;
|
|
|
|
std::deque<PoseHistoryItem> m_redoItems;
|
|
|
|
std::vector<RiggerBone> m_riggerBones;
|
2019-03-03 00:05:13 +00:00
|
|
|
std::vector<std::map<QString, std::map<QString, QString>>> m_otherFramesParameters;
|
|
|
|
std::set<QUuid> m_otherIds;
|
2018-11-07 08:02:55 +00:00
|
|
|
|
|
|
|
static float fromOutcomeX(float x);
|
|
|
|
static float toOutcomeX(float x);
|
|
|
|
static float fromOutcomeY(float y);
|
|
|
|
static float toOutcomeY(float y);
|
|
|
|
static float fromOutcomeZ(float z);
|
|
|
|
static float toOutcomeZ(float z);
|
2019-06-10 09:25:35 +00:00
|
|
|
static void firstSpinePositionAndLengthFromParameters(const std::map<QString, std::map<QString, QString>> ¶meters,
|
|
|
|
float *length, QVector3D *position);
|
2018-11-05 15:47:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|