Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef LEVELSELECTION_H
Toshihiro Shimizu 890ddd
#define LEVELSELECTION_H
Toshihiro Shimizu 890ddd
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
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 TVectorImage;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//====================================================
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*******************************************************************************
Toshihiro Shimizu 890ddd
//    LevelSelection  declaration
Toshihiro Shimizu 890ddd
//*******************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
luz paz 6454c4
  \brief    Selection type for level-based multi-frame selections targeting
Toshihiro Shimizu 890ddd
            primitives described by predefined filtering functions.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI LevelSelection : public TSelection {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  enum FramesMode     //!  Possible frames selection modes.
Shinya Kitaoka 120a6e
  { FRAMES_NONE,      //!< No frame is selected.
Shinya Kitaoka 120a6e
    FRAMES_CURRENT,   //!< Selects the (context-defined) current frame.
Shinya Kitaoka 120a6e
    FRAMES_SELECTED,  //!< Selects the frames specified in \p
Shinya Kitaoka 38fd86
                      //! TTool::getSelectedFrames().
Shinya Kitaoka 120a6e
    FRAMES_ALL,       //!< Selects the whole level.
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  enum Filter          //!  Possible selection filters.
luz paz 6454c4
  { EMPTY,             //!< Selection is empty - everything is filtered out.
Shinya Kitaoka 120a6e
    WHOLE,             //!< Selects everything - nothing is filtered out.
Shinya Kitaoka 120a6e
    SELECTED_STYLES,   //!< Acts only entities with selected palette styles.
Shinya Kitaoka 120a6e
    BOUNDARY_STROKES,  //!< Acts only on boundary strokes (applies only to
Shinya Kitaoka 38fd86
                       //! vector images).
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  typedef std::set<int></int>
Shinya Kitaoka 120a6e
      styles_container;  //!< Container of style indexes used together with the
Shinya Kitaoka 120a6e
                         //!  \p SELECTED_STYLES filter.
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  LevelSelection();  //!< Constructs an empty level selection.
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  /*! \remark   The selection is hereby considered empty \a only if it either
Shinya Kitaoka 120a6e
     has
Shinya Kitaoka 120a6e
          FramesMode FRAMES_NONE or Filter EMPTY. It is user's responsibility
Shinya Kitaoka 120a6e
          to check whether nontrivial selections are empty or not. */
Shinya Kitaoka 120a6e
Shinya Kitaoka 473e70
  bool isEmpty() const override;  //!< Returns whether the selection is empty.
Shinya Kitaoka 38fd86
  void selectNone()
Shinya Kitaoka 38fd86
      override;  //!< Resets the selection to empty. This is functionally
Shinya Kitaoka 38fd86
                 //!  equivalent to <tt>operator=(LevelSelection());</tt>
Shinya Kitaoka 120a6e
  FramesMode framesMode() const { return m_framesMode; }
Shinya Kitaoka 120a6e
  FramesMode &framesMode()  //!  Returns current frames selection mode.
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    return m_framesMode;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  Filter filter() const { return m_filter; }
Shinya Kitaoka 120a6e
  Filter &filter()  //!  Returns current styles selection mode.
Shinya Kitaoka 120a6e
  {
Shinya Kitaoka 120a6e
    return m_filter;
Shinya Kitaoka 120a6e
  }
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  const styles_container &styles() const { return m_styles; }
Shinya Kitaoka 120a6e
  styles_container &styles() {
Shinya Kitaoka 120a6e
    return m_styles;
Shinya Kitaoka 120a6e
  }  //!< Returns selected palette styles used with the
Shinya Kitaoka 120a6e
     //!  \p SELECTED_STYLES filter.
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  FramesMode m_framesMode;  //!< Selected level frames.
Shinya Kitaoka 120a6e
  Filter m_filter;          //!< Selection filter.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  std::set<int> m_styles;  //!< Selected palette styles used with the \p</int>
Shinya Kitaoka 38fd86
                           //! SELECTED_STYLES filter.
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//*******************************************************************************
Toshihiro Shimizu 890ddd
//    Related standalone functions
Toshihiro Shimizu 890ddd
//*******************************************************************************
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  \brief    Calculates the strokes on the boundary of a vector image.
Toshihiro Shimizu 890ddd
  \details  Boundary strokes are those with a side entirely adjacent
Toshihiro Shimizu 890ddd
            to a region with style index \p 0.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \return   The indexes of boundary strokes in the input image.
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI std::vector<int> getBoundaryStrokes(TVectorImage &vi);</int>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
/*!
Toshihiro Shimizu 890ddd
  \brief    Applies a selection filter to a given vector image.
Toshihiro Shimizu 890ddd
  \return   The stroke indexes included in the filtered selection.
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
  \remark   In case the filter is LevelSelection::BOUNDARY_STROKES, the
Shinya Kitaoka 120a6e
  resulting
Toshihiro Shimizu 890ddd
            selection is composed of all strokes which are even partially
Toshihiro Shimizu 890ddd
            adjacent to a region with style index \p 0.
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
  \sa       Function getBoundaryStrokes().
Toshihiro Shimizu 890ddd
*/
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
DVAPI std::vector<int> getSelectedStrokes(</int>
Shinya Kitaoka 120a6e
    TVectorImage &vi,  //!< Vector image whose strokes will be selected.
Shinya Kitaoka 120a6e
    const LevelSelection
Shinya Kitaoka 120a6e
        &levelSelection  //!< Selection filter for the specified image.
Shinya Kitaoka 120a6e
    );
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // LEVELSELECTION_H