|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef SKELETON_TOOL_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define SKELETON_TOOL_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tgeometry.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tproperty.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/hook.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/skeleton.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qcoreapplication></qcoreapplication>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace SkeletonSubtools {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class DragTool;
|
|
Toshihiro Shimizu |
890ddd |
class CommandHandler;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class HookData {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
int m_columnIndex;
|
|
Shinya Kitaoka |
120a6e |
int m_hookId; // 0=center (e.g. B,C,...), 1,2... = hook
|
|
Shinya Kitaoka |
120a6e |
TPointD m_pos;
|
|
Shinya Kitaoka |
120a6e |
std::string m_name; // name visualized in the balloons
|
|
Shinya Kitaoka |
120a6e |
bool m_isPivot; // true if this is the level "pivot", i.e. the current handle
|
|
Shinya Kitaoka |
120a6e |
HookData(TXsheet *xsh, int columnIndex, int hookId, const TPointD &pos);
|
|
Shinya Kitaoka |
120a6e |
std::string getHandle() const { return m_hookId > 0 ? "H" + m_name : m_name; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class MagicLink {
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
HookData m_h0, m_h1;
|
|
Shinya Kitaoka |
120a6e |
double m_dist2;
|
|
Shinya Kitaoka |
120a6e |
MagicLink(const HookData &h0, const HookData &h1, double dist2)
|
|
Shinya Kitaoka |
120a6e |
: m_h0(h0), m_h1(h1), m_dist2(dist2) {}
|
|
Shinya Kitaoka |
120a6e |
bool operator<(const MagicLink &link) const { return m_dist2 < link.m_dist2; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
shun-iwasawa |
ce90c2 |
} // namespace SkeletonSubtools
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class SkeletonTool : public TTool {
|
|
Shinya Kitaoka |
120a6e |
Q_DECLARE_TR_FUNCTIONS(SkeletonTool)
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SkeletonSubtools::DragTool *m_dragTool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD m_lastPos;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_curPos;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_firstPos;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_curCenter;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_parentProbe;
|
|
Shinya Kitaoka |
120a6e |
bool m_parentProbeEnabled;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool m_active;
|
|
Shinya Kitaoka |
120a6e |
bool m_firstTime;
|
|
Shinya Kitaoka |
120a6e |
int m_device;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TEnumProperty m_mode;
|
|
Shinya Kitaoka |
120a6e |
TBoolProperty m_showOnlyActiveSkeleton;
|
|
Shinya Kitaoka |
120a6e |
TBoolProperty m_globalKeyframes;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPropertyGroup m_prop;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<skeletonsubtools::magiclink> m_magicLinks;</skeletonsubtools::magiclink>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::set<int> m_temporaryPinnedColumns;</int>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int m_currentFrame;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SkeletonSubtools::CommandHandler *m_commandHandler;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// column currently selected, during a click&drag operation
|
|
Shinya Kitaoka |
120a6e |
int m_otherColumn;
|
|
Shinya Kitaoka |
120a6e |
TRectD m_otherColumnBBox;
|
|
Shinya Kitaoka |
120a6e |
TAffine m_otherColumnBBoxAff;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD m_labelPos;
|
|
Shinya Kitaoka |
120a6e |
std::string m_label;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
SkeletonTool();
|
|
Shinya Kitaoka |
120a6e |
~SkeletonTool();
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
ToolType getToolType() const override { return TTool::ColumnTool; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
void updateTranslation() override; // QString localization stuff
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool doesApply() const; // ritorna vero se posso deformare l'oggetto corrente
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
void onEnter() override {}
|
|
artisteacher |
fd1c1e |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
artisteacher |
fd1c1e |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
artisteacher |
fd1c1e |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
|
artisteacher |
fd1c1e |
void mouseMove(const TPointD &, const TMouseEvent &e) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
void onImageChanged() override { invalidate(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
void reset() override { m_temporaryPinnedColumns.clear(); }
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
bool onPropertyChanged(std::string propertyName) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
void draw() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void drawSkeleton(const Skeleton &skeleton, int row);
|
|
Shinya Kitaoka |
120a6e |
void drawLevelBoundingBox(int frame, int columnIndex);
|
|
Shinya Kitaoka |
120a6e |
void getImageBoundingBox(TRectD &bbox, TAffine &aff, int frame,
|
|
Shinya Kitaoka |
120a6e |
int columnIndex);
|
|
Shinya Kitaoka |
120a6e |
void drawIKJoint(const Skeleton::Bone *bone);
|
|
Shinya Kitaoka |
120a6e |
void drawJoint(const TPointD &p, bool current);
|
|
Shinya Kitaoka |
120a6e |
void drawBone(const TPointD &a, const TPointD &b, bool selected);
|
|
Shinya Kitaoka |
120a6e |
void drawIKBone(const TPointD &a, const TPointD &b);
|
|
Shinya Kitaoka |
120a6e |
void drawMainGadget(const TPointD ¢er);
|
|
Shinya Kitaoka |
120a6e |
void drawDrawingBrowser(const TXshCell &cell, const TPointD ¢er);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setParentProbe(const TPointD &parentProbe) {
|
|
Shinya Kitaoka |
120a6e |
m_parentProbe = parentProbe;
|
|
Shinya Kitaoka |
120a6e |
m_parentProbeEnabled = true;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void resetParentProbe() { m_parentProbeEnabled = false; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void drawHooks();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void computeMagicLinks();
|
|
Toshihiro Shimizu |
890ddd |
|
|
shun-iwasawa |
7f1e30 |
bool keyDown(QKeyEvent *event) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
void onActivate() override;
|
|
artisteacher |
fd1c1e |
void onDeactivate() override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
int getMagicLinkCount() const { return (int)m_magicLinks.size(); }
|
|
Shinya Kitaoka |
120a6e |
SkeletonSubtools::MagicLink getMagicLink(int index) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void magicLink(int index);
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
int getCursorId() const override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
// TRaster32P getToolIcon() const {return Pixmaps::arrow;}
|
|
artisteacher |
fd1c1e |
TPropertyGroup *getProperties(int targetType) override { return &m_prop; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
artisteacher |
fd1c1e |
void updateMatrix() override { setMatrix(getCurrentObjectParentMatrix()); }
|
|
artisteacher |
fd1c1e |
void addContextMenuItems(QMenu *menu) override;
|
|
Shinya Kitaoka |
120a6e |
bool select(const TSelection *) { return false; }
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void togglePinnedStatus(int columnIndex, int frame, bool shiftPressed);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void buildSkeleton(Skeleton &skeleton, int columnIndex);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setTemporaryPinnedColumns(const std::set<int> &tmp) {</int>
|
|
Shinya Kitaoka |
120a6e |
m_temporaryPinnedColumns = tmp;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
bool isGlobalKeyframesEnabled() const;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|