trying a code refactoring

This commit is contained in:
Giovanni Fattori
2026-01-05 23:14:04 +01:00
parent c406a99474
commit f15b6f8086
13 changed files with 1263 additions and 856 deletions
+40
View File
@@ -0,0 +1,40 @@
#include "LocalizationWorker.h"
#include "LocalizationService.h"
#include <vtkImageData.h>
LocalizationWorker::LocalizationWorker(QObject* parent)
: QObject(parent)
{
}
void LocalizationWorker::abort()
{
m_abort.store(true, std::memory_order_relaxed);
}
void LocalizationWorker::run(vtkImageData* volume, LocalizationParams params)
{
m_abort.store(false, std::memory_order_relaxed);
try {
MarkerList markers = LocalizationService::localize(
volume,
params,
[this](double p) { emit progress(p); },
[this]() { return m_abort.load(std::memory_order_relaxed); }
);
if (m_abort.load(std::memory_order_relaxed)) {
emit aborted();
return;
}
emit finished(std::move(markers));
} catch (const std::exception& e) {
// Keep behavior consistent with legacy code: treat as aborted.
// (UI can be extended to show the exception message.)
(void)e;
emit aborted();
}
}