Skip to content

Commit

Permalink
somehow, cursor3d will affect the behaviour of canvas source's behaviour
Browse files Browse the repository at this point in the history
now it is a temporary fixation for canvas source.
now it is suggested to use the internal method of MyImageViewer to extractVOI
related to issue #29
  • Loading branch information
wuzhuobin committed Nov 2, 2016
1 parent 89526ed commit b7fee48
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 68 deletions.
9 changes: 9 additions & 0 deletions codes/InteractorStyles/InteractorStylePaintBrush.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ void InteractorStylePaintBrush::OnMouseMove()

void InteractorStylePaintBrush::SetPaintBrushModeEnabled(bool b)
{
{
for (int i = 0; i < 6; ++i) {
//cout << GetInput()->GetExtent()[i] << ' ';
cout << GetExtent()[i] << ' ';
}
cout << endl;
}
/// Delete stuff if the mode is disabled to save memory
if (m_borderWidget != NULL)
{
Expand All @@ -289,6 +296,8 @@ void InteractorStylePaintBrush::SetPaintBrushModeEnabled(bool b)

if (b)
{


m_retangleRep = vtkBorderRepresentation::New();
m_borderWidget = vtkBorderWidget::New();
m_borderWidget->SetInteractor(this->GetInteractor());
Expand Down
2 changes: 1 addition & 1 deletion codes/MaximumWallThickness/MaximumWallThickness.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class MaximumWallThickness : public vtkObject
std::vector<DistanceLoopPair> GetDistanceLoopPairVect();

/* Two ways to specify the region of interest
1. Set image slice number, then default extent is extracted from SegmentationOverlay of mainwnd
1. Set image slice number, then default extent is extracted from Overlay of mainwnd
2. Directly set slice image
*/
void SetLumemIntensity(int i);
Expand Down
58 changes: 32 additions & 26 deletions codes/core/Core.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Core::Core(QObject* parent, QWidget* mainWindow)
// enable registration
m_ioManager->enableRegistration(true);

for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
m_2DimageViewer[i] = vtkSmartPointer<MyImageViewer>::New();
m_interactor[i] = vtkSmartPointer<vtkRenderWindowInteractor>::New();
Expand Down Expand Up @@ -101,10 +101,10 @@ vtkLookupTable * Core::GetLookupTable()

vtkRenderWindow * Core::GetRenderWindow(int num)
{
if (num < 0 || num > VIEWER_NUM) {
if (num < 0 || num > NUMBER_OF_2DVIEWERS) {
return NULL;
}
else if (num == VIEWER_NUM) {
else if (num == NUMBER_OF_2DVIEWERS) {
return m_3DimageViewer;
}
else {
Expand All @@ -114,7 +114,7 @@ vtkRenderWindow * Core::GetRenderWindow(int num)

void Core::RenderAllViewer()
{
for (int i = 0; i < VIEWER_NUM; ++i) {
for (int i = 0; i < NUMBER_OF_2DVIEWERS; ++i) {
if(m_2DimageViewer[i]->GetInput() != NULL)
m_2DimageViewer[i]->Render();
}
Expand Down Expand Up @@ -155,7 +155,7 @@ void Core::slotAddOverlayToImageViewer() {
this->DisplayErrorMessage("Selected segmentation has wrong spacing!");
return;
}
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
// The tableRange of LookupTable Change when the vtkImageViewer2::Render was call
// Very strange
Expand All @@ -173,7 +173,7 @@ void Core::slotVisualizeAll2DViewers()
slotValidatePatientInformation();
slotChangeView(MULTIPLANAR_VIEW);
if (m_firstInitialize) {
for (int i = 0; i < VIEWER_NUM; ++i) {
for (int i = 0; i < NUMBER_OF_2DVIEWERS; ++i) {
m_2DimageViewer[i]->SetupInteractor(m_interactor[i]);
m_style[i]->SetImageViewer(m_2DimageViewer[i]);
m_interactor[i]->SetInteractorStyle(m_style[i]);
Expand All @@ -190,6 +190,12 @@ void Core::slotVisualizeAll2DViewers()
(extent[3] - extent[2]) / 2,
(extent[5] - extent[4]) / 2);

int extent1[6] = { 400,500,400,500,30,100 };
for (int i = 0; i < NUMBER_OF_2DVIEWERS; ++i) {
m_2DimageViewer[i]->SetImageVOI(extent1);
m_2DimageViewer[i]->SetOverlayVOI(extent1);
}

emit signalVisualizeAllViewers();
}

Expand All @@ -207,7 +213,7 @@ void Core::slotChangeModality(QString modalityName, int viewerNum)

int index = this->m_imageManager->GetModalityIndex(modalityName);
if (m_viewMode == MULTIPLANAR_VIEW) {
for (int j = 0; j < VIEWER_NUM; ++j) {
for (int j = 0; j < NUMBER_OF_2DVIEWERS; ++j) {
m_2DimageViewer[j]->SetInputData(
this->m_imageManager->getListOfViewerInputImages()[index]);
m_2DimageViewer[j]->Render();
Expand Down Expand Up @@ -268,9 +274,9 @@ void Core::slotChangeView(int viewMode)
// SEGMENTATION_VIEW
if (viewMode) {
// i1 for looping all 5 vtkImage, while i2 for looping all 3 m_2DimageViewer
for (int i1 = 0, i2 = 0; i2 < VIEWER_NUM; ++i2)
for (int i1 = 0, i2 = 0; i2 < NUMBER_OF_2DVIEWERS; ++i2)
{
for (; i1 < this->m_imageManager->getListOfViewerInputImages().size() && i2 < VIEWER_NUM;
for (; i1 < this->m_imageManager->getListOfViewerInputImages().size() && i2 < NUMBER_OF_2DVIEWERS;
++i1) {
// skip the NULL image
if (this->m_imageManager->getListOfViewerInputImages()[i1] != NULL) {
Expand All @@ -284,7 +290,7 @@ void Core::slotChangeView(int viewMode)
++i2;
}
}
if (i1 >= m_imageManager->getListOfVtkImages().size() && i2 < VIEWER_NUM ) {
if (i1 >= m_imageManager->getListOfVtkImages().size() && i2 < NUMBER_OF_2DVIEWERS ) {
this->m_2DimageViewer[i2]->GetRenderWindow()->GetInteractor()->Disable();
// disable view props
m_2DimageViewer[i2]->SetAllBlack(true);
Expand All @@ -296,7 +302,7 @@ void Core::slotChangeView(int viewMode)
}
// MULTIPLANAR_VIEW
else {
for (int i = 0; i < VIEWER_NUM; ++i) {
for (int i = 0; i < NUMBER_OF_2DVIEWERS; ++i) {
// Change input to same image, default 0
// SetupInteractor should be ahead of InitializeHeader
m_2DimageViewer[i]->SetInputData(
Expand Down Expand Up @@ -392,7 +398,7 @@ void Core::slotChangeView(int viewMode)

void Core::slotNavigationMode()
{
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
m_style[i]->SetInteractorStyleToNavigation();
}
Expand All @@ -401,7 +407,7 @@ void Core::slotNavigationMode()
void Core::slotWindowLevelMode()
{

for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
m_style[i]->SetInteractorStyleToWindowLevel();
}
Expand All @@ -410,7 +416,7 @@ void Core::slotWindowLevelMode()

void Core::slotBrushMode()
{
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
m_style[i]->SetInteractorStyleToPaintBrush();
}
Expand All @@ -420,7 +426,7 @@ void Core::slotBrushMode()

void Core::slotSetBrushSize(int size)
{
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
if (m_style[i] != NULL) {
m_style[i]->GetPaintBrush()->SetBrushSize(size);
Expand All @@ -430,7 +436,7 @@ void Core::slotSetBrushSize(int size)

void Core::slotSetBrushShape(int shape)
{
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
if (m_style[i] != NULL) {
m_style[i]->GetPaintBrush()->SetBrushShape(shape);
Expand All @@ -439,7 +445,7 @@ void Core::slotSetBrushShape(int shape)
}

void Core::slotSetImageLayerColor(int layer) {
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
if (m_style[i] != NULL) {
m_style[i]->GetPaintBrush()->SetPaintBrushLabel(layer + 1);
Expand All @@ -450,7 +456,7 @@ void Core::slotSetImageLayerColor(int layer) {

void Core::slotSetPaintBrushToEraser(bool flag)
{
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
if (m_style[i] != NULL) {

Expand Down Expand Up @@ -781,7 +787,7 @@ void Core::ModeChangeUpdate(INTERACTION_MODE index)

void Core::slotContourMode()
{
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
m_style[i]->SetInteractorStyleToPolygonDraw();
}
Expand Down Expand Up @@ -898,17 +904,17 @@ void Core::slotExtractLumenDilateLabel(vtkImageData* im)
cout << im->GetExtent()[i] << ' ' << vesselWallImage->GetExtent()[i];
}
cout << endl;
for (int i = 0; i < VIEWER_NUM; ++i) {
for (int i = 0; i < NUMBER_OF_2DVIEWERS; ++i) {
m_style[i]->GetSmartContour2()->SetLumenImage(im);
m_style[i]->GetSmartContour2()->SetVesselWallImage(vesselWallImage);
}
}

void Core::slotRulerMode()
{
for (int i = 0; i < VIEWER_NUM; ++i) {
for (int i = 0; i < NUMBER_OF_2DVIEWERS; ++i) {
m_style[i]->SetInteractorStyleToRuler();
for (int j = 0; j < VIEWER_NUM; ++j) {
for (int j = 0; j < NUMBER_OF_2DVIEWERS; ++j) {
m_style[i]->GetRuler()->AddSynchronalRuler(m_style[j]->GetRuler());
}
}
Expand All @@ -918,7 +924,7 @@ void Core::slotRulerMode()

void Core::slotEnableMaximumWallThickneesLabel(bool flag)
{
for (int i = 0; i < VIEWER_NUM; ++i) {
for (int i = 0; i < NUMBER_OF_2DVIEWERS; ++i) {
m_style[i]->GetRuler()->EnableMaximumWallThickneesLabel(flag);
}
}
Expand Down Expand Up @@ -950,7 +956,7 @@ void Core::slotROIMode()

void Core::slotSmartContourMode()
{
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
m_style[i]->SetInteractorStyleToSmartContour();
}
Expand All @@ -960,7 +966,7 @@ void Core::slotSmartContourMode()

void Core::slotSmartContour2Mode()
{
for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
m_style[i]->SetInteractorStyleToSmartContour2();
}
Expand Down Expand Up @@ -1008,7 +1014,7 @@ void Core::slotSelectROI()
slotChangeView(MULTIPLANAR_VIEW);
this->m_imageManager->getOverlay()->SetDisplayExtent(newExtent);

for (int i = 0; i < VIEWER_NUM; i++)
for (int i = 0; i < NUMBER_OF_2DVIEWERS; i++)
{
this->m_2DimageViewer[i]->GetRenderer()->ResetCamera();
this->m_2DimageViewer[i]->GetInputLayer()->Modified();
Expand Down
8 changes: 4 additions & 4 deletions codes/core/Core.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class Core:public QObject
};

const static int DEFAULT_IMAGE = 0;
const static int VIEWER_NUM = 3;
const static int NUMBER_OF_2DVIEWERS = 3;

int* ConvertBoundsToExtent(double* bounds, bool clamping = true);
double* ConvertExtentToBounds(int* extent);
Expand Down Expand Up @@ -160,9 +160,9 @@ class Core:public QObject
void ModeChangeUpdate(INTERACTION_MODE);

// viewer
vtkSmartPointer<MyImageViewer> m_2DimageViewer[VIEWER_NUM];
vtkSmartPointer<vtkRenderWindowInteractor> m_interactor[VIEWER_NUM];
vtkSmartPointer<InteractorStyleSwitch> m_style[VIEWER_NUM];
vtkSmartPointer<MyImageViewer> m_2DimageViewer[NUMBER_OF_2DVIEWERS];
vtkSmartPointer<vtkRenderWindowInteractor> m_interactor[NUMBER_OF_2DVIEWERS];
vtkSmartPointer<InteractorStyleSwitch> m_style[NUMBER_OF_2DVIEWERS];
vtkRenderWindow* m_3DimageViewer;
vtkRenderer* m_3DDataRenderer;
vtkRenderer* m_3DAnnotationRenderer;
Expand Down
Loading

0 comments on commit b7fee48

Please sign in to comment.