From dea967fd888b667f5924a7b1de1ad2e84ad00646 Mon Sep 17 00:00:00 2001 From: Krad Date: Tue, 8 Nov 2022 14:18:06 +0800 Subject: [PATCH] Move VTKIS_ MODE to Define header ,move DraggableStyleEvents to Define header. --- src/src/Events/EventsCenter.h | 1 - .../ActorDraggableInteractorStyle.h | 27 +------------ src/src/Interaction/VolumeInteractorStyle.cpp | 24 +++++------ src/src/Interaction/VolumeInteractorStyle.h | 9 +---- src/src/Rendering/Core/RenderingDefines.h | 40 +++++++++++++++++++ .../Measure/RulerAnnotationActor.cpp | 2 +- .../Rendering/Measure/TextAnnotationActor.cpp | 2 +- src/src/Rendering/Viewer/DICOMImageViewer.cxx | 12 +++--- .../UI/Widget/ImageView/dicomimageview.cpp | 16 ++++---- .../Widget/ToolBar/VolumeRenderingToolBar.cpp | 2 +- 10 files changed, 71 insertions(+), 64 deletions(-) create mode 100644 src/src/Rendering/Core/RenderingDefines.h diff --git a/src/src/Events/EventsCenter.h b/src/src/Events/EventsCenter.h index b105b85..e8e720a 100644 --- a/src/src/Events/EventsCenter.h +++ b/src/src/Events/EventsCenter.h @@ -12,7 +12,6 @@ #define aLLEventMacro() \ _add_Event(DefaultEvent)\ - _add_Event(DragEvent)\ _add_Event(SyncStateChanged)\ _add_Event(AnnotationStateChanged)\ _add_Event(AnonymizeStateChanged)\ diff --git a/src/src/Interaction/ActorDraggableInteractorStyle.h b/src/src/Interaction/ActorDraggableInteractorStyle.h index 78f7a85..09f5fff 100644 --- a/src/src/Interaction/ActorDraggableInteractorStyle.h +++ b/src/src/Interaction/ActorDraggableInteractorStyle.h @@ -13,15 +13,7 @@ #include "functional" #include "vtkCornerAnnotation.h" #include "vtkCommand.h" - -#define VTKIS_DRAG 33 -#define VTKIS_MEASURE 36 -#define VTKIS_COLORMAP 37 - -#define VTKIS_IMAGE_PAN 5 -#define VTKIS_IMAGE_ZOOM 6 -#define VTKIS_IMAGE_WINDOWLEVEL 7 - +#include "Rendering/Core/RenderingDefines.h" class vtkProp; @@ -35,22 +27,7 @@ public: vtkTypeMacro(ActorDraggableInteractorStyle, vtkInteractorStyleImage); - enum DraggableStyleEvents { - DragEvent = vtkCommand::UserEvent + 300, - DragEndEvent, - StartMeasureEvent, - EndMeasureEvent, - SliceEvent, - SlicedEvent, - EndDollyEvent, - PopPropEvent, - DoubleClickEvent, - DeleteMeasureEvent, - RightButtonClickEvent, - ScalarOpacityEvent, - ScalarShiftEvent, - AfterViewerClicked - }; + /** * Called when the user moves the mouse diff --git a/src/src/Interaction/VolumeInteractorStyle.cpp b/src/src/Interaction/VolumeInteractorStyle.cpp index 4ea3237..f010078 100644 --- a/src/src/Interaction/VolumeInteractorStyle.cpp +++ b/src/src/Interaction/VolumeInteractorStyle.cpp @@ -39,23 +39,23 @@ void VolumeInteractorStyle::OnLeftButtonDown() { this->GrabFocus(this->EventCallbackCommand); switch(this->InteractionMode) { - case VOLUME_ROTATE3D: { + case VTKIS_VOLUME_ROTATE3D: { this->StartRotate(); break; } - case VOLUME_PAN: { + case VTKIS_VOLUME_PAN: { this->StartPan(); break; } - case VOLUME_ROTATE2D: { + case VTKIS_VOLUME_ROTATE2D: { this->StartSpin(); break; } - case VOLUME_ZOOM: { + case VTKIS_VOLUME_ZOOM: { this->StartDolly(); break; } - case VOLUME_WINDOW: { + case VTKIS_VOLUME_WINDOW: { this->WindowLevelStartPosition[0] = x; this->WindowLevelStartPosition[1] = y; this->StartWindowLevel(); @@ -66,7 +66,7 @@ void VolumeInteractorStyle::OnLeftButtonDown() { void VolumeInteractorStyle::OnLeftButtonUp() { switch (this->State) { - case VTKIS_WINDOW_LEVEL: + case VTKIS_VOLUME_WINDOW: this->EndWindowLevel(); if (this->Interactor) { this->ReleaseFocus(); @@ -81,7 +81,7 @@ void VolumeInteractorStyle::StartWindowLevel() { { return; } - this->StartState(VTKIS_WINDOW_LEVEL); + this->StartState(VTKIS_VOLUME_WINDOW); if (this->HandleObservers && this->HasObserver(vtkCommand::StartWindowLevelEvent)) @@ -101,7 +101,7 @@ void VolumeInteractorStyle::StartWindowLevel() { } void VolumeInteractorStyle::EndWindowLevel() { - if (this->State != VTKIS_WINDOW_LEVEL) + if (this->State != VTKIS_VOLUME_WINDOW) { return; } @@ -115,11 +115,9 @@ void VolumeInteractorStyle::EndWindowLevel() { void VolumeInteractorStyle::OnMouseMove() { int x = this->Interactor->GetEventPosition()[0]; int y = this->Interactor->GetEventPosition()[1]; - - switch (this->State) - { - case VTKIS_WINDOW_LEVEL: - this->FindPokedRenderer(x, y); + switch (this->State) { + case VTKIS_VOLUME_WINDOW: + this->FindPokedRenderer(x,y); this->WindowLevel(); this->InvokeEvent(vtkCommand::InteractionEvent, nullptr); break; diff --git a/src/src/Interaction/VolumeInteractorStyle.h b/src/src/Interaction/VolumeInteractorStyle.h index a444254..30c8f2f 100644 --- a/src/src/Interaction/VolumeInteractorStyle.h +++ b/src/src/Interaction/VolumeInteractorStyle.h @@ -6,14 +6,7 @@ #define OMEGAV_VOLUMEINTERACTORSTYLE_H #include - -#define VOLUME_ROTATE3D 0 -#define VOLUME_ROTATE2D 1 -#define VOLUME_ZOOM 2 -#define VOLUME_PAN 3 -#define VOLUME_WINDOW 4 - -#define VTKIS_WINDOW_LEVEL 1024 +#include "Rendering/Core/RenderingDefines.h" class vtkVolumeProperty; diff --git a/src/src/Rendering/Core/RenderingDefines.h b/src/src/Rendering/Core/RenderingDefines.h new file mode 100644 index 0000000..b403e06 --- /dev/null +++ b/src/src/Rendering/Core/RenderingDefines.h @@ -0,0 +1,40 @@ +// +// Created by Krad on 2022/11/3. +// + +#ifndef OMEGAV_DEFINES_H +#define OMEGAV_DEFINES_H + +#include + +#define VTKIS_DRAG 33 +#define VTKIS_MEASURE 36 +#define VTKIS_COLORMAP 37 +#define VTKIS_IMAGE_PAN 5 +#define VTKIS_IMAGE_ZOOM 6 +#define VTKIS_IMAGE_WINDOWLEVEL 7 +#define VTKIS_VOLUME_ROTATE3D 0 +#define VTKIS_VOLUME_ROTATE2D 1 +#define VTKIS_VOLUME_ZOOM 2 +#define VTKIS_VOLUME_PAN 3 +#define VTKIS_VOLUME_WINDOW 7 + +enum DraggableStyleEvents { + DragEvent = vtkCommand::UserEvent + 1200, + DragEndEvent, + StartMeasureEvent, + EndMeasureEvent, + SliceEvent, + SlicedEvent, + EndDollyEvent, + PopPropEvent, + DoubleClickEvent, + DeleteMeasureEvent, + RightButtonClickEvent, + ScalarOpacityEvent, + ScalarShiftEvent, + AfterViewerClicked +}; + + +#endif //OMEGAV_DEFINES_H diff --git a/src/src/Rendering/Measure/RulerAnnotationActor.cpp b/src/src/Rendering/Measure/RulerAnnotationActor.cpp index 81c5fef..71e284d 100644 --- a/src/src/Rendering/Measure/RulerAnnotationActor.cpp +++ b/src/src/Rendering/Measure/RulerAnnotationActor.cpp @@ -34,7 +34,7 @@ RulerAnnotationActor::RulerAnnotationActor() { //textProperty->SetFrameColor(1.0,0.0,0.0); textProperty->SetBackgroundColor(1.0, 0.0, 0.0); textProperty->SetBackgroundOpacity(0.3); - this->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::RightButtonClickEvent, this, + this->AddObserver(DraggableStyleEvents::RightButtonClickEvent, this, &RulerAnnotationActor::selfCalibCb); } diff --git a/src/src/Rendering/Measure/TextAnnotationActor.cpp b/src/src/Rendering/Measure/TextAnnotationActor.cpp index a396a27..123a255 100644 --- a/src/src/Rendering/Measure/TextAnnotationActor.cpp +++ b/src/src/Rendering/Measure/TextAnnotationActor.cpp @@ -68,7 +68,7 @@ TextAnnotationActor::TextAnnotationActor() { BaseDataPoints->SetPoint(1, 512, 512, 0); renderPoints->SetNumberOfPoints(2); this->AddObserver(DraggableActorEvents::DragEvent, this, &TextAnnotationActor::selfDragCb); - this->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::PopPropEvent, this, + this->AddObserver(DraggableStyleEvents::PopPropEvent, this, &TextAnnotationActor::selfPickCb); text = vtkActor2D::New(); vtkNew textMapper; diff --git a/src/src/Rendering/Viewer/DICOMImageViewer.cxx b/src/src/Rendering/Viewer/DICOMImageViewer.cxx index d9a20bf..90cf2d6 100644 --- a/src/src/Rendering/Viewer/DICOMImageViewer.cxx +++ b/src/src/Rendering/Viewer/DICOMImageViewer.cxx @@ -296,17 +296,17 @@ void DICOMImageViewer::InstallPipeline() { this->InteractorStyle->SetCurrentImageNumber(0); this->InteractorStyle->SetCornerAnnotation(cornerAnnotation); - this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::EndMeasureEvent, + this->InteractorStyle->AddObserver(DraggableStyleEvents::EndMeasureEvent, this, &DICOMImageViewer::AddMeasures); - this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::DeleteMeasureEvent, + this->InteractorStyle->AddObserver(DraggableStyleEvents::DeleteMeasureEvent, this, &DICOMImageViewer::RemoveMeasures); - this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::SliceEvent, this, + this->InteractorStyle->AddObserver(DraggableStyleEvents::SliceEvent, this, &DICOMImageViewer::ChangeSlice); //for convert vtkEvent to Qt signal - this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::SlicedEvent, this, + this->InteractorStyle->AddObserver(DraggableStyleEvents::SlicedEvent, this, &DICOMImageViewer::raiseEvent); - this->InteractorStyle->AddObserver(ActorDraggableInteractorStyle::DraggableStyleEvents::EndDollyEvent, this, + this->InteractorStyle->AddObserver(DraggableStyleEvents::EndDollyEvent, this, &DICOMImageViewer::raiseEvent); this->InteractorStyle->AddObserver(vtkCommand::EventIds::EndWindowLevelEvent, this, &DICOMImageViewer::raiseEvent); @@ -478,7 +478,7 @@ void DICOMImageViewer::SetSlice(int slice) { double focusPoint[5] = {.0, .0, .0 }; GetSlicePoint(focusPoint); double sliceData[5] ={focusPoint[0], focusPoint[1], focusPoint[2], offset, direction}; - InteractorStyle->InvokeEvent(ActorDraggableInteractorStyle::SlicedEvent, sliceData); + InteractorStyle->InvokeEvent(SlicedEvent, sliceData); } } diff --git a/src/src/UI/Widget/ImageView/dicomimageview.cpp b/src/src/UI/Widget/ImageView/dicomimageview.cpp index 722cac4..2ee2dad 100644 --- a/src/src/UI/Widget/ImageView/dicomimageview.cpp +++ b/src/src/UI/Widget/ImageView/dicomimageview.cpp @@ -170,11 +170,11 @@ void DicomImageView::loadSeries(SeriesImageSet *series) { //目前 替换了一部分包括SlicedEvent,EndDollyEvent,EndWindowLevelEvent,EndPanEvent,主要关联到sync ActorDraggableInteractorStyle *style = mImageViewer->GetInteractorStyle(); - style->AddObserver(ActorDraggableInteractorStyle::AfterViewerClicked, this, &DicomImageView::clicked); + style->AddObserver(AfterViewerClicked, this, &DicomImageView::clicked); style->AddObserver(vtkCommand::EventIds::WindowLevelEvent, this, &DicomImageView::windowLevelHandle); - style->AddObserver(ActorDraggableInteractorStyle::DoubleClickEvent, this, &DicomImageView::doubleClickHandle); - style->AddObserver(ActorDraggableInteractorStyle::ScalarOpacityEvent, this, &DicomImageView::scalarEventHandle); - style->AddObserver(ActorDraggableInteractorStyle::ScalarShiftEvent, this, &DicomImageView::scalarEventHandle); + style->AddObserver(DoubleClickEvent, this, &DicomImageView::doubleClickHandle); + style->AddObserver(ScalarOpacityEvent, this, &DicomImageView::scalarEventHandle); + style->AddObserver(ScalarShiftEvent, this, &DicomImageView::scalarEventHandle); } initScrollbar(); @@ -410,12 +410,12 @@ void DicomImageView::windowLevelHandle() { void DicomImageView::scalarEventHandle(vtkObject *, unsigned long eventId, void *calldata) { double *r = (double *) calldata; switch (eventId) { - case (ActorDraggableInteractorStyle::ScalarShiftEvent): + case (ScalarShiftEvent): qDebug() << "ScalarShiftEvent"; mImageViewer->SwitchToNextPreset(); break; - case (ActorDraggableInteractorStyle::ScalarOpacityEvent): + case (ScalarOpacityEvent): qDebug() << "ScalarOpacityEvent" << r[0]; setFusionOpacity(r[0]); break; @@ -444,11 +444,11 @@ void DicomImageView::dispatchEvent(vtkObject *, unsigned long eid, void *callDat mImageViewer->GetColorWindow()); break; } - case (ActorDraggableInteractorStyle::DraggableStyleEvents::EndDollyEvent):{ + case (DraggableStyleEvents::EndDollyEvent):{ emit onEndZoom(this, (double *) callData); break; } - case (ActorDraggableInteractorStyle::DraggableStyleEvents::SlicedEvent): { + case (DraggableStyleEvents::SlicedEvent): { mScrollBar->SetValueSilently(mImageViewer->GetSlice()); //invoke event emit onSlice(this, callData); diff --git a/src/src/UI/Widget/ToolBar/VolumeRenderingToolBar.cpp b/src/src/UI/Widget/ToolBar/VolumeRenderingToolBar.cpp index 1b98a7e..ef6b8d5 100644 --- a/src/src/UI/Widget/ToolBar/VolumeRenderingToolBar.cpp +++ b/src/src/UI/Widget/ToolBar/VolumeRenderingToolBar.cpp @@ -70,7 +70,7 @@ VolumeRenderingToolBar::VolumeRenderingToolBar(QWidget *parent) : QToolBar(paren group->addButton(btnRotate,1); group->addButton(btnZoom,2); group->addButton(btnPan,3); - group->addButton(btnWindow,1024); + group->addButton(btnWindow,7); group->setExclusive(true); connect(group, static_cast(&QButtonGroup::buttonClicked),this,&VolumeRenderingToolBar::modeButtonClicked);