Load data memory fix.(corner anno caused)

This commit is contained in:
Krad
2022-03-01 17:32:35 +08:00
parent 00ccdb8368
commit f36e8d2330
7 changed files with 331 additions and 310 deletions

View File

@@ -19,6 +19,7 @@ class SeriesImageSet;
class DICOMDirectoryHelper; class DICOMDirectoryHelper;
class ExtendMedicalImageProperties; class ExtendMedicalImageProperties;
class vtkDICOMImageReader2; class vtkDICOMImageReader2;
typedef std::map<std::string, SeriesImageSet*> ImageSetStore;
class DicomLoader { class DicomLoader {
public: public:
@@ -53,8 +54,8 @@ public:
} }
//if not duplicate
SeriesImageSet* InitFromRead(const UniqueIDInfo &uniqueID);// , DicomTagInfo_t* tag_info); SeriesImageSet* getSeriesImageSet(const UniqueIDInfo &uniqueID);
SeriesInfo_t* getSerieInfo(const UniqueIDInfo &uniqueID); SeriesInfo_t* getSerieInfo(const UniqueIDInfo &uniqueID);
SeriesImageSet* getFirstInstance(const UniqueIDInfo &uniqueID); SeriesImageSet* getFirstInstance(const UniqueIDInfo &uniqueID);
@@ -84,7 +85,7 @@ private:
ExtendMedicalImageProperties * currentImageProperty = nullptr; ExtendMedicalImageProperties * currentImageProperty = nullptr;
std::vector<ExtendMedicalImageProperties*> imageProperties; std::vector<ExtendMedicalImageProperties*> imageProperties;
vtkDICOMImageReader2 * reader = nullptr; vtkDICOMImageReader2 * reader = nullptr;
ImageSetStore store;
AddDicomType m_addType; AddDicomType m_addType;
PatientsMapType m_patients; PatientsMapType m_patients;
vtkObject* placeHolder; vtkObject* placeHolder;

View File

@@ -46,6 +46,11 @@ public slots:
void Slot_ViewClicked(DicomImageView *view); void Slot_ViewClicked(DicomImageView *view);
void Slot_ViewDoubleClicked(DicomImageView *view); void Slot_ViewDoubleClicked(DicomImageView *view);
void Slot_DragDropEvent(DicomImageView *view, thumbnailImage* tb); void Slot_DragDropEvent(DicomImageView *view, thumbnailImage* tb);
/**
* 缩略图点击槽函数会导致当前选中的view重新load数据
* @param tb 缩略图对象
* @return
*/
void Slot_ThumbnailClickEvent(thumbnailImage* tb); void Slot_ThumbnailClickEvent(thumbnailImage* tb);
void Slot_SyncEvent(DicomImageView *view, int interactionMode, void* calldata); void Slot_SyncEvent(DicomImageView *view, int interactionMode, void* calldata);

View File

