Improve corner annotation display.
This commit is contained in:
@@ -244,7 +244,7 @@ public:
|
||||
static int getSize(QSize size)
|
||||
{
|
||||
double ratio = size.width()*1.0 / desktop_width;
|
||||
int real = font_size - int(25.0*pow(1 - ratio, 2));
|
||||
int real = 20 - int(14.0*pow(1 - ratio, 2));
|
||||
return real;
|
||||
}
|
||||
static int desktop_height;
|
||||
|
||||
36
src/src/Rendering/Core/MarginCornerAnnotation.cpp
Normal file
36
src/src/Rendering/Core/MarginCornerAnnotation.cpp
Normal file
@@ -0,0 +1,36 @@
|
||||
//
|
||||
// Created by Krad on 2022/8/26.
|
||||
//
|
||||
|
||||
#include "MarginCornerAnnotation.h"
|
||||
|
||||
#include <vtkObjectFactory.h>
|
||||
|
||||
vtkStandardNewMacro(MarginCornerAnnotation);
|
||||
|
||||
MarginCornerAnnotation::MarginCornerAnnotation():vtkCornerAnnotation() {
|
||||
|
||||
}
|
||||
|
||||
MarginCornerAnnotation::~MarginCornerAnnotation() {
|
||||
|
||||
}
|
||||
|
||||
void MarginCornerAnnotation::SetTextActorsPosition(int *vsize) {
|
||||
this->TextActor[LowerLeft]->SetPosition ( margins[0], margins[3] );
|
||||
this->TextActor[LowerRight]->SetPosition ( vsize[0] - margins[3], margins[2] );
|
||||
this->TextActor[UpperLeft]->SetPosition ( margins[1], vsize[1] - margins[0] );
|
||||
this->TextActor[UpperRight]->SetPosition ( vsize[0] - margins[2], vsize[1] - margins[1] );
|
||||
|
||||
this->TextActor[LowerEdge]->SetPosition ( vsize[0]/2, margins[3] );
|
||||
this->TextActor[UpperEdge]->SetPosition ( vsize[0]/2, vsize[1] - margins[1] );
|
||||
this->TextActor[LeftEdge]->SetPosition ( margins[0], vsize[1]/2 );
|
||||
this->TextActor[RightEdge]->SetPosition ( vsize[0] - margins[2], vsize[1]/2 );
|
||||
}
|
||||
|
||||
void MarginCornerAnnotation::SetMargin(int left, int top, int right, int bottom) {
|
||||
margins[0]= left;
|
||||
margins[1]= top;
|
||||
margins[2]= right;
|
||||
margins[3]= bottom;
|
||||
}
|
||||
29
src/src/Rendering/Core/MarginCornerAnnotation.h
Normal file
29
src/src/Rendering/Core/MarginCornerAnnotation.h
Normal file
@@ -0,0 +1,29 @@
|
||||
//
|
||||
// Created by Krad on 2022/8/26.
|
||||
//
|
||||
|
||||
#ifndef OMEGAV_MARGINCORNERANNOTATION_H
|
||||
#define OMEGAV_MARGINCORNERANNOTATION_H
|
||||
|
||||
#include <vtkCornerAnnotation.h>
|
||||
class MarginCornerAnnotation: public vtkCornerAnnotation{
|
||||
public:
|
||||
vtkTypeMacro(MarginCornerAnnotation,vtkCornerAnnotation);
|
||||
static MarginCornerAnnotation *New();
|
||||
|
||||
protected:
|
||||
MarginCornerAnnotation();
|
||||
~MarginCornerAnnotation() override;
|
||||
void SetTextActorsPosition(int vsize[2]) override ;
|
||||
void SetMargin(int left, int top, int right, int bottom);
|
||||
void SetMargin(int v){
|
||||
SetMargin(v, v, v, v);
|
||||
}
|
||||
private:
|
||||
MarginCornerAnnotation(const MarginCornerAnnotation&) = delete;
|
||||
void operator=(const MarginCornerAnnotation&) = delete;
|
||||
int margins[4] = {8, 8, 8, 8};
|
||||
};
|
||||
|
||||
|
||||
#endif //OMEGAV_MARGINCORNERANNOTATION_H
|
||||
@@ -19,13 +19,13 @@
|
||||
#include <vtkScalarBarActor.h>
|
||||
#include <vtkDiscretizableColorTransferFunction.h>
|
||||
#include <vtkPiecewiseFunction.h>
|
||||
#include <vtkCornerAnnotation.h>
|
||||
#include <vtkTextActor.h>
|
||||
#include <vtkTextProperty.h>
|
||||
|
||||
#include "Rendering/Measure/MeasureStore.h"
|
||||
#include "IO/General/ColorMapReader.h"
|
||||
#include "Interaction/ActorDraggableInteractorStyle.h"
|
||||
#include "Rendering/Core/MarginCornerAnnotation.h"
|
||||
|
||||
namespace {
|
||||
//扭转存在偏转的坐标轴
|
||||
@@ -61,7 +61,7 @@ DICOMImageViewer::DICOMImageViewer()
|
||||
RenderWindow(nullptr), Renderer(nullptr), ImageStack(vtkImageStack::New()),
|
||||
ImageActor(vtkImageSlice::New()), ImageMapper(vtkImageSliceMapper::New()), FusionActor(nullptr),
|
||||
FusionMapper(nullptr), Interactor(nullptr), InteractorStyle(nullptr), OpacityActor(nullptr),
|
||||
cornerAnnotation(vtkCornerAnnotation::New()), bar(nullptr),
|
||||
cornerAnnotation(MarginCornerAnnotation::New()), bar(nullptr),
|
||||
SliceIJK(-1),SlicePlane(-1), FirstRender(1), Slice(0), loadedMeasureSlice(0),
|
||||
currentPresetIndex(1), Fusion(false), firstFusion(true), FusionOpacity(0.5), list(nullptr),
|
||||
measureStore(MeasureStore::Instance()),
|
||||
@@ -74,13 +74,14 @@ DICOMImageViewer::DICOMImageViewer()
|
||||
|
||||
vtkNew<vtkTextProperty> prop;
|
||||
prop->SetFontFamilyToArial();
|
||||
prop->ShadowOn();
|
||||
// prop->ShadowOn();
|
||||
this->cornerAnnotation->SetTextProperty(prop);
|
||||
this->cornerAnnotation->GetTextProperty()->SetColor(1, 1, 0.5);
|
||||
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(FontSizeHelper::font_size);
|
||||
cornerAnnotation->SetMaximumFontSize(20);
|
||||
cornerAnnotation->SetMinimumFontSize(8);
|
||||
|
||||
vtkRenderWindow *renwin = vtkRenderWindow::New();
|
||||
DICOMImageViewer::SetRenderWindow(renwin);
|
||||
|
||||
@@ -274,7 +274,6 @@ void DicomImageView::resizeEvent(QResizeEvent *event) {
|
||||
if (!mImageViewer) return;
|
||||
if (mImageViewer->GetvtkCornerAnnotation()) {
|
||||
mImageViewer->GetvtkCornerAnnotation()->SetMaximumFontSize(FontSizeHelper::getSize(frameGeometry().size()));
|
||||
|
||||
}
|
||||
|
||||
// force update ReferenceLine data
|
||||
@@ -459,9 +458,9 @@ void DicomImageView::dispatchEvent(vtkObject *, unsigned long eid, void *callDat
|
||||
//Image render & operation about--------------------------------------------------------------------------------------
|
||||
void DicomImageView::render() {
|
||||
if (hasSeries()) {
|
||||
if (mImageViewer->GetvtkCornerAnnotation()) {
|
||||
mImageViewer->GetvtkCornerAnnotation()->SetMaximumFontSize(FontSizeHelper::getSize(frameGeometry().size()));
|
||||
}
|
||||
// if (mImageViewer->GetvtkCornerAnnotation()) {
|
||||
// mImageViewer->GetvtkCornerAnnotation()->SetMaximumFontSize(FontSizeHelper::getSize(frameGeometry().size()));
|
||||
// }
|
||||
mImageViewer->Render();
|
||||
}
|
||||
|
||||
|
||||
@@ -272,6 +272,7 @@ void QDicomViewer::openDICOM(const std::string &dicomName, SeriesOpenMode openMo
|
||||
|
||||
//必须首先重置成1个窗口的布局
|
||||
ui->viewContainer->resetLayoutToSingle();
|
||||
//数据读取
|
||||
DicomLoader *helper = DicomLoader::GetInstance();
|
||||
helper->reset();
|
||||
//load image and tag
|
||||
|
||||
Reference in New Issue
Block a user