Commit e3ab90a2 authored by jcfr's avatar jcfr
Browse files

ENH: Added qMRMLSliceViewWidget classes and its corresponding QtDesigner plugin

First draft of the slice view and its controller widget

git-svn-id: http://svn.slicer.org/Slicer4/trunk@13877 3bd1e089-480b-0410-8dfb-8563597acbee
parent bb95653a
......@@ -48,6 +48,9 @@ SET(qMRMLWidgets_SRCS
qMRMLSceneFactoryWidget.h
qMRMLSceneModel.cxx
qMRMLSceneModel.h
qMRMLSliceViewWidget.cxx
qMRMLSliceViewWidget.h
qMRMLSliceViewWidget_p.h
qMRMLSortFilterProxyModel.cxx
qMRMLSortFilterProxyModel.h
qMRMLTransformProxyModel.cxx
......@@ -82,6 +85,8 @@ SET(qMRMLWidgets_MOC_SRCS
qMRMLNodeTreeSelector.h
qMRMLSceneFactoryWidget.h
qMRMLSceneModel.h
qMRMLSliceViewWidget.h
qMRMLSliceViewWidget_p.h
qMRMLSortFilterProxyModel.h
qMRMLTransformProxyModel.h
qMRMLTreeProxyModel.h
......@@ -97,6 +102,7 @@ SET(qMRMLWidgets_MOC_SRCS
SET(qMRMLWidgets_UI_SRCS
Resources/UI/qMRMLEventLoggerWidget.ui
Resources/UI/qMRMLSceneFactoryWidget.ui
Resources/UI/qMRMLSliceViewWidget.ui
Resources/UI/qMRMLTransformSliders.ui
Resources/UI/qMRMLVolumeThresholdWidget.ui
Resources/UI/qMRMLWindowLevelWidget.ui
......
......@@ -18,6 +18,8 @@ SET(designer_plugin_SRCS
qMRMLNodeSelectorPlugin.h
qMRMLNodeTreeSelectorPlugin.cxx
qMRMLNodeTreeSelectorPlugin.h
qMRMLSliceViewWidgetPlugin.cxx
qMRMLSliceViewWidgetPlugin.h
qMRMLTransformSlidersPlugin.cxx
qMRMLTransformSlidersPlugin.h
qMRMLTreeWidgetPlugin.cxx
......@@ -46,6 +48,7 @@ SET(designer_plugin_MOC_SRCS
qMRMLNodeSelectorPlugin.h
qMRMLNodeTreeSelectorPlugin.h
qMRMLSceneFactoryWidgetPlugin.h
qMRMLSliceViewWidgetPlugin.h
qMRMLTransformSlidersPlugin.h
qMRMLTreeWidgetPlugin.h
qMRMLVolumeThresholdWidgetPlugin.h
......
// qMRML includes
#include "qMRMLSliceViewWidgetPlugin.h"
#include "qMRMLSliceViewWidget.h"
//-----------------------------------------------------------------------------
qMRMLSliceViewWidgetPlugin::qMRMLSliceViewWidgetPlugin(QObject *_parent):QObject(_parent)
{
}
//-----------------------------------------------------------------------------
QWidget *qMRMLSliceViewWidgetPlugin::createWidget(QWidget *_parent)
{
qMRMLSliceViewWidget* _widget = new qMRMLSliceViewWidget("red", _parent);
return _widget;
}
//-----------------------------------------------------------------------------
QString qMRMLSliceViewWidgetPlugin::domXml() const
{
return "<widget class=\"qMRMLSliceViewWidget\" \
name=\"MRMLSliceViewWidget\">\n"
" <property name=\"geometry\">\n"
" <rect>\n"
" <x>0</x>\n"
" <y>0</y>\n"
" <width>200</width>\n"
" <height>200</height>\n"
" </rect>\n"
" </property>\n"
"</widget>\n";
}
//-----------------------------------------------------------------------------
QString qMRMLSliceViewWidgetPlugin::includeFile() const
{
return "qMRMLSliceViewWidget.h";
}
//-----------------------------------------------------------------------------
bool qMRMLSliceViewWidgetPlugin::isContainer() const
{
return false;
}
//-----------------------------------------------------------------------------
QString qMRMLSliceViewWidgetPlugin::name() const
{
return "qMRMLSliceViewWidget";
}
#ifndef __qMRMLSliceViewWidgetPlugin_h
#define __qMRMLSliceViewWidgetPlugin_h
#include "qMRMLWidgetsAbstractPlugin.h"
class QMRML_WIDGETS_PLUGIN_EXPORT qMRMLSliceViewWidgetPlugin :
public QObject,
public qMRMLWidgetsAbstractPlugin
{
Q_OBJECT
public:
qMRMLSliceViewWidgetPlugin(QObject *_parent = 0);
QWidget *createWidget(QWidget *_parent);
QString domXml() const;
// QIcon icon() const;
QString includeFile() const;
bool isContainer() const;
QString name() const;
};
#endif
......@@ -7,6 +7,7 @@
#include "qMRMLNodeComboBoxPlugin.h"
#include "qMRMLNodeSelectorPlugin.h"
#include "qMRMLNodeTreeSelectorPlugin.h"
#include "qMRMLSliceViewWidgetPlugin.h"
#include "qMRMLTransformSlidersPlugin.h"
#include "qMRMLTreeWidgetPlugin.h"
#include "qMRMLVolumeThresholdWidgetPlugin.h"
......@@ -34,6 +35,7 @@ public:
<< new qMRMLNodeComboBoxPlugin
<< new qMRMLNodeSelectorPlugin
<< new qMRMLNodeTreeSelectorPlugin
<< new qMRMLSliceViewWidgetPlugin
<< new qMRMLTransformSlidersPlugin
<< new qMRMLTreeWidgetPlugin
<< new qMRMLVolumeThresholdWidgetPlugin
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>qMRMLSliceViewWidget</class>
<widget class="qMRMLWidget" name="qMRMLSliceViewWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>595</width>
<height>518</height>
</rect>
</property>
<property name="windowTitle">
<string>qMRMLSliceViewWidget</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="QPushButton" name="PushButtonSliceViewName">
<property name="text">
<string>RED</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget" native="true">
<layout class="QGridLayout" name="gridLayout">
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QToolButton" name="toolButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../qMRMLWidgets.qrc">
<normaloff>:/Icons/SliceViewerOR.png</normaloff>:/Icons/SliceViewerOR.png</iconset>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="OrientationSelector">
<property name="toolTip">
<string>Select orientation</string>
</property>
<item>
<property name="text">
<string>Axial</string>
</property>
</item>
<item>
<property name="text">
<string>Sagital</string>
</property>
</item>
<item>
<property name="text">
<string>Coronal</string>
</property>
</item>
<item>
<property name="text">
<string>Reformat</string>
</property>
</item>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="ForgroundLayerOptionButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../qMRMLWidgets.qrc">
<normaloff>:/Icons/SliceViewerFG.png</normaloff>:/Icons/SliceViewerFG.png</iconset>
</property>
<property name="popupMode">
<enum>QToolButton::InstantPopup</enum>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="qMRMLNodeComboBox" name="ForegroundLayerNodeSelector">
<property name="toolTip">
<string>Select the foreground</string>
</property>
<property name="nodeTypes">
<stringlist>
<string>vtkMRMLVolumeNode</string>
</stringlist>
</property>
<property name="noneEnabled">
<bool>true</bool>
</property>
<property name="addEnabled">
<bool>false</bool>
</property>
<property name="removeEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QToolButton" name="LabelMapLayerOptionButton">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../qMRMLWidgets.qrc">
<normaloff>:/Icons/SliceViewerLB.png</normaloff>:/Icons/SliceViewerLB.png</iconset>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="qMRMLNodeComboBox" name="LabelMapSelector">
<property name="toolTip">
<string>Select the label map</string>
</property>
<property name="nodeTypes">
<stringlist>
<string>vtkMRMLVolumeNode</string>
</stringlist>
</property>
<property name="addEnabled">
<bool>false</bool>
</property>
<property name="removeEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QToolButton" name="BackgroundLayerOptionButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../qMRMLWidgets.qrc">
<normaloff>:/Icons/SliceViewerBG.png</normaloff>:/Icons/SliceViewerBG.png</iconset>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="qMRMLNodeComboBox" name="BackgroundLayerNodeSelector">
<property name="toolTip">
<string>Select the background</string>
</property>
<property name="nodeTypes">
<stringlist>
<string>vtkMRMLVolumeNode</string>
</stringlist>
</property>
<property name="noneEnabled">
<bool>true</bool>
</property>
<property name="addEnabled">
<bool>false</bool>
</property>
<property name="removeEnabled">
<bool>false</bool>
</property>
</widget>
</item>
<item row="2" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="LayerLinkToggle">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../qMRMLWidgets.qrc">
<normaloff>:/Icons/LinkOff.png</normaloff>
<normalon>:/Icons/LinkOn.png</normalon>:/Icons/LinkOff.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="LayerVisibilityToggle">
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="../qMRMLWidgets.qrc">
<normaloff>:/Icons/VisibleOff.png</normaloff>
<normalon>:/Icons/VisibleOn.png</normalon>:/Icons/VisibleOff.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="checked">
<bool>false</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="SliceMoreOptionButton">
<property name="text">
<string/>
</property>
<property name="icon">
<iconset resource="../qMRMLWidgets.qrc">
<normaloff>:/Icons/SliceMoreOptions.png</normaloff>:/Icons/SliceMoreOptions.png</iconset>
</property>
<property name="iconSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="ctkSliderSpinBoxWidget" name="SliceOffsetSlider"/>
</item>
</layout>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>4</number>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="margin">
<number>0</number>
</property>
<item>
<widget class="ctkVTKSliceView" name="VTKSliceView">
<property name="renderEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>ctkVTKSliceView</class>
<extends>QWidget</extends>
<header>ctkVTKSliceView.h</header>
</customwidget>
<customwidget>
<class>ctkSliderSpinBoxWidget</class>
<extends>QWidget</extends>
<header>ctkSliderSpinBoxWidget.h</header>
</customwidget>
<customwidget>
<class>qMRMLNodeComboBox</class>
<extends>QComboBox</extends>
<header>qMRMLNodeComboBox.h</header>
</customwidget>
<customwidget>
<class>qMRMLWidget</class>
<extends>QWidget</extends>
<header>qMRMLWidget.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<resources>
<include location="../qMRMLWidgets.qrc"/>
</resources>
<connections>
<connection>
<sender>qMRMLSliceViewWidget</sender>
<signal>mrmlSceneChanged(vtkMRMLScene*)</signal>
<receiver>BackgroundLayerNodeSelector</receiver>
<slot>setMRMLScene(vtkMRMLScene*)</slot>
<hints>
<hint type="sourcelabel">
<x>572</x>
<y>392</y>
</hint>
<hint type="destinationlabel">
<x>499</x>
<y>169</y>
</hint>
</hints>
</connection>
<connection>
<sender>qMRMLSliceViewWidget</sender>
<signal>mrmlSceneChanged(vtkMRMLScene*)</signal>
<receiver>LabelMapSelector</receiver>
<slot>setMRMLScene(vtkMRMLScene*)</slot>
<hints>
<hint type="sourcelabel">
<x>77</x>
<y>377</y>
</hint>
<hint type="destinationlabel">
<x>191</x>
<y>163</y>
</hint>
</hints>
</connection>
<connection>
<sender>qMRMLSliceViewWidget</sender>
<signal>mrmlSceneChanged(vtkMRMLScene*)</signal>
<receiver>ForegroundLayerNodeSelector</receiver>
<slot>setMRMLScene(vtkMRMLScene*)</slot>
<hints>
<hint type="sourcelabel">
<x>661</x>
<y>362</y>
</hint>
<hint type="destinationlabel">
<x>594</x>
<y>118</y>
</hint>
</hints>
</connection>
</connections>
</ui>
......@@ -3,6 +3,9 @@
<file>Icons/VisibleOff.png</file>
<file>Icons/VisibleOn.png</file>
<file>Icons/VisibleOrInvisible.png</file>
<file>Icons/LinkOff.png</file>
<file>Icons/LinkOn.png</file>
<file>Icons/LayoutChooseView.png</file>
<file>Icons/LayoutCompareView.png</file>
......@@ -17,5 +20,11 @@
<file>Icons/LayoutSideBySideCompareView.png</file>
<file>Icons/LayoutTabbed3DView.png</file>
<file>Icons/LayoutTabbedSliceView.png</file>
<file>Icons/SliceMoreOptions.png</file>
<file>Icons/SliceViewerBG.png</file>
<file>Icons/SliceViewerFG.png</file>
<file>Icons/SliceViewerLB.png</file>
<file>Icons/SliceViewerOR.png</file>
</qresource>
</RCC>
// Qt includes
// #include <QStringList>
#include <QDebug>
#include <QMenu>
// CTK includes
#include <ctkVTKSliceView.h>
#include <ctkLogger.h>
// qMRML includes
#include "qMRMLSliceViewWidget.h"
#include "qMRMLSliceViewWidget_p.h"
// MRML includes
#include <vtkMRMLSliceNode.h>
#include <vtkMRMLSliceCompositeNode.h>
#include <vtkMRMLScene.h>
// VTK includes
#include <vtkImageData.h>
// Convenient macro
#define VTK_CREATE(type, name) \
vtkSmartPointer<type> name = vtkSmartPointer<type>::New()
//--------------------------------------------------------------------------
static ctkLogger logger("org.slicer.libs.qmrmlwidgets.qMRMLSliceViewWidget");
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
// qMRMLSliceViewPrivate methods
//---------------------------------------------------------------------------
qMRMLSliceViewWidgetPrivate::qMRMLSliceViewWidgetPrivate()
{
logger.setTrace();
this->MRMLSliceNode = 0;
this->MRMLSliceCompositeNode = 0;
this->SliceOrientationToDescription["Axial"] = QLatin1String("I <-----> S");
this->SliceOrientationToDescription["Sagittal"] = QLatin1String("L <-----> R");
this->SliceOrientationToDescription["Coronal"] = QLatin1String("P <----> A");
this->SliceOrientationToDescription["Reformat"] = QLatin1String("Oblique");
}
//---------------------------------------------------------------------------
qMRMLSliceViewWidgetPrivate::~qMRMLSliceViewWidgetPrivate()
{
}
//---------------------------------------------------------------------------
void qMRMLSliceViewWidgetPrivate::setupUi(qMRMLWidget* widget)
{
CTK_P(qMRMLSliceViewWidget);
this->Ui_qMRMLSliceViewWidget::setupUi(widget);
// Set LabelMapSelector attributes
this->LabelMapSelector->addAttribute("vtkMRMLVolumeNode", "LabelMap", "1");
// Connect Orientation selector
this->connect(this->OrientationSelector, SIGNAL(currentIndexChanged(QString)),
p, SLOT(setSliceOrientation(QString)));
// Connect Foreground layer selector
this->connect(this->ForegroundLayerNodeSelector, SIGNAL(currentNodeChanged(vtkMRMLNode*)),
SLOT(onForegroundLayerNodeSelected(vtkMRMLNode*)));
// Connect Background layer selector
this->connect(this->BackgroundLayerNodeSelector, SIGNAL(currentNodeChanged(vtkMRMLNode*)),
SLOT(onBackgroundLayerNodeSelected(vtkMRMLNode*)));
// Connect Label map selector