@@ -154,8 +154,15 @@ bool DicomLoader::IsDuplicate(UniqueIDInfo_t* unique)
SeriesImageSet* DicomLoader::InitFromRead(const UniqueIDInfo &uniqueID)//, DicomTagInfo_t* tag_info) SeriesImageSet* DicomLoader::getSeriesImageSet(const UniqueIDInfo &uniqueID)//, DicomTagInfo_t* tag_info)
{ {
//only user key to the series level
auto key = uniqueID.patient_name+uniqueID.study_uid+uniqueID.series_uid;
if (store.count(key)>0)
{
//use cache instead load
return store[key];
}
if (reader) reader->Delete(); if (reader) reader->Delete();
reader = vtkDICOMImageReader2::New(); reader = vtkDICOMImageReader2::New();
reader->SetFileNames(*(currentImageProperty->GetFileNames())); reader->SetFileNames(*(currentImageProperty->GetFileNames()));
@@ -163,6 +170,7 @@ SeriesImageSet* DicomLoader::InitFromRead(const UniqueIDInfo &uniqueID)//, Dicom
SeriesImageSet* result = new SeriesImageSet(uniqueID,currentImageProperty,reader->GetOutput()); SeriesImageSet* result = new SeriesImageSet(uniqueID,currentImageProperty,reader->GetOutput());
reader->Delete(); reader->Delete();
reader = nullptr; reader = nullptr;
store[key] = result;
return result; return result;
} }
@@ -398,7 +406,7 @@ DicomTagInfo_t* DicomLoader::createDicomTagsInfo()
SeriesImageSet* DicomLoader::createSeries(UniqueIDInfo_t* uniqueID) SeriesImageSet* DicomLoader::createSeries(UniqueIDInfo_t* uniqueID)
{ {
SeriesImageSet* series =instance->InitFromRead(*uniqueID); SeriesImageSet* series = instance->getSeriesImageSet(*uniqueID);
series->setUpSeriesInstance(); series->setUpSeriesInstance();
return series; return series;

View File

@@ -355,6 +355,7 @@ infinitiViewer::~infinitiViewer()
{ {
if (this->ImageMapper) if (this->ImageMapper)
{ {
this->ImageMapper->SetInputData(nullptr);
this->ImageMapper->Delete(); this->ImageMapper->Delete();
this->ImageMapper = nullptr; this->ImageMapper = nullptr;
} }
@@ -363,6 +364,7 @@ infinitiViewer::~infinitiViewer()
this->ImageActor->Delete(); this->ImageActor->Delete();
this->ImageActor = nullptr; this->ImageActor = nullptr;
} }
if (this->FusionMapper) if (this->FusionMapper)
{ {
this->FusionMapper->Delete(); this->FusionMapper->Delete();
@@ -394,9 +396,14 @@ infinitiViewer::~infinitiViewer()
if (this->InteractorStyle) if (this->InteractorStyle)
{ {
this->InteractorStyle->SetCornerAnnotation(nullptr);
this->InteractorStyle->Delete(); this->InteractorStyle->Delete();
this->InteractorStyle = nullptr; this->InteractorStyle = nullptr;
} }
if (this->cornerAnnotation) {
this->cornerAnnotation->Delete();
this->cornerAnnotation = nullptr;
}
measureStore->RemoveAllInSeries(SOP_UID); measureStore->RemoveAllInSeries(SOP_UID);
// measureStore->Clear(); // measureStore->Clear();
//delete measureStore; //delete measureStore;
@@ -1202,15 +1209,15 @@ void infinitiViewer::initTopLeftCornerInfo(const std::string& lbl_ser_num, const
void infinitiViewer::initCornerInfo(ExtendMedicalImageProperties* pSeries) void infinitiViewer::initCornerInfo(ExtendMedicalImageProperties* pSeries)
{ {
if(pSeries->GetNumberOfWindowLevelPresets()>0) if (pSeries->GetNumberOfWindowLevelPresets() > 0)
{ {
double * wwwl = pSeries->GetNthWindowLevelPreset(0); double* wwwl = pSeries->GetNthWindowLevelPreset(0);
m_cornerInfo.win_level = (int)wwwl[1]; m_cornerInfo.win_level = (int)wwwl[1];
m_cornerInfo.win_width = (int)wwwl[0]; m_cornerInfo.win_width = (int)wwwl[0];
} }
char buffer [sizeof(long)*8+1]; char buffer[sizeof(long) * 8 + 1];
const char* s = ltoa(pSeries->GetFileNames()->size(), buffer, 10); const char* s = ltoa(pSeries->GetFileNames()->size(), buffer, 10);
m_cornerInfo.ConstAnno[TOP_LEFT].append(buffer); m_cornerInfo.ConstAnno[TOP_LEFT].append(buffer);
m_cornerInfo.ConstAnno[TOP_LEFT].append(" "); m_cornerInfo.ConstAnno[TOP_LEFT].append(" ");
m_cornerInfo.ConstAnno[TOP_LEFT].append(pSeries->GetSeriesNumber()); m_cornerInfo.ConstAnno[TOP_LEFT].append(pSeries->GetSeriesNumber());
@@ -1339,10 +1346,10 @@ void infinitiViewer::setUpImageViewer()
} }
void infinitiViewer::ActiveRuler() { void infinitiViewer::ActiveRuler() {
rulerActive = true; rulerActive = true;
} }
void infinitiViewer::UnActiveRuler() { void infinitiViewer::UnActiveRuler() {
rulerActive = false; rulerActive = false;
} }

View File

@@ -29,72 +29,78 @@
#include "QGlobals.h" #include "QGlobals.h"
vtkStandardNewMacro(ActorDraggableInteractorStyle); vtkStandardNewMacro(ActorDraggableInteractorStyle);
ActorDraggableInteractorStyle::ActorDraggableInteractorStyle() { ActorDraggableInteractorStyle::ActorDraggableInteractorStyle() {
this->AddObserver(vtkCommand::InteractionEvent,this,&ActorDraggableInteractorStyle::DispatchEvent); this->AddObserver(vtkCommand::InteractionEvent, this, &ActorDraggableInteractorStyle::DispatchEvent);
#ifdef _DEBUG #ifdef _DEBUG
this->AddObserver(DraggableStyleEvents::EndDollyEvent, this, &ActorDraggableInteractorStyle::TestOutPut); this->AddObserver(DraggableStyleEvents::EndDollyEvent, this, &ActorDraggableInteractorStyle::TestOutPut);
this->AddObserver(vtkCommand::EventIds::EndPanEvent, this, &ActorDraggableInteractorStyle::TestOutPut); this->AddObserver(vtkCommand::EventIds::EndPanEvent, this, &ActorDraggableInteractorStyle::TestOutPut);
this->AddObserver(vtkCommand::EventIds::EndRotateEvent, this, &ActorDraggableInteractorStyle::TestOutPut); this->AddObserver(vtkCommand::EventIds::EndRotateEvent, this, &ActorDraggableInteractorStyle::TestOutPut);
this->AddObserver(vtkCommand::EventIds::EndWindowLevelEvent, this, &ActorDraggableInteractorStyle::TestOutPut); this->AddObserver(vtkCommand::EventIds::EndWindowLevelEvent, this, &ActorDraggableInteractorStyle::TestOutPut);
this->AddObserver(DraggableStyleEvents::SlicedEvent, this, &ActorDraggableInteractorStyle::TestOutPut); this->AddObserver(DraggableStyleEvents::SlicedEvent, this, &ActorDraggableInteractorStyle::TestOutPut);
#endif #endif
} }
ActorDraggableInteractorStyle::~ActorDraggableInteractorStyle() { ActorDraggableInteractorStyle::~ActorDraggableInteractorStyle() {
if (scalarProp) {
scalarProp->Delete();
scalarProp = nullptr;
}
if (CornerAnnotation) {
CornerAnnotation->UnRegister(this);
}
} }
template<typename T> template<typename T>
void vtkValueMessageTemplate(vtkImageData* image, int* position, std::string& message) void vtkValueMessageTemplate(vtkImageData* image, int* position, std::string& message)
{ {
T* tuple = ((T*)image->GetScalarPointer(position)); T* tuple = ((T*)image->GetScalarPointer(position));
if (!tuple) if (!tuple)
{ {
return; return;
} }
int components = image->GetNumberOfScalarComponents(); int components = image->GetNumberOfScalarComponents();
for (int c = 0; c < components; ++c) for (int c = 0; c < components; ++c)
{ {
message += vtkVariant(tuple[c]).ToString(); message += vtkVariant(tuple[c]).ToString();
if (c != (components - 1)) if (c != (components - 1))
{ {
message += ", "; message += ", ";
} }
} }
//message += " )"; //message += " )";
} }
void ActorDraggableInteractorStyle::OnLeftButtonUp() { void ActorDraggableInteractorStyle::OnLeftButtonUp() {
switch (this->State) { switch (this->State) {
case VTKIS_DRAG: case VTKIS_DRAG:
DraggableActor::SafeDownCast(dragProp)->ApplyTransform(); DraggableActor::SafeDownCast(dragProp)->ApplyTransform();
this->EndDrag(); this->EndDrag();
break; break;
case VTKIS_MEASURE: case VTKIS_MEASURE:
measure->SetPlacing(measure->onMeasureLeftButtonUp(this->Interactor)); measure->SetPlacing(measure->onMeasureLeftButtonUp(this->Interactor));
if (!measure->isMeasurePlacing()) { if (!measure->isMeasurePlacing()) {
this->EndMeasure(); this->EndMeasure();
auto temp = measure; auto temp = measure;
measure = measure->GetNextMeasure(); measure = measure->GetNextMeasure();
if (!temp->Valid()){ if (!temp->Valid()) {
temp->ForceDelete(); temp->ForceDelete();
temp= nullptr; temp = nullptr;
} }
} }
break; break;
case VTKIS_COLORMAP: case VTKIS_COLORMAP:
this->EndColorMapping(); this->EndColorMapping();
break; break;
} }
vtkInteractorStyleImage::OnLeftButtonUp(); vtkInteractorStyleImage::OnLeftButtonUp();
} }
void ActorDraggableInteractorStyle::ColorMapping() void ActorDraggableInteractorStyle::ColorMapping()
{ {
vtkRenderWindowInteractor *rwi = this->Interactor; vtkRenderWindowInteractor* rwi = this->Interactor;
this->ScalarCurrentPosition[1] = rwi->GetEventPosition()[1]; this->ScalarCurrentPosition[1] = rwi->GetEventPosition()[1];
//pos[0] = (this->ScalarCurrentPosition[0] - this->ScalarStartPosition[0]); //pos[0] = (this->ScalarCurrentPosition[0] - this->ScalarStartPosition[0]);
double total = 0.01*((this->ScalarCurrentPosition[1] - this->ScalarStartPosition[1])/scalarSensitivity); double total = 0.01 * ((this->ScalarCurrentPosition[1] - this->ScalarStartPosition[1]) / scalarSensitivity);
double left = total - ConsumedOpacity; double left = total - ConsumedOpacity;
//printf("ColorMapping:%d,%d,%.2f \r\n", ScalarCurrentPosition[1], ScalarStartPosition[1],left); //printf("ColorMapping:%d,%d,%.2f \r\n", ScalarCurrentPosition[1], ScalarStartPosition[1],left);
if (abs(left) >= 0.01) { if (abs(left) >= 0.01) {
@@ -120,15 +126,15 @@ void ActorDraggableInteractorStyle::EndColorMapping()
void ActorDraggableInteractorStyle::Drag() { void ActorDraggableInteractorStyle::Drag() {
int* pos = this->Interactor->GetEventPosition(); int* pos = this->Interactor->GetEventPosition();
this->FindPokedRenderer(pos[0],pos[1]); this->FindPokedRenderer(pos[0], pos[1]);
DraggableActor::SafeDownCast(dragProp)->Transform(pos[0] - DragStartOrigin[0], pos[1] - DragStartOrigin[1]); DraggableActor::SafeDownCast(dragProp)->Transform(pos[0] - DragStartOrigin[0], pos[1] - DragStartOrigin[1]);
this->Interactor->Render(); this->Interactor->Render();
} }
void ActorDraggableInteractorStyle::MeasurePlace() { void ActorDraggableInteractorStyle::MeasurePlace() {
measure->onMeasureMouseMove(this->Interactor); measure->onMeasureMouseMove(this->Interactor);
} }
void ActorDraggableInteractorStyle::NoneStatePick() { void ActorDraggableInteractorStyle::NoneStatePick() {
@@ -141,7 +147,7 @@ void ActorDraggableInteractorStyle::NoneStatePick() {
if (result) if (result)
{ {
vtkProp* obj = picker->GetViewProp(); vtkProp* obj = picker->GetViewProp();
if (scalarProp != obj && scalarProp) { if (scalarProp != obj && scalarProp) {
scalarProp = nullptr; scalarProp = nullptr;
} }
@@ -205,11 +211,11 @@ void ActorDraggableInteractorStyle::NoneStatePick() {
scalarProp = nullptr; scalarProp = nullptr;
} }
dragProp = nullptr; dragProp = nullptr;
this->CornerAnnotation->SetText(BOTTOM_LEFT, ""); if (this->CornerAnnotation)this->CornerAnnotation->SetText(BOTTOM_LEFT, "");
} }
} }
this->CornerAnnotation->SetText(BOTTOM_LEFT, ""); if (this->CornerAnnotation)this->CornerAnnotation->SetText(BOTTOM_LEFT, "");
this->Interactor->Render(); this->Interactor->Render();
} }
@@ -218,33 +224,33 @@ void ActorDraggableInteractorStyle::OnMouseMove() {
int x = this->Interactor->GetEventPosition()[0]; int x = this->Interactor->GetEventPosition()[0];
int y = this->Interactor->GetEventPosition()[1]; int y = this->Interactor->GetEventPosition()[1];
switch (this->State) { switch (this->State) {
case VTKIS_MEASURE: case VTKIS_MEASURE:
MeasurePlace(); MeasurePlace();
//照抄源码不是很清楚这句话的作用可能有加速处理用户输入事件的作用连续InteractionEvent处理连续操作避免外部判断 //照抄源码不是很清楚这句话的作用可能有加速处理用户输入事件的作用连续InteractionEvent处理连续操作避免外部判断
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
break; break;
case VTKIS_DRAG: case VTKIS_DRAG:
Drag(); Drag();
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
break; break;
case VTKIS_NONE: case VTKIS_NONE:
NoneStatePick(); NoneStatePick();
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
break; break;
case VTKIS_COLORMAP: case VTKIS_COLORMAP:
this->FindPokedRenderer(x, y); this->FindPokedRenderer(x, y);
this->ColorMapping(); this->ColorMapping();
this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); this->InvokeEvent(vtkCommand::InteractionEvent, nullptr);
break; break;
} }
vtkInteractorStyleImage::OnMouseMove(); vtkInteractorStyleImage::OnMouseMove();
} }
void ActorDraggableInteractorStyle::WindowLevel() void ActorDraggableInteractorStyle::WindowLevel()
{ {
vtkRenderWindowInteractor *rwi = this->Interactor; vtkRenderWindowInteractor* rwi = this->Interactor;
this->WindowLevelCurrentPosition[0] = rwi->GetEventPosition()[0]; this->WindowLevelCurrentPosition[0] = rwi->GetEventPosition()[0];
this->WindowLevelCurrentPosition[1] = rwi->GetEventPosition()[1]; this->WindowLevelCurrentPosition[1] = rwi->GetEventPosition()[1];
@@ -256,7 +262,7 @@ void ActorDraggableInteractorStyle::WindowLevel()
} }
if (this->CurrentImageProperty) if (this->CurrentImageProperty)
{ {
int *size = this->CurrentRenderer->GetSize(); int* size = this->CurrentRenderer->GetSize();
double window = this->WindowLevelInitial[0]; double window = this->WindowLevelInitial[0];
double level = this->WindowLevelInitial[1]; double level = this->WindowLevelInitial[1];
@@ -332,56 +338,56 @@ void ActorDraggableInteractorStyle::OnRightButtonDown()
} }
} }
void ActorDraggableInteractorStyle::OnLeftButtonDown() { void ActorDraggableInteractorStyle::OnLeftButtonDown() {
int x = this->Interactor->GetEventPosition()[0]; int x = this->Interactor->GetEventPosition()[0];
int y = this->Interactor->GetEventPosition()[1]; int y = this->Interactor->GetEventPosition()[1];
this->FindPokedRenderer(x, y); this->FindPokedRenderer(x, y);
if (this->CurrentRenderer == nullptr) if (this->CurrentRenderer == nullptr)
{ {
return; return;
} }
// Redefine this button to handle window/level // Redefine this button to handle window/level
this->GrabFocus(this->EventCallbackCommand); this->GrabFocus(this->EventCallbackCommand);
if (selectedProp) { if (selectedProp) {
selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::UnSelectedEvent); selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::UnSelectedEvent);
selectedProp = nullptr; selectedProp = nullptr;
} }
if (dragProp){ if (dragProp) {
selectedProp = dragProp; selectedProp = dragProp;
selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::SelectedEvent); selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::SelectedEvent);
if (this->Interactor->GetRepeatCount()) if (this->Interactor->GetRepeatCount())
{ {
dragProp->InvokeEvent(DraggableStyleEvents::PopPropEvent, nullptr); dragProp->InvokeEvent(DraggableStyleEvents::PopPropEvent, nullptr);
} }
DragStartOrigin[0] = x; DragStartOrigin[0] = x;
DragStartOrigin[1] = y; DragStartOrigin[1] = y;
this->StartDrag(); this->StartDrag();
return; return;
} }
if (Interactor->GetRepeatCount()){ if (Interactor->GetRepeatCount()) {
if (measure) if (measure)
{ {
measure->SetPlacing(measure->onMeasureDoubleClick(this->Interactor)); measure->SetPlacing(measure->onMeasureDoubleClick(this->Interactor));
if (!measure->isMeasurePlacing()) { if (!measure->isMeasurePlacing()) {
this->EndMeasure(); this->EndMeasure();
auto temp = measure; auto temp = measure;
measure = measure->GetNextMeasure(); measure = measure->GetNextMeasure();
if (!temp->Valid()){ if (!temp->Valid()) {
temp->ForceDelete(); temp->ForceDelete();
temp= nullptr; temp = nullptr;
} }
} }
return; return;
} }
this->InvokeEvent(DraggableStyleEvents::DoubleClickEvent, nullptr); this->InvokeEvent(DraggableStyleEvents::DoubleClickEvent, nullptr);
return; return;
} }
if (measure) if (measure)
{ {
measure->SetPlacing(measure->onMeasureLeftButtonDown(this->Interactor)); measure->SetPlacing(measure->onMeasureLeftButtonDown(this->Interactor));
if(this->State!=VTKIS_MEASURE) this->StartMeasure(); if (this->State != VTKIS_MEASURE) this->StartMeasure();
return; return;
} }
if (scalarProp) if (scalarProp)
{ {
@@ -392,207 +398,207 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() {
} }
if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL) if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL)
{ {
this->WindowLevelStartPosition[0] = x; this->WindowLevelStartPosition[0] = x;
this->WindowLevelStartPosition[1] = y; this->WindowLevelStartPosition[1] = y;
this->StartWindowLevel(); this->StartWindowLevel();
} }
else if (this->InteractionMode == VTKIS_IMAGE_ZOOM) else if (this->InteractionMode == VTKIS_IMAGE_ZOOM)
{ {
this->DollyStartScale = this->CurrentRenderer->GetActiveCamera()->GetParallelScale(); this->DollyStartScale = this->CurrentRenderer->GetActiveCamera()->GetParallelScale();
this->StartDolly(); this->StartDolly();
} }
else if (this->InteractionMode == VTKIS_IMAGE_PAN) else if (this->InteractionMode == VTKIS_IMAGE_PAN)
{ {
this->StartPan(); this->StartPan();
} }
else if (this->InteractionMode == VTKIS_IMAGE_SLICING) else if (this->InteractionMode == VTKIS_IMAGE_SLICING)
{ {
this->StartSlice(); this->StartSlice();
} }
} }
void ActorDraggableInteractorStyle::ActiveMeasure(Measure *m) { void ActorDraggableInteractorStyle::ActiveMeasure(Measure* m) {
if (this->measure && nullptr == m) { if (this->measure && nullptr == m) {
this->measure->onTerminate(this->Interactor); this->measure->onTerminate(this->Interactor);
} }
this->measure = m; this->measure = m;
} }
void ActorDraggableInteractorStyle::UnActiveMeasure() { void ActorDraggableInteractorStyle::UnActiveMeasure() {
if (this->measure) { if (this->measure) {
this->measure->onTerminate(this->Interactor); this->measure->onTerminate(this->Interactor);
} }
this->EndMeasure(); this->EndMeasure();
this->measure = nullptr; this->measure = nullptr;
} }
void ActorDraggableInteractorStyle::DispatchEvent() { void ActorDraggableInteractorStyle::DispatchEvent() {
switch (this->State) { switch (this->State) {
case VTKIS_SLICE: case VTKIS_SLICE:
if (this->HandleObservers) { if (this->HandleObservers) {
//double check //double check
if (!this->CurrentImageSlice) { if (!this->CurrentImageSlice) {
this->SetCurrentImageNumber(this->CurrentImageNumber); this->SetCurrentImageNumber(this->CurrentImageNumber);
} }
if (!this->CurrentImageSlice) return; if (!this->CurrentImageSlice) return;
vtkImageSliceMapper *mapper = vtkImageSliceMapper::SafeDownCast(this->CurrentImageSlice->GetMapper()); vtkImageSliceMapper* mapper = vtkImageSliceMapper::SafeDownCast(this->CurrentImageSlice->GetMapper());
int slice[1] = {mapper ? mapper->GetSliceNumber() : -1}; int slice[1] = { mapper ? mapper->GetSliceNumber() : -1 };
//鼠标滑动不一定能造成翻页!!!所以需要进行一次判定 //鼠标滑动不一定能造成翻页!!!所以需要进行一次判定
if (slice[0] != lastslice) { if (slice[0] != lastslice) {
this->InvokeEvent(DraggableStyleEvents::SlicedEvent, slice); this->InvokeEvent(DraggableStyleEvents::SlicedEvent, slice);
lastslice = slice[0]; lastslice = slice[0];
} }
break; break;
} }
} }
} }
//重写部分逻辑在取imageProperty的时候把ImageSlice也取了。 //重写部分逻辑在取imageProperty的时候把ImageSlice也取了。
void ActorDraggableInteractorStyle::SetCurrentImageNumber(int i) void ActorDraggableInteractorStyle::SetCurrentImageNumber(int i)
{ {
this->CurrentImageNumber = i; this->CurrentImageNumber = i;
if (!this->CurrentRenderer) if (!this->CurrentRenderer)
{ {
return; return;
} }
vtkPropCollection* props = this->CurrentRenderer->GetViewProps(); vtkPropCollection* props = this->CurrentRenderer->GetViewProps();
vtkProp* prop = nullptr; vtkProp* prop = nullptr;
vtkAssemblyPath* path; vtkAssemblyPath* path;
vtkImageSlice* imageProp = nullptr; vtkImageSlice* imageProp = nullptr;
vtkCollectionSimpleIterator pit; vtkCollectionSimpleIterator pit;
for (int k = 0; k < 2; k++) for (int k = 0; k < 2; k++)
{ {
int j = 0; int j = 0;
for (props->InitTraversal(pit); (prop = props->GetNextProp(pit));) for (props->InitTraversal(pit); (prop = props->GetNextProp(pit));)
{ {
bool foundImageProp = false; bool foundImageProp = false;
for (prop->InitPathTraversal(); (path = prop->GetNextPath());) for (prop->InitPathTraversal(); (path = prop->GetNextPath());)
{ {
vtkProp* tryProp = path->GetLastNode()->GetViewProp(); vtkProp* tryProp = path->GetLastNode()->GetViewProp();
imageProp = vtkImageSlice::SafeDownCast(tryProp); imageProp = vtkImageSlice::SafeDownCast(tryProp);
if (imageProp) if (imageProp)
{ {
if (j == i && imageProp->GetPickable()) if (j == i && imageProp->GetPickable())
{ {
foundImageProp = true; foundImageProp = true;
break; break;
} }
imageProp = nullptr; imageProp = nullptr;
j++; j++;
} }
} }
if (foundImageProp) if (foundImageProp)
{ {
break; break;
} }
} }
if (i < 0) if (i < 0)
{ {
i += j; i += j;
} }
} }
vtkImageProperty* property = nullptr; vtkImageProperty* property = nullptr;
if (imageProp) if (imageProp)
{ {
property = imageProp->GetProperty(); property = imageProp->GetProperty();
if (imageProp != this->CurrentImageSlice) if (imageProp != this->CurrentImageSlice)
{ {
if (this->CurrentImageSlice) if (this->CurrentImageSlice)
{ {
this->CurrentImageSlice->Delete(); this->CurrentImageSlice->Delete();
} }
this->CurrentImageSlice = imageProp; this->CurrentImageSlice = imageProp;
if (this->CurrentImageSlice) if (this->CurrentImageSlice)
{ {
this->CurrentImageSlice->Register(this); this->CurrentImageSlice->Register(this);
} }
} }
} }
if (property != this->CurrentImageProperty) if (property != this->CurrentImageProperty)
{ {
if (this->CurrentImageProperty) if (this->CurrentImageProperty)
{ {
this->CurrentImageProperty->Delete(); this->CurrentImageProperty->Delete();
} }
this->CurrentImageProperty = property; this->CurrentImageProperty = property;
if (this->CurrentImageProperty) if (this->CurrentImageProperty)
{ {
this->CurrentImageProperty->Register(this); this->CurrentImageProperty->Register(this);
} }
} }
} }
void ActorDraggableInteractorStyle::EndDolly() { void ActorDraggableInteractorStyle::EndDolly() {
if (this->State != VTKIS_DOLLY) if (this->State != VTKIS_DOLLY)
{ {
return; return;
} }
this->StopState(); this->StopState();
if (this->CurrentRenderer == nullptr) if (this->CurrentRenderer == nullptr)
{ {
return; return;
} }
//激发缩放完成事件 //激发缩放完成事件
if (this->HandleObservers) { if (this->HandleObservers) {
vtkCamera *camera = this->CurrentRenderer->GetActiveCamera(); vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
double result[2] = {0.0, 0.0}; double result[2] = { 0.0, 0.0 };
//image 必然是ParallelProjection //image 必然是ParallelProjection
result[0] = this->DollyStartScale; result[0] = this->DollyStartScale;
result[1] = camera->GetParallelScale(); result[1] = camera->GetParallelScale();
this->InvokeEvent(DraggableStyleEvents::EndDollyEvent, result); this->InvokeEvent(DraggableStyleEvents::EndDollyEvent, result);
} }
} }
void ActorDraggableInteractorStyle::StartPan() { void ActorDraggableInteractorStyle::StartPan() {
vtkInteractorStyle::StartPan(); vtkInteractorStyle::StartPan();
vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
camera->GetFocalPoint(PanStartOrigin); camera->GetFocalPoint(PanStartOrigin);
} }
void ActorDraggableInteractorStyle::EndPan() { void ActorDraggableInteractorStyle::EndPan() {
if (this->State != VTKIS_PAN) return; if (this->State != VTKIS_PAN) return;
if (this->HandleObservers) { if (this->HandleObservers) {
vtkCamera *camera = this->CurrentRenderer->GetActiveCamera(); vtkCamera* camera = this->CurrentRenderer->GetActiveCamera();
double *nf = camera->GetFocalPoint(); double* nf = camera->GetFocalPoint();
double calldata[6] = {PanStartOrigin[0], PanStartOrigin[1], PanStartOrigin[2], nf[0], nf[1], nf[2]}; double calldata[6] = { PanStartOrigin[0], PanStartOrigin[1], PanStartOrigin[2], nf[0], nf[1], nf[2] };
this->InvokeEvent(vtkCommand::EventIds::EndPanEvent, calldata); this->InvokeEvent(vtkCommand::EventIds::EndPanEvent, calldata);
} }
this->StopState(); this->StopState();
} }
void ActorDraggableInteractorStyle::EndWindowLevel() { void ActorDraggableInteractorStyle::EndWindowLevel() {
if (this->State != VTKIS_WINDOW_LEVEL) { if (this->State != VTKIS_WINDOW_LEVEL) {
return; return;
} }
if (this->HandleObservers) { if (this->HandleObservers) {
double calldata[2] = {this->CurrentImageProperty->GetColorWindow(),this->CurrentImageProperty->GetColorLevel()}; double calldata[2] = { this->CurrentImageProperty->GetColorWindow(),this->CurrentImageProperty->GetColorLevel() };
this->InvokeEvent(vtkCommand::EndWindowLevelEvent, calldata); this->InvokeEvent(vtkCommand::EndWindowLevelEvent, calldata);
} }
this->StopState(); this->StopState();
} }
void ActorDraggableInteractorStyle::OnChar() { void ActorDraggableInteractorStyle::OnChar() {
vtkInteractorStyleImage::OnChar(); vtkInteractorStyleImage::OnChar();
vtkRenderWindowInteractor* rwi = this->Interactor; vtkRenderWindowInteractor* rwi = this->Interactor;
std::string keySym = rwi->GetKeySym(); std::string keySym = rwi->GetKeySym();
if (keySym=="Delete") if (keySym == "Delete")
{ {
if (selectedProp) if (selectedProp)
{ {
this->InvokeEvent(DraggableStyleEvents::DeleteMeasureEvent,selectedProp); this->InvokeEvent(DraggableStyleEvents::DeleteMeasureEvent, selectedProp);
} }
} }
} }

