Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef RASTER_SELECTION_H
Toshihiro Shimizu 890ddd
#define RASTER_SELECTION_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzCore includes
Toshihiro Shimizu 890ddd
#include "tcommon.h"
Toshihiro Shimizu 890ddd
#include "tpalette.h"
Toshihiro Shimizu 890ddd
#include "ttoonzimage.h"
Toshihiro Shimizu 890ddd
#include "trasterimage.h"
Toshihiro Shimizu 890ddd
#include "tstroke.h"
Toshihiro Shimizu 890ddd
#include "tdata.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzLib includes
Toshihiro Shimizu 890ddd
#include "toonz/ttileset.h"
Toshihiro Shimizu 890ddd
#include "toonz/txshcell.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
// TnzQt includes
Toshihiro Shimizu 890ddd
#include "toonzqt/selection.h"
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
// forward declaration
Toshihiro Shimizu 890ddd
class TTileSetCM32;
Toshihiro Shimizu 890ddd
class StrokesData;
Toshihiro Shimizu 890ddd
class RasterImageData;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//=============================================================================
Toshihiro Shimizu 890ddd
// RasterSelection
Toshihiro Shimizu 890ddd
//! Selection of TToonzImage and TRasterImage.
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka d1f6c4
class DVAPI RasterSelection final : public TSelection {
Shinya Kitaoka 120a6e
  TImageP m_currentImage;
Shinya Kitaoka 120a6e
  TXshCell m_currentImageCell;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TPaletteP m_oldPalette;
Shinya Kitaoka 120a6e
  TRectD m_selectionBbox;
Shinya Kitaoka 120a6e
  std::vector<tstroke> m_strokes;</tstroke>
Shinya Kitaoka 120a6e
  std::vector<tstroke> m_originalStrokes;</tstroke>
Shinya Kitaoka 120a6e
  TAffine m_affine;
Shinya Kitaoka 120a6e
  TPoint m_startPosition;
Shinya Kitaoka 120a6e
  TRasterP m_floatingSelection;
Shinya Kitaoka 120a6e
  TRasterP m_originalfloatingSelection;
Shinya Kitaoka 120a6e
  TFrameId m_fid;
Shinya Kitaoka 120a6e
  int m_transformationCount;
Shinya Kitaoka 120a6e
  bool m_isPastedSelection;
Shinya Kitaoka 120a6e
  bool m_noAntialiasing;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  void pasteSelection(const RasterImageData *data);
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  RasterSelection();
Shinya Kitaoka 120a6e
  RasterSelection(const RasterSelection &src);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  TSelection *clone() const;
Shinya Kitaoka 120a6e
  void notify();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const TImageP &getCurrentImage() const { return m_currentImage; }
Shinya Kitaoka 120a6e
  const TXshCell &getCurrentImageCell() const { return m_currentImageCell; }
Shinya Kitaoka 120a6e
  void setCurrentImage(const TImageP &img, const TXshCell &imageCell) {
Shinya Kitaoka 120a6e
    m_currentImage = img, m_currentImageCell = imageCell;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setStrokes(const std::vector<tstroke> &strokes) { m_strokes = strokes; }</tstroke>
Shinya Kitaoka 120a6e
  std::vector<tstroke> getStrokes() const { return m_strokes; }</tstroke>
Shinya Kitaoka 120a6e
  std::vector<tstroke> getOriginalStrokes() const { return m_originalStrokes; }</tstroke>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setTransformation(const TAffine &affine) { m_affine = affine; }
Shinya Kitaoka 120a6e
  TAffine getTransformation() const { return m_affine; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setStartPosition(const TPoint &position) { m_startPosition = position; }
Shinya Kitaoka 120a6e
  TPoint getStartPosition() const { return m_startPosition; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setFloatingSeletion(const TRasterP &floatingSelection) {
Shinya Kitaoka 120a6e
    m_floatingSelection = floatingSelection;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
  TRasterP getFloatingSelection() const { return m_floatingSelection; }
Shinya Kitaoka 120a6e
  TRasterP getOriginalFloatingSelection() const {
Shinya Kitaoka 120a6e
    return m_originalfloatingSelection;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setFrameId(const TFrameId &fid) { m_fid = fid; }
Shinya Kitaoka 120a6e
  TFrameId getFrameId() const { return m_fid; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  int getTransformationCount() const { return m_transformationCount; }
Shinya Kitaoka 120a6e
  void setTransformationCount(int transformationCount) {
Shinya Kitaoka 120a6e
    m_transformationCount = transformationCount;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  void setNoAntialiasing(bool value) { m_noAntialiasing = value; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isPastedSelection() const { return m_isPastedSelection; }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*! Returns strokes bounding box.*/
Shinya Kitaoka 120a6e
  TRectD getStrokesBound(std::vector<tstroke> strokes) const;</tstroke>
Shinya Kitaoka 120a6e
  /*! Returns m_strokes bounding box in world coordinates.
Shinya Kitaoka 120a6e
The bounding box results transformed if the selection is transformed.*/
Shinya Kitaoka 120a6e
  TRectD getSelectionBound() const;
Shinya Kitaoka 120a6e
  /*! Returns m_originlStrokes bounding box in world coordinates.*/
Shinya Kitaoka 120a6e
  TRectD getOriginalSelectionBound() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*! Return \b m_selectionBbox.
Shinya Kitaoka 120a6e
Can be different from getSelectionBound() after a free deform transformation. */
Shinya Kitaoka 120a6e
  TRectD getSelectionBbox() const;
Shinya Kitaoka 120a6e
  void setSelectionBbox(const TRectD &rect);
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void selectNone() override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Take a rect in world coordinates and put it in the selection.
Shinya Kitaoka 120a6e
  void select(const TRectD &rect);
Shinya Kitaoka 120a6e
  void select(TStroke &stroke);
Shinya Kitaoka 120a6e
  void selectAll();
Shinya Kitaoka 473e70
  bool isEmpty() const override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  void enableCommands() override;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isFloating() const;
Shinya Kitaoka 120a6e
  void transform(const TAffine &affine);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  // commands
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! Build the floating image using m_strokes.
Shinya Kitaoka 120a6e
  void makeFloating();
Shinya Kitaoka 120a6e
  //! Paste the floating image over the current image and empty the selection.
Shinya Kitaoka 120a6e
  void pasteFloatingSelection();
Shinya Kitaoka 120a6e
  //! Delete the floating image.
Shinya Kitaoka 120a6e
  void deleteSelection();
Shinya Kitaoka 120a6e
  //! Copy the floating image  in the clipboard.
Shinya Kitaoka 120a6e
  void copySelection();
Shinya Kitaoka 120a6e
  //! Cut the floating image.
Shinya Kitaoka 120a6e
  void cutSelection();
Shinya Kitaoka 120a6e
  //! Create the floating image using clipboard Data.
Shinya Kitaoka 120a6e
  void pasteSelection();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  bool isTransformed();
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // RASTER_SELECTION_H