Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef STROKE_SELECTION_H
Toshihiro Shimizu 890ddd
#define STROKE_SELECTION_H
Toshihiro Shimizu 890ddd
Shinya Kitaoka e5734a
#include <memory></memory>
Shinya Kitaoka e5734a
Toshihiro Shimizu 890ddd
// TnzQt includes
Toshihiro Shimizu 890ddd
#include "toonzqt/selection.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "tvectorimage.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// STD includes
Toshihiro Shimizu 890ddd
#include <set></set>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZTOOLS_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//    Forward declarations
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
class TGroupCommand;
Toshihiro Shimizu 890ddd
class TSceneHandle;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=========================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//****************************************************************************
Toshihiro Shimizu 890ddd
//    StrokeSelection  declaration
Toshihiro Shimizu 890ddd
//****************************************************************************
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI StrokeSelection final : public TSelection {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  typedef std::set<int> IndexesContainer;</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  StrokeSelection();
Shinya Kitaoka 120a6e
  ~StrokeSelection();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  StrokeSelection(const StrokeSelection &other);
Shinya Kitaoka 120a6e
  StrokeSelection &operator=(const StrokeSelection &other);
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  TGroupCommand *getGroupCommand() { return m_groupCommand.get(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setImage(const TVectorImageP &image) { m_vi = image; }
Shinya Kitaoka 120a6e
  const TVectorImageP &getImage() const { return m_vi; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  const IndexesContainer &getSelection() const { return m_indexes; }
Shinya Kitaoka 120a6e
  IndexesContainer &getSelection() { return m_indexes; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  bool isEmpty() const override { return m_indexes.empty(); }
Shinya Kitaoka 120a6e
  bool updateSelectionBBox() const { return m_updateSelectionBBox; }
Shinya Kitaoka 120a6e
  bool isSelected(int index) const { return (m_indexes.count(index) > 0); }
Shinya Kitaoka 120a6e
  void select(int index, bool on);
Shinya Kitaoka 120a6e
  void toggle(int index);
Shinya Kitaoka 473e70
  void selectNone() override { m_indexes.clear(); }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void setSceneHandle(TSceneHandle *tsh) { m_sceneHandle = tsh; }
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  // Commands
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void changeColorStyle(int styleIndex);
Shinya Kitaoka 120a6e
  void deleteStrokes();
Shinya Kitaoka 120a6e
  void copy();
Shinya Kitaoka 120a6e
  void cut();
Shinya Kitaoka 120a6e
  void paste();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  void removeEndpoints();
Toshihiro Shimizu 890ddd
Shinya Kitaoka 473e70
  void enableCommands() override;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  TVectorImageP m_vi;          //!< Selected vector image.
Shinya Kitaoka 120a6e
  IndexesContainer m_indexes;  //!< Selected stroke indexes in m_vi.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::unique_ptr<tgroupcommand> m_groupCommand;  //!< Groups commands wrapper.</tgroupcommand>
Shinya Kitaoka 120a6e
  TSceneHandle *m_sceneHandle;  //!< Global scene handle. \deprecated  Use
Shinya Kitaoka 38fd86
                                //! TApplication instead.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  /*!Set this boolean to true before call tool->notifyImageChanged() when you
Shinya Kitaoka 120a6e
want to reset strokes bbox.
Shinya Kitaoka 120a6e
N.B. after call tool->notifyImageChanged() set m_updateSelectionBBox to false.*/
Shinya Kitaoka 120a6e
  bool m_updateSelectionBBox;
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // STROKE_SELECTION_H