Skip to content

Commit

Permalink
ENH: Adding Enable Grid option for Resectogram, #190
Browse files Browse the repository at this point in the history
  • Loading branch information
RuoyanMeng authored and RafaelPalomar committed Apr 17, 2023
1 parent b6dbd4a commit 5e83cca
Show file tree
Hide file tree
Showing 8 changed files with 66 additions and 15 deletions.
11 changes: 10 additions & 1 deletion Liver/Liver.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ def setup(self):
self.resectogramWidget.Resection2DCheckBox.connect('stateChanged(int)', self.onResection2DChanged)
self.resectogramWidget.MirrorDisplayCheckBox.connect('stateChanged(int)', self.onMirrorDisplayCheckBoxChanged)
self.resectogramWidget.FlexibleBoundaryCheckBox.connect('stateChanged(int)', self.onFlexibleBoundaryCheckBoxChanged)
self.resectogramWidget.EnableGridCheckBox.connect('stateChanged(int)', self.onEnableGridCheckBoxChanged)
self.resectogramWidget.HepaticContourThicknessSpinBox.connect('valueChanged(double)', self.onHepaticContourThicknessChanged)
self.resectogramWidget.HepaticContourColorPickerButton.connect('colorChanged(QColor)', self.onHepaticContourColorChanged)
self.resectogramWidget.PortalContourThicknessSpinBox.connect('valueChanged(double)', self.onPortalContourThicknessChanged)
Expand Down Expand Up @@ -735,6 +736,7 @@ def onResection2DChanged(self):
self.resectogramWidget.PortalContourGroupBox.setEnabled(self.resectogramWidget.Resection2DCheckBox.isChecked())
self.resectogramWidget.VsacularSegmentsGroupBox.setEnabled(self.resectogramWidget.Resection2DCheckBox.isChecked())
self.resectogramWidget.FlexibleBoundaryCheckBox.setEnabled(self.resectogramWidget.Resection2DCheckBox.isChecked())
self.resectogramWidget.EnableGridCheckBox.setEnabled(self.resectogramWidget.Resection2DCheckBox.isChecked())
self.resectogramWidget.MirrorDisplayCheckBox.setEnabled(self.resectogramWidget.Resection2DCheckBox.isChecked())
renderers = slicer.app.layoutManager().threeDWidget(0).threeDView().renderWindow().GetRenderers()
if self.resectogramWidget.Resection2DCheckBox.isChecked() == 0 and renderers.GetNumberOfItems() == 5:
Expand All @@ -759,11 +761,18 @@ def onMirrorDisplayCheckBoxChanged(self):

def onFlexibleBoundaryCheckBoxChanged(self):
"""
This function is called when the resection2D checkbox changes.
This function is called when the EnableFlexibleBoundary checkbox changes.
"""
if self._currentResectionNode:
self._currentResectionNode.SetEnableFlexibleBoundary(self.resectogramWidget.FlexibleBoundaryCheckBox.isChecked())

def onEnableGridCheckBoxChanged(self):
"""
This function is called when the EnableGrid checkbox changes.
"""
if self._currentResectionNode:
self._currentResectionNode.SetEnableGrid(self.resectogramWidget.EnableGridCheckBox.isChecked())

