Commit 7108fb31 authored by finetjul's avatar finetjul
Browse files

ENH: Add "Volume Information" section into the Volumes module

git-svn-id: http://svn.slicer.org/Slicer4/trunk@15320 3bd1e089-480b-0410-8dfb-8563597acbee
parent aa2912d9
......@@ -10,13 +10,16 @@
<height>303</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="windowTitle">
<string>Form</string>
<string>Volume Information</string>
</property>
<layout class="QFormLayout" name="formLayout">
<property name="sizeConstraint">
<enum>QLayout::SetFixedSize</enum>
</property>
<property name="margin">
<number>0</number>
</property>
......
......@@ -20,12 +20,19 @@
class qMRMLVolumeThresholdWidgetPrivate: public Ui_qMRMLVolumeThresholdWidget
{
public:
qMRMLVolumeThresholdWidgetPrivate()
{
}
qMRMLVolumeThresholdWidgetPrivate();
vtkMRMLScalarVolumeNode* VolumeNode;
vtkMRMLScalarVolumeDisplayNode* VolumeDisplayNode;
};
// --------------------------------------------------------------------------
qMRMLVolumeThresholdWidgetPrivate::qMRMLVolumeThresholdWidgetPrivate()
{
this->VolumeNode = 0;
this->VolumeDisplayNode = 0;
}
// --------------------------------------------------------------------------
qMRMLVolumeThresholdWidget::qMRMLVolumeThresholdWidget(QWidget* _parent)
: Superclass(_parent)
......@@ -35,9 +42,6 @@ qMRMLVolumeThresholdWidget::qMRMLVolumeThresholdWidget(QWidget* _parent)
d->setupUi(this);
this->VolumeNode = NULL;
this->VolumeDisplayNode = NULL;
this->setAutoThreshold(2);
this->connect(d->VolumeThresholdRangeWidget, SIGNAL(valuesChanged(double, double)),
......@@ -47,7 +51,7 @@ qMRMLVolumeThresholdWidget::qMRMLVolumeThresholdWidget(QWidget* _parent)
SLOT(setAutoThreshold(int)));
// disable as there is not MRML Node associated with the widget
this->setEnabled(this->VolumeDisplayNode != NULL);
this->setEnabled(d->VolumeDisplayNode != NULL);
}
// --------------------------------------------------------------------------
......@@ -59,27 +63,27 @@ qMRMLVolumeThresholdWidget::~qMRMLVolumeThresholdWidget()
void qMRMLVolumeThresholdWidget::setAutoThreshold(int autoThreshold)
{
// 0-manual, 1-auto, 2-off
//Q_D(qMRMLVolumeThresholdWidget);
Q_D(qMRMLVolumeThresholdWidget);
if (this->VolumeDisplayNode)
if (d->VolumeDisplayNode)
{
int oldAuto = this->VolumeDisplayNode->GetAutoThreshold();
int oldApply = this->VolumeDisplayNode->GetApplyThreshold();
int oldAuto = d->VolumeDisplayNode->GetAutoThreshold();
int oldApply = d->VolumeDisplayNode->GetApplyThreshold();
int disabledModify = this->VolumeDisplayNode->StartModify();
int disabledModify = d->VolumeDisplayNode->StartModify();
if (autoThreshold != 2)
{
this->VolumeDisplayNode->SetApplyThreshold(1);
this->VolumeDisplayNode->SetAutoThreshold(autoThreshold);
d->VolumeDisplayNode->SetApplyThreshold(1);
d->VolumeDisplayNode->SetAutoThreshold(autoThreshold);
}
else
{
this->VolumeDisplayNode->SetApplyThreshold(0);
d->VolumeDisplayNode->SetApplyThreshold(0);
}
this->VolumeDisplayNode->EndModify(disabledModify);
d->VolumeDisplayNode->EndModify(disabledModify);
if (oldAuto != this->VolumeDisplayNode->GetAutoThreshold() ||
oldApply != this->VolumeDisplayNode->GetApplyThreshold())
if (oldAuto != d->VolumeDisplayNode->GetAutoThreshold() ||
oldApply != d->VolumeDisplayNode->GetApplyThreshold())
{
emit this->autoThresholdValueChanged(autoThreshold);
}
......@@ -106,31 +110,33 @@ bool qMRMLVolumeThresholdWidget::isOff() const
// --------------------------------------------------------------------------
void qMRMLVolumeThresholdWidget::setThreshold(double lowerThreshold, double upperThreshold)
{
if (this->VolumeDisplayNode)
Q_D(qMRMLVolumeThresholdWidget);
if (d->VolumeDisplayNode)
{
double oldLowerThreshold = this->VolumeDisplayNode->GetLowerThreshold();
double oldUpperThreshold = this->VolumeDisplayNode->GetUpperThreshold();
int disabledModify = this->VolumeDisplayNode->StartModify();
this->VolumeDisplayNode->SetLowerThreshold(lowerThreshold);
this->VolumeDisplayNode->SetUpperThreshold(upperThreshold);
if (this->VolumeDisplayNode->GetApplyThreshold() &&
(oldLowerThreshold != this->VolumeDisplayNode->GetLowerThreshold() ||
oldUpperThreshold != this->VolumeDisplayNode->GetUpperThreshold()) )
double oldLowerThreshold = d->VolumeDisplayNode->GetLowerThreshold();
double oldUpperThreshold = d->VolumeDisplayNode->GetUpperThreshold();
int disabledModify = d->VolumeDisplayNode->StartModify();
d->VolumeDisplayNode->SetLowerThreshold(lowerThreshold);
d->VolumeDisplayNode->SetUpperThreshold(upperThreshold);
if (d->VolumeDisplayNode->GetApplyThreshold() &&
(oldLowerThreshold != d->VolumeDisplayNode->GetLowerThreshold() ||
oldUpperThreshold != d->VolumeDisplayNode->GetUpperThreshold()) )
{
this->setAutoThreshold(0);
emit this->thresholdValuesChanged(lowerThreshold, upperThreshold);
}
this->VolumeDisplayNode->EndModify(disabledModify);
d->VolumeDisplayNode->EndModify(disabledModify);
}
}
// --------------------------------------------------------------------------
void qMRMLVolumeThresholdWidget::setLowerThreshold(double lowerThreshold)
{
if (this->VolumeDisplayNode)
Q_D(qMRMLVolumeThresholdWidget);
if (d->VolumeDisplayNode)
{
double upperThreshold = this->VolumeDisplayNode->GetUpperThreshold();
double upperThreshold = d->VolumeDisplayNode->GetUpperThreshold();
this->setThreshold(lowerThreshold, upperThreshold);
}
}
......@@ -138,9 +144,10 @@ void qMRMLVolumeThresholdWidget::setLowerThreshold(double lowerThreshold)
// --------------------------------------------------------------------------
void qMRMLVolumeThresholdWidget::setUpperThreshold(double upperThreshold)
{
if (this->VolumeDisplayNode)
Q_D(qMRMLVolumeThresholdWidget);
if (d->VolumeDisplayNode)
{
double lowerThreshold = this->VolumeDisplayNode->GetLowerThreshold();
double lowerThreshold = d->VolumeDisplayNode->GetLowerThreshold();
this->setThreshold(lowerThreshold, upperThreshold);
}
}
......@@ -165,20 +172,40 @@ double qMRMLVolumeThresholdWidget::upperThreshold() const
return max;
}
// --------------------------------------------------------------------------
vtkMRMLScalarVolumeDisplayNode* qMRMLVolumeThresholdWidget::mrmlDisplayNode()const
{
Q_D(const qMRMLVolumeThresholdWidget);
return d->VolumeDisplayNode;
}
// --------------------------------------------------------------------------
void qMRMLVolumeThresholdWidget::setMRMLVolumeDisplayNode(vtkMRMLScalarVolumeDisplayNode* node)
{
Q_D(qMRMLVolumeThresholdWidget);
if (d->VolumeDisplayNode == node)
{
return;
}
// each time the node is modified, the qt widgets are updated
this->qvtkReconnect(this->VolumeDisplayNode, node,
vtkCommand::ModifiedEvent, this, SLOT(updateWidgetFromMRML()));
this->qvtkReconnect(d->VolumeDisplayNode, node, vtkCommand::ModifiedEvent,
this, SLOT(updateWidgetFromMRML()));
this->VolumeDisplayNode = node;
d->VolumeDisplayNode = node;
this->setEnabled(node != 0);
this->updateWidgetFromMRML();
}
// --------------------------------------------------------------------------
vtkMRMLScalarVolumeNode* qMRMLVolumeThresholdWidget::mrmlVolumeNode()const
{
Q_D(const qMRMLVolumeThresholdWidget);
return d->VolumeNode;
}
// --------------------------------------------------------------------------
void qMRMLVolumeThresholdWidget::setMRMLVolumeNode(vtkMRMLNode* node)
{
......@@ -188,10 +215,16 @@ void qMRMLVolumeThresholdWidget::setMRMLVolumeNode(vtkMRMLNode* node)
// --------------------------------------------------------------------------
void qMRMLVolumeThresholdWidget::setMRMLVolumeNode(vtkMRMLScalarVolumeNode* volumeNode)
{
this->VolumeNode = volumeNode;
this->setMRMLVolumeDisplayNode(
volumeNode ? vtkMRMLScalarVolumeDisplayNode::SafeDownCast(
volumeNode->GetVolumeDisplayNode()) : 0);
Q_D(qMRMLVolumeThresholdWidget);
if (d->VolumeNode == volumeNode)
{
return;
}
// each time the node is modified, the qt widgets are updated
this->qvtkReconnect(d->VolumeNode, volumeNode, vtkCommand::ModifiedEvent,
this, SLOT(updateDisplayNode()));
d->VolumeNode = volumeNode;
this->updateDisplayNode();
}
// --------------------------------------------------------------------------
......@@ -208,15 +241,24 @@ void qMRMLVolumeThresholdWidget::setMaximum(double max)
d->VolumeThresholdRangeWidget->setMaximum(max);
}
// --------------------------------------------------------------------------
void qMRMLVolumeThresholdWidget::updateDisplayNode()
{
Q_D(qMRMLVolumeThresholdWidget);
this->setMRMLVolumeDisplayNode(
d->VolumeNode ? vtkMRMLScalarVolumeDisplayNode::SafeDownCast(
d->VolumeNode->GetVolumeDisplayNode()) : 0);
}
// --------------------------------------------------------------------------
void qMRMLVolumeThresholdWidget::updateWidgetFromMRML()
{
Q_D(qMRMLVolumeThresholdWidget);
if (this->VolumeDisplayNode)
if (d->VolumeDisplayNode)
{
int autoThresh = this->VolumeDisplayNode->GetAutoThreshold();
int applyThresh = this->VolumeDisplayNode->GetApplyThreshold();
int autoThresh = d->VolumeDisplayNode->GetAutoThreshold();
int applyThresh = d->VolumeDisplayNode->GetApplyThreshold();
int index = 0;
if (applyThresh == 0)
{
......@@ -228,15 +270,15 @@ void qMRMLVolumeThresholdWidget::updateWidgetFromMRML()
}
d->AutoManualComboBox->setCurrentIndex(index);
if (this->VolumeNode)
if (d->VolumeNode)
{
double range[2];
this->VolumeNode->GetImageData()->GetScalarRange(range);
d->VolumeNode->GetImageData()->GetScalarRange(range);
d->VolumeThresholdRangeWidget->setRange(range[0], range[1]);
}
double min = this->VolumeDisplayNode->GetLowerThreshold();
double max = this->VolumeDisplayNode->GetUpperThreshold();
double min = d->VolumeDisplayNode->GetLowerThreshold();
double max = d->VolumeDisplayNode->GetUpperThreshold();
d->VolumeThresholdRangeWidget->setValues(min, max );
}
}
......@@ -48,8 +48,7 @@ public:
///
/// Return the current MRML node of interest
vtkMRMLScalarVolumeNode* mrmlVolumeNode()const
{ return this->VolumeNode; };
vtkMRMLScalarVolumeNode* mrmlVolumeNode()const;
signals:
///
......@@ -82,6 +81,9 @@ public slots:
void setMRMLVolumeNode(vtkMRMLNode* node);
protected slots:
/// the volume node has been modified, maybe its displayNode has been
/// changed
void updateDisplayNode();
/// update widget GUI from MRML node
void updateWidgetFromMRML();
......@@ -89,8 +91,7 @@ protected slots:
protected:
///
/// Return the current MRML display node
vtkMRMLScalarVolumeDisplayNode* mrmlDisplayNode()const
{ return this->VolumeDisplayNode;};
vtkMRMLScalarVolumeDisplayNode* mrmlDisplayNode()const;
///
/// Set current MRML display node
......@@ -108,9 +109,6 @@ protected:
private:
Q_DECLARE_PRIVATE(qMRMLVolumeThresholdWidget);
Q_DISABLE_COPY(qMRMLVolumeThresholdWidget);
vtkMRMLScalarVolumeNode* VolumeNode;
vtkMRMLScalarVolumeDisplayNode* VolumeDisplayNode;
};
#endif
......@@ -263,6 +263,11 @@ double qMRMLWindowLevelWidget::level() const
void qMRMLWindowLevelWidget::setMRMLVolumeDisplayNode(vtkMRMLScalarVolumeDisplayNode* node)
{
Q_D(qMRMLWindowLevelWidget);
if (d->VolumeDisplayNode == node)
{
return;
}
// each time the node is modified, the qt widgets are updated
this->qvtkReconnect(d->VolumeDisplayNode, node,
vtkCommand::ModifiedEvent, this, SLOT(updateWidgetFromMRML()));
......@@ -284,6 +289,14 @@ void qMRMLWindowLevelWidget::setMRMLVolumeNode(vtkMRMLNode* node)
void qMRMLWindowLevelWidget::setMRMLVolumeNode(vtkMRMLScalarVolumeNode* volumeNode)
{
Q_D(qMRMLWindowLevelWidget);
if (volumeNode == d->VolumeNode)
{
return;
}
this->qvtkReconnect(d->VolumeNode, volumeNode, vtkCommand::ModifiedEvent,
this, SLOT(updateDisplayNode()));
d->VolumeNode = volumeNode;
if (d->VolumeNode)
{
......@@ -294,9 +307,7 @@ void qMRMLWindowLevelWidget::setMRMLVolumeNode(vtkMRMLScalarVolumeNode* volumeNo
range[1] = qMax(900., range[1]);
this->setRange(range[0], range[1]);
}
this->setMRMLVolumeDisplayNode(
volumeNode ?vtkMRMLScalarVolumeDisplayNode::SafeDownCast(
volumeNode->GetVolumeDisplayNode()) : 0);
this->updateDisplayNode();
}
// --------------------------------------------------------------------------
......@@ -325,6 +336,17 @@ void qMRMLWindowLevelWidget::setMaximumValue(double max)
this->setMinMaxRangeValue(this->minimumValue(), max);
}
// --------------------------------------------------------------------------
void qMRMLWindowLevelWidget::updateDisplayNode()
{
Q_D(qMRMLWindowLevelWidget);
this->setMRMLVolumeDisplayNode( d->VolumeNode ?
vtkMRMLScalarVolumeDisplayNode::SafeDownCast(
d->VolumeNode->GetVolumeDisplayNode()) :
0);
}
// --------------------------------------------------------------------------
void qMRMLWindowLevelWidget::updateWidgetFromMRML()
{
......
......@@ -105,6 +105,9 @@ public slots:
protected slots:
/// the volume node has been modified, maybe its displayNode has been
/// changed
void updateDisplayNode();
/// update widget GUI from MRML node
void updateWidgetFromMRML();
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>249</width>
<height>103</height>
<width>208</width>
<height>112</height>
</rect>
</property>
<property name="windowTitle">
......@@ -40,8 +40,8 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="ctkCollapsibleButton" name="CTKCollapsibleButton">
<item row="2" column="0" colspan="2">
<widget class="ctkCollapsibleButton" name="DisplayCollapsibleButton">
<property name="text">
<string>Display</string>
</property>
......@@ -55,7 +55,7 @@
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
<item row="3" column="0" colspan="2">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
......@@ -68,6 +68,24 @@
</property>
</spacer>
</item>
<item row="1" column="0" colspan="2">
<widget class="ctkCollapsibleButton" name="InfoCollapsibleButton">
<property name="text">
<string>Volume Information</string>
</property>
<property name="checked">
<bool>false</bool>
</property>
<property name="contentsFrameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="qMRMLVolumeInfoWidget" name="MRMLVolumeInfoWidget"/>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......@@ -82,6 +100,11 @@
<extends>QWidget</extends>
<header>qMRMLNodeComboBox.h</header>
</customwidget>
<customwidget>
<class>qMRMLVolumeInfoWidget</class>
<extends>QWidget</extends>
<header>qMRMLVolumeInfoWidget.h</header>
</customwidget>
<customwidget>
<class>qSlicerWidget</class>
<extends>QWidget</extends>
......@@ -121,12 +144,28 @@
<slot>setMRMLVolumeNode(vtkMRMLNode*)</slot>
<hints>
<hint type="sourcelabel">
<x>302</x>
<y>19</y>
</hint>
<hint type="destinationlabel">
<x>230</x>
<y>26</y>
<y>414</y>
</hint>
</hints>
</connection>
<connection>
<sender>ActiveVolumeNodeSelector</sender>
<signal>currentNodeChanged(vtkMRMLNode*)</signal>
<receiver>MRMLVolumeInfoWidget</receiver>
<slot>setVolumeNode(vtkMRMLNode*)</slot>
<hints>
<hint type="sourcelabel">
<x>152</x>
<y>11</y>
</hint>
<hint type="destinationlabel">
<x>221</x>
<y>70</y>
<x>155</x>
<y>133</y>
</hint>
</hints>
</connection>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment