Change orientation cube text logic.
This commit is contained in:
@@ -10,6 +10,7 @@
|
|||||||
#include <vtkRenderWindowInteractor.h>
|
#include <vtkRenderWindowInteractor.h>
|
||||||
#include <vtkCamera.h>
|
#include <vtkCamera.h>
|
||||||
#include <vtkImageData.h>
|
#include <vtkImageData.h>
|
||||||
|
#include <vtkProperty.h>
|
||||||
#include <vtkVolume.h>
|
#include <vtkVolume.h>
|
||||||
#include <vtkVolumeProperty.h>
|
#include <vtkVolumeProperty.h>
|
||||||
#include <vtkFixedPointVolumeRayCastMapper.h>
|
#include <vtkFixedPointVolumeRayCastMapper.h>
|
||||||
@@ -19,6 +20,8 @@
|
|||||||
#include <vtkCornerAnnotation.h>
|
#include <vtkCornerAnnotation.h>
|
||||||
#include <vtkPlane.h>
|
#include <vtkPlane.h>
|
||||||
#include <vtkBoundingBox.h>
|
#include <vtkBoundingBox.h>
|
||||||
|
#include <vtkOrientationMarkerWidget.h>
|
||||||
|
#include <vtkAnnotatedCubeActor.h>
|
||||||
|
|
||||||
|
|
||||||
#include "Interaction/VolumeInteractorStyle.h"
|
#include "Interaction/VolumeInteractorStyle.h"
|
||||||
@@ -46,7 +49,8 @@ VolumeRenderingViewer::VolumeRenderingViewer()
|
|||||||
, VolumeMapper(vtkFixedPointVolumeRayCastMapper::New())
|
, VolumeMapper(vtkFixedPointVolumeRayCastMapper::New())
|
||||||
, InteractorStyle(nullptr)
|
, InteractorStyle(nullptr)
|
||||||
, Interactor(nullptr)
|
, Interactor(nullptr)
|
||||||
, firstRender(true){
|
, firstRender(true)
|
||||||
|
, OrientationMarker(vtkOrientationMarkerWidget::New()){
|
||||||
if (gpuMode){
|
if (gpuMode){
|
||||||
auto mapper = vtkGPUVolumeRayCastMapper::New();
|
auto mapper = vtkGPUVolumeRayCastMapper::New();
|
||||||
mapper->SetUseJittering(1);
|
mapper->SetUseJittering(1);
|
||||||
@@ -155,7 +159,11 @@ void VolumeRenderingViewer::InstallPipeline() {
|
|||||||
Renderer->AddObserver(vtkCommand::EndEvent,this, &VolumeRenderingViewer::renderAnnotation);
|
Renderer->AddObserver(vtkCommand::EndEvent,this, &VolumeRenderingViewer::renderAnnotation);
|
||||||
this->Renderer->SetBackground(0.0, 0.0, 0.0);
|
this->Renderer->SetBackground(0.0, 0.0, 0.0);
|
||||||
}
|
}
|
||||||
//TODO: annotation for orientation
|
if (this->OrientationMarker && this->OrientationMarker->GetOrientationMarker()){
|
||||||
|
this->OrientationMarker->SetInteractor(this->Interactor);
|
||||||
|
this->OrientationMarker->EnabledOn();
|
||||||
|
this->OrientationMarker->InteractiveOn();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeRenderingViewer::UnInstallPipeline() {
|
void VolumeRenderingViewer::UnInstallPipeline() {
|
||||||
@@ -180,6 +188,11 @@ void VolumeRenderingViewer::UnInstallPipeline() {
|
|||||||
this->Interactor->SetInteractorStyle(nullptr);
|
this->Interactor->SetInteractorStyle(nullptr);
|
||||||
this->Interactor->SetRenderWindow(nullptr);
|
this->Interactor->SetRenderWindow(nullptr);
|
||||||
}
|
}
|
||||||
|
if (this->OrientationMarker){
|
||||||
|
this->OrientationMarker->SetInteractor(nullptr);
|
||||||
|
this->OrientationMarker->EnabledOff();
|
||||||
|
this->OrientationMarker->InteractiveOff();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void VolumeRenderingViewer::SetupInteractor(vtkRenderWindowInteractor * arg) {
|
void VolumeRenderingViewer::SetupInteractor(vtkRenderWindowInteractor * arg) {
|
||||||
@@ -331,8 +344,94 @@ void VolumeRenderingViewer::SetInteractorStyleMode(int mode) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char VolumeRenderingViewer::GetDirectionChar(const double *directionVector , int& worldDirection) const {
|
||||||
|
if (fabs(directionVector[0]) > 0.7){
|
||||||
|
worldDirection = 0;
|
||||||
|
return directionVector[0] > 0 ? 'L' : 'R';
|
||||||
|
}
|
||||||
|
if (fabs(directionVector[1])>0.7){
|
||||||
|
worldDirection = 1;
|
||||||
|
return directionVector[1]>0?'P':'A';
|
||||||
|
}
|
||||||
|
if (fabs(directionVector[2])>0.7){
|
||||||
|
worldDirection = 2;
|
||||||
|
return directionVector[2]>0?'H':'F';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void invertVector(double* vector){
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
vector[i] = - vector[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VolumeRenderingViewer::SetCoordsTransformMatrix(ExtendMedicalImageProperties *pSeries) {
|
void VolumeRenderingViewer::SetCoordsTransformMatrix(ExtendMedicalImageProperties *pSeries) {
|
||||||
OrientationMatrix->DeepCopy(pSeries->GetOrientationMatrix());
|
OrientationMatrix->DeepCopy(pSeries->GetOrientationMatrix());
|
||||||
|
|
||||||
|
if (!OrientationMarker->GetOrientationMarker())
|
||||||
|
{
|
||||||
|
vtkNew<vtkAnnotatedCubeActor> cube;
|
||||||
|
double zVector[4] = {.0, .0, 1., 1.};
|
||||||
|
double yVector[4] = {.0, 1., .0, 1.};
|
||||||
|
double xVector[4] = {1., .0, .0, 1.};
|
||||||
|
OrientationMatrix->MultiplyPoint(zVector,zVector);
|
||||||
|
OrientationMatrix->MultiplyPoint(yVector,yVector);
|
||||||
|
OrientationMatrix->MultiplyPoint(xVector,xVector);
|
||||||
|
char txt[2] = " ";
|
||||||
|
int direction = -1;
|
||||||
|
|
||||||
|
txt[0] = GetDirectionChar(zVector, direction);
|
||||||
|
cube->SetZPlusFaceText(txt);
|
||||||
|
invertVector(zVector);
|
||||||
|
txt[0] = GetDirectionChar(zVector);
|
||||||
|
cube->SetZMinusFaceText(txt);
|
||||||
|
|
||||||
|
txt[0] = GetDirectionChar(yVector);
|
||||||
|
cube->SetYPlusFaceText(txt);
|
||||||
|
invertVector(yVector);
|
||||||
|
txt[0] = GetDirectionChar(yVector);
|
||||||
|
cube->SetYMinusFaceText(txt);
|
||||||
|
|
||||||
|
txt[0] = GetDirectionChar(xVector);
|
||||||
|
cube->SetXPlusFaceText(txt);
|
||||||
|
invertVector(xVector);
|
||||||
|
txt[0] = GetDirectionChar(xVector);
|
||||||
|
cube->SetXMinusFaceText(txt);
|
||||||
|
switch (direction){
|
||||||
|
//冠状面
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
vtkErrorMacro("coronal")
|
||||||
|
cube->SetZFaceTextRotation(-90);
|
||||||
|
cube->SetXFaceTextRotation(90);
|
||||||
|
cube->SetYFaceTextRotation(180);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//矢状面
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
vtkErrorMacro("sagittal")
|
||||||
|
cube->SetZFaceTextRotation(-90);
|
||||||
|
cube->SetXFaceTextRotation(90);
|
||||||
|
cube->SetYFaceTextRotation(-90);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 2:
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
vtkErrorMacro("transverse")
|
||||||
|
cube->SetZFaceTextRotation(-90);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cube->GetTextEdgesProperty()->SetColor(1.0,1.0,.0);
|
||||||
|
cube->GetTextEdgesProperty()->SetLineWidth(2.0);
|
||||||
|
cube->GetCubeProperty()->SetColor(.0,.0,1.0);
|
||||||
|
OrientationMarker->SetOrientationMarker(cube);
|
||||||
|
this->OrientationMarker->SetInteractor(this->Interactor);
|
||||||
|
this->OrientationMarker->EnabledOn();
|
||||||
|
this->OrientationMarker->InteractiveOn();
|
||||||
|
}
|
||||||
//change to WToM
|
//change to WToM
|
||||||
OrientationMatrix->Invert();
|
OrientationMatrix->Invert();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ class vtkImageData;
|
|||||||
|
|
||||||
class vtkInformation;
|
class vtkInformation;
|
||||||
|
|
||||||
|
class vtkOrientationMarkerWidget;
|
||||||
|
|
||||||
class vtkRenderWindow;
|
class vtkRenderWindow;
|
||||||
|
|
||||||
@@ -115,11 +116,17 @@ private:
|
|||||||
vtkInteractorStyle *InteractorStyle;
|
vtkInteractorStyle *InteractorStyle;
|
||||||
vtkRenderWindowInteractor *Interactor;
|
vtkRenderWindowInteractor *Interactor;
|
||||||
vtkCornerAnnotation* annotation;
|
vtkCornerAnnotation* annotation;
|
||||||
|
vtkOrientationMarkerWidget* OrientationMarker;
|
||||||
vtkNew<vtkMatrix4x4> OrientationMatrix;
|
vtkNew<vtkMatrix4x4> OrientationMatrix;
|
||||||
bool gpuMode = false;
|
bool gpuMode = false;
|
||||||
bool firstRender = true;
|
bool firstRender = true;
|
||||||
|
|
||||||
void GetDirectionString(const double *directionVector, std::string &str) const;
|
void GetDirectionString(const double *directionVector, std::string &str) const;
|
||||||
|
char GetDirectionChar(const double *directionVector, int& worldDirection) const;
|
||||||
|
char GetDirectionChar(const double *directionVector) const{
|
||||||
|
int a;
|
||||||
|
return GetDirectionChar(directionVector, a);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user