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

Method ApplyColor

Modules/Core/src/Rendering/mitkImageVtkMapper2D.cpp:499–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

497}
498
499void mitk::ImageVtkMapper2D::ApplyColor(mitk::BaseRenderer *renderer)
500{
501 LocalStorage *localStorage = this->GetLocalStorage(renderer);
502
503 float rgb[3] = {1.0f, 1.0f, 1.0f};
504
505 // check for color prop and use it for rendering if it exists
506 // binary image hovering & binary image selection
507 bool hover = false;
508 bool selected = false;
509 bool binary = false;
510 GetDataNode()->GetBoolProperty("binaryimage.ishovering", hover, renderer);
511 GetDataNode()->GetBoolProperty("selected", selected, renderer);
512 GetDataNode()->GetBoolProperty("binary", binary, renderer);
513 if (binary && hover && !selected)
514 {
515 mitk::ColorProperty::Pointer colorprop =
516 dynamic_cast<mitk::ColorProperty *>(GetDataNode()->GetProperty("binaryimage.hoveringcolor", renderer));
517 if (colorprop.IsNotNull())
518 {
519 memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3 * sizeof(float));
520 }
521 else
522 {
523 GetDataNode()->GetColor(rgb, renderer, "color");
524 }
525 }
526 if (binary && selected)
527 {
528 mitk::ColorProperty::Pointer colorprop =
529 dynamic_cast<mitk::ColorProperty *>(GetDataNode()->GetProperty("binaryimage.selectedcolor", renderer));
530 if (colorprop.IsNotNull())
531 {
532 memcpy(rgb, colorprop->GetColor().GetDataPointer(), 3 * sizeof(float));
533 }
534 else
535 {
536 GetDataNode()->GetColor(rgb, renderer, "color");
537 }
538 }
539 if (!binary || (!hover && !selected))
540 {
541 GetDataNode()->GetColor(rgb, renderer, "color");
542 }
543
544 double rgbConv[3] = {(double)rgb[0], (double)rgb[1], (double)rgb[2]}; // conversion to double for VTK
545 localStorage->m_ShadowOutlineActor->GetProperty()->SetColor(rgbConv);
546 localStorage->m_ImageActor->GetProperty()->SetColor(rgbConv);
547
548 float shadowRGB[3] = {1.0f, 1.0f, 1.0f};
549 mitk::ColorProperty::Pointer colorprop =
550 dynamic_cast<mitk::ColorProperty *>(GetDataNode()->GetProperty("outline binary shadow color", renderer));
551 if (colorprop.IsNotNull())
552 {
553 memcpy(shadowRGB, colorprop->GetColor().GetDataPointer(), 3 * sizeof(float));
554 }
555 double shadowRGBConv[3] = {(double)shadowRGB[0], (double)shadowRGB[1], (double)shadowRGB[2]}; // conversion to double for VTK
556 localStorage->m_ShadowOutlineActor->GetProperty()->SetColor(shadowRGBConv);

Callers 1

ApplyRenderingModeMethod · 0.95

Calls 6

GetLocalStorageMethod · 0.95
IsNotNullMethod · 0.80
GetBoolPropertyMethod · 0.45
GetPropertyMethod · 0.45
GetColorMethod · 0.45
SetColorMethod · 0.45

Tested by

no test coverage detected