<commit_before>#include "mitkColoredRectangleRendering.h"

#include "mitkVtkLayerController.h"

#include <mitkStandardFileLocations.h>
#include <mitkConfig.h>
#include <itkObject.h>
#include <itkMacro.h>
#include <itksys/SystemTools.hxx>

#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkObjectFactory.h>
#include <vtkConfigure.h>

#include <vtkMitkRectangleProp.h>

mitk::ColoredRectangleRendering::ColoredRectangleRendering()
{
  m_RenderWindow           = NULL;
  m_RectangleRenderer      = vtkRenderer::New();

  m_IsEnabled         = false;
}

mitk::ColoredRectangleRendering::~ColoredRectangleRendering()
{
  if ( m_RenderWindow != NULL )
    if ( this->IsEnabled() )
      this->Disable();
  
  if ( m_RectangleRenderer != NULL )
    m_RectangleRenderer->Delete();

}

/**
 * Sets the renderwindow, in which the text
 * will be shown. Make sure, you have called this function
 * before calling Enable()
 */
void mitk::ColoredRectangleRendering::SetRenderWindow( vtkRenderWindow* renderWindow )
{
  m_RenderWindow = renderWindow;
}

/**
 * Returns the vtkRenderWindow, which is used
 * for displaying the text
 */
vtkRenderWindow* mitk::ColoredRectangleRendering::GetRenderWindow()
{
  return m_RenderWindow;
}

/**
 * Returns the renderer responsible for
 * rendering the  text into the
 * vtkRenderWindow
 */
vtkRenderer* mitk::ColoredRectangleRendering::GetVtkRenderer()
{
  return m_RectangleRenderer;
}

/**
 * Disables drawing of the text label collection.
 * If you want to enable it, call the Enable() function.
 */
void mitk::ColoredRectangleRendering::Disable()
{
  if ( this->IsEnabled())
  {
    #if ( VTK_MAJOR_VERSION >= 5 )
      m_RectangleRenderer->SetErase(1);
    #endif
    m_RenderWindow->SetErase(1);
    mitk::VtkLayerController::GetInstance(m_RenderWindow)->RemoveRenderer(m_RectangleRenderer);
    m_IsEnabled = false;
  }
}

/**
 * Enables drawing of the text label collection.
 * If you want to disable it, call the Disable() function.
 */
void mitk::ColoredRectangleRendering::Enable(float col1, float col2, float col3)
{
  vtkMitkRectangleProp* rect = vtkMitkRectangleProp::New();
  rect->SetRenderWindow(m_RenderWindow);
  rect->SetColor(col1, col2, col3);

  m_RectangleRenderer->AddViewProp(rect);
    
  if(!mitk::VtkLayerController::GetInstance(m_RenderWindow)->IsRendererInserted( m_RectangleRenderer ))
  {
    #if ( VTK_MAJOR_VERSION >= 5 )
      m_RectangleRenderer->SetErase(1);
    #endif
    m_RectangleRenderer->SetInteractive(0);

    m_RenderWindow->SetErase(1); 
    mitk::VtkLayerController::GetInstance(m_RenderWindow)->InsertForegroundRenderer(m_RectangleRenderer,true);
    
    m_IsEnabled = true;
  }
}
/**
 * Checks, if the text is currently
 * enabled (visible)
 */
bool mitk::ColoredRectangleRendering::IsEnabled()
{
  return  m_IsEnabled;
}
 
void mitk::ColoredRectangleRendering::SetRequestedRegionToLargestPossibleRegion()
{
    //nothing to do
}

bool mitk::ColoredRectangleRendering::RequestedRegionIsOutsideOfTheBufferedRegion()
{
    return false;    
}

bool mitk::ColoredRectangleRendering::VerifyRequestedRegion()
{
    return true;
}

void mitk::ColoredRectangleRendering::SetRequestedRegion(itk::DataObject*)
{
    //nothing to do
}

