Refactor Sync button update logic, disable sync when change slice orientation.

This commit is contained in:
Krad
2022-07-27 13:11:33 +08:00
parent 6f94cbf42c
commit 74a1817c1e
4 changed files with 43 additions and 30 deletions

View File

@@ -1,4 +1,6 @@
#pragma once
#ifndef OMEGAV_QGLOBALS_H
#define OMEGAV_QGLOBALS_H
#include <QWidget>
#include <QSize>
#include <QString>
@@ -10,6 +12,7 @@
#include <QVBoxLayout>
#include <QPushButton>
#include <memory>
#include "Events/EventsCenter.h"
#include <QGuiApplication>
#include <QScreen>
@@ -18,11 +21,11 @@
#include "IO/DICOM/ExtendMedicalImageProperties.h"
using namespace std;
// <20><><EFBFBD><EFBFBD>
//
#define Project_NAME "EquilibriumNine DicomViewer"
#define Project_VER "1.0.0.0"
//<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
//
#define Project_OrganizationName "EquilibriumNine"
#define Project_OrganizationDomain ""
@@ -318,6 +321,7 @@ public:
static void setSyncState(SyncState curState)
{
_syc_state = curState;
EventsCenter::TriggerEvent(SyncStateChanged);
}
static const QString SyncStateName[SYNC_STATE_NUM];// = { "AUTO_SYNC","MANUAL_SYNC","DIS_SYNC" };
static const QString SyncItemName[SYNC_ITEM_NUM];// = { "SLICE_LOC","ZOOM_PAN","WIDTH_LEVEL" };
@@ -362,3 +366,4 @@ typedef struct PatientInfo
}
}PatientInfo_t;
typedef std::map<std::string, PatientInfo_t*> PatientsMapType;
#endif OMEGAV_QGLOBALS_H

View File

@@ -13,7 +13,6 @@ Q_OBJECT
public :
void raise(vtkObject *sender, unsigned long eventId, void *callData = nullptr);
signals:
void raiseEvent(vtkObject *sender, unsigned long eventId, void *callData = nullptr);

View File

@@ -171,8 +171,11 @@ void QDicomViewer::createToolButton() {
this->SetupMinimizeTool(btnminimize);
this->SetupCloseTool(btnclose);
connect(btnMPR, &QToolButton::clicked, ui->viewContainer->getViewManager(),
&ImageViewManager::switchSliceOrientation);
connect(btnMPR, &QToolButton::clicked, [=](){
ui->viewContainer->getViewManager()->switchSliceOrientation();
SyncHelper::setSyncState(DIS_SYNC);
syncStateChanged();
});
}
void QDicomViewer::SetupFullScreenTool(QToolButton *btnfullscreen) {
@@ -482,7 +485,8 @@ void QDicomViewer::SetupFlipTool(QToolButton *flipBtn) {
}
//视窗操作sync mode
void QDicomViewer::SetupSyncTool(QToolButton *syncBtn) {
void QDicomViewer::SetupSyncTool(QToolButton *btn) {
syncBtn = btn;
syncBtn->setToolTip(QString("Toggle series synchronization"));
// Menu
QMenu * m = new QMenu(this);
@@ -513,35 +517,20 @@ void QDicomViewer::SetupSyncTool(QToolButton *syncBtn) {
//loop click
connect(syncBtn, &QToolButton::clicked, this,
&QDicomViewer::syncStateChanged);
&QDicomViewer::switchSyncState);
connect(EventsCenter::Default(), &EventsCenter::SyncStateChanged, this, &QDicomViewer::syncStateChanged);
}
void QDicomViewer::switchSyncState(){
SyncHelper::setSyncState((SyncState)((SyncHelper::getSyncState()+1)%3));
}
void QDicomViewer::syncStateChanged() const {
QToolButton* syncBtn = qobject_cast<QToolButton*>(sender());
SyncState curst = SyncHelper::getSyncState();
switch (curst) {
if (!syncBtn) return;
switch (SyncHelper::getSyncState()) {
case AUTO_SYNC:
syncBtn->setIcon(icon_manual);
m_sync_state_action->setText(QString(tr("CUR STATE: %1")).arg(SyncHelper::SyncStateName[MANUAL_SYNC]));
SyncHelper::setSyncState(MANUAL_SYNC);
m_sync_item_action[SLICE_POS]->setChecked(SyncHelper::getSyncItem(SLICE_POS));
m_sync_item_action[WIDTH_LEVEL]->setChecked(SyncHelper::getSyncItem(WIDTH_LEVEL));
m_sync_item_action[ZOOM_PAN]->setChecked(SyncHelper::getSyncItem(ZOOM_PAN));
break;
case MANUAL_SYNC:
syncBtn->setIcon(icon_dis);
m_sync_state_action->setText(QString(tr("CUR STATE: %1")).arg(SyncHelper::SyncStateName[DIS_SYNC]));
SyncHelper::setSyncState(DIS_SYNC);
for (int i = 0; i < SYNC_ITEM_NUM; i++) {
m_sync_item_action[i]->setChecked(false);
m_sync_item_action[i]->setDisabled(true);
}
break;
case DIS_SYNC:
syncBtn->setIcon(icon_auto);
m_sync_state_action->setText(QString(tr("CUR STATE: %1")).arg(SyncHelper::SyncStateName[AUTO_SYNC]));
SyncHelper::setSyncState(AUTO_SYNC);
for (int i = 0; i < SYNC_ITEM_NUM; i++) {
m_sync_item_action[i]->setDisabled(false);
}
@@ -549,6 +538,23 @@ void QDicomViewer::syncStateChanged() const {
m_sync_item_action[WIDTH_LEVEL]->setChecked(SyncHelper::getSyncItem(WIDTH_LEVEL));
m_sync_item_action[ZOOM_PAN]->setChecked(SyncHelper::getSyncItem(ZOOM_PAN));
break;
case MANUAL_SYNC:{
syncBtn->setIcon(icon_manual);
m_sync_state_action->setText(QString(tr("CUR STATE: %1")).arg(SyncHelper::SyncStateName[MANUAL_SYNC]));
m_sync_item_action[SLICE_POS]->setChecked(SyncHelper::getSyncItem(SLICE_POS));
m_sync_item_action[WIDTH_LEVEL]->setChecked(SyncHelper::getSyncItem(WIDTH_LEVEL));
m_sync_item_action[ZOOM_PAN]->setChecked(SyncHelper::getSyncItem(ZOOM_PAN));
break;
}
case DIS_SYNC:
syncBtn->setIcon(icon_dis);
m_sync_state_action->setText(QString(tr("CUR STATE: %1")).arg(SyncHelper::SyncStateName[DIS_SYNC]));
for (int i = 0; i < SYNC_ITEM_NUM; i++) {
m_sync_item_action[i]->setChecked(false);
m_sync_item_action[i]->setDisabled(true);
}
break;
default:
break;
}

View File

@@ -105,6 +105,7 @@ private:
QIcon icon_manual;
QIcon icon_auto;
QIcon icon_dis;
QToolButton* syncBtn = nullptr;
QAction *m_sync_item_action[SYNC_ITEM_NUM];
QAction* m_sync_state_action;
QAction* m_measure_hidden_action;
@@ -124,4 +125,6 @@ private:
AnnotationActorType m_cur_measure = AnnotationActorType::RulerAnn;
void syncStateChanged() const;
void switchSyncState();
};