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 99cef5ba authored by alexy's avatar alexy
Browse files

ENH: added qt volume display widgets


git-svn-id: http://svn.slicer.org/Slicer4/trunk@12327 3bd1e089-480b-0410-8dfb-8563597acbee
parent 1bb29ba9
......@@ -43,7 +43,7 @@ qMRMLWindowLevelWidget::qMRMLWindowLevelWidget(QWidget* _parent) : Superclass(_p
// TODO replace with double window/level
this->connect(d->WindowLevelRangeSlider, SIGNAL(rangeValuesChanged(int,int)),
SLOT(setWindowLevel(int, int)));
SLOT(setMinMaxRange(int, int)));
this->connect(d->AutoManualComboBox, SIGNAL(currentIndexChanged(int)),
SLOT(setAutoWindowLevel(int)));
......@@ -96,11 +96,34 @@ void qMRMLWindowLevelWidget::setWindowLevel(double window, double level)
}
}
// --------------------------------------------------------------------------
void qMRMLWindowLevelWidget::setMinMaxRange(double min, double max)
{
if (this->VolumeDisplayNode)
{
double oldWindow = this->VolumeDisplayNode->GetWindow();
double oldLevel = this->VolumeDisplayNode->GetLevel();
double window = max - min;
double level = 0.5*(min+max);
int disabledModify = this->VolumeDisplayNode->StartModify();
this->VolumeDisplayNode->SetWindow(window);
this->VolumeDisplayNode->SetLevel(level);
if (oldWindow != this->VolumeDisplayNode->GetWindow() ||
oldLevel != this->VolumeDisplayNode->GetLevel())
{
this->VolumeDisplayNode->SetAutoWindowLevel(0);
}
this->VolumeDisplayNode->EndModify(disabledModify);
}
}
// TODO remove when range becomes double
// --------------------------------------------------------------------------
void qMRMLWindowLevelWidget::setWindowLevel(int window, int level)
void qMRMLWindowLevelWidget::setMinMaxRange(int min, int max)
{
this->setWindowLevel((double)window, (double)level);
this->setMinMaxRange((double)min, (double)max);
}
// --------------------------------------------------------------------------
......
......@@ -70,10 +70,14 @@ public slots:
void setLevel(double level);
///
/// Sset window/level in once
/// Set window/level in once
void setWindowLevel(double window, double level);
///
/// Set min/max range
void setMinMaxRange(double min, double max);
// TODO remove when range becomes double
void setWindowLevel(int window, int level);
void setMinMaxRange(int min, int max);
///
/// Set the MRML node of interest
......
......@@ -17,16 +17,23 @@ SET(qt_module_SRCS
qSlicerVolumesModule.h
qSlicerVolumesModuleWidget.cxx
qSlicerVolumesModuleWidget.h
qSlicerVolumeDisplayWidget.cxx
qSlicerVolumeDisplayWidget.h
qSlicerScalarVolumeDisplayWidget.cxx
qSlicerScalarVolumeDisplayWidget.h
)
# Headers that should run through moc
SET(qt_module_MOC_SRCS
qSlicerVolumesModuleWidget.h
qSlicerVolumeDisplayWidget.h
qSlicerScalarVolumeDisplayWidget.h
)
# UI files
SET(qt_module_UI_SRCS
Resources/UI/qSlicerVolumesModule.ui
Resources/UI/qSlicerScalarVolumeDisplayWidget.ui
)
# Additional Target libraries
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>qSlicerScalarVolumeDisplayWidget</class>
<widget class="qSlicerWidget" name="qSlicerScalarVolumeDisplayWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>549</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="qMRMLWindowLevelWidget" name="MRMLWindowLevelWidget"/>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>qMRMLWindowLevelWidget</class>
<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/>
</ui>
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>qSlicerScalarVolumeDisplayWidget</class>
<widget class="qSlicerWidget" name="qSlicerVolumeDisplayWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>681</width>
<height>549</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
</layout>
</widget>
<resources/>
<connections/>
</ui>
......@@ -53,7 +53,7 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="qMRMLWindowLevelWidget" name="MRMLWindowLevelWidget"/>
<widget class="qSlicerVolumeDisplayWidget" name="VolumeDisplayWidget"/>
</item>
</layout>
</widget>
......@@ -106,7 +106,7 @@
<connection>
<sender>ActiveVolumeNodeSelector</sender>
<signal>currentNodeChanged(vtkMRMLNode*)</signal>
<receiver>MRMLWindowLevelWidget</receiver>
<receiver>VolumeDisplayWidget</receiver>
<slot>setMRMLVolumeNode(vtkMRMLNode*)</slot>
<hints>
<hint type="sourcelabel">
......
#include "qSlicerScalarVolumeDisplayWidget.h"
#include "ui_qSlicerScalarVolumeDisplayWidget.h"
#include "vtkMRMLScalarVolumeNode.h"
// QT includes
#include <QDebug>
//-----------------------------------------------------------------------------
class qSlicerScalarVolumeDisplayWidgetPrivate: public qCTKPrivate<qSlicerScalarVolumeDisplayWidget>,
public Ui_qSlicerScalarVolumeDisplayWidget
{
public:
};
// --------------------------------------------------------------------------
qSlicerScalarVolumeDisplayWidget::qSlicerScalarVolumeDisplayWidget(QWidget* _parent) : Superclass(_parent)
{
QCTK_INIT_PRIVATE(qSlicerScalarVolumeDisplayWidget);
QCTK_D(qSlicerScalarVolumeDisplayWidget);
d->setupUi(this);
// disable as there is not MRML Node associated with the widget
this->setEnabled(false);
}
// --------------------------------------------------------------------------
void qSlicerScalarVolumeDisplayWidget::setMRMLVolumeNode(vtkMRMLNode* node)
{
this->setMRMLVolumeNode(vtkMRMLScalarVolumeNode::SafeDownCast(node));
}
// --------------------------------------------------------------------------
void qSlicerScalarVolumeDisplayWidget::setMRMLVolumeNode(vtkMRMLScalarVolumeNode* volumeNode)
{
QCTK_D(qSlicerScalarVolumeDisplayWidget);
if (volumeNode)
{
d->MRMLWindowLevelWidget->setMRMLVolumeNode(volumeNode);
this->setEnabled(true);
}
}
#ifndef __qSlicerScalarVolumeDisplayWidget_h
#define __qSlicerScalarVolumeDisplayWidget_h
/// qVTK includes
#include <qVTKObject.h>
/// qCTK includes
#include <qCTKPimpl.h>
/// QT includes
#include <QWidget>
#include <qSlicerWidget.h>
#include "qSlicerVolumesModuleExport.h"
class vtkMRMLNode;
class vtkMRMLScalarVolumeNode;
class qSlicerScalarVolumeDisplayWidgetPrivate;
class Q_SLICER_QTMODULES_VOLUMES_EXPORT qSlicerScalarVolumeDisplayWidget : public qSlicerWidget
{
Q_OBJECT
public:
/// Constructors
typedef qSlicerWidget Superclass;
explicit qSlicerScalarVolumeDisplayWidget(QWidget* parent);
virtual ~qSlicerScalarVolumeDisplayWidget(){}
public slots:
///
/// Set the MRML node of interest
void setMRMLVolumeNode(vtkMRMLScalarVolumeNode* volumeNode);
void setMRMLVolumeNode(vtkMRMLNode* node);
protected slots:
protected:
private:
QCTK_DECLARE_PRIVATE(qSlicerScalarVolumeDisplayWidget);
};
#endif
#include "qSlicerVolumeDisplayWidget.h"
#include "qSlicerScalarVolumeDisplayWidget.h"
#include "vtkMRMLVolumeNode.h"
// QT includes
#include <QDebug>
// --------------------------------------------------------------------------
qSlicerVolumeDisplayWidget::qSlicerVolumeDisplayWidget(QWidget* _parent) : Superclass(_parent)
{
this->ScalarVolumeDisplayWidget = new qSlicerScalarVolumeDisplayWidget(this);
this->addWidget(this->ScalarVolumeDisplayWidget);
}
// --------------------------------------------------------------------------
void qSlicerVolumeDisplayWidget::setMRMLVolumeNode(vtkMRMLNode* volumeNode)
{
if (volumeNode)
{
if (std::string(volumeNode->GetClassName()) == std::string("vtkMRMLScalarVolumeNode"))
{
this->setCurrentWidget(this->ScalarVolumeDisplayWidget);
this->ScalarVolumeDisplayWidget->setMRMLVolumeNode(volumeNode);
}
}
}
#ifndef __qSlicerVolumeDisplayWidget_h
#define __qSlicerVolumeDisplayWidget_h
#include <QStackedWidget>
#include "qSlicerVolumesModuleExport.h"
class vtkMRMLNode;
class qSlicerScalarVolumeDisplayWidget;
class Q_SLICER_QTMODULES_VOLUMES_EXPORT qSlicerVolumeDisplayWidget : public QStackedWidget
{
Q_OBJECT
public:
/// Constructors
typedef QStackedWidget Superclass;
explicit qSlicerVolumeDisplayWidget(QWidget* parent=0);
virtual ~qSlicerVolumeDisplayWidget(){}
public slots:
///
/// Set the MRML node of interest
void setMRMLVolumeNode(vtkMRMLNode* node);
private:
qSlicerScalarVolumeDisplayWidget* ScalarVolumeDisplayWidget;
};
#endif
......@@ -19,6 +19,10 @@ void qSlicerVolumesModuleWidget::setup()
{
QCTK_D(qSlicerVolumesModuleWidget);
d->setupUi(this);
QObject::connect(d->ActiveVolumeNodeSelector, SIGNAL(currentNodeChanged(vtkMRMLNode*)), this,
SLOT(setActiveVolumeNode(vtkMRMLNode*)));
}
//-----------------------------------------------------------------------------
......@@ -26,3 +30,10 @@ QAction* qSlicerVolumesModuleWidget::showModuleAction()
{
return new QAction(QIcon(":/Icons/Volumes.png"), tr("Show Volumes module"), this);
}
//-----------------------------------------------------------------------------
void qSlicerVolumesModuleWidget::setActiveVolumeNode(vtkMRMLNode* node)
{
QCTK_D(qSlicerVolumesModuleWidget);
d->VolumeDisplayWidget->setMRMLVolumeNode(node);
}
......@@ -11,6 +11,7 @@
#include "qSlicerVolumesModuleExport.h"
class qSlicerVolumesModuleWidgetPrivate;
class vtkMRMLNode;
class Q_SLICER_QTMODULES_VOLUMES_EXPORT qSlicerVolumesModuleWidget :
public qSlicerAbstractModuleWidget
......@@ -24,6 +25,10 @@ public:
virtual QAction* showModuleAction();
public slots:
void setActiveVolumeNode(vtkMRMLNode* node);
protected:
virtual void setup();
......
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