|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef SKELETON_SUBTOOLS_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
#define SKELETON_SUBTOOLS_INCLUDED
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "tools/tool.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txsheet.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/skeleton.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/stageobjectutil.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/ikengine.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <qobject></qobject>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class SkeletonTool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
namespace SkeletonSubtools {
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DragTool {
|
|
Shinya Kitaoka |
120a6e |
SkeletonTool *m_tool;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DragTool(SkeletonTool *tool) : m_tool(tool) {}
|
|
Shinya Kitaoka |
120a6e |
virtual ~DragTool() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void draw() {}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonDown(const TPointD &pos, const TMouseEvent &) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonDrag(const TPointD &pos, const TMouseEvent &) = 0;
|
|
Shinya Kitaoka |
120a6e |
virtual void leftButtonUp(const TPointD &pos, const TMouseEvent &) = 0;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
SkeletonTool *getTool() const { return m_tool; }
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DragCenterTool final : public DragTool {
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId m_objId;
|
|
Shinya Kitaoka |
120a6e |
int m_frame;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
TPointD m_firstPos;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_oldCenter;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_center;
|
|
Shinya Kitaoka |
120a6e |
TAffine m_affine;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DragCenterTool(SkeletonTool *tool);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
class DragChannelTool : public DragTool {
|
|
Toshihiro Shimizu |
890ddd |
protected:
|
|
Shinya Kitaoka |
120a6e |
TStageObjectValues m_before, m_after;
|
|
Shinya Kitaoka |
120a6e |
bool m_dragged;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DragChannelTool(SkeletonTool *tool, TStageObject::Channel a0);
|
|
Shinya Kitaoka |
120a6e |
DragChannelTool(SkeletonTool *tool, TStageObject::Channel a0,
|
|
Shinya Kitaoka |
120a6e |
TStageObject::Channel a1);
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
void start();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TPointD getCenter();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double getOldValue(int index) const { return m_before.getValue(index); }
|
|
Shinya Kitaoka |
120a6e |
double getValue(int index) const { return m_after.getValue(index); }
|
|
Shinya Kitaoka |
120a6e |
void setValue(double v) {
|
|
Shinya Kitaoka |
120a6e |
m_after.setValue(v);
|
|
Shinya Kitaoka |
120a6e |
m_after.applyValues();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
void setValues(double v0, double v1) {
|
|
Shinya Kitaoka |
120a6e |
m_after.setValues(v0, v1);
|
|
Shinya Kitaoka |
120a6e |
m_after.applyValues();
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DragPositionTool final : public DragChannelTool {
|
|
Shinya Kitaoka |
120a6e |
TPointD m_firstPos;
|
|
Jeremy Bullock |
66c844 |
bool m_firstDrag = false;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DragPositionTool(SkeletonTool *tool);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class DragRotationTool final : public DragChannelTool {
|
|
Shinya Kitaoka |
120a6e |
TPointD m_lastPos;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_center;
|
|
Shinya Kitaoka |
120a6e |
bool m_snapped;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
DragRotationTool(SkeletonTool *tool, bool snapped);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &) override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class ParentChangeTool final : public DragTool {
|
|
Shinya Kitaoka |
120a6e |
TTool::Viewer *m_viewer;
|
|
shun_iwasawa |
bc352c |
TPointD m_firstWinPos;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_lastPos, m_lastPos2;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_center;
|
|
Shinya Kitaoka |
120a6e |
int m_index;
|
|
Shinya Kitaoka |
120a6e |
int m_handle;
|
|
Shinya Kitaoka |
120a6e |
bool m_snapped;
|
|
Shinya Kitaoka |
120a6e |
int m_mode;
|
|
Shinya Kitaoka |
120a6e |
TAffine m_affine;
|
|
Shinya Kitaoka |
120a6e |
TStageObjectId m_objId;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_oldCenter, m_oldOffset;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
struct Peer {
|
|
Shinya Kitaoka |
120a6e |
TPointD m_pos;
|
|
Shinya Kitaoka |
120a6e |
int m_columnIndex;
|
|
Shinya Kitaoka |
120a6e |
int m_handle; // 0=centerB,-1,-2,....=H1,H2...
|
|
Shinya Kitaoka |
120a6e |
int m_name; // per glPushName()
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
struct Element {
|
|
Shinya Kitaoka |
120a6e |
int m_columnIndex;
|
|
Shinya Kitaoka |
120a6e |
TRectD m_bbox;
|
|
Shinya Kitaoka |
120a6e |
TAffine m_aff;
|
|
Shinya Kitaoka |
120a6e |
std::vector<peer> m_peers;</peer>
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
std::map<int, element=""> m_elements;</int,>
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
double m_pixelSize;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ParentChangeTool(SkeletonTool *tool, TTool::Viewer *viewer);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &pos, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &pos, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &pos, const TMouseEvent &e) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void draw() override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
class IKToolUndo;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class IKTool final : public DragTool {
|
|
Shinya Kitaoka |
120a6e |
TTool::Viewer *m_viewer;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_pos;
|
|
Shinya Kitaoka |
120a6e |
Skeleton *m_skeleton;
|
|
Shinya Kitaoka |
120a6e |
int m_columnIndex;
|
|
Shinya Kitaoka |
120a6e |
IKEngine m_engine;
|
|
Shinya Kitaoka |
120a6e |
bool m_valid;
|
|
Jeremy Bullock |
66c844 |
bool m_rootInvolved;
|
|
Shinya Kitaoka |
120a6e |
TAffine m_footPlacement, m_firstFootPlacement;
|
|
Shinya Kitaoka |
120a6e |
TStageObject *m_foot, *m_firstFoot;
|
|
Jeremy Bullock |
66c844 |
bool m_frameOnNewPin;
|
|
Shinya Kitaoka |
120a6e |
IKToolUndo *m_undo;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
struct Joint {
|
|
Shinya Kitaoka |
120a6e |
Skeleton::Bone *m_bone, *m_prevBone;
|
|
Shinya Kitaoka |
120a6e |
int m_prevColumnIndex;
|
|
Shinya Kitaoka |
120a6e |
double m_angleOffset;
|
|
Shinya Kitaoka |
120a6e |
double m_sign;
|
|
Shinya Kitaoka |
120a6e |
bool m_active;
|
|
Shinya Kitaoka |
120a6e |
TStageObjectValues m_oldValues;
|
|
Shinya Kitaoka |
120a6e |
Joint()
|
|
Shinya Kitaoka |
120a6e |
: m_bone(0)
|
|
Shinya Kitaoka |
120a6e |
, m_prevBone(0)
|
|
Shinya Kitaoka |
120a6e |
, m_angleOffset(0)
|
|
Shinya Kitaoka |
120a6e |
, m_sign(1)
|
|
Shinya Kitaoka |
120a6e |
, m_active(true) {}
|
|
Shinya Kitaoka |
120a6e |
Joint(Skeleton::Bone *bone, Skeleton::Bone *prevBone, double sign)
|
|
Shinya Kitaoka |
120a6e |
: m_bone(bone)
|
|
Shinya Kitaoka |
120a6e |
, m_prevBone(prevBone)
|
|
Shinya Kitaoka |
120a6e |
, m_angleOffset(0)
|
|
Shinya Kitaoka |
120a6e |
, m_sign(sign)
|
|
Shinya Kitaoka |
120a6e |
, m_active(true) {}
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Shinya Kitaoka |
120a6e |
std::vector<joint> m_joints;</joint>
|
|
Shinya Kitaoka |
120a6e |
bool isParentOf(int columnIndex, int childColumnIndex) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
IKTool(SkeletonTool *tool, TTool::Viewer *viewer, Skeleton *skeleton,
|
|
Shinya Kitaoka |
120a6e |
int columnIndex);
|
|
Shinya Kitaoka |
120a6e |
~IKTool();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void initEngine(const TPointD &pos);
|
|
Shinya Kitaoka |
120a6e |
void storeOldValues();
|
|
Shinya Kitaoka |
120a6e |
void computeIHateIK();
|
|
Shinya Kitaoka |
120a6e |
void setAngleOffsets();
|
|
Shinya Kitaoka |
120a6e |
void apply();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &, const TMouseEvent &e) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void draw() override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class ChangeDrawingTool final : public DragTool {
|
|
Shinya Kitaoka |
120a6e |
int m_oldY;
|
|
Shinya Kitaoka |
120a6e |
int m_dir;
|
|
Shinya Kitaoka |
120a6e |
TUndo *m_undo;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
ChangeDrawingTool(SkeletonTool *tool, int d);
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDown(const TPointD &, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonDrag(const TPointD &, const TMouseEvent &e) override;
|
|
Shinya Kitaoka |
473e70 |
void leftButtonUp(const TPointD &, const TMouseEvent &e) override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
bool changeDrawing(int delta);
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//---------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class CommandHandler final : public QObject {
|
|
Shinya Kitaoka |
120a6e |
Q_OBJECT
|
|
Shinya Kitaoka |
120a6e |
Skeleton *m_skeleton;
|
|
Shinya Kitaoka |
120a6e |
std::set<int> *m_tempPinnedSet;</int>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
CommandHandler();
|
|
Shinya Kitaoka |
120a6e |
~CommandHandler();
|
|
Shinya Kitaoka |
120a6e |
void setTempPinnedSet(std::set<int> *tempPinnedSet) {</int>
|
|
Shinya Kitaoka |
120a6e |
m_tempPinnedSet = tempPinnedSet;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void setSkeleton(Skeleton *skeleton);
|
|
Toshihiro Shimizu |
890ddd |
public slots:
|
|
Shinya Kitaoka |
120a6e |
void clearPinnedRanges();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
} // namespace SkeletonSubtools
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#endif
|