Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
QmitkSegmentationOrganNamesHandling.cpp
Go to the documentation of this file.
1 /*===================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include <QStringList>
19 
20 namespace mitk
21 {
22  struct OrganNamesHandling
23  {
24  static QStringList GetDefaultOrganColorString()
25  {
26  QStringList organColors;
27 
29  anatomicalStructureColorPresets->LoadPreset();
30 
31  for (const auto& preset : anatomicalStructureColorPresets->GetColorPresets())
32  {
33  auto organName = preset.first.c_str();
34  auto color = QColor(preset.second.GetRed(), preset.second.GetGreen(), preset.second.GetBlue());
35 
36  AppendToOrganList(organColors, organName, color);
37  }
38  return organColors;
39  }
40 
41  static void UpdateOrganList(QStringList& organColors, const QString& organname, mitk::Color color)
42  {
43  QString listElement(organname + QColor(color.GetRed() * 255, color.GetGreen() * 255, color.GetBlue() * 255).name());
44 
45  // remove previous definition if necessary
46  int oldIndex = organColors.indexOf(QRegExp(QRegExp::escape(organname) + "#......", Qt::CaseInsensitive));
47  if (oldIndex < 0 || organColors.at(oldIndex) != listElement)
48  {
49  if (oldIndex >= 0)
50  {
51  organColors.removeAt(oldIndex);
52  }
53 
54  // add colored organ name AND sort list
55  organColors.append(listElement);
56  organColors.sort();
57  }
58  }
59 
60  static void AppendToOrganList(QStringList& organColors, const QString& organname, const QColor& color)
61  {
62  organColors.append(organname + color.name());
63  }
64  };
65 }
std::map< std::string, Color > const GetColorPresets()
DataCollection - Class to facilitate loading/accessing structured data.
static AnatomicalStructureColorPresets * New()
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)