View File

@@ -684,6 +684,9 @@ void DicomImageView::Render()
void DicomImageView::CopyFromSeries(SeriesImageSet *series) void DicomImageView::CopyFromSeries(SeriesImageSet *series)
{ {
if (_Series){
delete _Series;
}
_Series = series; _Series = series;
_ImageViewer->SetInputData(_Series->GetData()); _ImageViewer->SetInputData(_Series->GetData());
@@ -804,16 +807,14 @@ void DicomImageView::ResetView()
removeViewWithFusion(); removeViewWithFusion();
removeViewWithMeasure(); removeViewWithMeasure();
orphanizeSeriesInstance(); orphanizeSeriesInstance();
//_glWidt->update(); //_glWidt->update();
//_scrollBar = nullptr; //_scrollBar = nullptr;
_ImageViewer->Delete(); _ImageViewer->Delete();
_ImageViewer = nullptr; _ImageViewer = nullptr;
int count = _Series->GetData()->GetReferenceCount();
qDebug()<<count;
_Series = nullptr; _Series = nullptr;
_ScrollTriggerType = scrollScope::TriggerType::USER_TRIGGER; _ScrollTriggerType = scrollScope::TriggerType::USER_TRIGGER;

View File

@@ -407,13 +407,6 @@ void ViewContainerWidget::Slot_ThumbnailClickEvent(thumbnailImage* tb)
return; return;
} }
SeriesInfo_t* serie_info = tb->getSeriesInfo(); SeriesInfo_t* serie_info = tb->getSeriesInfo();
SeriesImageSet* old = nullptr;
bool copy = true;
if (view->HasSeries())
{
old = view->getSeriesInstance();
}
replaceViewWithSerie(serie_info->unique_info, view); replaceViewWithSerie(serie_info->unique_info, view);
setCurrentView(view); setCurrentView(view);
} }