Add annotations and referenceLine hide or show functions.

This commit is contained in:
Krad
2022-08-12 14:10:31 +08:00
parent b85b1ac717
commit 433613e851
10 changed files with 43 additions and 11 deletions

View File

@@ -200,13 +200,13 @@ public:
EventsCenter::TriggerEvent(AnonymizeStateChanged); EventsCenter::TriggerEvent(AnonymizeStateChanged);
} }
static bool IsAnno() static bool GetVisibility()
{ {
return annotOn; return annotOn;
} }
static void toggleAnno() static void setVisibility(bool v)
{ {
annotOn = !annotOn; annotOn = v;
EventsCenter::TriggerEvent(AnnotationStateChanged); EventsCenter::TriggerEvent(AnnotationStateChanged);
} }

View File

@@ -211,7 +211,7 @@ void ActorDraggableInteractorStyle::OnChar() {
void ActorDraggableInteractorStyle::NoneStatePick() { void ActorDraggableInteractorStyle::NoneStatePick() {
if (AnnoHelper::IsAnno()) { if (AnnoHelper::GetVisibility()) {
int *pos = this->Interactor->GetEventPosition(); int *pos = this->Interactor->GetEventPosition();
this->FindPokedRenderer(pos[0], pos[1]); this->FindPokedRenderer(pos[0], pos[1]);
int result = picker->PickProp(pos[0], pos[1], this->CurrentRenderer); int result = picker->PickProp(pos[0], pos[1], this->CurrentRenderer);

View File

@@ -14,6 +14,8 @@
#include <vtkProperty2D.h> #include <vtkProperty2D.h>
#include <vtkPolyLineSource.h> #include <vtkPolyLineSource.h>
bool ReferenceLineLegendActor::TypeVisibility = true;
vtkStandardNewMacro(ReferenceLineLegendActor) vtkStandardNewMacro(ReferenceLineLegendActor)
ReferenceLineLegendActor::ReferenceLineLegendActor() { ReferenceLineLegendActor::ReferenceLineLegendActor() {
@@ -53,7 +55,7 @@ int ReferenceLineLegendActor::RenderOverlay(vtkViewport *viewport) {
auto renderer = vtkRenderer::SafeDownCast(viewport); auto renderer = vtkRenderer::SafeDownCast(viewport);
if (!renderer) return 0; if (!renderer) return 0;
BuildShape(renderer); BuildShape(renderer);
if (Visibility){ if (Visibility && ReferenceLineLegendActor::TypeVisibility){
shadow2D->RenderOverlay(viewport); shadow2D->RenderOverlay(viewport);
return actor2D->RenderOverlay(viewport); return actor2D->RenderOverlay(viewport);
} }

View File

@@ -58,6 +58,14 @@ public:
Modified(); Modified();
} }
static bool GetTypeVisibility(){
return TypeVisibility;
};
static void SetTypeVisibility(bool v){
TypeVisibility = v;
}
protected: protected:
ReferenceLineLegendActor(); ReferenceLineLegendActor();
@@ -73,6 +81,7 @@ private:
void operator=(const ReferenceLineLegendActor &) = delete; void operator=(const ReferenceLineLegendActor &) = delete;
vtkTimeStamp mModifyTime; vtkTimeStamp mModifyTime;
static bool TypeVisibility;
}; };

View File

@@ -1129,7 +1129,7 @@ void infinitiViewer::InitTopLeftCornerInfo(const std::string &lbl_ser_num, const
} }
void infinitiViewer::UpdateCornerInfo(int index) { void infinitiViewer::UpdateCornerInfo(int index) {
if (AnnoHelper::IsAnno()) { if (AnnoHelper::GetVisibility()) {
if (index == TOP_LEFT) { if (index == TOP_LEFT) {
int maxSlice = this->GetSliceMax(); int maxSlice = this->GetSliceMax();
@@ -1167,7 +1167,7 @@ void infinitiViewer::UpdateCornerInfo(int index) {
} }
void infinitiViewer::UpdateCornerInfoAll() { void infinitiViewer::UpdateCornerInfoAll() {
if (AnnoHelper::IsAnno()) { if (AnnoHelper::GetVisibility()) {
UpdateCornerInfo(TOP_LEFT); UpdateCornerInfo(TOP_LEFT);
UpdateCornerInfo(BOTTOM_RIGHT); UpdateCornerInfo(BOTTOM_RIGHT);
UpdateCornerInfo(TOP_RIGHT); UpdateCornerInfo(TOP_RIGHT);
@@ -1184,7 +1184,7 @@ void infinitiViewer::UpdateCornerInfoAll() {
} }
void infinitiViewer::UpdateTopLeftCornerInfo() { void infinitiViewer::UpdateTopLeftCornerInfo() {
if (AnnoHelper::IsAnno()) { if (AnnoHelper::GetVisibility()) {
int maxSlice = this->GetSliceMax(); int maxSlice = this->GetSliceMax();
int currentSlice = this->GetSlice(); int currentSlice = this->GetSlice();
std::string msg_const = m_cornerInfo.ConstAnno[TOP_LEFT]; std::string msg_const = m_cornerInfo.ConstAnno[TOP_LEFT];
@@ -1334,7 +1334,7 @@ void infinitiViewer::UnActiveReferenceLine() {
} }
void infinitiViewer::RenderLegend() { void infinitiViewer::RenderLegend() {
if (AnnoHelper::IsAnno()) { if (AnnoHelper::GetVisibility()) {
if (Renderer) { if (Renderer) {
if (rulerActive)ruler->RenderOverlay(Renderer); if (rulerActive)ruler->RenderOverlay(Renderer);
referenceLine->RenderOverlay(Renderer); referenceLine->RenderOverlay(Renderer);

View File

@@ -514,3 +514,8 @@ void ImageViewManager::reloadCurrentView(DicomImageView * view){
emit currentViewReloaded(view); emit currentViewReloaded(view);
} }
void ImageViewManager::switchReferenceLineVisibility(bool v) {
ReferenceLineLegendActor::SetTypeVisibility(v);
renderAll();
}

View File

@@ -88,6 +88,8 @@ public:
void switchSliceOrientation(); void switchSliceOrientation();
void switchReferenceLineVisibility(bool v);
void updateCornerInfoAll(); void updateCornerInfoAll();
void updateCornerInfoPrivacy(); void updateCornerInfoPrivacy();

View File

@@ -280,6 +280,16 @@ void DefaultToolBar::initAnonymizeButton() {
mBtnAnonymize->setCheckable(true); mBtnAnonymize->setCheckable(true);
QMenu *m; QMenu *m;
m = new QMenu(this); m = new QMenu(this);
//显隐 Annotations
mActionHideAnnotations = m->addAction(tr("Annotations"), this, [=](bool value) {
AnnoHelper::setVisibility(value);
});
mActionHideAnnotations->setCheckable(true);
mActionHideAnnotations->setChecked(true);
//显隐 reference line
mActionHideReferenceLine = m->addAction(tr("Cross Reference Line"), this, &DefaultToolBar::referenceLineStateChange);
mActionHideReferenceLine->setCheckable(true);
mActionHideReferenceLine->setChecked(true);
//视窗操作,显隐测量 //视窗操作,显隐测量
mActionHideMeasure = m->addAction(tr("Hide all measurements"), this, [=](bool value) { mActionHideMeasure = m->addAction(tr("Hide all measurements"), this, [=](bool value) {
Measure::SetHidden(mActionHideMeasure->isChecked()); Measure::SetHidden(mActionHideMeasure->isChecked());

View File

@@ -39,6 +39,7 @@ signals:
void parentWindowClose(); void parentWindowClose();
void transform(TransFormType type); void transform(TransFormType type);
void showMeta(); void showMeta();
void referenceLineStateChange(bool isShow);
private: private:
QAction *addButton(QToolButton *button, const char *objectName); QAction *addButton(QToolButton *button, const char *objectName);
@@ -90,6 +91,8 @@ private:
QAction *mActionClose; QAction *mActionClose;
QAction *mActionFullScreen; QAction *mActionFullScreen;
QAction *mActionSyncState; QAction *mActionSyncState;
QAction *mActionHideAnnotations;
QAction *mActionHideReferenceLine;
QAction *mActionHideMeasure; QAction *mActionHideMeasure;
QAction *mActionHidePatData; QAction *mActionHidePatData;
QAction* mSyncActions[3]={nullptr,nullptr,nullptr}; QAction* mSyncActions[3]={nullptr,nullptr,nullptr};

View File

@@ -116,9 +116,10 @@ void QDicomViewer::createVCRToolbar(DicomImageView *v) {
//视窗操作wwwl //视窗操作wwwl
void QDicomViewer::initViewOperation() { void QDicomViewer::initViewOperation() {
// operation mode change // operation reference line hide and show
connect(ui->toolBar, &DefaultToolBar::referenceLineStateChange,
ui->viewContainer->getViewManager(), &ImageViewManager::switchReferenceLineVisibility); // operation mode change
connect(ui->toolBar, &DefaultToolBar::modeChanged, [=](int mode) { connect(ui->toolBar, &DefaultToolBar::modeChanged, [=](int mode) {
printf("mode:%d\r\n",mode);
ui->viewContainer->getViewManager()->setInteractionMode(mode); ui->viewContainer->getViewManager()->setInteractionMode(mode);
}); });
// custom window level // custom window level