/*============================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center (DKFZ)
All rights reserved.

Use of this source code is governed by a 3-clause BSD license that can be
found in the LICENSE file.

============================================================================*/

#ifndef mitkImageSliceSelector_h
#define mitkImageSliceSelector_h

#include <mitkSubImageSelector.h>
#include <MitkCoreExports.h>

namespace mitk
{
  /**
   * \brief Provides access to a single slice of the input image.
   *
   * If the input is generated by a ProcessObject, only the required data is
   * requested. The slice, time step, and channel can be selected via the
   * corresponding setter methods.
   *
   * \ingroup Process
   * \sa SubImageSelector
   * \sa ImageChannelSelector
   * \sa ImageTimeSelector
   */
  class MITKCORE_EXPORT ImageSliceSelector : public SubImageSelector
  {
  public:
    mitkClassMacro(ImageSliceSelector, SubImageSelector);

    itkFactorylessNewMacro(Self);

    itkCloneMacro(Self);

    /** \brief Get the slice number to extract. */
    itkGetConstMacro(SliceNr, int);
    /** \brief Set the slice number to extract. */
    itkSetMacro(SliceNr, int);

    /** \brief Get the time step number to extract. */
    itkGetConstMacro(TimeNr, int);
    /** \brief Set the time step number to extract. */
    itkSetMacro(TimeNr, int);

    /** \brief Get the channel number to extract. */
    itkGetConstMacro(ChannelNr, int);
    /** \brief Set the channel number to extract. */
    itkSetMacro(ChannelNr, int);

  protected:
    /** \brief Initialize output information (geometry, pixel type, dimensions) for the 2D slice output. */
    void GenerateOutputInformation() override;

    /** \brief Set the requested region on the input to match the selected slice, time step, and channel. */
    void GenerateInputRequestedRegion() override;

    /** \brief Extract the selected slice data from the input image. */
    void GenerateData() override;

    ImageSliceSelector();

    ~ImageSliceSelector() override;

    int m_SliceNr;

    int m_TimeNr;

    int m_ChannelNr;
  };

} // namespace mitk

#endif
