Slice orientation fix.

This commit is contained in:
Krad
2022-06-29 10:17:29 +08:00
parent 19dc130f12
commit 75a145e0c5

View File

@@ -708,8 +708,9 @@ void infinitiViewer::ResetZoomScaleToFitWindowSize() {
double whFactor = 0.5;
double ws = 1.0* size[0];
double hs = 1.0* size[1];
double hp = 1.0 * inputData->GetBounds()[upIndex*2+1];
double wp = 1.0 * inputData->GetBounds()[rightIndex*2+1];
double* bounds = inputData->GetBounds();
double hp = fabs(1.0 * (bounds[upIndex*2+1] - bounds[upIndex*2]));
double wp = fabs(1.0 * (bounds[rightIndex*2+1] - bounds[rightIndex*2]));
//because Parallel Scale is campare with half height
if(wp/hp>ws/hs){
double aspect = hs/ws;
@@ -1242,25 +1243,33 @@ void infinitiViewer::UpdateOrientation()
vtkCamera* cam = this->Renderer ? this->Renderer->GetActiveCamera() : nullptr;
if (cam)
{
switch (this->SliceOrientation)
{
case infinitiViewer::SLICE_ORIENTATION_XY:
{
cam->SetFocalPoint(0, 0, 0);
cam->SetPosition(0, 0, -1); // -1 if medical ?
cam->SetViewUp(0, -1, 0);
break;
case infinitiViewer::SLICE_ORIENTATION_XZ:
}
case infinitiViewer::SLICE_ORIENTATION_XZ:{
double zVec = GetInput()->GetSpacing()[2];
double upVal = (zVec > 0.0?1.0:-1.0);
cam->SetFocalPoint(0, 0, 0);
cam->SetPosition(0, 1, 0); // 1 if medical ?
cam->SetViewUp(0, 0, -1);
cam->SetPosition(0, 1*upVal, 0); // 1 if medical ?
cam->SetViewUp(0, 0, -1.0 *upVal);
break;
case infinitiViewer::SLICE_ORIENTATION_YZ:
}
case infinitiViewer::SLICE_ORIENTATION_YZ:{
double zVec = GetInput()->GetSpacing()[2];
double upVal = (zVec > 0.0?1.0:-1.0);
cam->SetFocalPoint(0, 0, 0);
cam->SetPosition( -1, 0, 0); // -1 if medical ?
cam->SetViewUp(0, 0, -1);
cam->SetPosition( -1 * upVal, 0, 0); // -1 if medical ?
cam->SetViewUp(0, 0, -1.0 *upVal);
break;
}
}
}
}