28 m_ActiveTubes(other.m_ActiveTubes),
29 m_LabelGroups(other.m_LabelGroups),
30 m_TubeToLabelsMap(other.m_TubeToLabelsMap),
31 m_Annotations(other.m_Annotations)
37 m_ActiveTubes.clear();
38 m_TubeToLabelsMap.clear();
40 for (
auto it = m_LabelGroups.begin(); it != m_LabelGroups.end(); it++)
42 m_LabelGroups.clear();
48 if (m_LabelGroups.size() > 0)
50 for (
auto it = m_TubeToLabelsMap.begin(); it != m_TubeToLabelsMap.end(); it++)
52 if (this->TubeDescriptorsCompare(tube, (*it).first.first))
55 LabelGroup *lg = this->GetLabelGroupByName((*it).first.second);
61 LabelGroup::Label *label = this->GetLabelByName((*m_LabelGroups.begin()),
"Undefined");
73 for (std::vector<TubeDescriptorType>::const_iterator it = m_ActiveTubes.begin(); it != m_ActiveTubes.end(); it++)
75 if (this->TubeDescriptorsCompare(tube, (*it)))
81 m_ActiveTubes.push_back(tube);
87 for (
auto it = m_ActiveTubes.begin(); it != m_ActiveTubes.end(); it++)
89 if (this->TubeDescriptorsCompare(tube, (*it)))
91 m_ActiveTubes.erase(it);
103 for (
auto it = tubes.begin(); it != tubes.end(); it++)
104 this->SetTubeActive(*it,
true);
109 for (std::vector<TubeDescriptorType>::const_iterator it = m_ActiveTubes.begin(); it != m_ActiveTubes.end(); it++)
111 if (this->TubeDescriptorsCompare((*it), tube))
119 return m_ActiveTubes;
125 m_ActiveTubes.clear();
131 for (
auto it = m_Annotations.begin(); it != m_Annotations.end(); it++)
133 if ((*it)->name == annotation->
name)
135 MITK_INFO <<
"An Annotation with this name already exists.";
139 m_Annotations.push_back(annotation);
143 for (
auto it = m_Annotations.begin(); it != m_Annotations.end(); it++)
145 if ((*it)->name == annotation)
152 return m_Annotations;
156 for (
auto it = m_Annotations.begin(); it != m_Annotations.end(); it++)
158 if ((*it)->name == annotation->
name)
160 m_Annotations.erase(it);
174 bool isActive(
false);
175 bool hasLabel(
false);
177 for (std::vector<TubeDescriptorType>::const_iterator it = m_ActiveTubes.begin(); it != m_ActiveTubes.end(); it++)
179 if (this->TubeDescriptorsCompare(tube, (*it)))
192 if (m_LabelGroups.size() > 0)
194 for (
auto it = m_TubeToLabelsMap.begin(); it != m_TubeToLabelsMap.end(); it++)
196 if (this->TubeDescriptorsCompare(tube, (*it).first.first))
198 LabelGroup *lg = this->GetLabelGroupByName((*it).first.second);
207 LabelGroup::Label *label = this->GetLabelByName(*(m_LabelGroups.begin()),
"Undefined");
218 bool isUndefined(label->
labelName.compare(
"Undefined") == 0);
219 for (
unsigned int i = 0; i < m_ActiveTubes.size(); i++)
221 bool isInList(
false);
222 for (
auto it = m_TubeToLabelsMap.begin(); it != m_TubeToLabelsMap.end(); it++)
224 if ((this->TubeDescriptorsCompare(it->first.first, m_ActiveTubes[i])) &&
230 m_TubeToLabelsMap.erase(it);
240 if (!isInList && !isUndefined)
243 m_TubeToLabelsMap.insert(std::pair<TubeToLabelGroupType, std::string>(tubeToLabelGroup, label->
labelName));
247 m_ActiveTubes.clear();
252 m_TubeToLabelsMap = tubeToLabelMap;
257 return m_TubeToLabelsMap;
263 for (
auto it = m_LabelGroups.begin(); it != m_LabelGroups.end(); it++)
265 if (labelGroup->
labelGroupName.compare((*it)->labelGroupName) == 0)
267 MITK_ERROR <<
"The label group must be unique! This name already exists!";
273 if (position < m_LabelGroups.size() - 1)
275 auto it = m_LabelGroups.begin() + position;
276 m_LabelGroups.insert(it, labelGroup);
280 m_LabelGroups.push_back(labelGroup);
283 if (position >= m_LabelGroups.size())
284 MITK_INFO <<
"Position is out of space. So the label group was added on last position: "
285 << m_LabelGroups.size() - 1;
292 auto foundElement = std::find(m_LabelGroups.begin(), m_LabelGroups.end(), labelGroup);
293 unsigned int pos = foundElement - m_LabelGroups.begin();
296 if (pos < m_LabelGroups.size())
299 for (
auto it = m_TubeToLabelsMap.begin(); it != m_TubeToLabelsMap.end(); it++)
302 m_TubeToLabelsMap.erase(it);
305 m_LabelGroups.erase(foundElement);
309 MITK_ERROR <<
"Could not find the label group!";
340 for (
auto it = m_TubeToLabelsMap.begin(); it != m_TubeToLabelsMap.end(); it++)
345 if (label->
labelName.compare((*it).second) == 0)
347 (*it).second = newName;
357 return m_LabelGroups;
362 return m_LabelGroups.size();
367 unsigned int pos = std::find(m_LabelGroups.begin(), m_LabelGroups.end(), labelGroup) - m_LabelGroups.begin();
369 if (pos < m_LabelGroups.size())
374 MITK_ERROR <<
"Could not find such a label group!";
375 return m_LabelGroups.size();
381 for (
auto it = m_LabelGroups.begin(); it != m_LabelGroups.end(); it++)
383 if (labelGroup.compare((*it)->labelGroupName) == 0)
387 MITK_ERROR <<
"Could not find such a label group!";
392 std::string labelName)
394 for (
auto it = labelGroup->
labels.begin(); it != labelGroup->
labels.end(); it++)
396 if (labelName.compare((*it)->labelName) == 0)
404 bool mitk::TubeGraphProperty::TubeDescriptorsCompare(
const TubeDescriptorType &tube1,
const TubeDescriptorType &tube2)
406 if (((tube1.first == tube2.first) && (tube1.second == tube2.second)) ||
407 ((tube1.first == tube2.second) && (tube1.second == tube2.first)))
413 bool mitk::TubeGraphProperty::IsEqual(
const BaseProperty &property)
const
425 bool mitk::TubeGraphProperty::Assign(
const BaseProperty &property)
436 std::stringstream result;
TubeGraph::TubeDescriptorType TubeDescriptorType
itk::SmartPointer< Self > Pointer
unsigned int GetNumberOfLabelGroups()
void DeactivateAllTubes()
void SetTubesToLabels(std::map< TubeToLabelGroupType, std::string > tubeToLabelMap)
void SetLabelForActivatedTubes(LabelGroup *labelGroup, LabelGroup::Label *label)
void RemoveAnnotation(Annotation *annotation)
void SetLabelColor(LabelGroup::Label *label, Color color)
LabelGroup * GetLabelGroupByName(std::string labelGroup)
void AddAnnotation(Annotation *annotation)
Color GetColorOfTube(const TubeDescriptorType &tube)
void AddLabelGroup(LabelGroup *labelGroup, unsigned int position)
Abstract base class for properties.
LabelGroupSetType GetLabelGroups()
std::pair< TubeDescriptorType, std::string > TubeToLabelGroupType
std::vector< TubeDescriptorType > GetActiveTubes()
Property for tube graphs.
std::vector< Annotation * > GetAnnotations()
void RemoveLabelGroup(LabelGroup *labelGroup)
void SetTubeActive(const TubeDescriptorType &tube, const bool &active)
std::map< TubeToLabelGroupType, std::string > GetTubesToLabels()
LabelGroup::Label * GetLabelByName(LabelGroup *labelGroup, std::string labelName)
std::string labelGroupName
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
void SetLabelVisibility(LabelGroup::Label *label, bool isVisible)
void SetTubesActive(std::vector< TubeDescriptorType > &tubes)
void RenameLabel(LabelGroup *labelGroup, LabelGroup::Label *label, std::string newName)
unsigned int GetIndexOfLabelGroup(LabelGroup *labelGroup)
std::vector< TubeGraphProperty::LabelGroup * > LabelGroupSetType
Annotation * GetAnnotationByName(std::string annotation)
bool IsTubeVisible(const TubeDescriptorType &tube)
virtual std::string GetValueAsString() const override
bool IsTubeActive(const TubeDescriptorType &tube)
virtual ~TubeGraphProperty()
std::vector< Label * > labels