MCPcopy Create free account
hub / github.com/MITK/MITK / SetDataNode

Method SetDataNode

Modules/QtWidgetsExt/src/QmitkTransferFunctionGeneratorWidget.cpp:308–354  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308void QmitkTransferFunctionGeneratorWidget::SetDataNode(mitk::DataNode *node, mitk::TimeStepType timestep)
309{
310 histoGramm = nullptr;
311
312 if (node)
313 {
314 tfpToChange = dynamic_cast<mitk::TransferFunctionProperty *>(node->GetProperty("TransferFunction"));
315
316 if (!tfpToChange)
317 node->SetProperty("TransferFunction", tfpToChange = mitk::TransferFunctionProperty::New());
318
319 mitk::TransferFunction::Pointer tf = tfpToChange->GetValue();
320
321 if (mitk::Image *image = dynamic_cast<mitk::Image *>(node->GetData()))
322 {
323 mitk::Image::Pointer inputImage = image;
324 if (image->GetTimeSteps() > 1)
325 {
326 if (!image->GetTimeGeometry()->IsValidTimeStep(timestep))
327 {
328 return;
329 }
330 mitk::ImageTimeSelector::Pointer timeselector = mitk::ImageTimeSelector::New();
331 timeselector->SetInput(image);
332 timeselector->SetTimeNr(timestep);
333 timeselector->UpdateLargestPossibleRegion();
334 inputImage = timeselector->GetOutput();
335 }
336
337 mitk::ImageStatisticsHolder *statistics = inputImage->GetStatistics();
338 histoMinimum = statistics->GetScalarValueMin();
339 histoMaximum = statistics->GetScalarValueMax();
340 }
341 else
342 {
343 MITK_WARN << "QmitkTransferFunctonGeneratorWidget does not support " << node->GetData()->GetNameOfClass()
344 << " instances";
345 }
346
347 thPos = (histoMinimum + histoMaximum) / 2.0;
348 }
349 else
350 {
351 tfpToChange = nullptr;
352 m_Controls->m_InfoPreset->setText(QString(""));
353 }
354}

Callers

nothing calls this directly

Calls 15

GetTimeStepsMethod · 0.80
GetStatisticsMethod · 0.80
GetScalarValueMinMethod · 0.80
GetScalarValueMaxMethod · 0.80
NewFunction · 0.50
QStringClass · 0.50
GetPropertyMethod · 0.45
SetPropertyMethod · 0.45
GetValueMethod · 0.45
GetDataMethod · 0.45
IsValidTimeStepMethod · 0.45
SetInputMethod · 0.45

Tested by

no test coverage detected