Refactor infinitiViewer.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -14,51 +14,74 @@
|
||||
#include "Common/QGlobals.h"
|
||||
|
||||
class vtkAlgorithm;
|
||||
|
||||
class vtkAlgorithmOutput;
|
||||
|
||||
class vtkImageStack;
|
||||
|
||||
class vtkImageSlice;
|
||||
|
||||
class vtkLookupTable;
|
||||
|
||||
class vtkScalarsToColors;
|
||||
|
||||
class vtkImageSliceMapper;
|
||||
|
||||
class vtkImageData;
|
||||
|
||||
class vtkInformation;
|
||||
|
||||
class ActorDraggableInteractorStyle;
|
||||
|
||||
class vtkRenderWindow;
|
||||
|
||||
class vtkRenderer;
|
||||
|
||||
class vtkRenderWindowInteractor;
|
||||
|
||||
class ExtendMedicalImageProperties;
|
||||
|
||||
class MeasureStore;
|
||||
|
||||
#define IN_TEST_MODE
|
||||
|
||||
|
||||
#ifdef IN_TEST_MODE
|
||||
|
||||
class vtkScalarBarActor;
|
||||
|
||||
#endif
|
||||
|
||||
class vtkCornerAnnotation;
|
||||
|
||||
class Measure;
|
||||
class infinitiViewer : public vtkObject
|
||||
{
|
||||
|
||||
class infinitiViewer : public vtkObject {
|
||||
public:
|
||||
static infinitiViewer *New();
|
||||
|
||||
vtkTypeMacro(infinitiViewer, vtkObject);
|
||||
|
||||
void PrintSelf(ostream &os, vtkIndent indent) override;
|
||||
|
||||
//vtkGetMacro(m_cornerAnnotation, vtkCornerAnnotation);
|
||||
vtkCornerAnnotation* GetvtkCornerAnnotation()
|
||||
{
|
||||
vtkCornerAnnotation *GetvtkCornerAnnotation() {
|
||||
return cornerAnnotation;
|
||||
}
|
||||
void updateCornerInfo(int index);
|
||||
void updateCornerInfoAll();
|
||||
void initCornerInfo(ExtendMedicalImageProperties *pSeriesTags);
|
||||
void updateOrienInfo();
|
||||
void setUpImageViewer();
|
||||
|
||||
void UpdateCornerInfo(int index);
|
||||
|
||||
void UpdateCornerInfoAll();
|
||||
|
||||
void InitCornerInfo(ExtendMedicalImageProperties *pSeries);
|
||||
|
||||
void UpdateOrientationInfo();
|
||||
|
||||
void SetupImageViewer();
|
||||
|
||||
//For Export
|
||||
void initTopLeftCornerInfo(const std::string &lbl_ser_num, const std::string &SeriesNumber);
|
||||
void InitTopLeftCornerInfo(const std::string &lbl_ser_num, const std::string &ser_num);
|
||||
|
||||
/**
|
||||
* Get the name of rendering window.
|
||||
*/
|
||||
@@ -74,7 +97,9 @@ public:
|
||||
* Set/Get the input image to the viewer.
|
||||
*/
|
||||
virtual void SetInputData(vtkImageData *in);
|
||||
|
||||
virtual vtkImageData *GetInput();
|
||||
|
||||
virtual void SetInputConnection(vtkAlgorithmOutput *input);
|
||||
|
||||
//@}
|
||||
@@ -83,30 +108,28 @@ public:
|
||||
* Set/get the slice orientation
|
||||
*/
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
SLICE_ORIENTATION_YZ = 0,
|
||||
SLICE_ORIENTATION_XZ = 1,
|
||||
SLICE_ORIENTATION_XY = 2
|
||||
};
|
||||
|
||||
vtkGetMacro(SliceOrientation, int);
|
||||
|
||||
virtual void SetSliceOrientation(int orientation);
|
||||
|
||||
virtual void SetSliceOrientationToXY()
|
||||
{
|
||||
virtual void SetSliceOrientationToXY() {
|
||||
this->SetSliceOrientation(infinitiViewer::SLICE_ORIENTATION_XY);
|
||||
}
|
||||
|
||||
virtual void SetSliceOrientationToYZ()
|
||||
{
|
||||
virtual void SetSliceOrientationToYZ() {
|
||||
this->SetSliceOrientation(infinitiViewer::SLICE_ORIENTATION_YZ);
|
||||
}
|
||||
|
||||
virtual void SetSliceOrientationToXZ()
|
||||
{
|
||||
virtual void SetSliceOrientationToXZ() {
|
||||
this->SetSliceOrientation(infinitiViewer::SLICE_ORIENTATION_XZ);
|
||||
}
|
||||
|
||||
int GetWorldSliceOrientation();
|
||||
//@{
|
||||
/**
|
||||
@@ -114,6 +137,7 @@ public:
|
||||
* this can be in X, Y or Z).
|
||||
*/
|
||||
virtual int GetSlice();
|
||||
|
||||
virtual void SetSlice(int s);
|
||||
//@}
|
||||
|
||||
@@ -123,13 +147,18 @@ public:
|
||||
* this can be in X, Y or Z).
|
||||
*/
|
||||
virtual int GetSliceMin();
|
||||
|
||||
virtual int GetSliceMax();
|
||||
|
||||
virtual void GetSliceRange(int range[2]) { this->GetSliceRange(range[0], range[1]); }
|
||||
|
||||
virtual void GetSliceRange(int &min, int &max);
|
||||
|
||||
virtual int *GetSliceRange();
|
||||
//@}
|
||||
|
||||
void ChangeSlice(vtkObject *, unsigned long eventid, void *calldata);
|
||||
|
||||
vtkSmartPointer<vtkPoints> GetSliceBoundPoints();
|
||||
|
||||
//@{
|
||||
@@ -137,10 +166,15 @@ public:
|
||||
* Set window and level for mapping pixels to colors.
|
||||
*/
|
||||
virtual double GetColorWindow();
|
||||
|
||||
virtual double GetColorLevel();
|
||||
|
||||
virtual void SetColorWindow(double s);
|
||||
|
||||
virtual void SetColorLevel(double s);
|
||||
|
||||
void SetNegativeMode(bool negative);
|
||||
|
||||
void SetLookupTable(vtkLookupTable *lut);
|
||||
//@}
|
||||
|
||||
@@ -149,12 +183,16 @@ public:
|
||||
* These are here when using a Tk window.
|
||||
*/
|
||||
virtual void SetDisplayId(void *a);
|
||||
|
||||
virtual void SetWindowId(void *a);
|
||||
|
||||
virtual void SetParentId(void *a);
|
||||
//@}
|
||||
|
||||
void SetZoomScale(double scale);
|
||||
|
||||
void SetPanOffset(const double *point);
|
||||
|
||||
void ResetZoomScaleToFitWindowSize();
|
||||
//@{
|
||||
/**
|
||||
@@ -169,6 +207,7 @@ public:
|
||||
* system's view/window and redraws it.
|
||||
*/
|
||||
virtual void SetPosition(int x, int y);
|
||||
|
||||
virtual void SetPosition(int a[2]) { this->SetPosition(a[0], a[1]); }
|
||||
//@}
|
||||
|
||||
@@ -188,6 +227,7 @@ public:
|
||||
* vtkCommand::WindowResizeEvent.
|
||||
*/
|
||||
virtual void SetSize(int width, int height);
|
||||
|
||||
virtual void SetSize(int a[2]) { this->SetSize(a[0], a[1]); }
|
||||
//@}
|
||||
|
||||
@@ -197,9 +237,13 @@ public:
|
||||
* image map instances.
|
||||
*/
|
||||
vtkGetObjectMacro(RenderWindow, vtkRenderWindow);
|
||||
|
||||
vtkGetObjectMacro(Renderer, vtkRenderer);
|
||||
|
||||
vtkGetObjectMacro(ImageActor, vtkImageSlice);
|
||||
|
||||
vtkGetObjectMacro(ImageMapper, vtkImageSliceMapper);
|
||||
|
||||
vtkGetObjectMacro(InteractorStyle, ActorDraggableInteractorStyle);
|
||||
//@}
|
||||
|
||||
@@ -208,6 +252,7 @@ public:
|
||||
* Set your own renderwindow and renderer
|
||||
*/
|
||||
virtual void SetRenderWindow(vtkRenderWindow *arg);
|
||||
|
||||
virtual void SetRenderer(vtkRenderer *arg);
|
||||
//@}
|
||||
|
||||
@@ -223,12 +268,15 @@ public:
|
||||
* need to invoke this prior to the first render.
|
||||
*/
|
||||
virtual void SetOffScreenRendering(vtkTypeBool);
|
||||
|
||||
virtual vtkTypeBool GetOffScreenRendering();
|
||||
|
||||
vtkBooleanMacro(OffScreenRendering, vtkTypeBool);
|
||||
//@}
|
||||
|
||||
|
||||
vtkGetMacro(Fusion, vtkTypeBool);
|
||||
|
||||
vtkSetMacro(Fusion, vtkTypeBool);
|
||||
//@{
|
||||
/**
|
||||
@@ -244,9 +292,12 @@ public:
|
||||
* Fusion Opacity, default is 0.5
|
||||
*/
|
||||
vtkGetMacro(FusionOpacity, double);
|
||||
|
||||
//@}
|
||||
void SetFusionOpacity(double);
|
||||
|
||||
void IncreFusionOpacity(double);
|
||||
|
||||
void SetScalarBarTitle(double);
|
||||
//@{
|
||||
/**
|
||||
@@ -303,31 +354,79 @@ public:
|
||||
void RemoveFusionActor();
|
||||
|
||||
void DeleteSelectedMeasure();
|
||||
|
||||
void DeleteCurrentSliceMeasure();
|
||||
|
||||
void DeleteCurrentSeriesMeasure();
|
||||
|
||||
void ActiveMeasure(Measure *m);
|
||||
|
||||
void UnActiveMeasure();
|
||||
|
||||
void ActiveRuler();
|
||||
|
||||
void UnActiveRuler();
|
||||
|
||||
//for convert vtkEvent to Qt signal
|
||||
vtkSignalRaiser *GetSignalRaiser() {
|
||||
return &raiser;
|
||||
}
|
||||
|
||||
void SyncSlicePoint(double *point);
|
||||
|
||||
void GetSlicePoint(double *point);
|
||||
|
||||
protected:
|
||||
infinitiViewer();
|
||||
|
||||
~infinitiViewer() override;
|
||||
|
||||
vtkAlgorithm *GetInputAlgorithm();
|
||||
|
||||
vtkInformation *GetInputInformation();
|
||||
|
||||
virtual void InstallPipeline();
|
||||
|
||||
virtual void UnInstallPipeline();
|
||||
|
||||
void PrepareFusionColorTable(vtkScalarsToColors *table, bool reset = false);
|
||||
|
||||
virtual void UpdateOrientation();
|
||||
|
||||
void LoadMeasures() {
|
||||
LoadMeasures(false);
|
||||
}
|
||||
|
||||
void LoadMeasures(bool forceReload);
|
||||
|
||||
void AddMeasures(vtkObject *, unsigned long eventid, void *calldata);
|
||||
|
||||
void RemoveMeasures(vtkObject *, unsigned long eventid, void *calldata);
|
||||
|
||||
private:
|
||||
infinitiViewer(const infinitiViewer &) = delete;
|
||||
|
||||
void operator=(const infinitiViewer &) = delete;
|
||||
|
||||
std::vector<std::vector<double>> fusion_tf_vector;
|
||||
//for convert vtkEvent to Qt signal
|
||||
vtkSignalRaiser raiser;
|
||||
|
||||
QList<Measure *> *list = nullptr;
|
||||
MeasureStore *measureStore;
|
||||
|
||||
void raiseEvent(vtkObject *sender, unsigned long eventId, void *callData = nullptr) {
|
||||
raiser.raiseEvent(sender, eventId, callData);
|
||||
}
|
||||
|
||||
void ClearCurrentSliceMeasure() const;
|
||||
|
||||
void ReloadCurrentSliceMeasure();
|
||||
|
||||
void UpdateTopLeftCornerInfo();
|
||||
|
||||
void RenderRuler();
|
||||
|
||||
vtkRenderWindow *RenderWindow;
|
||||
vtkRenderer *Renderer;
|
||||
vtkImageStack *ImageStack;
|
||||
@@ -339,58 +438,24 @@ protected:
|
||||
ActorDraggableInteractorStyle *InteractorStyle = nullptr;
|
||||
vtkTextActor *OpacityActor;
|
||||
vtkCornerAnnotation *cornerAnnotation;
|
||||
|
||||
#ifdef IN_TEST_MODE
|
||||
vtkScalarBarActor *bar;
|
||||
#endif
|
||||
|
||||
vtkNew<RulerLegendActor> ruler;
|
||||
vtkNew<vtkMatrix4x4> matrix;
|
||||
DicomCornerInfo m_cornerInfo;
|
||||
|
||||
int SliceOrientation;
|
||||
int FirstRender;
|
||||
int Slice;
|
||||
int loadedMeasureSlice;
|
||||
|
||||
int currentPresetIndex = 1;
|
||||
vtkTypeBool Fusion = false;
|
||||
vtkTypeBool firstFusion = true;
|
||||
|
||||
double FusionOpacity = 0.5;
|
||||
|
||||
|
||||
virtual void UpdateOrientation();
|
||||
vtkAlgorithm* GetInputAlgorithm();
|
||||
vtkInformation* GetInputInformation();
|
||||
void LoadMeasures(){
|
||||
LoadMeasures(false);
|
||||
}
|
||||
void LoadMeasures(bool forceReload);
|
||||
void AddMeasures(vtkObject*,unsigned long eventid,void* calldata );
|
||||
void RemoveMeasures(vtkObject*,unsigned long eventid,void* calldata );
|
||||
|
||||
private:
|
||||
infinitiViewer(const infinitiViewer&) = delete;
|
||||
void operator=(const infinitiViewer&) = delete;
|
||||
std::vector<std::vector<double>> fusion_tf_vector;
|
||||
//for convert vtkEvent to Qt signal
|
||||
vtkSignalRaiser raiser;
|
||||
|
||||
QList<Measure*>* list = nullptr;
|
||||
MeasureStore* measureStore;
|
||||
|
||||
void raiseEvent(vtkObject* sender,unsigned long eventId,void* callData = nullptr){
|
||||
raiser.raiseEvent(sender,eventId,callData);
|
||||
}
|
||||
void ClearCurrentSliceMeasure() const;
|
||||
void ReloadCurrentSliceMeasure();
|
||||
void updateTopLeftCornerInfo();
|
||||
|
||||
vtkNew<RulerLegendActor> ruler;
|
||||
bool rulerActive = false;
|
||||
void RenderRuler();
|
||||
int currentPresetIndex=1;
|
||||
int viewUpIndex = 0;
|
||||
int viewRightIndex = 1;
|
||||
DicomCornerInfo m_cornerInfo;
|
||||
char SOP_UID[20] = {0};
|
||||
double imageDataOrigin[3] = {.0, .0, .0};
|
||||
vtkNew<vtkMatrix4x4> matrix;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -128,7 +128,7 @@ void DicomImageView::Slot_WindowLevelEventForFusion(double level, double width)
|
||||
|
||||
void DicomImageView::Slot_Transformation()
|
||||
{
|
||||
mImageViewer->updateOrienInfo();
|
||||
mImageViewer->UpdateOrientationInfo();
|
||||
mImageViewer->Render();
|
||||
}
|
||||
|
||||
@@ -331,9 +331,9 @@ void DicomImageView::LoadSeries(SeriesImageSet *series)
|
||||
{
|
||||
mSeries = series;
|
||||
mImageViewer->SetInputData(mSeries->GetData());
|
||||
mImageViewer->initCornerInfo(series->GetProperty());
|
||||
mImageViewer->setUpImageViewer();
|
||||
mImageViewer->updateOrienInfo();
|
||||
mImageViewer->InitCornerInfo(series->GetProperty());
|
||||
mImageViewer->SetupImageViewer();
|
||||
mImageViewer->UpdateOrientationInfo();
|
||||
//以下是一些转接函数
|
||||
//使用connect 替代 AddObserver,避免出现多种事件机制架构
|
||||
connect(mImageViewer->GetSignalRaiser(),&vtkSignalRaiser::raiseEvent, this, &DicomImageView::syncEventFunc);
|
||||
@@ -350,7 +350,7 @@ void DicomImageView::LoadSeries(SeriesImageSet *series)
|
||||
//Callbacks------------------------------------------------------------------------------------
|
||||
void DicomImageView::updateWindowLevelCb(vtkObject* caller, unsigned long eid, void *calldata)
|
||||
{
|
||||
mImageViewer->updateCornerInfo(BOTTOM_RIGHT);
|
||||
mImageViewer->UpdateCornerInfo(BOTTOM_RIGHT);
|
||||
emit Signal_WindowLevelEventForFusion(mImageViewer->GetColorLevel(), mImageViewer->GetColorWindow());
|
||||
}
|
||||
|
||||
@@ -538,7 +538,7 @@ void DicomImageView::SetWindowLevel(double level, double width)
|
||||
mImageViewer->SetColorWindow(width);
|
||||
//You have to call updateConerInfo manually
|
||||
//only mouse event can rely on callback
|
||||
mImageViewer->updateCornerInfo(BOTTOM_RIGHT);
|
||||
mImageViewer->UpdateCornerInfo(BOTTOM_RIGHT);
|
||||
emit Signal_WindowLevelEventForFusion(level, width);
|
||||
|
||||
}
|
||||
@@ -652,7 +652,7 @@ void DicomImageView::updateCornerInfoAll()
|
||||
{
|
||||
if (HasSeries())
|
||||
{
|
||||
mImageViewer->updateCornerInfoAll();
|
||||
mImageViewer->UpdateCornerInfoAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,7 +660,7 @@ void DicomImageView::updateCornerInfoPrivacy()
|
||||
{
|
||||
if (HasSeries())
|
||||
{
|
||||
mImageViewer->updateCornerInfo(TOP_RIGHT);
|
||||
mImageViewer->UpdateCornerInfo(TOP_RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -802,8 +802,5 @@ void DicomImageView::viewerClicked() {
|
||||
}
|
||||
|
||||
void DicomImageView::SyncScrollBar() {
|
||||
// setScrollChangedType(scrollScope::TriggerType::SYNC_ONLY);
|
||||
mScrollBar->SetValueSilently(mImageViewer->GetSlice());
|
||||
mImageViewer->updateCornerInfo(TOP_LEFT);
|
||||
// setScrollChangedType(scrollScope::TriggerType::USER_TRIGGER);
|
||||
}
|
||||
|
||||
@@ -594,7 +594,6 @@ void QDicomViewer::SetupFlipTool(QToolButton* flipBtn)
|
||||
if (curV != nullptr && curV->HasSeries())
|
||||
{
|
||||
curV->Rotate(90, ROTATE_90_CCW);
|
||||
//curV->getImageViewer()->updateOrienInfo();
|
||||
}
|
||||
|
||||
});
|
||||
@@ -603,7 +602,6 @@ void QDicomViewer::SetupFlipTool(QToolButton* flipBtn)
|
||||
if (curV != nullptr && curV->HasSeries())
|
||||
{
|
||||
curV->Rotate(-90, ROTATE_90_CW);
|
||||
//curV->getImageViewer()->updateOrienInfo();
|
||||
}
|
||||
});
|
||||
m->addAction(tr("Rotate 180"), this, [&] {
|
||||
@@ -611,7 +609,6 @@ void QDicomViewer::SetupFlipTool(QToolButton* flipBtn)
|
||||
if (curV != nullptr && curV->HasSeries())
|
||||
{
|
||||
curV->Rotate(180, ROTATE_180);
|
||||
//curV->getImageViewer()->updateOrienInfo();
|
||||
}
|
||||
|
||||
});
|
||||
@@ -621,7 +618,6 @@ void QDicomViewer::SetupFlipTool(QToolButton* flipBtn)
|
||||
if (curV != nullptr && curV->HasSeries())
|
||||
{
|
||||
curV->HFlip();
|
||||
//curV->getImageViewer()->updateOrienInfo(H_FLIP);
|
||||
}
|
||||
});
|
||||
m->addAction(tr("Flip vertical"), this, [&] {
|
||||
@@ -629,7 +625,6 @@ void QDicomViewer::SetupFlipTool(QToolButton* flipBtn)
|
||||
if (curV != nullptr && curV->HasSeries())
|
||||
{
|
||||
curV->VFlip();
|
||||
//curV->getImageViewer()->updateOrienInfo(V_FLIP);
|
||||
}
|
||||
|
||||
});
|
||||
@@ -639,7 +634,6 @@ void QDicomViewer::SetupFlipTool(QToolButton* flipBtn)
|
||||
if (curV != nullptr && curV->HasSeries())
|
||||
{
|
||||
curV->ClearTransformations();
|
||||
//curV->getImageViewer()->updateOrienInfo(CLEAR);
|
||||
}
|
||||
});
|
||||
flipBtn->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
@@ -650,7 +644,6 @@ void QDicomViewer::SetupFlipTool(QToolButton* flipBtn)
|
||||
if (curV != nullptr && curV->HasSeries())
|
||||
{
|
||||
curV->Rotate(90, ROTATE_90_CCW);
|
||||
//curV->getImageViewer()->updateOrienInfo(ROTATE_90_CCW);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user