#ifndef DUST3D_POSE_DOCUMENT_H #define DUST3D_POSE_DOCUMENT_H #include #include #include #include "skeletondocument.h" #include "rigger.h" struct PoseHistoryItem { std::map> 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(); void sideVisibleStateChanged(SkeletonSide side); void partVisibleStateChanged(QUuid partId); 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; bool isNodeDeactivated(QUuid nodeId) const override; bool isEdgeDeactivated(QUuid edgeId) const override; void copyNodes(std::set nodeIdSet) const override; void updateTurnaround(const QImage &image); void updateOtherFramesParameters(const std::vector>> &otherFramesParameters); void reset(); void toParameters(std::map> ¶meters, const std::set &limitNodeIds=std::set()) const; void fromParameters(const std::vector *rigBones, const std::map> ¶meters); bool isSideVisible(SkeletonSide side); public slots: void saveHistoryItem(); void clearHistories(); 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); void switchChainSide(const std::set nodeIds); void setSideVisiableState(SkeletonSide side, bool visible); public: static const float m_nodeRadius; static const float m_groundPlaneHalfThickness; static const bool m_hideRootAndVirtual; static const float m_outcomeScaleFactor; private: QString findBoneNameByNodeId(const QUuid &nodeId); float findFootBottomY() const; void parametersToNodes(const std::vector *rigBones, std::map> *boneNameToIdsMap, std::map *m_partIdMap, bool isOther=false); void updateBonesFromParameters(std::vector *bones, const std::map> ¶meters, float firstSpineBoneLength, const QVector3D &firstSpineBonePosition, const QVector3D &neckJoint1BoneDirection); std::map> m_boneNameToIdsMap; std::map m_partIdMap; std::deque m_undoItems; std::deque m_redoItems; std::vector m_riggerBones; std::vector>> m_otherFramesParameters; std::set m_otherIds; std::set m_hiddenSides; 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); static void firstSpinePositionAndLengthFromParameters(const std::map> ¶meters, float *length, QVector3D *position); static void neckJoint1DirectionFromParameters(const std::map> ¶meters, QVector3D *direction); }; #endif