|
|
|
|
@@ -603,6 +603,14 @@ int infinitiViewer::GetSlice() {
|
|
|
|
|
return this->ImageMapper->GetSliceNumber();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void infinitiViewer::ChangeSlice(vtkObject *, unsigned long eventid, void *calldata) {
|
|
|
|
|
int lastSlice = GetSlice();
|
|
|
|
|
int* p = (int*)calldata;
|
|
|
|
|
int newSlice = lastSlice+(*p);
|
|
|
|
|
newSlice = newSlice<0?GetSliceMax():(newSlice>GetSliceMax()?0:newSlice);
|
|
|
|
|
SetSlice(newSlice);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void infinitiViewer::SetZoomScale(double scale) {
|
|
|
|
|
if (Renderer)
|
|
|
|
|
{
|
|
|
|
|
@@ -625,80 +633,6 @@ void infinitiViewer::SetPanOffset(double* p) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
void infinitiViewer::SetSliceOrientation(int orientation)
|
|
|
|
|
{
|
|
|
|
|
if (orientation < infinitiViewer::SLICE_ORIENTATION_YZ ||
|
|
|
|
|
orientation > infinitiViewer::SLICE_ORIENTATION_XY)
|
|
|
|
|
{
|
|
|
|
|
vtkErrorMacro("Error - invalid slice orientation " << orientation);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this->SliceOrientation == orientation)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->SliceOrientation = orientation;
|
|
|
|
|
|
|
|
|
|
// Update the viewer
|
|
|
|
|
|
|
|
|
|
int* range = this->GetSliceRange();
|
|
|
|
|
if (range)
|
|
|
|
|
{
|
|
|
|
|
this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->UpdateOrientation();
|
|
|
|
|
updateOrienInfo();
|
|
|
|
|
// this->UpdateDisplayExtent();
|
|
|
|
|
|
|
|
|
|
if (this->Renderer && this->GetInput())
|
|
|
|
|
{
|
|
|
|
|
double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
|
|
|
|
|
this->Renderer->ResetCamera();
|
|
|
|
|
this->Renderer->GetActiveCamera()->SetParallelScale(scale);
|
|
|
|
|
}
|
|
|
|
|
// first render to update imageMapper slice
|
|
|
|
|
this->Render();
|
|
|
|
|
//use SetSlice as second render the first image
|
|
|
|
|
SetSlice(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
void infinitiViewer::UpdateOrientation()
|
|
|
|
|
{
|
|
|
|
|
// Set the camera position
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
cam->SetFocalPoint(0, 0, 0);
|
|
|
|
|
cam->SetPosition(0, 1, 0); // 1 if medical ?
|
|
|
|
|
cam->SetViewUp(0, 0, -1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case infinitiViewer::SLICE_ORIENTATION_YZ:
|
|
|
|
|
cam->SetFocalPoint(0, 0, 0);
|
|
|
|
|
cam->SetPosition( 1, 0, 0); // -1 if medical ?
|
|
|
|
|
cam->SetViewUp(0, 0, -1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
void infinitiViewer::SetPosition(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
@@ -801,6 +735,7 @@ void infinitiViewer::InstallPipeline()
|
|
|
|
|
|
|
|
|
|
this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::EndMeasureEvent, this, &infinitiViewer::AddMeasures);
|
|
|
|
|
this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::DeleteMeasureEvent, this, &infinitiViewer::RemoveMeasures);
|
|
|
|
|
this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::SliceEvent, this, &infinitiViewer::ChangeSlice);
|
|
|
|
|
this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::SlicedEvent, this, &infinitiViewer::LoadMeasures);
|
|
|
|
|
|
|
|
|
|
//for convert vtkEvent to Qt signal
|
|
|
|
|
@@ -1145,6 +1080,80 @@ public:
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
void infinitiViewer::SetSliceOrientation(int orientation)
|
|
|
|
|
{
|
|
|
|
|
if (orientation < infinitiViewer::SLICE_ORIENTATION_YZ ||
|
|
|
|
|
orientation > infinitiViewer::SLICE_ORIENTATION_XY)
|
|
|
|
|
{
|
|
|
|
|
vtkErrorMacro("Error - invalid slice orientation " << orientation);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (this->SliceOrientation == orientation)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->SliceOrientation = orientation;
|
|
|
|
|
|
|
|
|
|
// Update the viewer
|
|
|
|
|
|
|
|
|
|
int* range = this->GetSliceRange();
|
|
|
|
|
if (range)
|
|
|
|
|
{
|
|
|
|
|
this->Slice = static_cast<int>((range[0] + range[1]) * 0.5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this->UpdateOrientation();
|
|
|
|
|
updateOrienInfo();
|
|
|
|
|
// this->UpdateDisplayExtent();
|
|
|
|
|
|
|
|
|
|
if (this->Renderer && this->GetInput())
|
|
|
|
|
{
|
|
|
|
|
double scale = this->Renderer->GetActiveCamera()->GetParallelScale();
|
|
|
|
|
this->Renderer->ResetCamera();
|
|
|
|
|
this->Renderer->GetActiveCamera()->SetParallelScale(scale);
|
|
|
|
|
}
|
|
|
|
|
// first render to update imageMapper slice
|
|
|
|
|
this->Render();
|
|
|
|
|
//use SetSlice as second render the first image
|
|
|
|
|
SetSlice(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------
|
|
|
|
|
void infinitiViewer::UpdateOrientation()
|
|
|
|
|
{
|
|
|
|
|
// Set the camera position
|
|
|
|
|
|
|
|
|
|
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:
|
|
|
|
|
cam->SetFocalPoint(0, 0, 0);
|
|
|
|
|
cam->SetPosition(0, 1, 0); // 1 if medical ?
|
|
|
|
|
cam->SetViewUp(0, 0, -1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case infinitiViewer::SLICE_ORIENTATION_YZ:
|
|
|
|
|
cam->SetFocalPoint(0, 0, 0);
|
|
|
|
|
cam->SetPosition( -1, 0, 0); // -1 if medical ?
|
|
|
|
|
cam->SetViewUp(0, 0, -1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void infinitiViewer::updateTopLeftCornerInfo()
|
|
|
|
|
{
|
|
|
|
|
if (AnnoHelper::IsAnno()) {
|
|
|
|
|
@@ -1288,7 +1297,7 @@ int getOrientationIndex(double* v){
|
|
|
|
|
if(fabs(v[1])>=fabs(v[2])) max_index=1;
|
|
|
|
|
else max_index = 2;
|
|
|
|
|
}
|
|
|
|
|
return v[max_index]>0?max_index*2:2*max_index+1;
|
|
|
|
|
return v[max_index]<0?max_index*2:2*max_index+1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int getOppositeOrientation(int f){
|
|
|
|
|
@@ -1298,13 +1307,14 @@ int getOppositeOrientation(int f){
|
|
|
|
|
|
|
|
|
|
void infinitiViewer::updateOrienInfo()
|
|
|
|
|
{
|
|
|
|
|
static const char* dds[6] ={"R","L","P","A","F","H"};
|
|
|
|
|
static const char* dds[6] ={"R","L","A","P","F","H"};
|
|
|
|
|
double proj[4] ={0,0,0,1};
|
|
|
|
|
Renderer->GetActiveCamera()->GetDirectionOfProjection(proj);
|
|
|
|
|
double invertProj[4] ={-proj[0],-proj[1],-proj[2],1};
|
|
|
|
|
double viewUp[4]= {0,0,0,1};
|
|
|
|
|
this->Renderer->GetActiveCamera()->GetViewUp(viewUp);
|
|
|
|
|
double viewRight[4] = {0, 0, 0, 1};
|
|
|
|
|
vtkMath::Cross(viewUp,proj, viewRight);
|
|
|
|
|
vtkMath::Cross(proj,viewUp, viewRight);
|
|
|
|
|
|
|
|
|
|
double viewUpVector[4]= {0,0,0,1};
|
|
|
|
|
double viewRightVector[4]= {0,0,0,1};
|
|
|
|
|
|