From 5f5bb02cc0181eb9a8af343d7043c82411515092 Mon Sep 17 00:00:00 2001 From: Paul Yushkevich Date: Mon, 25 Mar 2024 10:48:23 -0400 Subject: [PATCH] Fixed bug with >1024 pixel images and snake mode --- Logic/Framework/GenericImageData.cxx | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/Logic/Framework/GenericImageData.cxx b/Logic/Framework/GenericImageData.cxx index 9f8c7a22..af9411fc 100644 --- a/Logic/Framework/GenericImageData.cxx +++ b/Logic/Framework/GenericImageData.cxx @@ -288,6 +288,17 @@ ::AddOverlay(GuidedNativeImageIO *io) this->AddOverlayInternal(wrapper); } +void GenericImageData::AddOverlay(ImageWrapperBase *new_layer) +{ + // Additional configuration for the wrapper (normally called in CreateAnatomicImageWrapper) + for(int i = 0; i < 3; i++) + new_layer->SetDisplayViewportGeometry(i, m_DisplayViewportGeometry[i]); + + this->AddOverlayInternal(new_layer, true); +} + + + void GenericImageData ::AddCoregOverlay(GuidedNativeImageIO *io, ITKTransformType *transform) @@ -714,6 +725,11 @@ LabelImageWrapper *GenericImageData::GetFirstSegmentationLayer() void GenericImageData::PushBackImageWrapper(LayerRole role, ImageWrapperBase *wrapper) { + // TODO: this is being called in too many places, but for now this is a band-aid bug + // fix to avoid crash when the viewport geometry is not set in a wrapper + for(int i = 0; i < 3; i++) + wrapper->SetDisplayViewportGeometry(i, m_DisplayViewportGeometry[i]); + // Append the wrapper m_Wrappers[role].push_back(wrapper); @@ -777,6 +793,13 @@ void GenericImageData::SetSingleImageWrapper(LayerRole role, ImageWrapperBase *wrapper) { assert(m_Wrappers[role].size() == 1); + + // TODO: this is being called in too many places, but for now this is a band-aid bug + // fix to avoid crash when the viewport geometry is not set in a wrapper + for(int i = 0; i < 3; i++) + wrapper->SetDisplayViewportGeometry(i, m_DisplayViewportGeometry[i]); + + // Assign the first wrapper in role m_Wrappers[role].front() = wrapper; // Rebroadcast the wrapper-related events as our own events @@ -841,11 +864,6 @@ std::string GenericImageData::GenerateNickname(LayerRole role) } -void GenericImageData::AddOverlay(ImageWrapperBase *new_layer) -{ - this->AddOverlayInternal(new_layer, true); -} - ImageMeshLayers * GenericImageData::GetMeshLayers() {