def onHepaticContourThicknessChanged(self):
"""
This function is called when the resection margin spinbox changes.
Expand Down
34 changes: 24 additions & 10 deletions Liver/Resources/UI/ResectogramWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,29 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="FlexibleBoundaryCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Enable Flexible Boundary</string>
</property>
</widget>
<item >
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QCheckBox" name="FlexibleBoundaryCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Enable Flexible Boundary</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="EnableGridCheckBox">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Enable Grid</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="ctkCollapsibleGroupBox" name="HepaticContourGroupBox">
Expand Down Expand Up @@ -349,4 +363,4 @@
</hints>
</connection>
</connections>
</ui>
</ui>
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ vtkMRMLNodeNewMacro(vtkMRMLMarkupsBezierSurfaceDisplayNode);
vtkMRMLMarkupsBezierSurfaceDisplayNode::vtkMRMLMarkupsBezierSurfaceDisplayNode()
:ClipOut(false), WidgetVisibility(true),
ResectionMarginColor{0.0f, 0.0f, 0.0f}, UncertaintyMarginColor{0.0f, 0.0f, 0.0f},
ResectionOpacity(1.0f), GridDivisions(0.0f), GridThickness(0.0f), ShowResection2D(false), EnableFlexibleBoundary(false), MirrorDisplay(false),
ResectionOpacity(1.0f), GridDivisions(0.0f), GridThickness(0.0f), ShowResection2D(false), EnableFlexibleBoundary(false), MirrorDisplay(false), EnableGrid(false),
HepaticContourColor{0.0f, 151.0/255.0f, 206.0/255.0f}, PortalContourColor{216.0/255.0f, 101.0/255.0f, 79.0/255.0f}, TextureNumComps(0)
{
}
Expand Down
12 changes: 12 additions & 0 deletions LiverMarkups/MRML/vtkMRMLMarkupsBezierSurfaceDisplayNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ class VTK_SLICER_LIVERMARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsBezierSurfaceDisp
void SetEnableFlexibleBoundary(int value)
{ this->EnableFlexibleBoundary = value!=0?1:0; this->Modified();}

/// Set the Resection2D state variable
vtkSetMacro(EnableGrid, bool);
/// Get the Resection2D state variable
vtkGetMacro(EnableGrid, bool);
/// Get the Resection2D state variable as integer
int GetEnableGrid() const
{ return static_cast<int>(this->EnableGrid);}
/// set the Resection2D state variable as integer
void SetEnableGrid(int value)
{ this->EnableGrid = value!=0?1:0; this->Modified();}

/// Set the Resection2D state variable
vtkSetMacro(MirrorDisplay, bool);
/// Get the Resection2D state variable
Expand Down Expand Up @@ -185,6 +196,7 @@ class VTK_SLICER_LIVERMARKUPS_MODULE_MRML_EXPORT vtkMRMLMarkupsBezierSurfaceDisp
float PortalContourColor[3];
int TextureNumComps;
bool EnableFlexibleBoundary;
bool EnableGrid;
bool MirrorDisplay;

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,11 +618,16 @@ void vtkSlicerBezierSurfaceRepresentation3D::UpdateBezierSurfaceDisplay(vtkMRMLM
this->BezierSurfaceResectionMapper2D->SetResectionMarginColor(displayNode->GetResectionMarginColor());
this->BezierSurfaceResectionMapper2D->SetUncertaintyMarginColor(displayNode->GetUncertaintyMarginColor());
this->BezierSurfaceResectionMapper2D->SetInterpolatedMargins(displayNode->GetInterpolatedMargins());
this->BezierSurfaceResectionMapper2D->SetGridDivisions(displayNode->GetGridDivisions());
this->BezierSurfaceResectionMapper2D->SetGridThicknessFactor(displayNode->GetGridThickness());
this->BezierSurfaceResectionMapper2D->SetHepaticContourColor(displayNode->GetHepaticContourColor());
this->BezierSurfaceResectionMapper2D->SetPortalContourColor(displayNode->GetPortalContourColor());
this->BezierSurfaceResectionMapper2D->SetTextureNumComps(displayNode->GetTextureNumComps());
if (displayNode->GetEnableGrid()){
this->BezierSurfaceResectionMapper2D->SetGridDivisions(displayNode->GetGridDivisions());
this->BezierSurfaceResectionMapper2D->SetGridThicknessFactor(displayNode->GetGridThickness());
} else {
this->BezierSurfaceResectionMapper2D->SetGridDivisions(0.0);
this->BezierSurfaceResectionMapper2D->SetGridThicknessFactor(0.0);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions LiverResections/Logic/vtkSlicerLiverResectionsLogic.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ void vtkSlicerLiverResectionsLogic::ProcessMRMLNodesEvents(vtkObject *caller,
bezierSurfaceDisplayNode->SetShowResection2D(resectionNode->GetShowResection2D());
bezierSurfaceDisplayNode->SetMirrorDisplay(resectionNode->GetMirrorDisplay());
bezierSurfaceDisplayNode->SetEnableFlexibleBoundary(resectionNode->GetEnableFlexibleBoundary());
bezierSurfaceDisplayNode->SetEnableGrid(resectionNode->GetEnableGrid());
bezierSurfaceDisplayNode->SetTextureNumComps(resectionNode->GetTextureNumComps());
bezierSurfaceDisplayNode->SetClipOut(resectionNode->GetClipOut());
bezierSurfaceDisplayNode->SetWidgetVisibility(resectionNode->GetWidgetVisibility());
Expand Down
2 changes: 1 addition & 1 deletion LiverResections/MRML/vtkMRMLLiverResectionNode.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ vtkMRMLLiverResectionNode::vtkMRMLLiverResectionNode()
ResectionMarginColor{1.0f, 0.0f, 0.0f}, UncertaintyMarginColor{1.0f, 1.0f, 0.0f},
ResectionOpacity(1.0f), GridVisibility(false), GridThickness(0.0f), ShowResection2D(false), HepaticContourThickness(0.3f), PortalContourThickness(0.3f),
HepaticContourColor{0.0f, 151.0/255.0f, 206.0/255.0f}, PortalContourColor{216.0/255.0f, 101.0/255.0f, 79.0/255.0f},
TextureNumComps(0), EnableFlexibleBoundary(false), MirrorDisplay(false)
TextureNumComps(0), EnableFlexibleBoundary(false), MirrorDisplay(false), EnableGrid(false)
{
}

Expand Down
10 changes: 10 additions & 0 deletions LiverResections/MRML/vtkMRMLLiverResectionNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,15 @@ class VTK_SLICER_LIVERRESECTIONS_MODULE_MRML_EXPORT vtkMRMLLiverResectionNode
// Set the EnableFlexibleBoundary state variable
vtkSetMacro(EnableFlexibleBoundary, int);

// Set the EnableGrid state variable
vtkSetMacro(EnableGrid, bool);

// Get the EnableGrid state variable
vtkGetMacro(EnableGrid, bool);

// Set the EnableGrid state variable
vtkSetMacro(EnableGrid, int);

// Get HepaticContourThickness margin
vtkGetMacro(HepaticContourThickness, double);

Expand Down Expand Up @@ -355,6 +364,7 @@ class VTK_SLICER_LIVERRESECTIONS_MODULE_MRML_EXPORT vtkMRMLLiverResectionNode
float GridThickness;
bool ShowResection2D;
bool EnableFlexibleBoundary;
bool EnableGrid;
double HepaticContourThickness; //Resection margin in mm
double PortalContourThickness; //Uncertainty margin in mm
float HepaticContourColor[3];
Expand Down

0 comments on commit 5e83cca

Please sign in to comment.