31 #include <itkObjectFactory.h> 34 : m_EventConfig(
"DisplayConfigMITK.xml"),
35 m_ToolManager(nullptr),
40 m_PredicateImage3D(
NodePredicateAnd::New(m_PredicateImages, m_PredicateDimension)),
47 m_PredicateImageColorful(
NodePredicateAnd::New(m_PredicateNotBinary, m_PredicateNotSegmentation)),
48 m_PredicateImageColorfulNotHelper(
NodePredicateAnd::New(m_PredicateImageColorful, m_PredicateNotHelper)),
49 m_PredicateReference(
NodePredicateAnd::New(m_PredicateImage3D, m_PredicateImageColorfulNotHelper)),
50 m_IsSegmentationPredicate(
52 m_InteractorType(type),
53 m_DisplayInteractorConfigs(),
54 m_InteractorModule(interactorModule)
69 if (m_InteractorType.empty())
74 auto isThisModule =
nullptr == m_InteractorModule;
76 auto module = isThisModule
81 SetEventConfig(isThisModule ?
"SegmentationToolsConfig.xml" : m_InteractorType +
"Config.xml", module);
83 catch (
const std::exception &e)
85 MITK_ERROR <<
"Could not load statemachine pattern " << m_InteractorType <<
".xml with exception: " << e.what();
124 m_DisplayInteractorConfigs.clear();
125 std::vector<us::ServiceReference<InteractionEventObserver>> listEventObserver =
127 for (
auto it = listEventObserver.begin(); it != listEventObserver.end(); ++it)
130 if (displayInteractor !=
nullptr)
133 m_DisplayInteractorConfigs.insert(std::make_pair(*it, displayInteractor->GetEventConfig()));
139 if (displayActionEventBroadcast !=
nullptr)
142 m_DisplayInteractorConfigs.insert(std::make_pair(*it, displayActionEventBroadcast->GetEventConfig()));
144 displayActionEventBroadcast->SetEventConfig(
m_EventConfig.c_str());
153 for (
auto it = m_DisplayInteractorConfigs.begin(); it != m_DisplayInteractorConfigs.end(); ++it)
158 if (displayInteractor !=
nullptr)
165 if (displayActionEventBroadcast !=
nullptr)
172 m_DisplayInteractorConfigs.clear();
175 itk::Object::Pointer
mitk::Tool::GetGUI(
const std::string &toolkitPrefix,
const std::string &toolkitPostfix)
177 itk::Object::Pointer object;
179 std::string classname = this->GetNameOfClass();
180 std::string guiClassname = toolkitPrefix + classname + toolkitPostfix;
182 std::list<itk::LightObject::Pointer> allGUIs = itk::ObjectFactoryBase::CreateAllInstance(guiClassname.c_str());
183 for (
auto iter = allGUIs.begin(); iter != allGUIs.end(); ++iter)
187 object =
dynamic_cast<itk::Object *
>(iter->GetPointer());
191 MITK_ERROR <<
"There is more than one GUI for " << classname <<
" (several factories claim ability to produce a " 192 << guiClassname <<
" ) " << std::endl;
202 return m_PredicateReference.GetPointer();
207 return m_IsSegmentationPredicate.GetPointer();
211 const std::string &organName,
219 PixelType pixelType(mitk::MakeScalarPixelType<DefaultSegmentationDataType>());
225 segmentation->Initialize(pixelType, 3, dimensions);
226 segmentation->AddLayer();
230 segmentation->Initialize(original);
234 label->SetName(organName);
235 label->SetColor(color);
237 segmentation->GetActiveLabelSet()->AddLabel(label);
238 segmentation->GetActiveLabelSet()->SetActiveLabel(1);
242 if (segmentation->GetDimension() < 4)
244 for (
unsigned int dim = 0; dim < segmentation->GetDimension(); ++dim)
246 byteSize *= segmentation->GetDimension(dim);
251 memset(writeAccess.GetData(), 0, byteSize);
256 for (
unsigned int dim = 0; dim < 3; ++dim)
258 byteSize *= segmentation->GetDimension(dim);
261 for (
unsigned int volumeNumber = 0; volumeNumber < segmentation->GetDimension(3); volumeNumber++)
265 memset(writeAccess.GetData(), 0, byteSize);
272 segmentation->SetTimeGeometry(originalGeometry);
276 Tool::ErrorMessage(
"Original image does not have a 'Time sliced geometry'! Cannot create a segmentation.");
284 const std::string &organName,
292 segmentationNode->SetData(image);
303 lutProp->SetLookupTable(lut);
304 segmentationNode->SetProperty(
"LookupTable", lutProp);
305 segmentationNode->SetProperty(
"texture interpolation",
BoolProperty::New(
false));
310 segmentationNode->SetProperty(
"reslice interpolation",
317 return segmentationNode;
Predicate that evaluates if the given DataNode has a specific property. If the second parameter is nu...
Composite predicate that negates its child predicate Changed: NodePredicateNot now derives from NodeP...
Base class to implement InteractionEventObservers.
Observer that manages the interaction with the display.
Base of all data objects.
Predicate that evaluates if the given DataNodes data object has the specified dimension, for datasets where dimension is applicable.
bool HandleEvent(InteractionEvent *event, DataNode *dataNode)
bool LoadStateMachine(const std::string &filename, const us::Module *module=nullptr)
Loads XML resource.
DataCollection - Class to facilitate loading/accessing structured data.
void * GetService(const ServiceReferenceBase &reference)
The LevelWindow class Class to store level/window values.
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
unsigned int GetDimension() const
Get dimension of the image.
This class serves as an event state machine while simultaneously observing interaction events...
Module * GetModule() const
Image class for storing images.
mitk::Image::Pointer image
std::vector< ServiceReferenceU > GetServiceReferences(const std::string &clazz, const std::string &filter=std::string())
itk::RGBPixel< float > Color
Color Standard RGB color typedef (float)
ImageWriteAccessor class to get locked write-access for a particular image part.
Predicate that evaluates if the given DataNodes data object is of a specific data type...
static ModuleContext * GetModuleContext()
Returns the module context of the calling module.
Composite predicate that forms a logical AND relation from its child predicates.
Class for nodes of the DataTree.
Composite predicate that forms a logical OR relation from its child predicates.
Class for defining the data type of pixels.
bool SetEventConfig(const std::string &filename, const us::Module *module=nullptr)
Loads a configuration from an XML resource.