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