Refactor sync event.1
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Common/QGlobals.h"
|
#include "Common/QGlobals.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vtkImageData.h>
|
#include <vtkImageData.h>
|
||||||
@@ -38,10 +38,7 @@ public:
|
|||||||
|
|
||||||
bool IntersectWorldBounds(SeriesImageSet* imageSet);
|
bool IntersectWorldBounds(SeriesImageSet* imageSet);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
||||||
vtkSmartPointer <vtkImageData> m_image;
|
vtkSmartPointer <vtkImageData> m_image;
|
||||||
ExtendMedicalImageProperties* m_property = nullptr;
|
ExtendMedicalImageProperties* m_property = nullptr;
|
||||||
|
|
||||||
std::string m_pUniqueID;
|
std::string m_pUniqueID;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -582,6 +582,18 @@ void infinitiViewer::SetPanOffset(const double *p) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void infinitiViewer::setPanFocalPoint(const double *p) {
|
||||||
|
double fp[3] = {0.0, 0.0, 0.0};
|
||||||
|
double newP[3] = {p[0], p[1], p[2]};
|
||||||
|
Renderer->GetActiveCamera()->GetPosition(fp);
|
||||||
|
newP[SliceOrientation] = fp[2];
|
||||||
|
Renderer->GetActiveCamera()->SetPosition(newP);
|
||||||
|
Renderer->GetActiveCamera()->GetFocalPoint(fp);
|
||||||
|
newP[SliceOrientation] = fp[2];
|
||||||
|
Renderer->GetActiveCamera()->SetFocalPoint(newP);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// window----------------------------------------------------------------------
|
// window----------------------------------------------------------------------
|
||||||
double infinitiViewer::GetColorWindow() {
|
double infinitiViewer::GetColorWindow() {
|
||||||
return this->ImageActor->GetProperty()->GetColorWindow();
|
return this->ImageActor->GetProperty()->GetColorWindow();
|
||||||
|
|||||||
@@ -193,6 +193,8 @@ vtkTypeMacro(infinitiViewer, vtkObject);
|
|||||||
|
|
||||||
void SetPanOffset(const double *point);
|
void SetPanOffset(const double *point);
|
||||||
|
|
||||||
|
void setPanFocalPoint(const double *point);
|
||||||
|
|
||||||
void ResetZoomScaleToFitWindowSize();
|
void ResetZoomScaleToFitWindowSize();
|
||||||
//@{
|
//@{
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "dicomimageview.h"
|
#include "dicomimageview.h"
|
||||||
|
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -372,12 +372,12 @@ void DicomImageView::clearFusionContext() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Callbacks------------------------------------------------------------------------------------
|
//Callbacks------------------------------------------------------------------------------------
|
||||||
void DicomImageView::updateWindowLevelCb() {
|
void DicomImageView::windowLevelHandle() {
|
||||||
mImageViewer->UpdateCornerInfo(BOTTOM_RIGHT);
|
mImageViewer->UpdateCornerInfo(BOTTOM_RIGHT);
|
||||||
emit onFusionWindowChange(mImageViewer->GetColorLevel(), mImageViewer->GetColorWindow());
|
emit onFusionWindowChange(mImageViewer->GetColorLevel(), mImageViewer->GetColorWindow());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DicomImageView::scalarEventCb(vtkObject *, unsigned long eventId, void *calldata) {
|
void DicomImageView::scalarEventHandle(vtkObject *, unsigned long eventId, void *calldata) {
|
||||||
double *r = (double *) calldata;
|
double *r = (double *) calldata;
|
||||||
switch (eventId) {
|
switch (eventId) {
|
||||||
case (ActorDraggableInteractorStyle::ScalarShiftEvent):
|
case (ActorDraggableInteractorStyle::ScalarShiftEvent):
|
||||||
@@ -395,31 +395,36 @@ void DicomImageView::scalarEventCb(vtkObject *, unsigned long eventId, void *cal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DicomImageView::doubleclickedEventCb() {
|
void DicomImageView::doubleClickHandle() {
|
||||||
emit onViewDoubleClick(this);
|
emit onViewDoubleClick(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO:重新匹配该函数,部分逻辑可以直接保留,需要注意Endxxx系列事件不是仅仅为了sync设计的
|
void DicomImageView::dispatchEvent(vtkObject *, unsigned long eid, void *callData) {
|
||||||
void DicomImageView::syncEventFunc(vtkObject *, unsigned long eid, void *calldata) {
|
|
||||||
|
|
||||||
int *r = (int *) calldata;
|
int *r = (int *) callData;
|
||||||
switch (eid) {
|
switch (eid) {
|
||||||
case (vtkCommand::EventIds::EndPanEvent):
|
case (vtkCommand::EventIds::EndPanEvent):{
|
||||||
emit onSync(this, VTKIS_IMAGE_PAN, calldata);
|
emit onEndPan(this, callData);
|
||||||
break;
|
break;
|
||||||
case (vtkCommand::EventIds::EndWindowLevelEvent):
|
}
|
||||||
|
case (vtkCommand::EventIds::EndWindowLevelEvent):{
|
||||||
//update corner info through callback
|
//update corner info through callback
|
||||||
emit onSync(this, VTKIS_IMAGE_WINDOWLEVEL, calldata);
|
emit onEndWindowLevel(this,
|
||||||
|
mImageViewer->GetColorLevel(),
|
||||||
|
mImageViewer->GetColorWindow());
|
||||||
break;
|
break;
|
||||||
case (ActorDraggableInteractorStyle::DraggableStyleEvents::EndDollyEvent):
|
}
|
||||||
emit onSync(this, VTKIS_IMAGE_ZOOM, calldata);
|
case (ActorDraggableInteractorStyle::DraggableStyleEvents::EndDollyEvent):{
|
||||||
|
double newScaleFactor = ((double *) callData)[1];
|
||||||
|
emit onEndZoom(this, newScaleFactor);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case (ActorDraggableInteractorStyle::DraggableStyleEvents::SlicedEvent): {
|
case (ActorDraggableInteractorStyle::DraggableStyleEvents::SlicedEvent): {
|
||||||
mScrollBar->SetValueSilently(r[0]);
|
mScrollBar->SetValueSilently(r[0]);
|
||||||
//invoke event
|
//invoke event
|
||||||
double focusPoint[3] = {.0, .0, .0};
|
double focusPoint[3] = {.0, .0, .0};
|
||||||
mImageViewer->GetSlicePoint(focusPoint);
|
mImageViewer->GetSlicePoint(focusPoint);
|
||||||
emit onSync(this, VTKIS_IMAGE_SLICING, focusPoint);
|
emit onSlice(this, focusPoint);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -481,12 +486,18 @@ void DicomImageView::setZoomScale(double scale) {
|
|||||||
|
|
||||||
void DicomImageView::setPanOffset(double *pan) {
|
void DicomImageView::setPanOffset(double *pan) {
|
||||||
if (hasSeries()) {
|
if (hasSeries()) {
|
||||||
|
|
||||||
mImageViewer->SetPanOffset(pan);
|
mImageViewer->SetPanOffset(pan);
|
||||||
mImageViewer->Render();
|
mImageViewer->Render();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DicomImageView::setPanFocalPoint(double *pan) {
|
||||||
|
if (hasSeries()) {
|
||||||
|
mImageViewer->setPanFocalPoint(pan);
|
||||||
|
mImageViewer->Render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void DicomImageView::resetPanZoom() {
|
void DicomImageView::resetPanZoom() {
|
||||||
if (hasSeries()) {
|
if (hasSeries()) {
|
||||||
mImageViewer->GetRenderer()->ResetCamera();
|
mImageViewer->GetRenderer()->ResetCamera();
|
||||||
@@ -582,6 +593,7 @@ void DicomImageView::rotateImage(double angle, TransFormType operation) {
|
|||||||
void DicomImageView::ClearTransformations() {
|
void DicomImageView::ClearTransformations() {
|
||||||
if (hasSeries()) {
|
if (hasSeries()) {
|
||||||
int slice = mImageViewer->GetSlice();
|
int slice = mImageViewer->GetSlice();
|
||||||
|
//reset flip and rotation
|
||||||
mImageViewer->UpdateOrientation();
|
mImageViewer->UpdateOrientation();
|
||||||
resetPanZoom();
|
resetPanZoom();
|
||||||
//avoid black out problem
|
//avoid black out problem
|
||||||
|
|||||||
@@ -116,6 +116,8 @@ public:
|
|||||||
|
|
||||||
void setPanOffset(double *p);
|
void setPanOffset(double *p);
|
||||||
|
|
||||||
|
void setPanFocalPoint(double *p);
|
||||||
|
|
||||||
void SyncScrollBar();
|
void SyncScrollBar();
|
||||||
|
|
||||||
//CineMode
|
//CineMode
|
||||||
@@ -177,6 +179,14 @@ signals:
|
|||||||
|
|
||||||
void onSync(DicomImageView *view, int interactionMode, void *calldata);
|
void onSync(DicomImageView *view, int interactionMode, void *calldata);
|
||||||
|
|
||||||
|
void onSlice(DicomImageView *view, void *calldata);
|
||||||
|
|
||||||
|
void onEndPan(DicomImageView *view, void * offsetVector);
|
||||||
|
|
||||||
|
void onEndZoom(DicomImageView *view, double newScaleFactor);
|
||||||
|
|
||||||
|
void onEndWindowLevel(DicomImageView *view, double level, double window);
|
||||||
|
|
||||||
void onFusionWindowChange(double level, double width);
|
void onFusionWindowChange(double level, double width);
|
||||||
|
|
||||||
void onTransform(TransFormType);
|
void onTransform(TransFormType);
|
||||||
@@ -262,14 +272,14 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Callback
|
//Callback
|
||||||
void doubleclickedEventCb();
|
void doubleClickHandle();
|
||||||
|
|
||||||
void scalarEventCb(vtkObject *sender, unsigned long eventId, void *calldata = nullptr);
|
void scalarEventHandle(vtkObject *sender, unsigned long eventId, void *calldata = nullptr);
|
||||||
|
|
||||||
void updateWindowLevelCb();
|
void windowLevelHandle();
|
||||||
|
|
||||||
|
|
||||||
void syncEventFunc(vtkObject *caller, unsigned long eid, void *calldata);
|
void dispatchEvent(vtkObject *caller, unsigned long eid, void *callData);
|
||||||
|
|
||||||
void initCineModeThread();
|
void initCineModeThread();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user