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

135 lines
4.3 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 LEVELSELECTION_H
#define LEVELSELECTION_H
// TnzQt includes
#include "toonzqt/selection.h"
// TnzCore includes
#include "tcommon.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 TVectorImage;
//====================================================
//*******************************************************************************
// LevelSelection declaration
//*******************************************************************************
/*!
\brief Selection type for level-based multi-frame selections targeting
2016-03-19 06:57:51 +13:00
primitives described by predefined filtering functions.
*/
2016-06-15 18:43:10 +12:00
class DVAPI LevelSelection : public TSelection {
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
enum FramesMode //! Possible frames selection modes.
{ FRAMES_NONE, //!< No frame is selected.
FRAMES_CURRENT, //!< Selects the (context-defined) current frame.
FRAMES_SELECTED, //!< Selects the frames specified in \p
2016-06-20 14:23:05 +12:00
//! TTool::getSelectedFrames().
2016-06-15 18:43:10 +12:00
FRAMES_ALL, //!< Selects the whole level.
};
enum Filter //! Possible selection filters.
{ EMPTY, //!< Selection is empty - everything is filtered out.
2016-06-15 18:43:10 +12:00
WHOLE, //!< Selects everything - nothing is filtered out.
SELECTED_STYLES, //!< Acts only entities with selected palette styles.
BOUNDARY_STROKES, //!< Acts only on boundary strokes (applies only to
2016-06-20 14:23:05 +12:00
//! vector images).
2016-06-15 18:43:10 +12:00
};
typedef std::set<int>
styles_container; //!< Container of style indexes used together with the
//! \p SELECTED_STYLES filter.
2016-03-19 06:57:51 +13:00
public:
2016-06-15 18:43:10 +12:00
LevelSelection(); //!< Constructs an empty level selection.
/*! \remark The selection is hereby considered empty \a only if it either
has
FramesMode FRAMES_NONE or Filter EMPTY. It is user's responsibility
to check whether nontrivial selections are empty or not. */
2016-06-19 20:06:29 +12:00
bool isEmpty() const override; //!< Returns whether the selection is empty.
2016-06-20 14:23:05 +12:00
void selectNone()
override; //!< Resets the selection to empty. This is functionally
//! equivalent to <TT>operator=(LevelSelection());</TT>
2016-06-15 18:43:10 +12:00
FramesMode framesMode() const { return m_framesMode; }
FramesMode &framesMode() //! Returns current frames selection mode.
{
return m_framesMode;
}
Filter filter() const { return m_filter; }
Filter &filter() //! Returns current styles selection mode.
{
return m_filter;
}
const styles_container &styles() const { return m_styles; }
styles_container &styles() {
return m_styles;
} //!< Returns selected palette styles used with the
//! \p SELECTED_STYLES filter.
2016-03-19 06:57:51 +13:00
private:
2016-06-15 18:43:10 +12:00
FramesMode m_framesMode; //!< Selected level frames.
Filter m_filter; //!< Selection filter.
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
std::set<int> m_styles; //!< Selected palette styles used with the \p
2016-06-20 14:23:05 +12:00
//! SELECTED_STYLES filter.
2016-03-19 06:57:51 +13:00
};
//*******************************************************************************
// Related standalone functions
//*******************************************************************************
/*!
\brief Calculates the strokes on the boundary of a vector image.
\details Boundary strokes are those with <I>a side entirely adjacent</I>
to a region with style index \p 0.
\return The indexes of boundary strokes in the input image.
*/
DVAPI std::vector<int> getBoundaryStrokes(TVectorImage &vi);
//------------------------------------------------------------------------
/*!
\brief Applies a selection filter to a given vector image.
\return The stroke indexes included in the filtered selection.
2016-06-15 18:43:10 +12:00
\remark In case the filter is LevelSelection::BOUNDARY_STROKES, the
resulting
2016-03-19 06:57:51 +13:00
selection is composed of all strokes which are <I>even partially</I>
adjacent to a region with style index \p 0.
\sa Function getBoundaryStrokes().
*/
DVAPI std::vector<int> getSelectedStrokes(
2016-06-15 18:43:10 +12:00
TVectorImage &vi, //!< Vector image whose strokes will be selected.
const LevelSelection
&levelSelection //!< Selection filter for the specified image.
);
2016-03-19 06:57:51 +13:00
2016-06-15 18:43:10 +12:00
#endif // LEVELSELECTION_H