Refactor QDicomViewer, extract toolbar DefaultToolBar class,add state check.
This commit is contained in:
@@ -393,6 +393,28 @@ bool ImageViewManager::checkViewFusion(DicomImageView *view) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ImageViewManager::checkSyncAbility(DicomImageView* view) {
|
||||||
|
bool flag = false;
|
||||||
|
this->smartDo([](auto v, auto callData) {
|
||||||
|
bool *d = (bool *) callData;
|
||||||
|
if (d[0]) return;
|
||||||
|
if (v->hasSeries()) {
|
||||||
|
d[0] = true;
|
||||||
|
}
|
||||||
|
}, view, &flag, ImageViewManager::SameStudySeries);
|
||||||
|
if (flag) return AUTO_SYNC;
|
||||||
|
this->smartDo([](auto v, auto callData) {
|
||||||
|
bool *d = (bool *) callData;
|
||||||
|
if (d[0]) return;
|
||||||
|
if (v->hasSeries()) {
|
||||||
|
d[0] = true;
|
||||||
|
}
|
||||||
|
}, view, &flag, ImageViewManager::SameOrientationSeries);
|
||||||
|
|
||||||
|
if (flag) return MANUAL_SYNC;
|
||||||
|
return DIS_SYNC;
|
||||||
|
}
|
||||||
|
|
||||||
void ImageViewManager::clearCurrentView() {
|
void ImageViewManager::clearCurrentView() {
|
||||||
currentView->viewCleared();
|
currentView->viewCleared();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ public:
|
|||||||
|
|
||||||
void switchFusion(bool fusion);
|
void switchFusion(bool fusion);
|
||||||
|
|
||||||
|
int checkSyncAbility(DicomImageView* view);
|
||||||
|
|
||||||
enum DoScope {
|
enum DoScope {
|
||||||
Current,
|
Current,
|
||||||
SameSeries,
|
SameSeries,
|
||||||
|
|||||||
@@ -17,10 +17,12 @@ ImageViewStateCheckWorker::~ImageViewStateCheckWorker() {
|
|||||||
|
|
||||||
void ImageViewStateCheckWorker::checkImageViewState(DicomImageView *view) {
|
void ImageViewStateCheckWorker::checkImageViewState(DicomImageView *view) {
|
||||||
if (!mManager || !view) return;
|
if (!mManager || !view) return;
|
||||||
QThread::sleep(2);
|
|
||||||
ViewFunctionState state;
|
ViewFunctionState state;
|
||||||
state.canSync=false;
|
if (view->hasSeries()){
|
||||||
state.canMPR=true;
|
state.canSync=mManager->checkSyncAbility(view);
|
||||||
state.canFusion=true;
|
state.canMPR=view->checkMPRAble();
|
||||||
emit imageViewStateChanged(state);
|
state.canFusion=mManager->checkViewFusion(view);
|
||||||
|
emit imageViewStateChanged(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class DicomImageView;
|
|||||||
class ImageViewManager;
|
class ImageViewManager;
|
||||||
|
|
||||||
struct ViewFunctionState{
|
struct ViewFunctionState{
|
||||||
bool canSync;
|
int canSync;
|
||||||
bool canMPR;
|
bool canMPR;
|
||||||
bool canFusion;
|
bool canFusion;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -737,3 +737,7 @@ bool DicomImageView::checkFusion(DicomImageView *overlap) {
|
|||||||
return DicomImageView::checkFusion(this, overlap);
|
return DicomImageView::checkFusion(this, overlap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DicomImageView::checkMPRAble(DicomImageView *view) {
|
||||||
|
return (view->getSeriesInstance()->GetProperty()->GetSliceCount() > 20 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,10 +32,6 @@ public:
|
|||||||
|
|
||||||
~DicomImageView() override;
|
~DicomImageView() override;
|
||||||
|
|
||||||
static bool checkFusion(DicomImageView *base, DicomImageView *overlap);
|
|
||||||
|
|
||||||
bool checkFusion(DicomImageView *overlap);
|
|
||||||
|
|
||||||
void showMetaData();
|
void showMetaData();
|
||||||
|
|
||||||
QVTKOpenGLNativeWidget *getGLWidget() {
|
QVTKOpenGLNativeWidget *getGLWidget() {
|
||||||
@@ -64,12 +60,12 @@ public:
|
|||||||
//Reset
|
//Reset
|
||||||
void resetView();
|
void resetView();
|
||||||
|
|
||||||
|
|
||||||
//Corner Info
|
//Corner Info
|
||||||
void updateCornerInfoAll();
|
void updateCornerInfoAll();
|
||||||
|
|
||||||
void updateCornerInfoPrivacy();
|
void updateCornerInfoPrivacy();
|
||||||
|
|
||||||
|
|
||||||
//Window level
|
//Window level
|
||||||
void getWindowLevel(double &level, double &width);
|
void getWindowLevel(double &level, double &width);
|
||||||
|
|
||||||
@@ -84,7 +80,6 @@ public:
|
|||||||
|
|
||||||
void rotateImage(double angle, TransFormType operation);
|
void rotateImage(double angle, TransFormType operation);
|
||||||
|
|
||||||
|
|
||||||
//Fusion
|
//Fusion
|
||||||
bool isFusion();
|
bool isFusion();
|
||||||
|
|
||||||
@@ -94,6 +89,10 @@ public:
|
|||||||
|
|
||||||
void unloadFusion();
|
void unloadFusion();
|
||||||
|
|
||||||
|
bool checkFusion(DicomImageView *overlap);
|
||||||
|
|
||||||
|
static bool checkFusion(DicomImageView *base, DicomImageView *overlap);
|
||||||
|
|
||||||
|
|
||||||
//Measure
|
//Measure
|
||||||
void activeMeasure(Measure *m);
|
void activeMeasure(Measure *m);
|
||||||
@@ -152,6 +151,7 @@ public:
|
|||||||
//Negative
|
//Negative
|
||||||
void negativeWindow();
|
void negativeWindow();
|
||||||
|
|
||||||
|
//MPR
|
||||||
void setSliceOrientation(int orientation);
|
void setSliceOrientation(int orientation);
|
||||||
|
|
||||||
int getSliceOrientation();
|
int getSliceOrientation();
|
||||||
@@ -168,6 +168,12 @@ public:
|
|||||||
mImageViewer->applySliceOffset(offset, direction);
|
mImageViewer->applySliceOffset(offset, direction);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool checkMPRAble(){
|
||||||
|
return DicomImageView::checkMPRAble(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool checkMPRAble(DicomImageView* view);
|
||||||
|
|
||||||
void loadSeries(SeriesImageSet *series);
|
void loadSeries(SeriesImageSet *series);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|||||||
@@ -363,7 +363,7 @@ void DefaultToolBar::SetupFusionTool() {
|
|||||||
});
|
});
|
||||||
mBtnFusion->setPopupMode(QToolButton::MenuButtonPopup);
|
mBtnFusion->setPopupMode(QToolButton::MenuButtonPopup);
|
||||||
mBtnFusion->setMenu(m);
|
mBtnFusion->setMenu(m);
|
||||||
// mBtnFusion->setEnabled(false);
|
mBtnFusion->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultToolBar::SetupCineTool() {
|
void DefaultToolBar::SetupCineTool() {
|
||||||
@@ -408,16 +408,24 @@ void DefaultToolBar::SetupMPR(){
|
|||||||
syncStateChanged();
|
syncStateChanged();
|
||||||
emit changeSliceOrientation();
|
emit changeSliceOrientation();
|
||||||
});
|
});
|
||||||
// mBtnMPR->setEnabled(false);
|
mBtnMPR->setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultToolBar::resetNeedCheckFunctionButtons(){
|
void DefaultToolBar::resetNeedCheckFunctionButtons(){
|
||||||
// mBtnMPR->setEnabled(false);
|
mBtnMPR->setEnabled(false);
|
||||||
mBtnFusion->setEnabled(false);
|
mBtnFusion->setEnabled(false);
|
||||||
SyncHelper::setSyncState(DIS_SYNC);
|
SyncHelper::setSyncState(DIS_SYNC);
|
||||||
syncStateChanged();
|
syncStateChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DefaultToolBar::updateNeedCheckFunctionButtons(ViewFunctionState state)
|
||||||
|
{
|
||||||
|
mBtnMPR->setEnabled(state.canMPR);
|
||||||
|
mBtnFusion->setEnabled(state.canFusion);
|
||||||
|
// SyncHelper::setSyncState((SyncState)state.canSync);
|
||||||
|
// syncStateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void DefaultToolBar::SetupScreenTool() {
|
void DefaultToolBar::SetupScreenTool() {
|
||||||
mBtnFullScreen->setToolTip(QString("Full screen"));
|
mBtnFullScreen->setToolTip(QString("Full screen"));
|
||||||
connect(mBtnFullScreen, &QToolButton::clicked, this, [=] {
|
connect(mBtnFullScreen, &QToolButton::clicked, this, [=] {
|
||||||
|
|||||||
@@ -6,7 +6,9 @@
|
|||||||
#define OMEGAV_DEFAULTTOOLBAR_H
|
#define OMEGAV_DEFAULTTOOLBAR_H
|
||||||
|
|
||||||
#include <QToolBar>
|
#include <QToolBar>
|
||||||
|
|
||||||
#include "Common/QGlobals.h"
|
#include "Common/QGlobals.h"
|
||||||
|
#include "UI/Manager/ImageViewStateCheckWorker.h"
|
||||||
|
|
||||||
class QButtonGroup;
|
class QButtonGroup;
|
||||||
|
|
||||||
@@ -18,6 +20,7 @@ public:
|
|||||||
~DefaultToolBar();
|
~DefaultToolBar();
|
||||||
|
|
||||||
void resetNeedCheckFunctionButtons();
|
void resetNeedCheckFunctionButtons();
|
||||||
|
void updateNeedCheckFunctionButtons(ViewFunctionState state);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void openFile();
|
void openFile();
|
||||||
|
|||||||
@@ -72,8 +72,8 @@ void QDicomViewer::SetupConnections() {
|
|||||||
connect(ui->viewContainer->getViewManager(),
|
connect(ui->viewContainer->getViewManager(),
|
||||||
&ImageViewManager::currentViewReload,
|
&ImageViewManager::currentViewReload,
|
||||||
&worker,&ImageViewStateCheckWorker::checkImageViewState, Qt::QueuedConnection);
|
&worker,&ImageViewStateCheckWorker::checkImageViewState, Qt::QueuedConnection);
|
||||||
// connect(&worker,&ImageViewStateCheckWorker::imageViewStateChanged,
|
connect(&worker,&ImageViewStateCheckWorker::imageViewStateChanged,
|
||||||
// this,&QDicomViewer::resetToolBarButtons, Qt::QueuedConnection);
|
ui->toolBar,&DefaultToolBar::updateNeedCheckFunctionButtons, Qt::QueuedConnection);
|
||||||
workerManager.registerWorker(&worker);
|
workerManager.registerWorker(&worker);
|
||||||
|
|
||||||
//通知左侧的缩略图bar ,当前选中series的变换
|
//通知左侧的缩略图bar ,当前选中series的变换
|
||||||
|
|||||||
Reference in New Issue
Block a user