tahoma2d/toonz/sources/include/tools/strokeselection.h

99 lines
2.5 KiB
C
Raw Normal View History

2016-05-17 03:04:11 +12:00
#pragma once
2016-03-19 06:57:51 +13:00
#ifndef STROKE_SELECTION_H
#define STROKE_SELECTION_H
2016-04-14 19:51:50 +12:00
#include <memory>
2016-03-19 06:57:51 +13:00
// TnzQt includes
#include "toonzqt/selection.h"
// TnzCore includes
#include "tcommon.h"
#include "tvectorimage.h"
// STD includes
#include <set>
#undef DVAPI
#undef DVVAR
#ifdef TNZTOOLS_EXPORTS
#define DVAPI DV_EXPORT_API
#define DVVAR DV_EXPORT_VAR
#else
#define DVAPI DV_IMPORT_API
#define DVVAR DV_IMPORT_VAR
#endif
//=========================================================
// Forward declarations
class TGroupCommand;
class TSceneHandle;
//=========================================================
//****************************************************************************
// StrokeSelection declaration
//****************************************************************************
class DVAPI StrokeSelection final : public TSelection {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
typedef std::set<int> IndexesContainer;
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
StrokeSelection();
~StrokeSelection();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
StrokeSelection(const StrokeSelection &other);
StrokeSelection &operator=(const StrokeSelection &other);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
TGroupCommand *getGroupCommand() { return m_groupCommand.get(); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setImage(const TVectorImageP &image) { m_vi = image; }
const TVectorImageP &getImage() const { return m_vi; }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
const IndexesContainer &getSelection() const { return m_indexes; }
IndexesContainer &getSelection() { return m_indexes; }
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
bool isEmpty() const override { return m_indexes.empty(); }
2016-06-15 18:43:10 +12:00
bool updateSelectionBBox() const { return m_updateSelectionBBox; }
bool isSelected(int index) const { return (m_indexes.count(index) > 0); }
void select(int index, bool on);
void toggle(int index);
2016-06-19 20:06:29 +12:00
void selectNone() override { m_indexes.clear(); }
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void setSceneHandle(TSceneHandle *tsh) { m_sceneHandle = tsh; }
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
// Commands
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void changeColorStyle(int styleIndex);
void deleteStrokes();
void copy();
void cut();
void paste();
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
void removeEndpoints();
2016-03-19 06:57:51 +13:00
2016-06-19 20:06:29 +12:00
void enableCommands() override;
2016-03-19 06:57:51 +13:00
void selectAll();
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
TVectorImageP m_vi; //!< Selected vector image.
IndexesContainer m_indexes; //!< Selected stroke indexes in m_vi.
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
std::unique_ptr<TGroupCommand> m_groupCommand; //!< Groups commands wrapper.
TSceneHandle *m_sceneHandle; //!< Global scene handle. \deprecated Use
2016-06-20 14:23:05 +12:00
//! TApplication instead.
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
/*!Set this boolean to true before call tool->notifyImageChanged() when you
want to reset strokes bbox.
N.B. after call tool->notifyImageChanged() set m_updateSelectionBBox to false.*/
bool m_updateSelectionBBox;
2016-03-19 06:57:51 +13:00
};
2016-06-15 18:43:10 +12:00
#endif // STROKE_SELECTION_H