|
Shinya Kitaoka |
810553 |
#pragma once
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#ifndef HOOK_SELECTION
|
|
Toshihiro Shimizu |
890ddd |
#define HOOK_SELECTION
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/selection.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonzqt/dvmimedata.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/txshlevel.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "toonz/hook.h"
|
|
Toshihiro Shimizu |
890ddd |
#include "tundo.h"
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
#include <set></set>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// HookUndo
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class HookUndo final : public TUndo {
|
|
Shinya Kitaoka |
120a6e |
HookSet m_oldHooks, m_newHooks;
|
|
Shinya Kitaoka |
120a6e |
TXshLevelP m_level;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
HookUndo(const TXshLevelP &level);
|
|
Shinya Kitaoka |
120a6e |
~HookUndo();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void onAdd() override;
|
|
Shinya Kitaoka |
120a6e |
void assignHookSet(const HookSet &src) const;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
void undo() const override;
|
|
Shinya Kitaoka |
473e70 |
void redo() const override;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
int getSize() const override;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// HooksData
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class HooksData final : public DvMimeData {
|
|
Shinya Kitaoka |
120a6e |
struct HookPosition {
|
|
Shinya Kitaoka |
120a6e |
int m_id;
|
|
Shinya Kitaoka |
120a6e |
TPointD m_aPos, m_bPos;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
HookPosition(int id, const TPointD &aPos, const TPointD &bPos)
|
|
Shinya Kitaoka |
120a6e |
: m_id(id), m_aPos(aPos), m_bPos(bPos) {}
|
|
Shinya Kitaoka |
120a6e |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
std::vector<hookposition> m_hookPositions;</hookposition>
|
|
Shinya Kitaoka |
120a6e |
TXshLevelP m_level;
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
HooksData(const TXshLevelP &level);
|
|
Shinya Kitaoka |
120a6e |
~HooksData();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
473e70 |
HooksData *clone() const override;
|
|
Shinya Kitaoka |
120a6e |
void storeHookPositions(const std::vector<int> &ids);</int>
|
|
Shinya Kitaoka |
120a6e |
void restoreHookPositions() const;
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
//=============================================================================
|
|
Toshihiro Shimizu |
890ddd |
// HookSelection
|
|
Toshihiro Shimizu |
890ddd |
//
|
|
Toshihiro Shimizu |
890ddd |
// Derived from TSelection. Control which hooks are currently selected
|
|
Toshihiro Shimizu |
890ddd |
// Note that a hook is made of two different parts (used e.g. to "pass the hook"
|
|
Shinya Kitaoka |
120a6e |
// between the feet in a walking cycle) that can be independently selected
|
|
Shinya Kitaoka |
120a6e |
// (1=A,2=B)
|
|
Toshihiro Shimizu |
890ddd |
//-----------------------------------------------------------------------------
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
d1f6c4 |
class HookSelection final : public TSelection {
|
|
Shinya Kitaoka |
120a6e |
TXshLevelP m_level;
|
|
Shinya Kitaoka |
120a6e |
std::set<std::pair<int, int="">> m_hooks; // hookId, side : 1=A 2=B</std::pair<int,>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Toshihiro Shimizu |
890ddd |
public:
|
|
Shinya Kitaoka |
120a6e |
HookSelection();
|
|
Shinya Kitaoka |
120a6e |
~HookSelection();
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
TSelection *clone() const;
|
|
Shinya Kitaoka |
120a6e |
void setLevel(const TXshLevelP &level) { m_level = level; }
|
|
Shinya Kitaoka |
120a6e |
void select(int id, int side);
|
|
Shinya Kitaoka |
120a6e |
void unselect(int id, int side);
|
|
Shinya Kitaoka |
120a6e |
bool isSelected(int id, int side) const;
|
|
Shinya Kitaoka |
120a6e |
void invertSelection(int id, int side);
|
|
Shinya Kitaoka |
473e70 |
bool isEmpty() const override;
|
|
Shinya Kitaoka |
473e70 |
void selectNone() override { m_hooks.clear(); }
|
|
Shinya Kitaoka |
120a6e |
HookSet *getHookSet() const;
|
|
Shinya Kitaoka |
120a6e |
bool select(const TSelection *s);
|
|
Shinya Kitaoka |
473e70 |
void enableCommands() override;
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
// commands
|
|
Shinya Kitaoka |
120a6e |
void deleteSelectedHooks();
|
|
Shinya Kitaoka |
120a6e |
void copySelectedHooks();
|
|
Shinya Kitaoka |
120a6e |
void cutSelectedHooks();
|
|
Shinya Kitaoka |
120a6e |
void pasteSelectedHooks();
|
|
Toshihiro Shimizu |
890ddd |
};
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
#endif // HOOK_SELECTION
|