<commit_msg>FIX (#1115): vtkRenderer::EraseOff() to keep the z-buffer for picking.<commit_after>#include "mitkColoredRectangleRendering.h"

#include "mitkVtkLayerController.h"

#include <mitkStandardFileLocations.h>
#include <mitkConfig.h>
#include <itkObject.h>
#include <itkMacro.h>
#include <itksys/SystemTools.hxx>

#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkObjectFactory.h>
#include <vtkConfigure.h>

#include <vtkMitkRectangleProp.h>

mitk::ColoredRectangleRendering::ColoredRectangleRendering()
{
  m_RenderWindow           = NULL;
  m_RectangleRenderer      = vtkRenderer::New();

  m_IsEnabled         = false;
}

mitk::ColoredRectangleRendering::~ColoredRectangleRendering()
{
  if ( m_RenderWindow != NULL )
    if ( this->IsEnabled() )
      this->Disable();
  
  if ( m_RectangleRenderer != NULL )
    m_RectangleRenderer->Delete();

}

/**
 * Sets the renderwindow, in which the text
 * will be shown. Make sure, you have called this function
 * before calling Enable()
 */
void mitk::ColoredRectangleRendering::SetRenderWindow( vtkRenderWindow* renderWindow )
{
  m_RenderWindow = renderWindow;
}

/**
 * Returns the vtkRenderWindow, which is used
 * for displaying the text
 */
vtkRenderWindow* mitk::ColoredRectangleRendering::GetRenderWindow()
{
  return m_RenderWindow;
}

/**
 * Returns the renderer responsible for
 * rendering the  text into the
 * vtkRenderWindow
 */
vtkRenderer* mitk::ColoredRectangleRendering::GetVtkRenderer()
{
  return m_RectangleRenderer;
}

/**
 * Disables drawing of the text label collection.
 * If you want to enable it, call the Enable() function.
 */
void mitk::ColoredRectangleRendering::Disable()
{
  if ( this->IsEnabled())
  {
    #if ( VTK_MAJOR_VERSION >= 5 )
      m_RectangleRenderer->EraseOn();
    #else
      m_RenderWindow->SetErase(1);
    #endif
    mitk::VtkLayerController::GetInstance(m_RenderWindow)->RemoveRenderer(m_RectangleRenderer);
    m_IsEnabled = false;
  }
}

/**
 * Enables drawing of the text label collection.
 * If you want to disable it, call the Disable() function.
 */
void mitk::ColoredRectangleRendering::Enable(float col1, float col2, float col3)
{
  vtkMitkRectangleProp* rect = vtkMitkRectangleProp::New();
  rect->SetRenderWindow(m_RenderWindow);
  rect->SetColor(col1, col2, col3);

  m_RectangleRenderer->AddViewProp(rect);
    
  if(!mitk::VtkLayerController::GetInstance(m_RenderWindow)->IsRendererInserted( m_RectangleRenderer ))
  {
    #if ( VTK_MAJOR_VERSION >= 5 )
      m_RectangleRenderer->EraseOff();
    #else
      m_RenderWindow->SetErase(0); 
    #endif
    m_RectangleRenderer->SetInteractive(0);
    
    mitk::VtkLayerController::GetInstance(m_RenderWindow)->InsertForegroundRenderer(m_RectangleRenderer,true);
    
    m_IsEnabled = true;
  }
}
/**
 * Checks, if the text is currently
 * enabled (visible)
 */
bool mitk::ColoredRectangleRendering::IsEnabled()
{
  return  m_IsEnabled;
}
 
void mitk::ColoredRectangleRendering::SetRequestedRegionToLargestPossibleRegion()
{
    //nothing to do
}

bool mitk::ColoredRectangleRendering::RequestedRegionIsOutsideOfTheBufferedRegion()
{
    return false;    
}

bool mitk::ColoredRectangleRendering::VerifyRequestedRegion()
{
    return true;
}

void mitk::ColoredRectangleRendering::SetRequestedRegion(itk::DataObject*)
{
    //nothing to do
}


{'fraction_non_alphanumeric': 0.11657003356728715, 'fraction_numerical': 0.0042722001830942935, 'mean_word_length': 4.953678474114441, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '927272', 'n_tokens_mistral': 2173, 'n_tokens_neox': 2173, 'n_words': 412}