18 #include <itkCommand.h>
26 mitk::LabelSet::~LabelSet()
28 m_LabelContainer.clear();
33 m_LookupTable(other.GetLookupTable()->
Clone()),
34 m_ActiveLabelValue(other.GetActiveLabel()->GetValue()),
35 m_Layer(other.GetLayer())
45 m_LabelContainer[otherIt->first]->AddObserver(itk::ModifiedEvent(), command);
51 ModifyLabelEvent.Send();
52 Superclass::Modified();
57 return m_LabelContainer.end();
62 return m_LabelContainer.begin();
67 return m_LabelContainer.end();
72 return m_LabelContainer.begin();
77 return m_LabelContainer.size();
88 m_ActiveLabelValue = pixelValue;
89 ActiveLabelEvent.Send(pixelValue);
95 return m_LabelContainer.count(pixelValue) > 0 ?
true :
false;
102 if (m_LabelContainer.size() >= max_size)
108 newLabel->SetLayer(m_Layer);
111 if (m_LabelContainer.empty())
113 pixelValue = newLabel->GetValue();
117 pixelValue = m_LabelContainer.rbegin()->first;
119 if (pixelValue >= newLabel->GetValue() && m_LabelContainer.find(newLabel->GetValue()) != m_LabelContainer.end())
122 newLabel->SetValue(pixelValue);
126 pixelValue = newLabel->GetValue();
131 m_LabelContainer[pixelValue] = newLabel;
132 UpdateLookupTable(pixelValue);
136 newLabel->AddObserver(itk::ModifiedEvent(), command);
139 SetActiveLabel(newLabel->GetValue());
140 AddLabelEvent.Send();
146 if (m_LabelContainer.size() > 255)
150 newLabel->SetName(name);
151 newLabel->SetColor(color);
174 auto it = m_LabelContainer.rbegin();
175 PixelType nextActivePixelValue = it->first;
177 for (; it != m_LabelContainer.rend(); it++)
179 if (it->first == pixelValue)
181 it->second->RemoveAllObservers();
182 m_LabelContainer.erase(pixelValue);
185 nextActivePixelValue = it->first;
188 if (m_ActiveLabelValue == pixelValue)
190 if (ExistLabel(nextActivePixelValue))
191 SetActiveLabel(nextActivePixelValue);
193 SetActiveLabel(m_LabelContainer.rbegin()->first);
196 RemoveLabelEvent.Send();
203 auto _it = IteratorBegin();
204 for (; _it != IteratorConstEnd();)
206 RemoveLabelEvent.Send();
207 m_LabelContainer.erase(_it++);
209 AllLabelsModifiedEvent.Send();
214 auto _end = m_LabelContainer.end();
215 auto _it = m_LabelContainer.begin();
216 for (; _it != _end; ++_it)
217 _it->second->SetLocked(value);
218 AllLabelsModifiedEvent.Send();
224 auto _end = m_LabelContainer.end();
225 auto _it = m_LabelContainer.begin();
226 for (; _it != _end; ++_it)
228 _it->second->SetVisible(value);
229 UpdateLookupTable(_it->first);
231 AllLabelsModifiedEvent.Send();
237 const mitk::Color &color = GetLabel(pixelValue)->GetColor();
240 m_LookupTable->GetTableValue(static_cast<int>(pixelValue), rgba);
241 rgba[0] = color.GetRed();
242 rgba[1] = color.GetGreen();
243 rgba[2] = color.GetBlue();
244 if (GetLabel(pixelValue)->GetVisible())
245 rgba[3] = GetLabel(pixelValue)->GetOpacity();
248 m_LookupTable->SetTableValue(static_cast<int>(pixelValue), rgba);
253 if (m_LabelContainer.find(pixelValue) == m_LabelContainer.end())
255 return m_LabelContainer[pixelValue];
260 auto it = m_LabelContainer.find(pixelValue);
261 if (it == m_LabelContainer.end())
263 return it->second.GetPointer();
268 bool returnValue =
true;
271 MITK_INFO(verbose) <<
"--- LabelSet Equal ---";
277 returnValue = *lhsLUT == *rhsLUT;
280 MITK_INFO(verbose) <<
"Lookup tabels not equal.";
289 MITK_INFO(verbose) <<
"Active label not equal.";
298 MITK_INFO(verbose) <<
"Layer index not equal.";
307 MITK_INFO(verbose) <<
"Number of labels not equal.";
319 returnValue = rhsit->first == lhsit->first;
322 MITK_INFO(verbose) <<
"Label in label container not equal.";
327 returnValue =
mitk::Equal(*(rhsit->second), *(lhsit->second), eps, verbose);
330 MITK_INFO(verbose) <<
"Label in label container not equal.";
LabelContainerIteratorType IteratorEnd()
Returns a iterator pointing to the end of the container.
itk::SmartPointer< Self > Pointer
unsigned int GetNumberOfLabels() const
void UpdateLookupTable(PixelType pixelValue)
LookupTable::Pointer m_LookupTable
void OnLabelModified()
Recall itk::Object::Modified event from a label and send a ModifyLabelEvent.
void SetAllLabelsLocked(bool)
A data structure describing a label.
LabelContainerConstIteratorType IteratorConstEnd() const
Returns a const iterator pointing to the end of the container.
LabelContainerType::iterator LabelContainerIteratorType
void AddLabel(mitk::Label *label)
void PrintSelf(std::ostream &os, itk::Indent indent) const override
void SetColor(const mitk::Color &)
LabelContainerType m_LabelContainer
static const PixelType MAX_LABEL_VALUE
The maximum value a label can get: Since the value is of type unsigned short MAX_LABEL_VALUE = 65535...
LabelContainerType::const_iterator LabelContainerConstIteratorType
bool ExistLabel(PixelType)
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
void SetActiveLabel(PixelType)
MITKCORE_EXPORT const ScalarType eps
LabelContainerConstIteratorType IteratorConstBegin() const
Returns a const iterator poiting to the begining of the container.
mitk::Label::PixelType PixelType
LabelContainerIteratorType IteratorBegin()
Returns a iterator poiting to the begining of the container.
void SetLayer(unsigned int)
void RenameLabel(PixelType, const std::string &, const Color &)
Label * GetLabel(PixelType pixelValue)
void RemoveLabel(PixelType)
void SetName(const std::string &name)
The LookupTable class mitk wrapper for a vtkLookupTableThis class can be used to color images with a ...
void SetAllLabelsVisible(bool)
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.