Fix Fusion Actor block bug.
This commit is contained in:
@@ -24,7 +24,7 @@
|
||||
#include "ExtendMedicalImageProperties.h"
|
||||
#include "util/ColorMapReader.h"
|
||||
#include "vtkMath.h"
|
||||
|
||||
#include "vtkImageStack.h"
|
||||
|
||||
|
||||
|
||||
@@ -44,12 +44,17 @@ void infinitiViewer::SetFusionInputData(vtkImageData* data)
|
||||
if (!this->GetInput()) return;
|
||||
if (!simpleFusionableCheck(data, this->GetInput())) return;
|
||||
if (!this->FusionMapper) {
|
||||
this->FusionMapper = vtkImageSliceMapper::New();
|
||||
auto m = vtkImageSliceMapper::New();
|
||||
// m->SetBaseImageMapper(ImageMapper);
|
||||
this->FusionMapper = m;
|
||||
this->FusionMapper->SliceAtFocalPointOn();
|
||||
this->FusionMapper->SliceFacesCameraOn();
|
||||
|
||||
FusionMapper->SetInputData(data);
|
||||
this->FusionActor = vtkImageSlice::New();
|
||||
FusionActor->SetPickable(false);
|
||||
//must set fusion image slice layer to 1 to make main image is active layer of image stack
|
||||
FusionActor->GetProperty()->SetLayerNumber(1);
|
||||
FusionActor->SetPickable(false);
|
||||
FusionActor->SetMapper(FusionMapper);
|
||||
}
|
||||
else if (data == FusionMapper->GetInput()) return;
|
||||
@@ -286,7 +291,9 @@ void infinitiViewer::RemoveFusionActor()
|
||||
void infinitiViewer::RemoveFusionData()
|
||||
{
|
||||
if (!FusionMapper) return;
|
||||
if (Renderer->HasViewProp(FusionActor)) Renderer->RemoveViewProp(FusionActor);
|
||||
if (ImageStack->HasImage(FusionActor)) {
|
||||
ImageStack->RemoveImage(FusionActor);
|
||||
}
|
||||
FusionMapper->Delete();
|
||||
FusionMapper = nullptr;
|
||||
FusionActor->Delete();
|
||||
@@ -303,12 +310,14 @@ infinitiViewer::infinitiViewer()
|
||||
{
|
||||
this->RenderWindow = nullptr;
|
||||
this->Renderer = nullptr;
|
||||
this->ImageStack = vtkImageStack::New();
|
||||
this->ImageActor = vtkImageSlice::New();
|
||||
this->ImageMapper = vtkImageSliceMapper::New();
|
||||
this->ImageMapper->SliceAtFocalPointOn();
|
||||
this->ImageMapper->SliceFacesCameraOn();
|
||||
|
||||
this->ImageActor->SetPickable(true);
|
||||
this->ImageActor->SetMapper(this->ImageMapper);
|
||||
ImageStack->AddImage(ImageActor);
|
||||
this->FusionActor = nullptr;
|
||||
this->FusionMapper = nullptr;
|
||||
this->Interactor = nullptr;
|
||||
@@ -595,7 +604,12 @@ void infinitiViewer::SetSlice(int slice)
|
||||
|
||||
double npv = origin[this->SliceOrientation] + this->Slice * spacing[this->SliceOrientation];
|
||||
camera->SetDistance(fabs(npv - pos[this->SliceOrientation]));
|
||||
if (Fusion && FusionMapper){
|
||||
FusionMapper->SetClippingPlanes(ImageMapper->GetClippingPlanes());
|
||||
}
|
||||
|
||||
this->Render();
|
||||
|
||||
this->InvokeEvent(infinitiViewerEvents::SlicedEvent, nullptr);
|
||||
}
|
||||
|
||||
@@ -611,6 +625,37 @@ void infinitiViewer::ChangeSlice(vtkObject *, unsigned long eventid, void *calld
|
||||
SetSlice(newSlice);
|
||||
}
|
||||
|
||||
vtkSmartPointer<vtkPoints> infinitiViewer::GetSliceBoundPoints(){
|
||||
double bounds[6] ={.0, .0, .0, .0, .0, .0};
|
||||
ImageMapper->GetBounds(bounds);
|
||||
vtkCamera* camera = this->Renderer->GetActiveCamera();
|
||||
double fpt[3] = {.0, .0, .0};
|
||||
camera->GetFocalPoint(fpt);
|
||||
bounds[SliceOrientation*2] = fpt[SliceOrientation];
|
||||
vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New();
|
||||
//只取4个点
|
||||
pts->InsertNextPoint(bounds[0],bounds[2],bounds[4]);
|
||||
if (SliceOrientation!=1){
|
||||
pts->InsertNextPoint(bounds[0],bounds[3],bounds[4]);
|
||||
if (SliceOrientation!=2) {
|
||||
pts->InsertNextPoint(bounds[0], bounds[3], bounds[5]);
|
||||
pts->InsertNextPoint(bounds[0], bounds[2], bounds[5]);
|
||||
}
|
||||
}
|
||||
if (SliceOrientation!=0){
|
||||
if (SliceOrientation!=1){
|
||||
pts->InsertNextPoint(bounds[1],bounds[3],bounds[4]);
|
||||
pts->InsertNextPoint(bounds[1],bounds[2],bounds[4]);
|
||||
}
|
||||
else{
|
||||
pts->InsertNextPoint(bounds[1],bounds[2],bounds[4]);
|
||||
pts->InsertNextPoint(bounds[1],bounds[2],bounds[5]);
|
||||
pts->InsertNextPoint(bounds[0],bounds[2],bounds[5]);
|
||||
}
|
||||
}
|
||||
return pts;
|
||||
}
|
||||
|
||||
void infinitiViewer::SetZoomScale(double scale) {
|
||||
if (Renderer)
|
||||
{
|
||||
@@ -751,13 +796,14 @@ void infinitiViewer::InstallPipeline()
|
||||
|
||||
if (this->Renderer && this->ImageActor)
|
||||
{
|
||||
this->Renderer->AddViewProp(this->ImageActor);
|
||||
this->Renderer->AddViewProp(this->ImageStack);
|
||||
// this->Renderer->AddViewProp(this->ImageActor);
|
||||
this->Renderer->GetActiveCamera()->SetParallelProjection(1);
|
||||
this->Renderer->SetBackground(0.0, 0.0, 0.0);
|
||||
}
|
||||
if (this->Renderer && this->FusionActor && Fusion)
|
||||
{
|
||||
this->Renderer->AddViewProp(this->FusionActor);
|
||||
this->ImageStack->AddImage(this->FusionActor);
|
||||
}
|
||||
if (this->Renderer && this->cornerAnnotation)
|
||||
{
|
||||
@@ -933,12 +979,16 @@ void infinitiViewer::Render()
|
||||
}
|
||||
if (this->GetInput())
|
||||
{
|
||||
if (Fusion && FusionActor && !this->Renderer->HasViewProp(FusionActor)) {
|
||||
this->Renderer->AddActor(FusionActor);
|
||||
if (Fusion && FusionActor && !this->ImageStack->HasImage(FusionActor)) {
|
||||
// this->Renderer->AddActor(FusionActor);
|
||||
|
||||
this->ImageStack->AddImage(FusionActor);
|
||||
}
|
||||
if (!Fusion && FusionActor && this->Renderer->HasViewProp(FusionActor))
|
||||
if (!Fusion && FusionActor && this->ImageStack->HasImage(FusionActor))
|
||||
{
|
||||
this->Renderer->RemoveViewProp(FusionActor);
|
||||
// this->Renderer->RemoveViewProp(FusionActor);
|
||||
this->ImageStack->RemoveImage(FusionActor);
|
||||
|
||||
}
|
||||
this->LoadMeasures();
|
||||
this->RenderWindow->Render();
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
|
||||
class vtkAlgorithm;
|
||||
class vtkAlgorithmOutput;
|
||||
class vtkImageStack;
|
||||
class vtkImageSlice;
|
||||
class vtkLookupTable;
|
||||
class vtkScalarsToColors;
|
||||
@@ -135,6 +136,7 @@ public:
|
||||
//@}
|
||||
|
||||
void ChangeSlice(vtkObject*,unsigned long eventid,void* calldata);
|
||||
vtkSmartPointer<vtkPoints> GetSliceBoundPoints();
|
||||
|
||||
//@{
|
||||
/**
|
||||
@@ -330,6 +332,7 @@ protected:
|
||||
|
||||
vtkRenderWindow* RenderWindow;
|
||||
vtkRenderer* Renderer;
|
||||
vtkImageStack* ImageStack;
|
||||
vtkImageSlice* ImageActor;
|
||||
vtkImageSlice* FusionActor;
|
||||
vtkImageSliceMapper* ImageMapper;
|
||||
@@ -367,7 +370,7 @@ private:
|
||||
|
||||
void updateTopLeftCornerInfo();
|
||||
|
||||
|
||||
|
||||
|
||||
infinitiViewer(const infinitiViewer&) = delete;
|
||||
void operator=(const infinitiViewer&) = delete;
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "vtkProp.h"
|
||||
#include "vtkPropCollection.h"
|
||||
#include "vtkImageSlice.h"
|
||||
#include "vtkImageStack.h"
|
||||
#include "vtkAssemblyPath.h"
|
||||
#include "vtkRenderer.h"
|
||||
#include "vtkImageSliceMapper.h"
|
||||
@@ -489,6 +490,7 @@ void ActorDraggableInteractorStyle::DispatchEvent() {
|
||||
//重写部分逻辑,在取imageProperty的时候把ImageSlice也取了。
|
||||
void ActorDraggableInteractorStyle::SetCurrentImageNumber(int i)
|
||||
{
|
||||
// return;
|
||||
this->CurrentImageNumber = i;
|
||||
if (!this->CurrentRenderer)
|
||||
{
|
||||
@@ -512,7 +514,7 @@ void ActorDraggableInteractorStyle::SetCurrentImageNumber(int i)
|
||||
imageProp = vtkImageSlice::SafeDownCast(tryProp);
|
||||
if (imageProp)
|
||||
{
|
||||
if (j == i && imageProp->GetPickable())
|
||||
if (j == i)
|
||||
{
|
||||
foundImageProp = true;
|
||||
break;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <vtkPropPicker.h>
|
||||
#include <vtkPointPicker.h>
|
||||
#include <vtkImageSlice.h>
|
||||
#include "vtkInteractorStyleImage.h"
|
||||
#include "vtkNew.h" // For ivars
|
||||
#include "functional"
|
||||
@@ -120,10 +121,12 @@ public:
|
||||
}
|
||||
void ActiveMeasure(Measure* m);
|
||||
void UnActiveMeasure();
|
||||
//void SetCornderAnnoEna(bool enable)
|
||||
//{
|
||||
// isCornderAnno = enable;
|
||||
//}
|
||||
|
||||
void SetCurrentImageSlice(vtkImageSlice* slice){
|
||||
CurrentImageSlice = slice;
|
||||
CurrentImageProperty = slice->GetProperty();
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
ActorDraggableInteractorStyle();
|
||||
|
||||
Reference in New Issue
Block a user