Fix AdjustOrthogonalScale bug(when width/height > ScreenAspectRatio)

This commit is contained in:
Krad
2023-01-16 13:41:45 +08:00
parent 78b89c976f
commit 344e289031

View File

@@ -396,14 +396,17 @@ void ResliceImageViewer::AdjustOrthogonalScale() {
double * viewUp = camera->GetViewUp(); double * viewUp = camera->GetViewUp();
vtkImageData * data = Mapper->GetInput(); vtkImageData * data = Mapper->GetInput();
int index = abs(((int)viewUp[0]) * 0 + ((int)viewUp[1]) * 1 + ((int)viewUp[2]) * 2); int index = abs(((int)viewUp[0]) * 0 + ((int)viewUp[1]) * 1 + ((int)viewUp[2]) * 2);
double * proj = camera->GetDirectionOfProjection();
int index2 = abs((int)proj[0]+(int)viewUp[0] -1) * 0 +
abs((int)proj[1]+(int)viewUp[1]-1) * 1 + abs((int)proj[2]+(int)viewUp[2]-1) * 2;
double ratio = Renderer->GetTiledAspectRatio(); double ratio = Renderer->GetTiledAspectRatio();
double pixelScale = data->GetDimensions()[index]*data->GetSpacing()[index]; double pixelScaleHeight = data->GetDimensions()[index] * data->GetSpacing()[index];
if (ratio<1.0){ double pixelScaleWidth = data->GetDimensions()[index2] * data->GetSpacing()[index2];
camera->SetParallelScale(pixelScale/2/ratio+3); if (ratio<pixelScaleWidth/pixelScaleHeight){
camera->SetParallelScale(pixelScaleWidth / 2 / ratio + 1);
} }
else{ else{
camera->SetParallelScale(pixelScale/2+3); camera->SetParallelScale(pixelScaleHeight / 2 + 1);
} }
} }