<commit_before>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

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

#include "mitkOverlayManager.h"
#include "mitkBaseRenderer.h"

mitk::OverlayManager::OverlayManager()
{
}

mitk::OverlayManager::~OverlayManager()
{
}

void mitk::OverlayManager::AddBaseRenderer(mitk::BaseRenderer* renderer)
{
  std::pair<BaseRendererSet::iterator,bool> inSet;
  inSet = m_BaseRendererSet.insert(renderer);
  if(inSet.second)
  {
    OverlaySet::iterator it;
    for ( it=m_OverlaySet.begin() ; it != m_OverlaySet.end(); it++ )
    {
      (*it)->AddToBaseRenderer(renderer);
    }
  }
}

void mitk::OverlayManager::RemoveBaseRenderer(mitk::BaseRenderer* renderer)
{
  if(!renderer)
    return;
  std::pair<BaseRendererSet::iterator,bool> inSet;
  inSet = m_BaseRendererSet.insert(renderer);
  m_BaseRendererSet.erase(inSet.first);
}

void mitk::OverlayManager::AddOverlay(const Overlay::Pointer& overlay)
{
  std::pair<OverlaySet::iterator,bool> inSet;
  inSet = m_OverlaySet.insert(overlay);
  if(inSet.second)
  {
    BaseRendererSet::iterator it;
    for ( it=m_BaseRendererSet.begin() ; it != m_BaseRendererSet.end(); it++ )
    {
      overlay->AddToBaseRenderer(*it);
    }
  }
}

void mitk::OverlayManager::RemoveOverlay(const Overlay::Pointer &overlay)
{
  std::pair<OverlaySet::iterator,bool> inSet;
  inSet = m_OverlaySet.insert(overlay);
  if(!inSet.second)
  {
    BaseRendererSet::iterator it;
    for ( it=m_BaseRendererSet.begin() ; it != m_BaseRendererSet.end(); it++ )
    {
      overlay->RemoveFromBaseRenderer(*it);
    }
  }
  m_OverlaySet.erase(inSet.first);
}

void mitk::OverlayManager::RemoveAllOverlays()
{
  OverlaySet::iterator it;
  for ( it=m_OverlaySet.begin() ; it != m_OverlaySet.end(); it++ )
  {
    RemoveOverlay(*it);
  }
  m_OverlaySet.clear();
}

void mitk::OverlayManager::UpdateOverlays(mitk::BaseRenderer* baseRenderer)
{
  OverlaySet::iterator it;
  for ( it=m_OverlaySet.begin() ; it != m_OverlaySet.end(); it++ )
  {
    (*it)->Update(baseRenderer);
  }
  std::pair<std::string,std::string> fdjs("fds","fsd");
  UpdateLayouts(baseRenderer);
}


void mitk::OverlayManager::SetLayouter(Overlay *overlay, const std::string &identifier, mitk::BaseRenderer *renderer)
{
  if(renderer)
  {
    AbstractOverlayLayouter::Pointer layouter = GetLayouter(renderer,identifier);
    if(layouter.IsNull())
    {
      MITK_WARN << "Layouter " << identifier << " cannot be found or created!";
      return;
    }
    else
    {
      layouter->AddOverlay(overlay);
    }
  }
}

void mitk::OverlayManager::UpdateLayouts(mitk::BaseRenderer *renderer)
{
  LayouterMap layouters = m_LayouterMap[renderer];
  LayouterMap::iterator it;
  for ( it=layouters.begin() ; it != layouters.end(); it++ )<commit_msg>remove unintentionally committed line<commit_after>/*===================================================================

The Medical Imaging Interaction Toolkit (MITK)

Copyright (c) German Cancer Research Center,
Division of Medical and Biological Informatics.
All rights reserved.

This software is distributed WITHOUT ANY WARRANTY; without
even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE.

See LICENSE.txt or http://www.mitk.org for details.

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

#include "mitkOverlayManager.h"
#include "mitkBaseRenderer.h"

mitk::OverlayManager::OverlayManager()
{
}

mitk::OverlayManager::~OverlayManager()
{
}

void mitk::OverlayManager::AddBaseRenderer(mitk::BaseRenderer* renderer)
{
  std::pair<BaseRendererSet::iterator,bool> inSet;
  inSet = m_BaseRendererSet.insert(renderer);
  if(inSet.second)
  {
    OverlaySet::iterator it;
    for ( it=m_OverlaySet.begin() ; it != m_OverlaySet.end(); it++ )
    {
      (*it)->AddToBaseRenderer(renderer);
    }
  }
}

void mitk::OverlayManager::RemoveBaseRenderer(mitk::BaseRenderer* renderer)
{
  if(!renderer)
    return;
  std::pair<BaseRendererSet::iterator,bool> inSet;
  inSet = m_BaseRendererSet.insert(renderer);
  m_BaseRendererSet.erase(inSet.first);
}

void mitk::OverlayManager::AddOverlay(const Overlay::Pointer& overlay)
{
  std::pair<OverlaySet::iterator,bool> inSet;
  inSet = m_OverlaySet.insert(overlay);
  if(inSet.second)
  {
    BaseRendererSet::iterator it;
    for ( it=m_BaseRendererSet.begin() ; it != m_BaseRendererSet.end(); it++ )
    {
      overlay->AddToBaseRenderer(*it);
    }
  }
}

void mitk::OverlayManager::RemoveOverlay(const Overlay::Pointer &overlay)
{
  std::pair<OverlaySet::iterator,bool> inSet;
  inSet = m_OverlaySet.insert(overlay);
  if(!inSet.second)
  {
    BaseRendererSet::iterator it;
    for ( it=m_BaseRendererSet.begin() ; it != m_BaseRendererSet.end(); it++ )
    {
      overlay->RemoveFromBaseRenderer(*it);
    }
  }
  m_OverlaySet.erase(inSet.first);
}

void mitk::OverlayManager::RemoveAllOverlays()
{
  OverlaySet::iterator it;
  for ( it=m_OverlaySet.begin() ; it != m_OverlaySet.end(); it++ )
  {
    RemoveOverlay(*it);
  }
  m_OverlaySet.clear();
}

void mitk::OverlayManager::UpdateOverlays(mitk::BaseRenderer* baseRenderer)
{
  OverlaySet::iterator it;
  for ( it=m_OverlaySet.begin() ; it != m_OverlaySet.end(); it++ )
  {
    (*it)->Update(baseRenderer);
  }
  UpdateLayouts(baseRenderer);
}


void mitk::OverlayManager::SetLayouter(Overlay *overlay, const std::string &identifier, mitk::BaseRenderer *renderer)
{
  if(renderer)
  {
    AbstractOverlayLayouter::Pointer layouter = GetLayouter(renderer,identifier);
    if(layouter.IsNull())
    {
      MITK_WARN << "Layouter " << identifier << " cannot be found or created!";
      return;
    }
    else
    {
      layouter->AddOverlay(overlay);
    }
  }
}

void mitk::OverlayManager::UpdateLayouts(mitk::BaseRenderer *renderer)
{
  LayouterMap layouters = m_LayouterMap[renderer];
  LayouterMap::iterator it;
  for ( it=layouters.begin() ; it != layouters.end(); it++ )
{'fraction_non_alphanumeric': 0.17831057478564624, 'fraction_numerical': 0.0, 'mean_word_length': 5.163405088062622, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '2754383', 'n_tokens_mistral': 2034, 'n_tokens_neox': 2096, 'n_words': 357}