diff --git a/VirtualReality/Widgets/CMakeLists.txt b/VirtualReality/Widgets/CMakeLists.txt index a486627..ebe6039 100644 --- a/VirtualReality/Widgets/CMakeLists.txt +++ b/VirtualReality/Widgets/CMakeLists.txt @@ -12,6 +12,8 @@ set(${KIT}_INCLUDE_DIRECTORIES ${vtkSlicerVirtualRealityModuleMRML_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS} ${qSlicerSubjectHierarchyModuleWidgets_INCLUDE_DIRS} + ${qSlicerSegmentationsModuleWidgets_INCLUDE_DIRS} + ${qSlicerSegmentationsEditorEffects_INCLUDE_DIRS} ) set(${KIT}_SRCS @@ -24,6 +26,8 @@ set(${KIT}_SRCS qMRMLVirtualRealityHomeWidget.h qMRMLVirtualRealityDataModuleWidget.cxx qMRMLVirtualRealityDataModuleWidget.h + qMRMLVirtualRealitySegmentEditorWidget.cxx + qMRMLVirtualRealitySegmentEditorWidget.h ) set(${KIT}_MOC_SRCS @@ -32,11 +36,13 @@ set(${KIT}_MOC_SRCS qMRML${MODULE_NAME}View_p.h qMRMLVirtualRealityHomeWidget.h qMRMLVirtualRealityDataModuleWidget.h + qMRMLVirtualRealitySegmentEditorWidget.h ) set(${KIT}_UI_SRCS Resources/UI/qMRMLVirtualRealityHomeWidget.ui Resources/UI/qMRMLVirtualRealityDataModuleWidget.ui + Resources/UI/qMRMLVirtualRealitySegmentEditorWidget.ui Resources/UI/qMRML${MODULE_NAME}TransformWidget.ui ) @@ -50,6 +56,8 @@ set(${KIT}_TARGET_LIBRARIES vtkSlicerCamerasModuleLogic ${VTK_LIBRARIES} qSlicerSubjectHierarchyModuleWidgets + qSlicerSegmentationsModuleWidgets + ) #----------------------------------------------------------------------------- diff --git a/VirtualReality/Widgets/Resources/UI/qMRMLVirtualRealitySegmentEditorWidget.ui b/VirtualReality/Widgets/Resources/UI/qMRMLVirtualRealitySegmentEditorWidget.ui new file mode 100644 index 0000000..9cf629d --- /dev/null +++ b/VirtualReality/Widgets/Resources/UI/qMRMLVirtualRealitySegmentEditorWidget.ui @@ -0,0 +1,79 @@ + + + qMRMLVirtualRealitySegmentEditorWidget + + + + 0 + 0 + 589 + 590 + + + + + 100 + 0 + + + + qMRMLSegmentEditorWidget + + + + 4 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + + qMRMLWidget + QWidget +
qMRMLWidget.h
+ 1 +
+ + qMRMLSegmentEditorWidget + qMRMLWidget +
qMRMLSegmentEditorWidget.h
+ 1 +
+
+ + + + + + + qMRMLVirtualRealitySegmentEditorWidget + mrmlSceneChanged(vtkMRMLScene*) + SegmentEditorWidget + setMRMLScene(vtkMRMLScene*) + + + 189 + 581 + + + 189 + 533 + + + + +
diff --git a/VirtualReality/Widgets/qMRMLVirtualRealityHomeWidget.cxx b/VirtualReality/Widgets/qMRMLVirtualRealityHomeWidget.cxx index 1109042..a3704ce 100644 --- a/VirtualReality/Widgets/qMRMLVirtualRealityHomeWidget.cxx +++ b/VirtualReality/Widgets/qMRMLVirtualRealityHomeWidget.cxx @@ -23,10 +23,14 @@ #include "qMRMLVirtualRealityHomeWidget.h" #include "ui_qMRMLVirtualRealityHomeWidget.h" #include "qMRMLVirtualRealityDataModuleWidget.h" +#include "qMRMLVirtualRealitySegmentEditorWidget.h" // VirtualReality MRML includes #include "vtkMRMLVirtualRealityViewNode.h" +// Segmentations includes +#include "vtkMRMLSegmentEditorNode.h" + // VTK includes #include @@ -55,6 +59,7 @@ class qMRMLVirtualRealityHomeWidgetPrivate : public Ui_qMRMLVirtualRealityHomeWi /// Virtual reality view MRML node vtkWeakPointer VirtualRealityViewNode; qMRMLVirtualRealityDataModuleWidget* DataModuleWidget; + qMRMLVirtualRealitySegmentEditorWidget* SegmentEditorWidget; }; //----------------------------------------------------------------------------- @@ -63,6 +68,7 @@ qMRMLVirtualRealityHomeWidgetPrivate::qMRMLVirtualRealityHomeWidgetPrivate(qMRML { this->VirtualRealityViewNode = nullptr; this->DataModuleWidget = nullptr; + this->SegmentEditorWidget = nullptr; } //----------------------------------------------------------------------------- @@ -400,8 +406,18 @@ void qMRMLVirtualRealityHomeWidget::registerDefaultModules() d->DataModuleWidget = new qMRMLVirtualRealityDataModuleWidget(this); d->DataModuleWidget->setMRMLScene(this->mrmlScene()); + d->SegmentEditorWidget = new qMRMLVirtualRealitySegmentEditorWidget(this); + d->SegmentEditorWidget->setMRMLScene(this->mrmlScene()); QIcon dataIcon(QPixmap(":/Icons/SubjectHierarchy.png")); + QIcon segmentEditorIcon(QPixmap(":/Icons/SegmentEditor.png")); this->addModuleButton(d->DataModuleWidget, dataIcon); + this->addModuleButton(d->SegmentEditorWidget, segmentEditorIcon); +} + +void qMRMLVirtualRealityHomeWidget::setMRMLSegmentEditorNode(vtkMRMLSegmentEditorNode* newSegmentEditorNode) +{ + Q_D(qMRMLVirtualRealityHomeWidget); + d->SegmentEditorWidget->setMRMLSegmentEditorNode(newSegmentEditorNode); } diff --git a/VirtualReality/Widgets/qMRMLVirtualRealityHomeWidget.h b/VirtualReality/Widgets/qMRMLVirtualRealityHomeWidget.h index 59e44e0..31e4559 100644 --- a/VirtualReality/Widgets/qMRMLVirtualRealityHomeWidget.h +++ b/VirtualReality/Widgets/qMRMLVirtualRealityHomeWidget.h @@ -38,6 +38,7 @@ class vtkMRMLVirtualRealityViewNode; class qMRMLVirtualRealityHomeWidgetPrivate; +class vtkMRMLSegmentEditorNode; /// \ingroup SlicerVirtualReality_Widgets class Q_SLICER_QTMODULES_VIRTUALREALITY_WIDGETS_EXPORT qMRMLVirtualRealityHomeWidget : public qMRMLWidget @@ -62,8 +63,11 @@ class Q_SLICER_QTMODULES_VIRTUALREALITY_WIDGETS_EXPORT qMRMLVirtualRealityHomeWi /// \param icon The icon that appears on the button in the home widget Q_INVOKABLE void addModuleButton(QWidget* moduleWidget, QIcon& icon); - /// Register default modules: Data - Q_INVOKABLE void registerDefaultModules(); + /// Register default modules: Data, Segment Editor + Q_INVOKABLE void registerDefaultModules(); + + /// Set the segment editor node for the segment editor widget + Q_INVOKABLE void setMRMLSegmentEditorNode(vtkMRMLSegmentEditorNode* newSegmentEditorNode); public slots: /// Set virtual reality view MRML node diff --git a/VirtualReality/Widgets/qMRMLVirtualRealitySegmentEditorWidget.cxx b/VirtualReality/Widgets/qMRMLVirtualRealitySegmentEditorWidget.cxx new file mode 100644 index 0000000..5640241 --- /dev/null +++ b/VirtualReality/Widgets/qMRMLVirtualRealitySegmentEditorWidget.cxx @@ -0,0 +1,118 @@ +/*============================================================================== + + Copyright (c) Laboratory for Percutaneous Surgery (PerkLab) + Queen's University, Kingston, ON, Canada. All Rights Reserved. + + See COPYRIGHT.txt + or http://www.slicer.org/copyright/copyright.txt for details. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + This file was originally developed by Csaba Pinter, PerkLab, Queen's University + and was supported through the Applied Cancer Research Unit program of Cancer Care + Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care + and CANARIE. + +==============================================================================*/ + +// VirtualReality Widgets includes +#include "qMRMLVirtualRealitySegmentEditorWidget.h" +#include "ui_qMRMLVirtualRealitySegmentEditorWidget.h" + +// VirtualReality MRML includes +#include "vtkMRMLVirtualRealityViewNode.h" + +// Segmentations includes +#include "vtkMRMLSegmentEditorNode.h" + +// Qt includes +#include +#include "qpushbutton.h" +#include "ctkMenuButton.h" +#include "qtoolbutton.h" + +//----------------------------------------------------------------------------- +class qMRMLVirtualRealitySegmentEditorWidgetPrivate : public Ui_qMRMLVirtualRealitySegmentEditorWidget +{ + Q_DECLARE_PUBLIC(qMRMLVirtualRealitySegmentEditorWidget); + +protected: + qMRMLVirtualRealitySegmentEditorWidget* const q_ptr; + +public: + qMRMLVirtualRealitySegmentEditorWidgetPrivate(qMRMLVirtualRealitySegmentEditorWidget& object); + virtual ~qMRMLVirtualRealitySegmentEditorWidgetPrivate(); + + void init(); +}; + +//----------------------------------------------------------------------------- +qMRMLVirtualRealitySegmentEditorWidgetPrivate::qMRMLVirtualRealitySegmentEditorWidgetPrivate(qMRMLVirtualRealitySegmentEditorWidget& object) + : q_ptr(&object) +{ +} + +//----------------------------------------------------------------------------- +qMRMLVirtualRealitySegmentEditorWidgetPrivate::~qMRMLVirtualRealitySegmentEditorWidgetPrivate() +{ +} + +//----------------------------------------------------------------------------- +void qMRMLVirtualRealitySegmentEditorWidgetPrivate::init() +{ + Q_Q(qMRMLVirtualRealitySegmentEditorWidget); + this->setupUi(q); + + //List of effects to be used in VR; effects not listed here are not shown in the widget + QStringList effectNameOrder; + effectNameOrder.append("None"); + effectNameOrder.append("Paint"); + effectNameOrder.append("Erase"); + effectNameOrder.append("Level tracing"); + effectNameOrder.append("Grow from seeds"); + effectNameOrder.append("Smoothing"); + effectNameOrder.append("Scissors"); + effectNameOrder.append("Logical Operators"); + this->SegmentEditorWidget->setEffectNameOrder(effectNameOrder); + + //Hide unneeded effects and buttons + this->SegmentEditorWidget->setUnorderedEffectsVisible(false); + this->SegmentEditorWidget->setSwitchToSegmentationsButtonVisible(false); + this->SegmentEditorWidget->findChild("SpecifyGeometryButton")->setVisible(false); + this->SegmentEditorWidget->findChild("SliceRotateWarningButton")->setVisible(false); + this->SegmentEditorWidget->findChild("Show3DButton")->setVisible(false); +} + +//----------------------------------------------------------------------------- +// qMRMLVirtualRealitySegmentEditorWidget methods + +//----------------------------------------------------------------------------- +qMRMLVirtualRealitySegmentEditorWidget::qMRMLVirtualRealitySegmentEditorWidget(QWidget* _parent) + : qMRMLWidget(_parent) + , d_ptr(new qMRMLVirtualRealitySegmentEditorWidgetPrivate(*this)) +{ + Q_D(qMRMLVirtualRealitySegmentEditorWidget); + d->init(); + + this->updateWidgetFromMRML(); +} + +//----------------------------------------------------------------------------- +qMRMLVirtualRealitySegmentEditorWidget::~qMRMLVirtualRealitySegmentEditorWidget() += default; + +//----------------------------------------------------------------------------- +void qMRMLVirtualRealitySegmentEditorWidget::updateWidgetFromMRML() +{ + //Q_D(qMRMLVirtualRealitySegmentEditorWidget); +} + +void qMRMLVirtualRealitySegmentEditorWidget::setMRMLSegmentEditorNode(vtkMRMLSegmentEditorNode* newSegmentEditorNode) +{ + Q_D(qMRMLVirtualRealitySegmentEditorWidget); + d->SegmentEditorWidget->setMRMLSegmentEditorNode(newSegmentEditorNode); +} diff --git a/VirtualReality/Widgets/qMRMLVirtualRealitySegmentEditorWidget.h b/VirtualReality/Widgets/qMRMLVirtualRealitySegmentEditorWidget.h new file mode 100644 index 0000000..93c10f9 --- /dev/null +++ b/VirtualReality/Widgets/qMRMLVirtualRealitySegmentEditorWidget.h @@ -0,0 +1,67 @@ +/*============================================================================== + + Copyright (c) Laboratory for Percutaneous Surgery (PerkLab) + Queen's University, Kingston, ON, Canada. All Rights Reserved. + + See COPYRIGHT.txt + or http://www.slicer.org/copyright/copyright.txt for details. + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + This file was originally developed by Csaba Pinter, PerkLab, Queen's University + and was supported through the Applied Cancer Research Unit program of Cancer Care + Ontario with funds provided by the Ontario Ministry of Health and Long-Term Care + and CANARIE. + +==============================================================================*/ + +#ifndef __qMRMLVirtualRealitySegmentEditorWidget_h +#define __qMRMLVirtualRealitySegmentEditorWidget_h + +// VirtualReality Widgets includes +#include "qSlicerVirtualRealityModuleWidgetsExport.h" + +// MRMLWidgets includes +#include "qMRMLWidget.h" + +// CTK includes +#include +#include + +class qMRMLVirtualRealitySegmentEditorWidgetPrivate; +class vtkMRMLSegmentEditorNode; + +/// \ingroup SlicerVirtualReality_Widgets +class Q_SLICER_QTMODULES_VIRTUALREALITY_WIDGETS_EXPORT qMRMLVirtualRealitySegmentEditorWidget : public qMRMLWidget +{ + Q_OBJECT + QVTK_OBJECT + +public: + typedef qMRMLWidget Superclass; + /// Constructor + explicit qMRMLVirtualRealitySegmentEditorWidget(QWidget* parent = nullptr); + /// Destructor + ~qMRMLVirtualRealitySegmentEditorWidget() override; + + void setMRMLSegmentEditorNode(vtkMRMLSegmentEditorNode* newSegmentEditorNode); + +public slots: + +protected slots: + /// Update widgets from the MRML node + void updateWidgetFromMRML(); + +protected: + QScopedPointer d_ptr; + +private: + Q_DECLARE_PRIVATE(qMRMLVirtualRealitySegmentEditorWidget); + Q_DISABLE_COPY(qMRMLVirtualRealitySegmentEditorWidget); +}; + +#endif