Replace vtkCornerAnnotation with a FastCornerAnnotationActor.
This commit is contained in:
@@ -51,14 +51,14 @@ enum DicomModality
|
|||||||
|
|
||||||
enum CornerPos
|
enum CornerPos
|
||||||
{
|
{
|
||||||
BOTTOM_LEFT,
|
TOP_MIDDLE,
|
||||||
BOTTOM_RIGHT,
|
LEFT_MIDDLE,
|
||||||
TOP_LEFT,
|
|
||||||
TOP_RIGHT,
|
|
||||||
BOTTOM_MIDDLE,
|
BOTTOM_MIDDLE,
|
||||||
RIGHT_MIDDLE,
|
RIGHT_MIDDLE,
|
||||||
LEFT_MIDDLE,
|
TOP_LEFT,
|
||||||
TOP_MIDDLE,
|
BOTTOM_LEFT,
|
||||||
|
TOP_RIGHT,
|
||||||
|
BOTTOM_RIGHT,
|
||||||
TOP_RIGHT_PRIVACY
|
TOP_RIGHT_PRIVACY
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
#include <vtkRenderer.h>
|
#include <vtkRenderer.h>
|
||||||
#include <vtkSmartPointer.h>
|
#include <vtkSmartPointer.h>
|
||||||
#include <vtkRenderWindow.h>
|
#include <vtkRenderWindow.h>
|
||||||
#include <vtkCornerAnnotation.h>
|
|
||||||
#include <vtkWindowToImageFilter.h>
|
#include <vtkWindowToImageFilter.h>
|
||||||
#include <vtkImageCast.h>
|
#include <vtkImageCast.h>
|
||||||
#include <vtkPNGWriter.h>
|
#include <vtkPNGWriter.h>
|
||||||
|
|||||||
@@ -8,14 +8,15 @@
|
|||||||
#include <vtkPropPicker.h>
|
#include <vtkPropPicker.h>
|
||||||
#include <vtkPointPicker.h>
|
#include <vtkPointPicker.h>
|
||||||
#include <vtkImageSlice.h>
|
#include <vtkImageSlice.h>
|
||||||
|
#include <vtkActor2D.h>
|
||||||
#include "vtkInteractorStyleImage.h"
|
#include "vtkInteractorStyleImage.h"
|
||||||
#include "vtkNew.h" // For ivars
|
#include "vtkNew.h" // For ivars
|
||||||
#include "functional"
|
#include "functional"
|
||||||
#include "vtkCornerAnnotation.h"
|
|
||||||
#include "vtkCommand.h"
|
#include "vtkCommand.h"
|
||||||
#include <vtkVersion.h>
|
#include <vtkVersion.h>
|
||||||
|
|
||||||
#include "Rendering/Core/RenderingDefines.h"
|
#include "Rendering/Core/RenderingDefines.h"
|
||||||
|
#include "Rendering/Legend/FastCornerAnnotationActor.h"
|
||||||
|
|
||||||
|
|
||||||
class vtkProp;
|
class vtkProp;
|
||||||
@@ -94,7 +95,7 @@ vtkTypeMacro(ActorDraggableInteractorStyle, vtkInteractorStyleImage);
|
|||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
vtkSetObjectMacro(CornerAnnotation, vtkCornerAnnotation);
|
vtkSetObjectMacro(CornerAnnotation, FastCornerAnnotationActor);
|
||||||
|
|
||||||
vtkProp *GetSelectedProp() {
|
vtkProp *GetSelectedProp() {
|
||||||
return selectedProp;
|
return selectedProp;
|
||||||
@@ -182,7 +183,7 @@ private:
|
|||||||
vtkProp *dragProp = nullptr;
|
vtkProp *dragProp = nullptr;
|
||||||
vtkProp *selectedProp = nullptr;
|
vtkProp *selectedProp = nullptr;
|
||||||
int DragStartOrigin[2] = {0, 0};
|
int DragStartOrigin[2] = {0, 0};
|
||||||
vtkCornerAnnotation *CornerAnnotation = nullptr;
|
FastCornerAnnotationActor *CornerAnnotation = nullptr;
|
||||||
//bool isCornderAnno = true;
|
//bool isCornderAnno = true;
|
||||||
Measure *measure = nullptr;
|
Measure *measure = nullptr;
|
||||||
double PanStartOrigin[3] = {0.0, 0.0, 0.0};
|
double PanStartOrigin[3] = {0.0, 0.0, 0.0};
|
||||||
|
|||||||
120
src/src/Rendering/Legend/FastCornerAnnotationActor.cpp
Normal file
120
src/src/Rendering/Legend/FastCornerAnnotationActor.cpp
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
//
|
||||||
|
// Created by Krad on 2022/12/29.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "FastCornerAnnotationActor.h"
|
||||||
|
|
||||||
|
#include <vtkObjectFactory.h>
|
||||||
|
#include <vtkRenderer.h>
|
||||||
|
#include <vtkRenderWindow.h>
|
||||||
|
#include <vtkTextActor.h>
|
||||||
|
#include <vtkTextProperty.h>
|
||||||
|
#include <vtkCoordinate.h>
|
||||||
|
|
||||||
|
vtkStandardNewMacro(FastCornerAnnotationActor);
|
||||||
|
|
||||||
|
FastCornerAnnotationActor::FastCornerAnnotationActor()
|
||||||
|
: vtkProp(){
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
Actors[i] = vtkTextActor::New();
|
||||||
|
Actors[i]->Register(this);
|
||||||
|
Actors[i]->SetTextScaleModeToNone();
|
||||||
|
Actors[i]->SetUseBorderAlign(true);
|
||||||
|
Actors[i]->GetTextProperty()->SetFontFamilyToCourier();
|
||||||
|
Actors[i]->GetTextProperty()->SetFontSize(13);
|
||||||
|
Actors[i]->GetTextProperty()->BoldOn();
|
||||||
|
Actors[i]->GetTextProperty()->ShadowOn();
|
||||||
|
Actors[i]->GetActualPositionCoordinate()->SetCoordinateSystemToDisplay();
|
||||||
|
Actors[i]->SetPosition(5,5);
|
||||||
|
Actors[i]->Delete();
|
||||||
|
}
|
||||||
|
|
||||||
|
Actors[0]->GetTextProperty()->SetJustificationToCentered();
|
||||||
|
Actors[0]->GetTextProperty()->SetVerticalJustificationToTop();
|
||||||
|
Actors[1]->GetTextProperty()->SetJustificationToLeft();
|
||||||
|
Actors[1]->GetTextProperty()->SetVerticalJustificationToCentered();
|
||||||
|
Actors[2]->GetTextProperty()->SetJustificationToCentered();
|
||||||
|
Actors[2]->GetTextProperty()->SetVerticalJustificationToBottom();
|
||||||
|
Actors[3]->GetTextProperty()->SetJustificationToRight();
|
||||||
|
Actors[3]->GetTextProperty()->SetVerticalJustificationToCentered();
|
||||||
|
Actors[4]->GetTextProperty()->SetJustificationToLeft();
|
||||||
|
Actors[4]->GetTextProperty()->SetVerticalJustificationToTop();
|
||||||
|
Actors[4]->GetTextProperty()->SetVerticalJustificationToTop();
|
||||||
|
Actors[5]->GetTextProperty()->SetJustificationToLeft();
|
||||||
|
Actors[5]->GetTextProperty()->SetVerticalJustificationToBottom();
|
||||||
|
Actors[6]->GetTextProperty()->SetJustificationToRight();
|
||||||
|
Actors[6]->GetTextProperty()->SetVerticalJustificationToTop();
|
||||||
|
Actors[7]->GetTextProperty()->SetJustificationToRight();
|
||||||
|
Actors[7]->GetTextProperty()->SetVerticalJustificationToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
|
FastCornerAnnotationActor::~FastCornerAnnotationActor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
+---------+
|
||||||
|
|4 0 6|
|
||||||
|
| |
|
||||||
|
|1 3|
|
||||||
|
| |
|
||||||
|
|5 2 7|
|
||||||
|
+---------+
|
||||||
|
*/
|
||||||
|
void FastCornerAnnotationActor::SetText(int index , const char* text) {
|
||||||
|
Actors[index]->SetInput(text);
|
||||||
|
this->Modified();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FastCornerAnnotationActor::ReleaseGraphicsResources(vtkWindow * window) {
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
Actors[i]->ReleaseGraphicsResources(window);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int FastCornerAnnotationActor::RenderOverlay(vtkViewport *viewport) {
|
||||||
|
auto renderer = vtkRenderer::SafeDownCast(viewport);
|
||||||
|
bool ret = false;
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
ret = Actors[i]->RenderOverlay(viewport);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
int FastCornerAnnotationActor::RenderOpaqueGeometry(vtkViewport * viewport) {
|
||||||
|
int ret = 0;
|
||||||
|
auto renderer = vtkRenderer::SafeDownCast(viewport);
|
||||||
|
if (LoadTime.GetMTime()< renderer->GetRenderWindow()->GetMTime())
|
||||||
|
{
|
||||||
|
ResetTextPosition(renderer);
|
||||||
|
LoadTime.Modified();
|
||||||
|
}
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
ret = Actors[i]->RenderOpaqueGeometry(viewport);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
vtkTypeBool FastCornerAnnotationActor::HasTranslucentPolygonalGeometry() {
|
||||||
|
bool ret = true;
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
ret = true && Actors[i]->HasTranslucentPolygonalGeometry();
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FastCornerAnnotationActor::ResetTextPosition(vtkRenderer* renderer) {
|
||||||
|
double x = 1.0, y = 1.0;
|
||||||
|
renderer->NormalizedDisplayToDisplay(x, y);
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
Actors[i]->GetActualPosition2Coordinate()->SetCoordinateSystemToDisplay();
|
||||||
|
Actors[i]->SetPosition2(x - 5,y - 5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void FastCornerAnnotationActor::ClearAllTexts() {
|
||||||
|
for (int i = 0; i < 8; ++i) {
|
||||||
|
Actors[i]->SetInput("");
|
||||||
|
}
|
||||||
|
}
|
||||||
72
src/src/Rendering/Legend/FastCornerAnnotationActor.h
Normal file
72
src/src/Rendering/Legend/FastCornerAnnotationActor.h
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
//
|
||||||
|
// Created by Krad on 2022/12/29.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef OMEGAV_FASTCORNERANNOTATIONACTOR_H
|
||||||
|
#define OMEGAV_FASTCORNERANNOTATIONACTOR_H
|
||||||
|
|
||||||
|
#include <vtkProp.h>
|
||||||
|
|
||||||
|
class vtkRenderer;
|
||||||
|
class vtkTextActor;
|
||||||
|
|
||||||
|
class FastCornerAnnotationActor: public vtkProp {
|
||||||
|
public:
|
||||||
|
//@{
|
||||||
|
/**
|
||||||
|
* Standard methods for instances of this class.
|
||||||
|
*/
|
||||||
|
static FastCornerAnnotationActor *New();
|
||||||
|
|
||||||
|
vtkTypeMacro(FastCornerAnnotationActor, vtkProp);
|
||||||
|
|
||||||
|
//@{
|
||||||
|
/**
|
||||||
|
* Methods to make this class behave as a vtkProp.
|
||||||
|
*/
|
||||||
|
double *GetBounds() VTK_SIZEHINT(6) override { return nullptr; }
|
||||||
|
|
||||||
|
void GetActors(vtkPropCollection *) override {}
|
||||||
|
|
||||||
|
void GetVolumes(vtkPropCollection *) override {}
|
||||||
|
|
||||||
|
void ShallowCopy(vtkProp *prop) override {};
|
||||||
|
|
||||||
|
void ReleaseGraphicsResources(vtkWindow *) override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method use to make this actor render in 2D scene;
|
||||||
|
* @param viewport
|
||||||
|
* @return render is success
|
||||||
|
*/
|
||||||
|
int RenderOverlay(vtkViewport *viewport) override;
|
||||||
|
|
||||||
|
int RenderOpaqueGeometry(vtkViewport *vtkNotUsed(viewport)) override;
|
||||||
|
|
||||||
|
int RenderTranslucentPolygonalGeometry(vtkViewport *vtkNotUsed(viewport)) override { return 0; }
|
||||||
|
|
||||||
|
int RenderVolumetricGeometry(vtkViewport *vtkNotUsed(viewport)) override { return 0; }
|
||||||
|
|
||||||
|
vtkTypeBool HasTranslucentPolygonalGeometry() override;
|
||||||
|
|
||||||
|
void SetText(int index ,const char* text);
|
||||||
|
|
||||||
|
void ClearAllTexts();
|
||||||
|
protected:
|
||||||
|
FastCornerAnnotationActor();
|
||||||
|
|
||||||
|
~FastCornerAnnotationActor() override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
FastCornerAnnotationActor(const FastCornerAnnotationActor &) = delete;
|
||||||
|
|
||||||
|
void operator=(const FastCornerAnnotationActor &) = delete;
|
||||||
|
|
||||||
|
void ResetTextPosition(vtkRenderer * renderer);
|
||||||
|
vtkTextActor* Actors[8]={nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr,nullptr};
|
||||||
|
bool FirstRender = true;
|
||||||
|
vtkTimeStamp LoadTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif //OMEGAV_FASTCORNERANNOTATIONACTOR_H
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include <vtkObjectFactory.h>
|
#include <vtkObjectFactory.h>
|
||||||
#include <vtkPolyData.h>
|
#include <vtkPolyData.h>
|
||||||
#include <vtkProperty2D.h>
|
#include <vtkProperty2D.h>
|
||||||
|
#include <vtkActor2D.h>
|
||||||
#include <vtkRenderer.h>
|
#include <vtkRenderer.h>
|
||||||
#include <vtkRenderWindow.h>
|
#include <vtkRenderWindow.h>
|
||||||
#include <vtkRenderWindowInteractor.h>
|
#include <vtkRenderWindowInteractor.h>
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include <vtkTextProperty.h>
|
#include <vtkTextProperty.h>
|
||||||
|
|
||||||
#include "Rendering/Measure/MeasureStore.h"
|
#include "Rendering/Measure/MeasureStore.h"
|
||||||
|
#include "Rendering/Legend/FastCornerAnnotationActor.h"
|
||||||
#include "IO/General/ColorMapReader.h"
|
#include "IO/General/ColorMapReader.h"
|
||||||
#include "Interaction/ActorDraggableInteractorStyle.h"
|
#include "Interaction/ActorDraggableInteractorStyle.h"
|
||||||
#include "Rendering/Core/MarginCornerAnnotation.h"
|
#include "Rendering/Core/MarginCornerAnnotation.h"
|
||||||
@@ -61,7 +62,7 @@ DICOMImageViewer::DICOMImageViewer()
|
|||||||
RenderWindow(nullptr), Renderer(nullptr), ImageStack(vtkImageStack::New()),
|
RenderWindow(nullptr), Renderer(nullptr), ImageStack(vtkImageStack::New()),
|
||||||
ImageActor(vtkImageSlice::New()), ImageMapper(vtkImageSliceMapper::New()), FusionActor(nullptr),
|
ImageActor(vtkImageSlice::New()), ImageMapper(vtkImageSliceMapper::New()), FusionActor(nullptr),
|
||||||
FusionMapper(nullptr), Interactor(nullptr), InteractorStyle(nullptr), OpacityActor(nullptr),
|
FusionMapper(nullptr), Interactor(nullptr), InteractorStyle(nullptr), OpacityActor(nullptr),
|
||||||
cornerAnnotation(MarginCornerAnnotation::New()), bar(nullptr),
|
cornerAnnotation(FastCornerAnnotationActor::New()), bar(nullptr),
|
||||||
SliceIJK(-1), SlicePlane(-1), FirstRender(1), Slice(0), loadedMeasureSlice(0),
|
SliceIJK(-1), SlicePlane(-1), FirstRender(1), Slice(0), loadedMeasureSlice(0),
|
||||||
currentPresetIndex(1), Fusion(false), firstFusion(true), FusionOpacity(0.5), list(nullptr),
|
currentPresetIndex(1), Fusion(false), firstFusion(true), FusionOpacity(0.5), list(nullptr),
|
||||||
measureStore(MeasureStore::Instance()),
|
measureStore(MeasureStore::Instance()),
|
||||||
@@ -72,16 +73,6 @@ DICOMImageViewer::DICOMImageViewer()
|
|||||||
this->ImageActor->SetMapper(this->ImageMapper);
|
this->ImageActor->SetMapper(this->ImageMapper);
|
||||||
ImageStack->AddImage(ImageActor);
|
ImageStack->AddImage(ImageActor);
|
||||||
|
|
||||||
vtkNew<vtkTextProperty> prop;
|
|
||||||
prop->SetFontFamilyToArial();
|
|
||||||
this->cornerAnnotation->SetTextProperty(prop);
|
|
||||||
this->cornerAnnotation->GetTextProperty()->SetColor(0.0, 1, 1);
|
|
||||||
// Annotate the image with window/level and mouse over pixel information
|
|
||||||
cornerAnnotation->SetLinearFontScaleFactor(2);
|
|
||||||
cornerAnnotation->SetNonlinearFontScaleFactor(1);
|
|
||||||
cornerAnnotation->SetMaximumFontSize(20);
|
|
||||||
cornerAnnotation->SetMinimumFontSize(8);
|
|
||||||
|
|
||||||
vtkRenderWindow *renwin = vtkRenderWindow::New();
|
vtkRenderWindow *renwin = vtkRenderWindow::New();
|
||||||
DICOMImageViewer::SetRenderWindow(renwin);
|
DICOMImageViewer::SetRenderWindow(renwin);
|
||||||
renwin->Delete();
|
renwin->Delete();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class MeasureStore;
|
|||||||
|
|
||||||
class vtkScalarBarActor;
|
class vtkScalarBarActor;
|
||||||
|
|
||||||
class vtkCornerAnnotation;
|
class FastCornerAnnotationActor;
|
||||||
|
|
||||||
class Measure;
|
class Measure;
|
||||||
|
|
||||||
@@ -59,9 +59,6 @@ public:
|
|||||||
void PrintSelf(ostream &os, vtkIndent indent) override;
|
void PrintSelf(ostream &os, vtkIndent indent) override;
|
||||||
|
|
||||||
//vtkGetMacro(m_cornerAnnotation, vtkCornerAnnotation);
|
//vtkGetMacro(m_cornerAnnotation, vtkCornerAnnotation);
|
||||||
vtkCornerAnnotation *GetvtkCornerAnnotation() {
|
|
||||||
return cornerAnnotation;
|
|
||||||
}
|
|
||||||
|
|
||||||
void UpdateCornerInfo(int index);
|
void UpdateCornerInfo(int index);
|
||||||
|
|
||||||
@@ -439,7 +436,7 @@ private:
|
|||||||
vtkRenderWindowInteractor *Interactor;
|
vtkRenderWindowInteractor *Interactor;
|
||||||
ActorDraggableInteractorStyle *InteractorStyle = nullptr;
|
ActorDraggableInteractorStyle *InteractorStyle = nullptr;
|
||||||
vtkTextActor *OpacityActor;
|
vtkTextActor *OpacityActor;
|
||||||
vtkCornerAnnotation *cornerAnnotation;
|
FastCornerAnnotationActor *cornerAnnotation;
|
||||||
vtkScalarBarActor *bar;
|
vtkScalarBarActor *bar;
|
||||||
vtkNew<RulerLegendActor> ruler;
|
vtkNew<RulerLegendActor> ruler;
|
||||||
vtkNew<ReferenceLineLegendActor> referenceLine;
|
vtkNew<ReferenceLineLegendActor> referenceLine;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "Rendering/Legend/ResliceCursorLegendActor.h"
|
#include "Rendering/Legend/ResliceCursorLegendActor.h"
|
||||||
#include "Rendering/Legend/FastOrientationLegendActor.h"
|
#include "Rendering/Legend/FastCornerAnnotationActor.h"
|
||||||
#include "Rendering/Legend/ResliceSquareLegendActor.h"
|
#include "Rendering/Legend/ResliceSquareLegendActor.h"
|
||||||
#include "Interaction/ResliceImageInteractorStyle.h"
|
#include "Interaction/ResliceImageInteractorStyle.h"
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ ResliceImageViewer::ResliceImageViewer()
|
|||||||
, cursor2(ResliceCursorLegendActor::New())
|
, cursor2(ResliceCursorLegendActor::New())
|
||||||
, Square(ResliceSquareLegendActor::New())
|
, Square(ResliceSquareLegendActor::New())
|
||||||
, Actor(vtkImageSlice::New())
|
, Actor(vtkImageSlice::New())
|
||||||
, annotation(vtkCornerAnnotation::New())
|
, annotation(FastCornerAnnotationActor::New())
|
||||||
, OrientationMatrix(vtkMatrix4x4::New())
|
, OrientationMatrix(vtkMatrix4x4::New())
|
||||||
, DefaultOrientation(0)
|
, DefaultOrientation(0)
|
||||||
, FirstRender(true)
|
, FirstRender(true)
|
||||||
@@ -77,13 +77,6 @@ ResliceImageViewer::ResliceImageViewer()
|
|||||||
|
|
||||||
vtkNew<vtkTextProperty> prop;
|
vtkNew<vtkTextProperty> prop;
|
||||||
prop->SetFontFamilyToArial();
|
prop->SetFontFamilyToArial();
|
||||||
this->annotation->SetTextProperty(prop);
|
|
||||||
this->annotation->GetTextProperty()->SetColor(.0,1.,1.);
|
|
||||||
// Annotate the image with window/level and mouse over pixel information
|
|
||||||
this->annotation->SetLinearFontScaleFactor(2);
|
|
||||||
this->annotation->SetNonlinearFontScaleFactor(1);
|
|
||||||
this->annotation->SetMaximumFontSize(20);
|
|
||||||
this->annotation->SetMinimumFontSize(8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ResliceImageViewer::~ResliceImageViewer() {
|
ResliceImageViewer::~ResliceImageViewer() {
|
||||||
@@ -191,7 +184,7 @@ void ResliceImageViewer::Render() {
|
|||||||
MeasureRenderer->SetLayer(1);
|
MeasureRenderer->SetLayer(1);
|
||||||
MeasureRenderer->AddActor2D(cursor1);
|
MeasureRenderer->AddActor2D(cursor1);
|
||||||
MeasureRenderer->AddActor2D(cursor2);
|
MeasureRenderer->AddActor2D(cursor2);
|
||||||
MeasureRenderer->AddActor(annotation);
|
|
||||||
cursor1->SetSlicePoint(MeasureRenderer->GetActiveCamera()->GetFocalPoint());
|
cursor1->SetSlicePoint(MeasureRenderer->GetActiveCamera()->GetFocalPoint());
|
||||||
cursor2->SetSlicePoint(MeasureRenderer->GetActiveCamera()->GetFocalPoint());
|
cursor2->SetSlicePoint(MeasureRenderer->GetActiveCamera()->GetFocalPoint());
|
||||||
cursor1->SetProjectDirectionVector(MeasureRenderer->GetActiveCamera()->GetDirectionOfProjection());
|
cursor1->SetProjectDirectionVector(MeasureRenderer->GetActiveCamera()->GetDirectionOfProjection());
|
||||||
@@ -240,6 +233,7 @@ void ResliceImageViewer::Render() {
|
|||||||
cursor2->AddObserver(ResliceCursorLegendActor::ROLL,this, &ResliceImageViewer::handleRoll);
|
cursor2->AddObserver(ResliceCursorLegendActor::ROLL,this, &ResliceImageViewer::handleRoll);
|
||||||
cursor2->AddObserver(ResliceCursorLegendActor::MOVE,this, &ResliceImageViewer::handleMove);
|
cursor2->AddObserver(ResliceCursorLegendActor::MOVE,this, &ResliceImageViewer::handleMove);
|
||||||
MeasureRenderer->AddActor2D(Square);
|
MeasureRenderer->AddActor2D(Square);
|
||||||
|
MeasureRenderer->AddActor(annotation);
|
||||||
UpdateDirectionAnnotation();
|
UpdateDirectionAnnotation();
|
||||||
Render();
|
Render();
|
||||||
return;
|
return;
|
||||||
@@ -380,13 +374,13 @@ void ResliceImageViewer::UpdateDirectionAnnotation() {
|
|||||||
double viewLeft[4] = {-viewRight[0], -viewRight[1], -viewRight[2], 1.};
|
double viewLeft[4] = {-viewRight[0], -viewRight[1], -viewRight[2], 1.};
|
||||||
std::string str;
|
std::string str;
|
||||||
GetDirectionString(viewUp, str);
|
GetDirectionString(viewUp, str);
|
||||||
annotation->SetText(7,str.c_str() );
|
annotation->SetText(0,str.c_str() );
|
||||||
GetDirectionString(viewRight, str);
|
GetDirectionString(viewRight, str);
|
||||||
annotation->SetText(5,str.c_str() );
|
annotation->SetText(3,str.c_str() );
|
||||||
GetDirectionString(viewDown, str);
|
GetDirectionString(viewDown, str);
|
||||||
annotation->SetText(4,str.c_str() );
|
annotation->SetText(2,str.c_str() );
|
||||||
GetDirectionString(viewLeft, str);
|
GetDirectionString(viewLeft, str);
|
||||||
annotation->SetText(6,str.c_str() );
|
annotation->SetText(1,str.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResliceImageViewer::ResetHandle() {
|
void ResliceImageViewer::ResetHandle() {
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ class ResliceCursorLegendActor;
|
|||||||
|
|
||||||
class ResliceSquareLegendActor;
|
class ResliceSquareLegendActor;
|
||||||
|
|
||||||
class vtkCornerAnnotation;
|
class FastCornerAnnotationActor;
|
||||||
|
|
||||||
class ResliceImageViewer :public vtkObject {
|
class ResliceImageViewer :public vtkObject {
|
||||||
public:
|
public:
|
||||||
@@ -87,7 +87,7 @@ private:
|
|||||||
ResliceCursorLegendActor* cursor2;
|
ResliceCursorLegendActor* cursor2;
|
||||||
ResliceSquareLegendActor* Square;
|
ResliceSquareLegendActor* Square;
|
||||||
vtkImageSlice* Actor;
|
vtkImageSlice* Actor;
|
||||||
vtkCornerAnnotation* annotation;
|
FastCornerAnnotationActor* annotation;
|
||||||
vtkMatrix4x4* OrientationMatrix;
|
vtkMatrix4x4* OrientationMatrix;
|
||||||
int DefaultOrientation;
|
int DefaultOrientation;
|
||||||
bool FirstRender;
|
bool FirstRender;
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#include <vtkGPUVolumeRayCastMapper.h>
|
#include <vtkGPUVolumeRayCastMapper.h>
|
||||||
#include <vtkPiecewiseFunction.h>
|
#include <vtkPiecewiseFunction.h>
|
||||||
#include <vtkColorTransferFunction.h>
|
#include <vtkColorTransferFunction.h>
|
||||||
#include <vtkCornerAnnotation.h>
|
|
||||||
#include <vtkTextProperty.h>
|
#include <vtkTextProperty.h>
|
||||||
#include <vtkPlane.h>
|
#include <vtkPlane.h>
|
||||||
#include <vtkBoundingBox.h>
|
#include <vtkBoundingBox.h>
|
||||||
@@ -29,6 +28,7 @@
|
|||||||
#include "IO/DICOM/ExtendMedicalImageProperties.h"
|
#include "IO/DICOM/ExtendMedicalImageProperties.h"
|
||||||
#include "Rendering/Measure/VolRulerAnnotationActor.h"
|
#include "Rendering/Measure/VolRulerAnnotationActor.h"
|
||||||
#include "Rendering/Measure/VolArrowAnnotationActor.h"
|
#include "Rendering/Measure/VolArrowAnnotationActor.h"
|
||||||
|
#include "Rendering/Legend/FastCornerAnnotationActor.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
enum ViewDirection{
|
enum ViewDirection{
|
||||||
@@ -78,7 +78,7 @@ VolumeRenderingViewer::VolumeRenderingViewer()
|
|||||||
, RenderWindow(nullptr)
|
, RenderWindow(nullptr)
|
||||||
, Renderer(nullptr)
|
, Renderer(nullptr)
|
||||||
, VolumeActor(vtkVolume::New())
|
, VolumeActor(vtkVolume::New())
|
||||||
, annotation(vtkCornerAnnotation::New())
|
, annotation(FastCornerAnnotationActor::New())
|
||||||
, VolumeMapper(SmartFixedPointVolumeRayCastMapper::New())
|
, VolumeMapper(SmartFixedPointVolumeRayCastMapper::New())
|
||||||
, InteractorStyle(nullptr)
|
, InteractorStyle(nullptr)
|
||||||
, Interactor(nullptr)
|
, Interactor(nullptr)
|
||||||
@@ -132,13 +132,6 @@ VolumeRenderingViewer::VolumeRenderingViewer()
|
|||||||
VolumeActor->SetMapper(VolumeMapper);
|
VolumeActor->SetMapper(VolumeMapper);
|
||||||
vtkNew<vtkTextProperty> prop;
|
vtkNew<vtkTextProperty> prop;
|
||||||
prop->SetFontFamilyToArial();
|
prop->SetFontFamilyToArial();
|
||||||
this->annotation->SetTextProperty(prop);
|
|
||||||
this->annotation->GetTextProperty()->SetColor(.0,1.,1.);
|
|
||||||
// Annotate the image with window/level and mouse over pixel information
|
|
||||||
this->annotation->SetLinearFontScaleFactor(2);
|
|
||||||
this->annotation->SetNonlinearFontScaleFactor(1);
|
|
||||||
this->annotation->SetMaximumFontSize(20);
|
|
||||||
this->annotation->SetMinimumFontSize(8);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
VolumeRenderingViewer::~VolumeRenderingViewer() {
|
VolumeRenderingViewer::~VolumeRenderingViewer() {
|
||||||
@@ -342,7 +335,7 @@ void VolumeRenderingViewer::renderWindowAnnotation() {
|
|||||||
double wl = (range[0]+range[1])/2.0;
|
double wl = (range[0]+range[1])/2.0;
|
||||||
double ww = (range[1] - range[0]);
|
double ww = (range[1] - range[0]);
|
||||||
sprintf(buff,"WW:%.0f WL:%.0f", ww,wl);
|
sprintf(buff,"WW:%.0f WL:%.0f", ww,wl);
|
||||||
annotation->SetText(0,buff );
|
annotation->SetText(5,buff );
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeRenderingViewer::renderOrientationAnnotation() {
|
void VolumeRenderingViewer::renderOrientationAnnotation() {
|
||||||
@@ -361,13 +354,13 @@ void VolumeRenderingViewer::renderOrientationAnnotation() {
|
|||||||
double viewLeft[4] = {-viewRight[0], -viewRight[1], -viewRight[2], 1.};
|
double viewLeft[4] = {-viewRight[0], -viewRight[1], -viewRight[2], 1.};
|
||||||
std::string str;
|
std::string str;
|
||||||
GetDirectionString(viewUp, str);
|
GetDirectionString(viewUp, str);
|
||||||
annotation->SetText(7,str.c_str() );
|
annotation->SetText(0,str.c_str() );
|
||||||
GetDirectionString(viewRight, str);
|
GetDirectionString(viewRight, str);
|
||||||
annotation->SetText(5,str.c_str() );
|
annotation->SetText(3,str.c_str() );
|
||||||
GetDirectionString(viewDown, str);
|
GetDirectionString(viewDown, str);
|
||||||
annotation->SetText(4,str.c_str() );
|
annotation->SetText(2,str.c_str() );
|
||||||
GetDirectionString(viewLeft, str);
|
GetDirectionString(viewLeft, str);
|
||||||
annotation->SetText(6,str.c_str() );
|
annotation->SetText(1,str.c_str() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeRenderingViewer::GetDirectionString(const double *directionVector, std::string &str) const {
|
void VolumeRenderingViewer::GetDirectionString(const double *directionVector, std::string &str) const {
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ class vtkVolume;
|
|||||||
|
|
||||||
class vtkVolumeMapper;
|
class vtkVolumeMapper;
|
||||||
|
|
||||||
class vtkCornerAnnotation;
|
class FastCornerAnnotationActor;
|
||||||
|
|
||||||
class ExtendMedicalImageProperties;
|
class ExtendMedicalImageProperties;
|
||||||
|
|
||||||
@@ -121,7 +121,7 @@ private:
|
|||||||
vtkVolumeMapper *VolumeMapper;
|
vtkVolumeMapper *VolumeMapper;
|
||||||
vtkInteractorStyle *InteractorStyle;
|
vtkInteractorStyle *InteractorStyle;
|
||||||
vtkRenderWindowInteractor *Interactor;
|
vtkRenderWindowInteractor *Interactor;
|
||||||
vtkCornerAnnotation* annotation;
|
FastCornerAnnotationActor* annotation;
|
||||||
vtkOrientationMarkerWidget* OrientationMarker;
|
vtkOrientationMarkerWidget* OrientationMarker;
|
||||||
vtkNew<vtkMatrix4x4> OrientationMatrix;
|
vtkNew<vtkMatrix4x4> OrientationMatrix;
|
||||||
bool gpuMode = false;
|
bool gpuMode = false;
|
||||||
|
|||||||
@@ -277,9 +277,6 @@ void DicomImageView::mousePressEvent(QMouseEvent *event) {
|
|||||||
void DicomImageView::resizeEvent(QResizeEvent *event) {
|
void DicomImageView::resizeEvent(QResizeEvent *event) {
|
||||||
//auto size conner info
|
//auto size conner info
|
||||||
if (!mImageViewer) return;
|
if (!mImageViewer) return;
|
||||||
if (mImageViewer->GetvtkCornerAnnotation()) {
|
|
||||||
mImageViewer->GetvtkCornerAnnotation()->SetMaximumFontSize(FontSizeHelper::getSize(frameGeometry().size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
// force update ReferenceLine data
|
// force update ReferenceLine data
|
||||||
mImageViewer->modifiedReferenceLine();
|
mImageViewer->modifiedReferenceLine();
|
||||||
@@ -463,10 +460,6 @@ void DicomImageView::dispatchEvent(vtkObject *, unsigned long eid, void *callDat
|
|||||||
//Image render & operation about--------------------------------------------------------------------------------------
|
//Image render & operation about--------------------------------------------------------------------------------------
|
||||||
void DicomImageView::render() {
|
void DicomImageView::render() {
|
||||||
if (hasSeries()) {
|
if (hasSeries()) {
|
||||||
if (mIsFirstRenderAfterLoad && mImageViewer->GetvtkCornerAnnotation()) {
|
|
||||||
mImageViewer->GetvtkCornerAnnotation()->SetMaximumFontSize(FontSizeHelper::getSize(frameGeometry().size()));
|
|
||||||
mIsFirstRenderAfterLoad = false;
|
|
||||||
}
|
|
||||||
mImageViewer->Render();
|
mImageViewer->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user