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