diff --git a/src/include/base/DicomLoader.h b/src/include/base/DicomLoader.h index 6586d17..a6af540 100644 --- a/src/include/base/DicomLoader.h +++ b/src/include/base/DicomLoader.h @@ -19,6 +19,7 @@ class SeriesImageSet; class DICOMDirectoryHelper; class ExtendMedicalImageProperties; class vtkDICOMImageReader2; +typedef std::map ImageSetStore; class DicomLoader { 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); SeriesImageSet* getFirstInstance(const UniqueIDInfo &uniqueID); @@ -84,7 +85,7 @@ private: ExtendMedicalImageProperties * currentImageProperty = nullptr; std::vector imageProperties; vtkDICOMImageReader2 * reader = nullptr; - + ImageSetStore store; AddDicomType m_addType; PatientsMapType m_patients; vtkObject* placeHolder; diff --git a/src/include/view/viewcontainerwidget.h b/src/include/view/viewcontainerwidget.h index dfb1853..576cece 100644 --- a/src/include/view/viewcontainerwidget.h +++ b/src/include/view/viewcontainerwidget.h @@ -46,6 +46,11 @@ public slots: void Slot_ViewClicked(DicomImageView *view); void Slot_ViewDoubleClicked(DicomImageView *view); void Slot_DragDropEvent(DicomImageView *view, thumbnailImage* tb); + /** + * 缩略图点击槽函数,会导致当前选中的view重新load数据 + * @param tb 缩略图对象 + * @return + */ void Slot_ThumbnailClickEvent(thumbnailImage* tb); void Slot_SyncEvent(DicomImageView *view, int interactionMode, void* calldata); diff --git a/src/src/base/DicomLoader.cpp b/src/src/base/DicomLoader.cpp index 3ae4f0e..9d86386 100644 --- a/src/src/base/DicomLoader.cpp +++ b/src/src/base/DicomLoader.cpp @@ -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(); reader = vtkDICOMImageReader2::New(); reader->SetFileNames(*(currentImageProperty->GetFileNames())); @@ -163,6 +170,7 @@ SeriesImageSet* DicomLoader::InitFromRead(const UniqueIDInfo &uniqueID)//, Dicom SeriesImageSet* result = new SeriesImageSet(uniqueID,currentImageProperty,reader->GetOutput()); reader->Delete(); reader = nullptr; + store[key] = result; return result; } @@ -398,7 +406,7 @@ DicomTagInfo_t* DicomLoader::createDicomTagsInfo() SeriesImageSet* DicomLoader::createSeries(UniqueIDInfo_t* uniqueID) { - SeriesImageSet* series =instance->InitFromRead(*uniqueID); + SeriesImageSet* series = instance->getSeriesImageSet(*uniqueID); series->setUpSeriesInstance(); return series; diff --git a/src/src/base/infinitiViewer.cxx b/src/src/base/infinitiViewer.cxx index 9138809..e9a10af 100644 --- a/src/src/base/infinitiViewer.cxx +++ b/src/src/base/infinitiViewer.cxx @@ -355,6 +355,7 @@ infinitiViewer::~infinitiViewer() { if (this->ImageMapper) { + this->ImageMapper->SetInputData(nullptr); this->ImageMapper->Delete(); this->ImageMapper = nullptr; } @@ -363,6 +364,7 @@ infinitiViewer::~infinitiViewer() this->ImageActor->Delete(); this->ImageActor = nullptr; } + if (this->FusionMapper) { this->FusionMapper->Delete(); @@ -394,9 +396,14 @@ infinitiViewer::~infinitiViewer() if (this->InteractorStyle) { + this->InteractorStyle->SetCornerAnnotation(nullptr); this->InteractorStyle->Delete(); this->InteractorStyle = nullptr; } + if (this->cornerAnnotation) { + this->cornerAnnotation->Delete(); + this->cornerAnnotation = nullptr; + } measureStore->RemoveAllInSeries(SOP_UID); // measureStore->Clear(); //delete measureStore; @@ -1202,15 +1209,15 @@ void infinitiViewer::initTopLeftCornerInfo(const std::string& lbl_ser_num, const void infinitiViewer::initCornerInfo(ExtendMedicalImageProperties* pSeries) { - if(pSeries->GetNumberOfWindowLevelPresets()>0) - { - double * wwwl = pSeries->GetNthWindowLevelPreset(0); - m_cornerInfo.win_level = (int)wwwl[1]; - m_cornerInfo.win_width = (int)wwwl[0]; - } + if (pSeries->GetNumberOfWindowLevelPresets() > 0) + { + double* wwwl = pSeries->GetNthWindowLevelPreset(0); + m_cornerInfo.win_level = (int)wwwl[1]; + m_cornerInfo.win_width = (int)wwwl[0]; + } - char buffer [sizeof(long)*8+1]; - const char* s = ltoa(pSeries->GetFileNames()->size(), buffer, 10); + char buffer[sizeof(long) * 8 + 1]; + const char* s = ltoa(pSeries->GetFileNames()->size(), buffer, 10); m_cornerInfo.ConstAnno[TOP_LEFT].append(buffer); m_cornerInfo.ConstAnno[TOP_LEFT].append(" "); m_cornerInfo.ConstAnno[TOP_LEFT].append(pSeries->GetSeriesNumber()); @@ -1339,10 +1346,10 @@ void infinitiViewer::setUpImageViewer() } void infinitiViewer::ActiveRuler() { - rulerActive = true; + rulerActive = true; } void infinitiViewer::UnActiveRuler() { - rulerActive = false; + rulerActive = false; } diff --git a/src/src/measure/ActorDraggableInteractorStyle.cpp b/src/src/measure/ActorDraggableInteractorStyle.cpp index bc63b9c..41893b4 100644 --- a/src/src/measure/ActorDraggableInteractorStyle.cpp +++ b/src/src/measure/ActorDraggableInteractorStyle.cpp @@ -29,72 +29,78 @@ #include "QGlobals.h" vtkStandardNewMacro(ActorDraggableInteractorStyle); ActorDraggableInteractorStyle::ActorDraggableInteractorStyle() { - this->AddObserver(vtkCommand::InteractionEvent,this,&ActorDraggableInteractorStyle::DispatchEvent); + this->AddObserver(vtkCommand::InteractionEvent, this, &ActorDraggableInteractorStyle::DispatchEvent); #ifdef _DEBUG - this->AddObserver(DraggableStyleEvents::EndDollyEvent, this, &ActorDraggableInteractorStyle::TestOutPut); - this->AddObserver(vtkCommand::EventIds::EndPanEvent, this, &ActorDraggableInteractorStyle::TestOutPut); - this->AddObserver(vtkCommand::EventIds::EndRotateEvent, this, &ActorDraggableInteractorStyle::TestOutPut); - this->AddObserver(vtkCommand::EventIds::EndWindowLevelEvent, this, &ActorDraggableInteractorStyle::TestOutPut); - this->AddObserver(DraggableStyleEvents::SlicedEvent, this, &ActorDraggableInteractorStyle::TestOutPut); + this->AddObserver(DraggableStyleEvents::EndDollyEvent, this, &ActorDraggableInteractorStyle::TestOutPut); + this->AddObserver(vtkCommand::EventIds::EndPanEvent, this, &ActorDraggableInteractorStyle::TestOutPut); + this->AddObserver(vtkCommand::EventIds::EndRotateEvent, this, &ActorDraggableInteractorStyle::TestOutPut); + this->AddObserver(vtkCommand::EventIds::EndWindowLevelEvent, this, &ActorDraggableInteractorStyle::TestOutPut); + this->AddObserver(DraggableStyleEvents::SlicedEvent, this, &ActorDraggableInteractorStyle::TestOutPut); #endif } ActorDraggableInteractorStyle::~ActorDraggableInteractorStyle() { - + if (scalarProp) { + scalarProp->Delete(); + scalarProp = nullptr; + } + if (CornerAnnotation) { + CornerAnnotation->UnRegister(this); + } } template void vtkValueMessageTemplate(vtkImageData* image, int* position, std::string& message) { - T* tuple = ((T*)image->GetScalarPointer(position)); - if (!tuple) - { - return; - } - int components = image->GetNumberOfScalarComponents(); - for (int c = 0; c < components; ++c) - { - message += vtkVariant(tuple[c]).ToString(); - if (c != (components - 1)) - { - message += ", "; - } - } - //message += " )"; + T* tuple = ((T*)image->GetScalarPointer(position)); + if (!tuple) + { + return; + } + int components = image->GetNumberOfScalarComponents(); + for (int c = 0; c < components; ++c) + { + message += vtkVariant(tuple[c]).ToString(); + if (c != (components - 1)) + { + message += ", "; + } + } + //message += " )"; } void ActorDraggableInteractorStyle::OnLeftButtonUp() { - switch (this->State) { - case VTKIS_DRAG: - DraggableActor::SafeDownCast(dragProp)->ApplyTransform(); - this->EndDrag(); - break; - case VTKIS_MEASURE: - measure->SetPlacing(measure->onMeasureLeftButtonUp(this->Interactor)); - if (!measure->isMeasurePlacing()) { - this->EndMeasure(); - auto temp = measure; - measure = measure->GetNextMeasure(); - if (!temp->Valid()){ - temp->ForceDelete(); - temp= nullptr; - } - } - break; - case VTKIS_COLORMAP: - this->EndColorMapping(); - break; - } - vtkInteractorStyleImage::OnLeftButtonUp(); + switch (this->State) { + case VTKIS_DRAG: + DraggableActor::SafeDownCast(dragProp)->ApplyTransform(); + this->EndDrag(); + break; + case VTKIS_MEASURE: + measure->SetPlacing(measure->onMeasureLeftButtonUp(this->Interactor)); + if (!measure->isMeasurePlacing()) { + this->EndMeasure(); + auto temp = measure; + measure = measure->GetNextMeasure(); + if (!temp->Valid()) { + temp->ForceDelete(); + temp = nullptr; + } + } + break; + case VTKIS_COLORMAP: + this->EndColorMapping(); + break; + } + vtkInteractorStyleImage::OnLeftButtonUp(); } -void ActorDraggableInteractorStyle::ColorMapping() +void ActorDraggableInteractorStyle::ColorMapping() { - vtkRenderWindowInteractor *rwi = this->Interactor; + vtkRenderWindowInteractor* rwi = this->Interactor; this->ScalarCurrentPosition[1] = rwi->GetEventPosition()[1]; //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; //printf("ColorMapping:%d,%d,%.2f \r\n", ScalarCurrentPosition[1], ScalarStartPosition[1],left); if (abs(left) >= 0.01) { @@ -120,15 +126,15 @@ void ActorDraggableInteractorStyle::EndColorMapping() void ActorDraggableInteractorStyle::Drag() { - int* pos = this->Interactor->GetEventPosition(); - this->FindPokedRenderer(pos[0],pos[1]); - DraggableActor::SafeDownCast(dragProp)->Transform(pos[0] - DragStartOrigin[0], pos[1] - DragStartOrigin[1]); - this->Interactor->Render(); + int* pos = this->Interactor->GetEventPosition(); + this->FindPokedRenderer(pos[0], pos[1]); + DraggableActor::SafeDownCast(dragProp)->Transform(pos[0] - DragStartOrigin[0], pos[1] - DragStartOrigin[1]); + this->Interactor->Render(); } void ActorDraggableInteractorStyle::MeasurePlace() { - measure->onMeasureMouseMove(this->Interactor); + measure->onMeasureMouseMove(this->Interactor); } void ActorDraggableInteractorStyle::NoneStatePick() { @@ -141,7 +147,7 @@ void ActorDraggableInteractorStyle::NoneStatePick() { if (result) { - vtkProp* obj = picker->GetViewProp(); + vtkProp* obj = picker->GetViewProp(); if (scalarProp != obj && scalarProp) { scalarProp = nullptr; } @@ -205,11 +211,11 @@ void ActorDraggableInteractorStyle::NoneStatePick() { scalarProp = nullptr; } dragProp = nullptr; - this->CornerAnnotation->SetText(BOTTOM_LEFT, ""); + if (this->CornerAnnotation)this->CornerAnnotation->SetText(BOTTOM_LEFT, ""); } } - this->CornerAnnotation->SetText(BOTTOM_LEFT, ""); - this->Interactor->Render(); + if (this->CornerAnnotation)this->CornerAnnotation->SetText(BOTTOM_LEFT, ""); + this->Interactor->Render(); } @@ -218,33 +224,33 @@ void ActorDraggableInteractorStyle::OnMouseMove() { int x = this->Interactor->GetEventPosition()[0]; int y = this->Interactor->GetEventPosition()[1]; - switch (this->State) { - case VTKIS_MEASURE: - MeasurePlace(); - //照抄源码,不是很清楚这句话的作用,可能有加速处理用户输入事件的作用(连续InteractionEvent处理连续操作,避免外部判断) - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); - break; - case VTKIS_DRAG: - Drag(); - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); - break; - case VTKIS_NONE: - NoneStatePick(); - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); - break; - case VTKIS_COLORMAP: - this->FindPokedRenderer(x, y); - this->ColorMapping(); - this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); - break; + switch (this->State) { + case VTKIS_MEASURE: + MeasurePlace(); + //照抄源码,不是很清楚这句话的作用,可能有加速处理用户输入事件的作用(连续InteractionEvent处理连续操作,避免外部判断) + this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); + break; + case VTKIS_DRAG: + Drag(); + this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); + break; + case VTKIS_NONE: + NoneStatePick(); + this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); + break; + case VTKIS_COLORMAP: + this->FindPokedRenderer(x, y); + this->ColorMapping(); + this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); + break; - } - vtkInteractorStyleImage::OnMouseMove(); + } + vtkInteractorStyleImage::OnMouseMove(); } void ActorDraggableInteractorStyle::WindowLevel() { - vtkRenderWindowInteractor *rwi = this->Interactor; + vtkRenderWindowInteractor* rwi = this->Interactor; this->WindowLevelCurrentPosition[0] = rwi->GetEventPosition()[0]; this->WindowLevelCurrentPosition[1] = rwi->GetEventPosition()[1]; @@ -256,7 +262,7 @@ void ActorDraggableInteractorStyle::WindowLevel() } if (this->CurrentImageProperty) { - int *size = this->CurrentRenderer->GetSize(); + int* size = this->CurrentRenderer->GetSize(); double window = this->WindowLevelInitial[0]; double level = this->WindowLevelInitial[1]; @@ -315,7 +321,7 @@ void ActorDraggableInteractorStyle::WindowLevel() } } -void ActorDraggableInteractorStyle::OnRightButtonDown() +void ActorDraggableInteractorStyle::OnRightButtonDown() { int x = this->Interactor->GetEventPosition()[0]; int y = this->Interactor->GetEventPosition()[1]; @@ -332,58 +338,58 @@ void ActorDraggableInteractorStyle::OnRightButtonDown() } } void ActorDraggableInteractorStyle::OnLeftButtonDown() { - int x = this->Interactor->GetEventPosition()[0]; - int y = this->Interactor->GetEventPosition()[1]; + int x = this->Interactor->GetEventPosition()[0]; + int y = this->Interactor->GetEventPosition()[1]; - this->FindPokedRenderer(x, y); - if (this->CurrentRenderer == nullptr) - { - return; - } - // Redefine this button to handle window/level - this->GrabFocus(this->EventCallbackCommand); + this->FindPokedRenderer(x, y); + if (this->CurrentRenderer == nullptr) + { + return; + } + // Redefine this button to handle window/level + this->GrabFocus(this->EventCallbackCommand); if (selectedProp) { selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::UnSelectedEvent); selectedProp = nullptr; } - if (dragProp){ + if (dragProp) { selectedProp = dragProp; selectedProp->InvokeEvent(DraggableActor::DraggableActorEvents::SelectedEvent); - if (this->Interactor->GetRepeatCount()) + if (this->Interactor->GetRepeatCount()) { dragProp->InvokeEvent(DraggableStyleEvents::PopPropEvent, nullptr); } - DragStartOrigin[0] = x; - DragStartOrigin[1] = y; - this->StartDrag(); - return; - } - if (Interactor->GetRepeatCount()){ - if (measure) - { - measure->SetPlacing(measure->onMeasureDoubleClick(this->Interactor)); - if (!measure->isMeasurePlacing()) { - this->EndMeasure(); - auto temp = measure; - measure = measure->GetNextMeasure(); - if (!temp->Valid()){ - temp->ForceDelete(); - temp= nullptr; - } - } - return; - } - this->InvokeEvent(DraggableStyleEvents::DoubleClickEvent, nullptr); - return; - } - if (measure) - { - measure->SetPlacing(measure->onMeasureLeftButtonDown(this->Interactor)); - if(this->State!=VTKIS_MEASURE) this->StartMeasure(); - return; - } + DragStartOrigin[0] = x; + DragStartOrigin[1] = y; + this->StartDrag(); + return; + } + if (Interactor->GetRepeatCount()) { + if (measure) + { + measure->SetPlacing(measure->onMeasureDoubleClick(this->Interactor)); + if (!measure->isMeasurePlacing()) { + this->EndMeasure(); + auto temp = measure; + measure = measure->GetNextMeasure(); + if (!temp->Valid()) { + temp->ForceDelete(); + temp = nullptr; + } + } + return; + } + this->InvokeEvent(DraggableStyleEvents::DoubleClickEvent, nullptr); + return; + } + if (measure) + { + measure->SetPlacing(measure->onMeasureLeftButtonDown(this->Interactor)); + if (this->State != VTKIS_MEASURE) this->StartMeasure(); + return; + } - if (scalarProp) + if (scalarProp) { ScalarStartPosition[0] = x; ScalarStartPosition[1] = y; @@ -392,207 +398,207 @@ void ActorDraggableInteractorStyle::OnLeftButtonDown() { } - if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL) - { - this->WindowLevelStartPosition[0] = x; - this->WindowLevelStartPosition[1] = y; - this->StartWindowLevel(); - } - else if (this->InteractionMode == VTKIS_IMAGE_ZOOM) - { - this->DollyStartScale = this->CurrentRenderer->GetActiveCamera()->GetParallelScale(); - this->StartDolly(); - } - else if (this->InteractionMode == VTKIS_IMAGE_PAN) - { - this->StartPan(); - } - else if (this->InteractionMode == VTKIS_IMAGE_SLICING) - { - this->StartSlice(); - } + if (this->InteractionMode == VTKIS_IMAGE_WINDOWLEVEL) + { + this->WindowLevelStartPosition[0] = x; + this->WindowLevelStartPosition[1] = y; + this->StartWindowLevel(); + } + else if (this->InteractionMode == VTKIS_IMAGE_ZOOM) + { + this->DollyStartScale = this->CurrentRenderer->GetActiveCamera()->GetParallelScale(); + this->StartDolly(); + } + else if (this->InteractionMode == VTKIS_IMAGE_PAN) + { + this->StartPan(); + } + else if (this->InteractionMode == VTKIS_IMAGE_SLICING) + { + this->StartSlice(); + } } -void ActorDraggableInteractorStyle::ActiveMeasure(Measure *m) { - if (this->measure && nullptr == m) { - this->measure->onTerminate(this->Interactor); - } - this->measure = m; +void ActorDraggableInteractorStyle::ActiveMeasure(Measure* m) { + if (this->measure && nullptr == m) { + this->measure->onTerminate(this->Interactor); + } + this->measure = m; } void ActorDraggableInteractorStyle::UnActiveMeasure() { - if (this->measure) { - this->measure->onTerminate(this->Interactor); - } - this->EndMeasure(); - this->measure = nullptr; + if (this->measure) { + this->measure->onTerminate(this->Interactor); + } + this->EndMeasure(); + this->measure = nullptr; } void ActorDraggableInteractorStyle::DispatchEvent() { - switch (this->State) { - case VTKIS_SLICE: + switch (this->State) { + case VTKIS_SLICE: - if (this->HandleObservers) { - //double check - if (!this->CurrentImageSlice) { - this->SetCurrentImageNumber(this->CurrentImageNumber); - } - if (!this->CurrentImageSlice) return; - vtkImageSliceMapper *mapper = vtkImageSliceMapper::SafeDownCast(this->CurrentImageSlice->GetMapper()); - int slice[1] = {mapper ? mapper->GetSliceNumber() : -1}; - //鼠标滑动不一定能造成翻页!!!所以需要进行一次判定 - if (slice[0] != lastslice) { - this->InvokeEvent(DraggableStyleEvents::SlicedEvent, slice); - lastslice = slice[0]; - } - break; - } - } + if (this->HandleObservers) { + //double check + if (!this->CurrentImageSlice) { + this->SetCurrentImageNumber(this->CurrentImageNumber); + } + if (!this->CurrentImageSlice) return; + vtkImageSliceMapper* mapper = vtkImageSliceMapper::SafeDownCast(this->CurrentImageSlice->GetMapper()); + int slice[1] = { mapper ? mapper->GetSliceNumber() : -1 }; + //鼠标滑动不一定能造成翻页!!!所以需要进行一次判定 + if (slice[0] != lastslice) { + this->InvokeEvent(DraggableStyleEvents::SlicedEvent, slice); + lastslice = slice[0]; + } + break; + } + } } //重写部分逻辑,在取imageProperty的时候把ImageSlice也取了。 void ActorDraggableInteractorStyle::SetCurrentImageNumber(int i) { - this->CurrentImageNumber = i; - if (!this->CurrentRenderer) - { - return; - } - vtkPropCollection* props = this->CurrentRenderer->GetViewProps(); - vtkProp* prop = nullptr; - vtkAssemblyPath* path; - vtkImageSlice* imageProp = nullptr; - vtkCollectionSimpleIterator pit; + this->CurrentImageNumber = i; + if (!this->CurrentRenderer) + { + return; + } + vtkPropCollection* props = this->CurrentRenderer->GetViewProps(); + vtkProp* prop = nullptr; + vtkAssemblyPath* path; + vtkImageSlice* imageProp = nullptr; + vtkCollectionSimpleIterator pit; - for (int k = 0; k < 2; k++) - { - int j = 0; - for (props->InitTraversal(pit); (prop = props->GetNextProp(pit));) - { - bool foundImageProp = false; - for (prop->InitPathTraversal(); (path = prop->GetNextPath());) - { - vtkProp* tryProp = path->GetLastNode()->GetViewProp(); - imageProp = vtkImageSlice::SafeDownCast(tryProp); - if (imageProp) - { - if (j == i && imageProp->GetPickable()) - { - foundImageProp = true; - break; - } - imageProp = nullptr; - j++; - } - } - if (foundImageProp) - { - break; - } - } - if (i < 0) - { - i += j; - } - } + for (int k = 0; k < 2; k++) + { + int j = 0; + for (props->InitTraversal(pit); (prop = props->GetNextProp(pit));) + { + bool foundImageProp = false; + for (prop->InitPathTraversal(); (path = prop->GetNextPath());) + { + vtkProp* tryProp = path->GetLastNode()->GetViewProp(); + imageProp = vtkImageSlice::SafeDownCast(tryProp); + if (imageProp) + { + if (j == i && imageProp->GetPickable()) + { + foundImageProp = true; + break; + } + imageProp = nullptr; + j++; + } + } + if (foundImageProp) + { + break; + } + } + if (i < 0) + { + i += j; + } + } - vtkImageProperty* property = nullptr; - if (imageProp) - { - property = imageProp->GetProperty(); - if (imageProp != this->CurrentImageSlice) - { - if (this->CurrentImageSlice) - { - this->CurrentImageSlice->Delete(); - } + vtkImageProperty* property = nullptr; + if (imageProp) + { + property = imageProp->GetProperty(); + if (imageProp != this->CurrentImageSlice) + { + if (this->CurrentImageSlice) + { + this->CurrentImageSlice->Delete(); + } - this->CurrentImageSlice = imageProp; + this->CurrentImageSlice = imageProp; - if (this->CurrentImageSlice) - { - this->CurrentImageSlice->Register(this); - } - } - } + if (this->CurrentImageSlice) + { + this->CurrentImageSlice->Register(this); + } + } + } - if (property != this->CurrentImageProperty) - { - if (this->CurrentImageProperty) - { - this->CurrentImageProperty->Delete(); - } + if (property != this->CurrentImageProperty) + { + if (this->CurrentImageProperty) + { + this->CurrentImageProperty->Delete(); + } - this->CurrentImageProperty = property; + this->CurrentImageProperty = property; - if (this->CurrentImageProperty) - { - this->CurrentImageProperty->Register(this); - } - } + if (this->CurrentImageProperty) + { + this->CurrentImageProperty->Register(this); + } + } } void ActorDraggableInteractorStyle::EndDolly() { - if (this->State != VTKIS_DOLLY) - { - return; - } - this->StopState(); - if (this->CurrentRenderer == nullptr) - { - return; - } - //激发缩放完成事件 - if (this->HandleObservers) { - vtkCamera *camera = this->CurrentRenderer->GetActiveCamera(); - double result[2] = {0.0, 0.0}; - //image 必然是ParallelProjection - result[0] = this->DollyStartScale; - result[1] = camera->GetParallelScale(); - this->InvokeEvent(DraggableStyleEvents::EndDollyEvent, result); - } + if (this->State != VTKIS_DOLLY) + { + return; + } + this->StopState(); + if (this->CurrentRenderer == nullptr) + { + return; + } + //激发缩放完成事件 + if (this->HandleObservers) { + vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); + double result[2] = { 0.0, 0.0 }; + //image 必然是ParallelProjection + result[0] = this->DollyStartScale; + result[1] = camera->GetParallelScale(); + this->InvokeEvent(DraggableStyleEvents::EndDollyEvent, result); + } } void ActorDraggableInteractorStyle::StartPan() { - vtkInteractorStyle::StartPan(); - vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); - camera->GetFocalPoint(PanStartOrigin); + vtkInteractorStyle::StartPan(); + vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); + camera->GetFocalPoint(PanStartOrigin); } void ActorDraggableInteractorStyle::EndPan() { - if (this->State != VTKIS_PAN) return; - if (this->HandleObservers) { - vtkCamera *camera = this->CurrentRenderer->GetActiveCamera(); - double *nf = camera->GetFocalPoint(); - double calldata[6] = {PanStartOrigin[0], PanStartOrigin[1], PanStartOrigin[2], nf[0], nf[1], nf[2]}; - this->InvokeEvent(vtkCommand::EventIds::EndPanEvent, calldata); - } - this->StopState(); + if (this->State != VTKIS_PAN) return; + if (this->HandleObservers) { + vtkCamera* camera = this->CurrentRenderer->GetActiveCamera(); + double* nf = camera->GetFocalPoint(); + double calldata[6] = { PanStartOrigin[0], PanStartOrigin[1], PanStartOrigin[2], nf[0], nf[1], nf[2] }; + this->InvokeEvent(vtkCommand::EventIds::EndPanEvent, calldata); + } + this->StopState(); } void ActorDraggableInteractorStyle::EndWindowLevel() { - if (this->State != VTKIS_WINDOW_LEVEL) { - return; - } - if (this->HandleObservers) { - double calldata[2] = {this->CurrentImageProperty->GetColorWindow(),this->CurrentImageProperty->GetColorLevel()}; - this->InvokeEvent(vtkCommand::EndWindowLevelEvent, calldata); - } - this->StopState(); + if (this->State != VTKIS_WINDOW_LEVEL) { + return; + } + if (this->HandleObservers) { + double calldata[2] = { this->CurrentImageProperty->GetColorWindow(),this->CurrentImageProperty->GetColorLevel() }; + this->InvokeEvent(vtkCommand::EndWindowLevelEvent, calldata); + } + this->StopState(); } void ActorDraggableInteractorStyle::OnChar() { - vtkInteractorStyleImage::OnChar(); - vtkRenderWindowInteractor* rwi = this->Interactor; + vtkInteractorStyleImage::OnChar(); + vtkRenderWindowInteractor* rwi = this->Interactor; std::string keySym = rwi->GetKeySym(); - if (keySym=="Delete") - { - if (selectedProp) - { - this->InvokeEvent(DraggableStyleEvents::DeleteMeasureEvent,selectedProp); - } - } + if (keySym == "Delete") + { + if (selectedProp) + { + this->InvokeEvent(DraggableStyleEvents::DeleteMeasureEvent, selectedProp); + } + } } diff --git a/src/src/view/dicomimageview.cpp b/src/src/view/dicomimageview.cpp index 4b7c7c9..f2c4bb6 100644 --- a/src/src/view/dicomimageview.cpp +++ b/src/src/view/dicomimageview.cpp @@ -684,6 +684,9 @@ void DicomImageView::Render() void DicomImageView::CopyFromSeries(SeriesImageSet *series) { + if (_Series){ + delete _Series; + } _Series = series; _ImageViewer->SetInputData(_Series->GetData()); @@ -804,16 +807,14 @@ void DicomImageView::ResetView() removeViewWithFusion(); removeViewWithMeasure(); - - - - orphanizeSeriesInstance(); //_glWidt->update(); //_scrollBar = nullptr; _ImageViewer->Delete(); _ImageViewer = nullptr; + int count = _Series->GetData()->GetReferenceCount(); + qDebug()<getSeriesInfo(); - SeriesImageSet* old = nullptr; - bool copy = true; - - if (view->HasSeries()) - { - old = view->getSeriesInstance(); - } replaceViewWithSerie(serie_info->unique_info, view); setCurrentView(view); }