Introduce ImageViewManager
This commit is contained in:
55
src/src/view/ImageViewManager.cpp
Normal file
55
src/src/view/ImageViewManager.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
void ImageViewManager::smartDo(ImageViewManager::SmartDoCallback cb, ImageViewManager::DoScope scope,DicomImageView* exceptView) {
|
||||
switch (scope) {
|
||||
case DoScope::Current:{
|
||||
if (currentView)
|
||||
cb(currentView);
|
||||
break;
|
||||
}
|
||||
case DoScope::SameSeries:{
|
||||
//TODO: need add same series and same direction check and do logic!
|
||||
break;
|
||||
}
|
||||
case DoScope::SameSeriesExceptSelf:{
|
||||
//TODO: need add same series and same direction check and do logic!
|
||||
break;
|
||||
}
|
||||
case DoScope::AllExceptSelf:
|
||||
std::for_each(vList.begin(),vList.end(),[=](auto v){
|
||||
if (v == exceptView) return;
|
||||
cb(v);
|
||||
});
|
||||
case DoScope::All:
|
||||
default:
|
||||
std::for_each(vList.begin(),vList.end(),[=](auto v){
|
||||
cb(v);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void ImageViewManager::setCurrentView(DicomImageView* view) {
|
||||
currentView = view;
|
||||
}
|
||||
39
src/src/view/ImageViewManager.h
Normal file
39
src/src/view/ImageViewManager.h
Normal file
@@ -0,0 +1,39 @@
|
||||
//
|
||||
// Created by Krad on 2022/3/9.
|
||||
//
|
||||
|
||||
#ifndef OMEGAV_IMAGEVIEWMANAGER_H
|
||||
#define OMEGAV_IMAGEVIEWMANAGER_H
|
||||
#include <QObject>
|
||||
#include <QList>
|
||||
#include "dicomimageview.h"
|
||||
|
||||
|
||||
class ImageViewManager:public QObject {
|
||||
|
||||
Q_OBJECT
|
||||
public:
|
||||
ImageViewManager();
|
||||
~ImageViewManager();
|
||||
bool contains(DicomImageView* view);
|
||||
void add(DicomImageView* view);
|
||||
void remove(DicomImageView* view);
|
||||
void setCurrentView(DicomImageView* view);
|
||||
|
||||
enum DoScope{
|
||||
Current,
|
||||
SameSeries,
|
||||
SameSeriesExceptSelf,
|
||||
AllExceptSelf,
|
||||
All
|
||||
};
|
||||
typedef void(*SmartDoCallback)(DicomImageView*);
|
||||
void smartDo(SmartDoCallback cb, DoScope scope = Current,DicomImageView* exceptView = nullptr );
|
||||
|
||||
private:
|
||||
QList<DicomImageView*> vList;
|
||||
DicomImageView *currentView = nullptr;
|
||||
};
|
||||
|
||||
|
||||
#endif //OMEGAV_IMAGEVIEWMANAGER_H
|
||||
@@ -1,7 +1,4 @@
|
||||
#include "view/DicomImageView.h"
|
||||
//#include <DcmFile.h>
|
||||
//#include <DcmDataset.h>
|
||||
//#include "view/subview/metaDataWindow.h"
|
||||
#include "view/dicomimageview.h"
|
||||
#include <QMessageBox>
|
||||
#include <QDebug>
|
||||
#include <QMimeData>
|
||||
@@ -84,24 +81,6 @@ MyTitleBar * DicomImageView::createMyTitleBar()
|
||||
return titleBar;
|
||||
}
|
||||
|
||||
void DicomImageView::ToggleNegativeMode()
|
||||
{
|
||||
if (HasSeries())
|
||||
{
|
||||
if (isNegative)
|
||||
{
|
||||
_ImageViewer->SetNegativeMode(false);
|
||||
isNegative = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ImageViewer->SetNegativeMode(true);
|
||||
isNegative = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void DicomImageView::initScrollbar()
|
||||
{
|
||||
//_MinSlice = _ImageViewer->GetSliceMin();
|
||||
@@ -161,7 +140,6 @@ void DicomImageView::Slot_ViewEmpty()
|
||||
|
||||
void DicomImageView::Slot_viewDoubleclicked()
|
||||
{
|
||||
//emit Signal_ViewClicked(this);
|
||||
emit Signal_viewDoubleclicked(this);
|
||||
}
|
||||
|
||||
@@ -189,43 +167,27 @@ void DicomImageView::wheelEvent(QWheelEvent *event)
|
||||
|
||||
if (event->delta() > 0)
|
||||
{
|
||||
//
|
||||
//cout << "scroll forward" << endl;
|
||||
if (_Slice > _MinSlice)
|
||||
{
|
||||
_Slice -= 1;
|
||||
|
||||
//this->SetSlice(_Slice);
|
||||
_scrollBar->setValue(_Slice);
|
||||
|
||||
//emit Signal_scrollValueChanged(this, _Slice);
|
||||
//emit scroll_ValueChanged(_Slice);
|
||||
//mySetSlice(_Slice);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Slice = _MinSlice;
|
||||
//this->SetSlice(_Slice);
|
||||
_scrollBar->setValue(_Slice);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
//cout << "scroll backward" << endl;
|
||||
if (_Slice < _MaxSlice)
|
||||
{
|
||||
_Slice += 1;
|
||||
//this->SetSlice(_Slice);
|
||||
_scrollBar->setValue(_Slice);
|
||||
//emit Signal_scrollValueChanged(this, _Slice);
|
||||
//emit scroll_ValueChanged(_Slice);
|
||||
//mySetSlice(_Slice);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Slice = _MaxSlice;
|
||||
//this->SetSlice(_Slice);
|
||||
_scrollBar->setValue(_Slice);
|
||||
}
|
||||
}
|
||||
@@ -271,8 +233,6 @@ void DicomImageView::dropEvent(QDropEvent *e) {
|
||||
thumbnailImage *tb = qobject_cast<thumbnailImage*>(
|
||||
(QObject *)(e->mimeData()->text().toULongLong()));
|
||||
if (tb) {
|
||||
//SetSeriesInstance(s);
|
||||
//this->UpdataSeriesInstance();
|
||||
emit Signal_DragDropEvent(this, tb);
|
||||
}
|
||||
}
|
||||
@@ -342,7 +302,7 @@ void DicomImageView::SetFusionInput(DicomImageView *overlay)
|
||||
|
||||
}
|
||||
|
||||
void DicomImageView::IncreFusionOpacity(double percent) {
|
||||
void DicomImageView::SetFusionOpacity(double percent) {
|
||||
if (IsFusion()) {
|
||||
_ImageViewer->IncreFusionOpacity(percent);
|
||||
_ImageViewer->Render();
|
||||
@@ -425,6 +385,7 @@ void DicomImageView::LoadSeries(SeriesImageSet *series)
|
||||
style->AddObserver(ActorDraggableInteractorStyle::ScalarShiftEvent, this, &DicomImageView::scalarEventCb);
|
||||
}
|
||||
|
||||
//Callbacks------------------------------------------------------------------------------------
|
||||
void DicomImageView::updateWindowLevelCb(vtkObject*caller, unsigned long eid, void *calldata)
|
||||
{
|
||||
_ImageViewer->updateCornerInfo(BOTTOM_RIGHT);
|
||||
@@ -443,7 +404,7 @@ void DicomImageView::scalarEventCb(vtkObject* sender, unsigned long eventId, voi
|
||||
break;
|
||||
case(ActorDraggableInteractorStyle::ScalarOpacityEvent):
|
||||
qDebug() << "ScalarOpacityEvent" << r[0];
|
||||
IncreFusionOpacity(r[0]);
|
||||
SetFusionOpacity(r[0]);
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -626,6 +587,24 @@ void DicomImageView::SetWindowLevel(double level, double width)
|
||||
}
|
||||
}
|
||||
|
||||
void DicomImageView::ToggleNegativeMode()
|
||||
{
|
||||
if (HasSeries())
|
||||
{
|
||||
if (isNegative)
|
||||
{
|
||||
_ImageViewer->SetNegativeMode(false);
|
||||
isNegative = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ImageViewer->SetNegativeMode(true);
|
||||
isNegative = true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void DicomImageView::HFlip()
|
||||
{
|
||||
if (HasSeries()) {
|
||||
|
||||
@@ -80,7 +80,7 @@ public:
|
||||
|
||||
//Fusion
|
||||
bool IsFusion();
|
||||
void IncreFusionOpacity(double percent);
|
||||
void SetFusionOpacity(double percent);
|
||||
void SetFusionInput(DicomImageView *overlap);
|
||||
void removeViewWithFusion();
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ QList<DicomImageView *> ViewContainerWidget::getViewList() const {
|
||||
return view_list_;
|
||||
}
|
||||
|
||||
|
||||
DicomImageView *ViewContainerWidget::getCurrentView() const {
|
||||
return current_view_;
|
||||
}
|
||||
@@ -58,7 +57,6 @@ DicomImageView* ViewContainerWidget::getNextView() const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
void ViewContainerWidget::Slot_SyncEvent(DicomImageView *view, int interactionMode, void* calldata)
|
||||
{
|
||||
|
||||
@@ -334,7 +332,6 @@ void ViewContainerWidget::emptyCurrentView()
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ViewContainerWidget::Slot_ViewEmpty(DicomImageView *view)
|
||||
{
|
||||
if (view != nullptr)
|
||||
|
||||
Reference in New Issue
Block a user