Image* VolumeDisplayUnit::getCurrentDisplayedImage() const
{
    if (m_volume && getViewPlane() == OrthogonalPlane::XYPlane)
    {
        return m_volume->getImage(m_sliceHandler->getCurrentSlice(), m_sliceHandler->getCurrentPhase());
    }
    else
    {
        return 0;
    }
}
double VolumeDisplayUnit::getCurrentSpacingBetweenSlices() const
{
    if (getVolume())
    {
        int zIndex = getViewPlane().getZIndex();
        
        return getVolume()->getSpacing()[zIndex];
    }
    else
    {
        return 0.0;
    }
}
double VolumeDisplayUnit::getCurrentDisplayedImageDepth() const
{
    if (getVolume())
    {
        double zSpacing = getCurrentSpacingBetweenSlices();
        int zIndex = getViewPlane().getZIndex();
        double zOrigin = getVolume()->getOrigin()[zIndex];
        
        return zOrigin + zSpacing * getSlice();
    }
    else
    {
        return 0.0;
    }
}
void VolumeDisplayUnit::updateCurrentImageDefaultPresets()
{
    if (getViewPlane() == OrthogonalPlane::XYPlane)
    {
        Image *image = getVolume()->getImage(m_sliceHandler->getCurrentSlice(), m_sliceHandler->getCurrentPhase());
        if (image)
        {
            for (int i = 0; i < image->getNumberOfWindowLevels(); ++i)
            {
                WindowLevel windowLevel = WindowLevelHelper().getDefaultWindowLevelForPresentation(image, i);
                m_windowLevelData->updatePreset(windowLevel);
            }
        }
    }
    
    WindowLevel wl = m_windowLevelData->getCurrentPreset();
    m_imagePipeline->setWindowLevel(wl.getWidth(), wl.getCenter());
}
void VolumeDisplayUnit::updateCurrentImageDefaultPresets()
{
    if (getViewPlane() == OrthogonalPlane::XYPlane)
    {
        Image *image = getVolume()->getImage(m_sliceHandler->getCurrentSlice(), m_sliceHandler->getCurrentPhase());
        if (image)
        {
            for (int i = 0; i < image->getNumberOfVoiLuts(); ++i)
            {
                VoiLut voiLut = VoiLutHelper().getDefaultVoiLutForPresentation(image, i);
                m_voiLutData->updatePreset(voiLut);
            }
        }
    }
    
    VoiLut voiLut = m_voiLutData->getCurrentPreset();
    setVoiLut(voiLut);
}