An update will be applied December 9th, between 12PM and 1:00PM EST (UTC -5:00). The site may be slow during that time.

Commit 11ebf8de authored by finetjul's avatar finetjul
Browse files

ENH: Add histogram widget into the Volume module panel: qSlicerScalarVolumeDisplayWidget

git-svn-id: http://svn.slicer.org/Slicer4/trunk@13677 3bd1e089-480b-0410-8dfb-8563597acbee
parent 1bdb00af
......@@ -15,14 +15,48 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="qMRMLVolumeThresholdWidget" name="MRMLVolumeThresholdWidget"/>
<widget class="qMRMLVolumeThresholdWidget" name="MRMLVolumeThresholdWidget" native="true"/>
</item>
<item>
<widget class="qMRMLWindowLevelWidget" name="MRMLWindowLevelWidget"/>
<widget class="qMRMLWindowLevelWidget" name="MRMLWindowLevelWidget" native="true"/>
</item>
<item>
<widget class="ctkTransferFunctionWidget" name="TransferFunctionWidget">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>150</height>
</size>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ctkTransferFunctionWidget</class>
<extends>QGraphicsView</extends>
<header>ctkTransferFunctionWidget.h</header>
</customwidget>
<customwidget>
<class>qSlicerWidget</class>
<extends>QWidget</extends>
<header>qSlicerWidget.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>qMRMLVolumeThresholdWidget</class>
<extends>QWidget</extends>
......@@ -33,12 +67,6 @@
<extends>QWidget</extends>
<header>qMRMLWindowLevelWidget.h</header>
</customwidget>
<customwidget>
<class>qSlicerWidget</class>
<extends>QWidget</extends>
<header>qSlicerWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources/>
<connections/>
......
......@@ -6,38 +6,34 @@
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>549</height>
<width>525</width>
<height>319</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Active Volume</string>
</property>
</widget>
</item>
<item>
<widget class="qMRMLNodeComboBox" name="ActiveVolumeNodeSelector">
<property name="nodeTypes">
<stringlist>
<string>vtkMRMLVolumeNode</string>
</stringlist>
</property>
<property name="addEnabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="ActiveVolumeLabel">
<property name="text">
<string>Active Volume</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="qMRMLNodeComboBox" name="ActiveVolumeNodeSelector">
<property name="nodeTypes" stdset="0">
<stringlist>
<string>vtkMRMLVolumeNode</string>
</stringlist>
</property>
<property name="addEnabled" stdset="0">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<item row="1" column="0" colspan="2">
<widget class="ctkCollapsibleButton" name="CTKCollapsibleButton">
<property name="text">
<string>Display</string>
......@@ -47,11 +43,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="qSlicerVolumeDisplayWidget" name="VolumeDisplayWidget" native="true"/>
</item>
</layout>
<widget class="qSlicerVolumeDisplayWidget" name="VolumeDisplayWidget" native="true"/>
</item>
</layout>
</widget>
......
......@@ -4,22 +4,60 @@
// Qt includes
#include <QDebug>
// CTK includes
#include <ctkTransferFunctionScene.h>
#include <ctkTransferFunctionBarsItem.h>
#include <ctkVTKHistogram.h>
// MRML includes
#include "vtkMRMLScalarVolumeNode.h"
// VTK includes
#include <vtkPointData.h>
//-----------------------------------------------------------------------------
class qSlicerScalarVolumeDisplayWidgetPrivate: public ctkPrivate<qSlicerScalarVolumeDisplayWidget>,
public Ui_qSlicerScalarVolumeDisplayWidget
{
public:
qSlicerScalarVolumeDisplayWidgetPrivate();
~qSlicerScalarVolumeDisplayWidgetPrivate();
void init();
ctkVTKHistogram* Histogram;
};
//-----------------------------------------------------------------------------
qSlicerScalarVolumeDisplayWidgetPrivate::qSlicerScalarVolumeDisplayWidgetPrivate()
{
this->Histogram = new ctkVTKHistogram();
}
//-----------------------------------------------------------------------------
qSlicerScalarVolumeDisplayWidgetPrivate::~qSlicerScalarVolumeDisplayWidgetPrivate()
{
delete this->Histogram;
this->Histogram = 0;
}
//-----------------------------------------------------------------------------
void qSlicerScalarVolumeDisplayWidgetPrivate::init()
{
CTK_P(qSlicerScalarVolumeDisplayWidget);
this->setupUi(p);
qobject_cast<ctkTransferFunctionScene*>(this->TransferFunctionWidget->scene())
->setTransferFunction(this->Histogram);
ctkTransferFunctionBarsItem* barsItem =
new ctkTransferFunctionBarsItem(this->Histogram);
barsItem->setBarWidth(1.);
this->TransferFunctionWidget->scene()->addItem(barsItem);
}
// --------------------------------------------------------------------------
qSlicerScalarVolumeDisplayWidget::qSlicerScalarVolumeDisplayWidget(QWidget* _parent) : Superclass(_parent)
{
CTK_INIT_PRIVATE(qSlicerScalarVolumeDisplayWidget);
CTK_D(qSlicerScalarVolumeDisplayWidget);
d->setupUi(this);
d->init();
// disable as there is not MRML Node associated with the widget
this->setEnabled(false);
......@@ -35,11 +73,9 @@ void qSlicerScalarVolumeDisplayWidget::setMRMLVolumeNode(vtkMRMLNode* node)
void qSlicerScalarVolumeDisplayWidget::setMRMLVolumeNode(vtkMRMLScalarVolumeNode* volumeNode)
{
CTK_D(qSlicerScalarVolumeDisplayWidget);
if (volumeNode)
{
d->MRMLWindowLevelWidget->setMRMLVolumeNode(volumeNode);
d->MRMLVolumeThresholdWidget->setMRMLVolumeNode(volumeNode);
this->setEnabled(true);
}
d->MRMLWindowLevelWidget->setMRMLVolumeNode(volumeNode);
d->MRMLVolumeThresholdWidget->setMRMLVolumeNode(volumeNode);
d->Histogram->setDataArray(volumeNode->GetImageData()->GetPointData()->GetScalars());
d->Histogram->build();
this->setEnabled(volumeNode != 0);
}
......@@ -17,12 +17,13 @@ qSlicerVolumeDisplayWidget::qSlicerVolumeDisplayWidget(QWidget* _parent) : Super
// --------------------------------------------------------------------------
void qSlicerVolumeDisplayWidget::setMRMLVolumeNode(vtkMRMLNode* volumeNode)
{
if (volumeNode)
{
if (std::string(volumeNode->GetClassName()) == std::string("vtkMRMLScalarVolumeNode"))
if (volumeNode == 0)
{
this->setCurrentWidget(this->ScalarVolumeDisplayWidget);
this->ScalarVolumeDisplayWidget->setMRMLVolumeNode(volumeNode);
return;
}
if (volumeNode->IsA("vtkMRMLScalarVolumeNode"))
{
this->ScalarVolumeDisplayWidget->setMRMLVolumeNode(volumeNode);
this->setCurrentWidget(this->ScalarVolumeDisplayWidget);
}
}
}
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