96 lines
3.0 KiB
C++
96 lines
3.0 KiB
C++
// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "JFJochReader.h"
|
|
#include "../common/PixelMask.h"
|
|
|
|
void JFJochReader::LoadImage(int64_t image_number, int64_t summation_factor) {
|
|
// It would be a mess to load two images at the same time
|
|
// so loading is protected via mutex
|
|
// yet copying share_ptr pointer is atomic and needs no mutex protection
|
|
|
|
std::unique_lock ul(current_image_mutex);
|
|
auto image = LoadImageInternal(image_number);
|
|
if (image) {
|
|
for (int i = 1; i < summation_factor; i++) {
|
|
auto tmp = LoadImageInternal(image_number + i);
|
|
if (tmp)
|
|
image->AddImage(*tmp);
|
|
}
|
|
}
|
|
if (roi)
|
|
image->CalcROI(roi.get());
|
|
image->BraggIntegrate(bragg_integration_settings);
|
|
current_image = image;
|
|
}
|
|
|
|
std::shared_ptr<const JFJochReaderImage> JFJochReader::CopyImage() {
|
|
return current_image;
|
|
}
|
|
|
|
void JFJochReader::CalcROI() {
|
|
if (roi && current_image) {
|
|
auto image = std::make_shared<JFJochReaderImage>(*current_image);
|
|
image->CalcROI(roi.get());
|
|
current_image = image;
|
|
}
|
|
}
|
|
|
|
void JFJochReader::BraggIntegrate() {
|
|
if (roi && current_image) {
|
|
auto image = std::make_shared<JFJochReaderImage>(*current_image);
|
|
image->BraggIntegrate(bragg_integration_settings);
|
|
current_image = image;
|
|
}
|
|
}
|
|
|
|
void JFJochReader::ClearROI() {
|
|
std::unique_lock lg(current_image_mutex);
|
|
roi = {};
|
|
CalcROI();
|
|
}
|
|
|
|
void JFJochReader::SetROI(const ROIBox &input) {
|
|
std::unique_lock lg(current_image_mutex);
|
|
roi = std::make_unique<ROIBox>(input);
|
|
CalcROI();
|
|
}
|
|
|
|
void JFJochReader::SetROI(const ROICircle &input) {
|
|
std::unique_lock lg(current_image_mutex);
|
|
roi = std::make_unique<ROICircle>(input);
|
|
CalcROI();
|
|
}
|
|
|
|
void JFJochReader::SetStartMessage(const std::shared_ptr<JFJochReaderDataset> &val) {
|
|
std::unique_lock ul(start_message_mutex);
|
|
start_message = val;
|
|
if (start_message)
|
|
start_message->experiment.ImportBraggIntegrationSettings(bragg_integration_settings);
|
|
}
|
|
|
|
std::shared_ptr<const JFJochReaderDataset> JFJochReader::GetStartMessage() const {
|
|
std::unique_lock ul(start_message_mutex);
|
|
if (!start_message)
|
|
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid, "File not loaded");
|
|
return start_message;
|
|
}
|
|
|
|
void JFJochReader::SetBraggIntegrationSettings(const BraggIntegrationSettings &settings) {
|
|
std::unique_lock lg(current_image_mutex);
|
|
bragg_integration_settings = settings;
|
|
BraggIntegrate();
|
|
}
|
|
|
|
BraggIntegrationSettings JFJochReader::GetBraggIntegrationSettings() const {
|
|
std::unique_lock lg(current_image_mutex);
|
|
return bragg_integration_settings;
|
|
}
|
|
|
|
void JFJochReader::UpdateExperiment(const DiffractionExperiment &experiment) {
|
|
std::scoped_lock lock(current_image_mutex, start_message_mutex);
|
|
|
|
// auto new_dataset = std::make_shared<JFJochReaderDataset>(current_image.get());
|
|
|
|
|
|
} |