77 lines
2.2 KiB
C++
77 lines
2.2 KiB
C++
//
|
|
// Created by Krad on 2022/3/9.
|
|
//
|
|
|
|
#include "ImageViewManager.h"
|
|
#include "algorithm"
|
|
|
|
bool ImageViewManager::contains(DicomImageView *view) {
|
|
auto iter = std::find(vList.begin(),vList.end(),view);
|
|
return !(iter == vList.end());
|
|
}
|
|
|
|
void ImageViewManager::add(DicomImageView *view) {
|
|
if (view && !contains(view)){
|
|
vList.push_back(view);
|
|
}
|
|
}
|
|
|
|
void ImageViewManager::remove(DicomImageView *view) {
|
|
if (view && contains(view)){
|
|
vList.removeOne(view);
|
|
delete view;
|
|
}
|
|
}
|
|
|
|
void ImageViewManager::remove(int idx) {
|
|
if (idx >= vList.size()) return;
|
|
auto view = vList.at(idx);
|
|
vList.removeOne(view);
|
|
delete view;
|
|
}
|
|
|
|
void ImageViewManager::smartDo(SmartDoCallback cb, DicomImageView *sourceView, void* callData, DoScope scope) {
|
|
switch (scope) {
|
|
case DoScope::Current:{
|
|
if (currentView)
|
|
cb(currentView, callData);
|
|
break;
|
|
}
|
|
case DoScope::SameSeries:{
|
|
std::for_each(vList.begin(),vList.end(),[=](auto v){
|
|
//check series
|
|
auto series = sourceView->getSeriesInstance();
|
|
if (v->getSeriesInstance()==series && v->GetSliceOrientation() == sourceView->GetSliceOrientation()){
|
|
cb(v, callData);
|
|
}
|
|
|
|
});
|
|
break;
|
|
}
|
|
case DoScope::SameSeriesExceptSelf:{
|
|
std::for_each(vList.begin(),vList.end(),[=](auto v){
|
|
if (v == sourceView) return;
|
|
//check series
|
|
auto series = sourceView->getSeriesInstance();
|
|
if (v->getSeriesInstance()==series && v->GetSliceOrientation() == sourceView->GetSliceOrientation()){
|
|
cb(v, callData);
|
|
}
|
|
});
|
|
break;
|
|
}
|
|
case DoScope::AllExceptSelf:
|
|
{
|
|
std::for_each(vList.begin(),vList.end(),[=](auto v){
|
|
if (v == sourceView) return;
|
|
cb(v, callData);
|
|
});
|
|
break;
|
|
}
|
|
case DoScope::All:
|
|
default:
|
|
std::for_each(vList.begin(),vList.end(),[=](auto v){
|
|
cb(v, callData);
|
|
});
|
|
}
|
|
}
|