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

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 mitkSubImageSelector_h
#define mitkSubImageSelector_h

#include <mitkBaseData.h>
#include <mitkImageDataItem.h>
#include <mitkImageToImageFilter.h>
#include <MitkCoreExports.h>

namespace mitk
{
  /**
   * \brief Base class of all classes providing access to parts of an image.
   *
   * Base class of all classes providing access to parts of an image, e.g., to
   * a slice (mitk::ImageSliceSelector) or a volume at a specific time
   * (mitk::ImageTimeSelector). If the input is generated by a ProcessObject,
   * only the required data is requested.
   *
   * \ingroup Process
   */
  class MITKCORE_EXPORT SubImageSelector : public ImageToImageFilter
  {
  public:
    /** Run-time type information (and related methods). */
    mitkClassMacro(SubImageSelector, ImageToImageFilter);

    itkFactorylessNewMacro(Self);

    itkCloneMacro(Self);

    /**
     * \brief Set the position number for sub-image selection.
     *
     * \param[in] p the position number.
     */
    virtual void SetPosNr(int p);

    SubImageSelector();

    ~SubImageSelector() override;

  protected:
    /**
     * \brief Get the data item for the specified slice.
     *
     * \param[in] s the slice index.
     * \param[in] t the time step.
     * \param[in] n the channel number.
     * \return The image data item pointer for the requested slice.
     */
    mitk::Image::ImageDataItemPointer GetSliceData(int s = 0, int t = 0, int n = 0);

    /**
     * \brief Get the data item for the specified volume.
     *
     * \param[in] t the time step.
     * \param[in] n the channel number.
     * \return The image data item pointer for the requested volume.
     */
    mitk::Image::ImageDataItemPointer GetVolumeData(int t = 0, int n = 0);

    /**
     * \brief Get the data item for the specified channel.
     *
     * \param[in] n the channel number.
     * \return The image data item pointer for the requested channel.
     */
    mitk::Image::ImageDataItemPointer GetChannelData(int n = 0);

    /**
     * \brief Set the data item for the specified slice in the output image.
     *
     * \param[in] dataItem the data item to set.
     * \param[in] s the slice index.
     * \param[in] t the time step.
     * \param[in] n the channel number.
     */
    void SetSliceItem(mitk::Image::ImageDataItemPointer dataItem, int s = 0, int t = 0, int n = 0);

    /**
     * \brief Set the data item for the specified volume in the output image.
     *
     * \param[in] dataItem the data item to set.
     * \param[in] t the time step.
     * \param[in] n the channel number.
     */
    void SetVolumeItem(mitk::Image::ImageDataItemPointer dataItem, int t = 0, int n = 0);

    /**
     * \brief Set the data item for the specified channel in the output image.
     *
     * \param[in] dataItem the data item to set.
     * \param[in] n the channel number.
     */
    void SetChannelItem(mitk::Image::ImageDataItemPointer dataItem, int n = 0);
  };

} // namespace mitk

#endif
