From e8d503cdd0fbb10e21f4e02f41b1aa2a58a10e1b Mon Sep 17 00:00:00 2001 From: Krad Date: Thu, 24 Nov 2022 14:07:03 +0800 Subject: [PATCH] Fix AngleAnnotationActor & TextAnnotationActor highlight disable bug. --- src/src/Rendering/Measure/AngleAnnotationActor.cpp | 3 +++ src/src/Rendering/Measure/TextAnnotationActor.cpp | 14 +++++++++++++- src/src/Rendering/Measure/TextAnnotationActor.h | 2 ++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/src/Rendering/Measure/AngleAnnotationActor.cpp b/src/src/Rendering/Measure/AngleAnnotationActor.cpp index 0aea332..b780a38 100644 --- a/src/src/Rendering/Measure/AngleAnnotationActor.cpp +++ b/src/src/Rendering/Measure/AngleAnnotationActor.cpp @@ -110,6 +110,9 @@ void AngleAnnotationActor::BuildShape() { } void AngleAnnotationActor::Highlight(int highlightOn) { + bool temp = highlightOn > 0; + if (temp == this->Highlighted) return; + this->Highlighted = temp; if (this->Highlighted) { actor2D->GetProperty()->SetColor(1.0, 1.0, 0.0); textProperty->SetColor(1.0, 1.0, 0.0); diff --git a/src/src/Rendering/Measure/TextAnnotationActor.cpp b/src/src/Rendering/Measure/TextAnnotationActor.cpp index 9032086..fc0ba0e 100644 --- a/src/src/Rendering/Measure/TextAnnotationActor.cpp +++ b/src/src/Rendering/Measure/TextAnnotationActor.cpp @@ -59,7 +59,7 @@ void TextAnnotationActor::ResetTextProp() { mTextProperty->SetFrame(false); //textProperty->SetFrameColor(1.0, 0.0, 0.0); mTextProperty->SetBackgroundColor(1.0, 0.0, 0.0); - mTextProperty->SetBackgroundOpacity(0.3); + mTextProperty->SetBackgroundOpacity(0.0); } TextAnnotationActor::TextAnnotationActor() { @@ -148,3 +148,15 @@ bool TextAnnotationActor::onMeasureLeftButtonUp(vtkRenderWindowInteractor *iren) mIren = iren; return false; } + +void TextAnnotationActor::RenderWithState() { + if (this->Highlighted) { + mTextProperty->SetBackgroundRGBA(1.0, 1.0, 0.0,0.2); + return; + } + if (this->Selected) { + mTextProperty->SetBackgroundRGBA(1.0, 0.0, 0.0,0.2); + return; + } + mTextProperty->SetBackgroundRGBA(1.0, 1.0, 0.0,0.0); +} diff --git a/src/src/Rendering/Measure/TextAnnotationActor.h b/src/src/Rendering/Measure/TextAnnotationActor.h index 34b5843..2748392 100644 --- a/src/src/Rendering/Measure/TextAnnotationActor.h +++ b/src/src/Rendering/Measure/TextAnnotationActor.h @@ -54,6 +54,8 @@ vtkTypeMacro(TextAnnotationActor, DraggableActor); SetWorldPosition2(pos[0], pos[1], pos[2]); } + void RenderWithState(); + bool onMeasureLeftButtonDown(vtkRenderWindowInteractor *) override; void onMeasureMouseMove(vtkRenderWindowInteractor *) override;