Skip to content

Commit d749324

Browse files
SalehChoueibAndras Lassocpinterdgmatomohammadrashid0917
authored andcommitted
ENH: Initial VR home widget implementation
This commit is intended to implement features described in #43 by integrating changes originally associated with the following branches: * dgmato/gui-widgets-interactions - initially developed between 2021-12-15 and 2022-05-23 by @dgmato with contributions from @cpinter. - based on the "gui-widgets-module" branch * dgmato/gui-widgets-module - initially developed between 2018-10-18 and 2021-10-0523 by @cpinter with contributions from @dgmato, @lassoan, @SalehChoueib and @mohammadrashid0917 - with first commit titled "ENH: Initial VR home widget implementation" based of "dgmato/virtual-widget" branch. * dgmato/virtual-widget - initial commit contributed by @SalehChoueib on 2018-10-18 (ENH: Add virtual widget from arbitrary Qt Widget !WIP!) - follow-up development by @cpinter and @mohammadrashid0917 between 2019-05-13 and 2019-06-13 ------------ Commits originally associated with branch "dgmato/gui-widgets-interactions": * ENH: Remove unused UI widget in GUI Widgets module * ENH: Do not load avatar models when setting up VR pointer * ENH: Add new button to set up interaction Set up will include getting the VR controller transform node and applying that transform to the pointer model. * ENH: Add GUIWidgets module to Virtual Reality category for easy access * ENH: Load avatar models and transform pointer by right controller transform * ENH: Reorganize code and remove unused code * COMP: Fix build error due to Slicer API changes * ENH: Add new module target library vtkSlicerMarkupsModuleMRMLDisplayableManager * ENH: Send mouse release event to complete simulated mouse click after press event * ENH: Modify coordinate system for GUI widget Origin is located on the top left corner in Qt widgets. * ENH: Add button "Start interaction" to simulate interaction with VR pointer * ENH: Add module to simulate VR pointer display and movement ------------ Commits originally associated with branch "dgmato/gui-widgets-module": * ENH: Add buttons in GUIWidgets to show VR widgets; Fix include dirs variable in CMake * ENH: Add GUIWidgets module that provides in-VR Qt widget This is still a prototype, a few crucial features are needed: - Handle mouse interactions on the widget: forward events to Qt - Support moving the widget to arbitrary position - Implement outline tube and handle to grab with the controller - Option to keep widget floating in certain position relative to head motion (~HUD) - Implement laser pointer and use the intersection with these widgets as mouse interaction See more history: https://github.com/cpinter/VtkQWidgetTest * ENH: Creating and registering VR segment editor widget Creates and registers the VR segment editor widget (which can be switched to from the VR home widget) * BUG: Fix issues in VR home widget and the data widget * ENH: Creating and registering VR data module widget Creates and registers the VR data module widget (which can be switched to from the VR home widget) * ENH: Convert the interactor style to use the new vtkMRMLViewInteractorStyle Fix build error with Slicer-4.10 * STYLE: Add function documentation * ENH: Initial VR home widget implementation Squashed commits (originally associated with branch "dgmato/virtual-widget") * ENH: Create framework for registering VR modules Adds registerModule function to qMRMLVRView which can be called to create a new button for that module on the Modules bar in the VR home widget * ENH: Make VR home widget controls functional These changes make it so that changes in the module widget (viewable in Slicer) are reflected in the home widget (viewable in VR) and vice versa * ENH: Add VR optimized Qt Style Sheet This style sheet makes the text in the VR menu widget bigger, and gives the buttons and slider handles different colors for unpressed, hover, and pressed statuses. * ENH: Add VR home widget WIP Its UI is more or less complete but events are not handled and style sheet is needed * ENH: Add virtual widget from arbitrary Qt Widget !WIP! Co-authored-by: Andras Lasso <[email protected]> Co-authored-by: Csaba Pinter <[email protected]> Co-authored-by: David Garcia Mato <[email protected]> Co-authored-by: Mohammad Rashid <[email protected]> Co-authored-by: Sal Choueib <[email protected]>
1 parent bb214d6 commit d749324

File tree

58 files changed

+6003
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+6003
-8
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ endif()
5757
#-----------------------------------------------------------------------------
5858
# Extension modules
5959
add_subdirectory(VirtualReality)
60+
add_subdirectory(GUIWidgets)
61+
add_subdirectory(PointerSimulator)
6062
## NEXT_MODULE
6163

6264
#-----------------------------------------------------------------------------

GUIWidgets/CMakeLists.txt

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
2+
#-----------------------------------------------------------------------------
3+
set(MODULE_NAME GUIWidgets)
4+
set(MODULE_TITLE ${MODULE_NAME})
5+
6+
string(TOUPPER ${MODULE_NAME} MODULE_NAME_UPPER)
7+
8+
#-----------------------------------------------------------------------------
9+
add_subdirectory(MRML)
10+
add_subdirectory(Logic)
11+
add_subdirectory(VTKWidgets)
12+
# add_subdirectory(MRMLDM)
13+
# add_subdirectory(Widgets)
14+
15+
#-----------------------------------------------------------------------------
16+
set(MODULE_EXPORT_DIRECTIVE "Q_SLICER_QTMODULES_${MODULE_NAME_UPPER}_EXPORT")
17+
18+
# Current_{source,binary} and Slicer_{Libs,Base} already included
19+
set(MODULE_INCLUDE_DIRECTORIES
20+
${CMAKE_CURRENT_SOURCE_DIR}/MRML
21+
${CMAKE_CURRENT_BINARY_DIR}/MRML
22+
${CMAKE_CURRENT_SOURCE_DIR}/Logic
23+
${CMAKE_CURRENT_BINARY_DIR}/Logic
24+
${CMAKE_CURRENT_SOURCE_DIR}/VTKWidgets
25+
${CMAKE_CURRENT_BINARY_DIR}/VTKWidgets
26+
# ${CMAKE_CURRENT_SOURCE_DIR}/Widgets
27+
# ${CMAKE_CURRENT_BINARY_DIR}/Widgets
28+
${qSlicerMarkupsModuleWidgets_INCLUDE_DIRS}
29+
${qSlicerVirtualRealityModuleWidgets_INCLUDE_DIRS}
30+
)
31+
32+
set(MODULE_SRCS
33+
qSlicer${MODULE_NAME}Module.cxx
34+
qSlicer${MODULE_NAME}Module.h
35+
qSlicer${MODULE_NAME}ModuleWidget.cxx
36+
qSlicer${MODULE_NAME}ModuleWidget.h
37+
)
38+
39+
set(MODULE_MOC_SRCS
40+
qSlicer${MODULE_NAME}Module.h
41+
qSlicer${MODULE_NAME}ModuleWidget.h
42+
)
43+
44+
set(MODULE_UI_SRCS
45+
Resources/UI/qSlicer${MODULE_NAME}ModuleWidget.ui
46+
)
47+
48+
set(MODULE_TARGET_LIBRARIES
49+
vtkSlicer${MODULE_NAME}ModuleMRML
50+
vtkSlicer${MODULE_NAME}ModuleLogic
51+
vtkSlicer${MODULE_NAME}ModuleVTKWidgets
52+
# vtkSlicer${MODULE_NAME}ModuleMRMLDisplayableManager
53+
# qSlicer${MODULE_NAME}ModuleWidgets
54+
vtkSlicerMarkupsModuleMRMLDisplayableManager
55+
qSlicerMarkupsModuleWidgets
56+
qSlicerVirtualRealityModuleWidgets
57+
vtkSlicerVirtualRealityModuleLogic
58+
)
59+
60+
set(MODULE_RESOURCES
61+
Resources/qSlicer${MODULE_NAME}Module.qrc
62+
)
63+
64+
#-----------------------------------------------------------------------------
65+
slicerMacroBuildLoadableModule(
66+
NAME ${MODULE_NAME}
67+
TITLE ${MODULE_TITLE}
68+
EXPORT_DIRECTIVE ${MODULE_EXPORT_DIRECTIVE}
69+
INCLUDE_DIRECTORIES ${MODULE_INCLUDE_DIRECTORIES}
70+
SRCS ${MODULE_SRCS}
71+
MOC_SRCS ${MODULE_MOC_SRCS}
72+
UI_SRCS ${MODULE_UI_SRCS}
73+
TARGET_LIBRARIES ${MODULE_TARGET_LIBRARIES}
74+
RESOURCES ${MODULE_RESOURCES}
75+
WITH_GENERIC_TESTS
76+
)
77+
78+
#-----------------------------------------------------------------------------
79+
if(BUILD_TESTING)
80+
add_subdirectory(Testing)
81+
endif()

GUIWidgets/Logic/CMakeLists.txt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
project(vtkSlicer${MODULE_NAME}ModuleLogic)
2+
3+
set(KIT ${PROJECT_NAME})
4+
5+
set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_MODULE_LOGIC_EXPORT")
6+
7+
set(${KIT}_INCLUDE_DIRECTORIES
8+
)
9+
10+
set(${KIT}_SRCS
11+
vtkSlicer${MODULE_NAME}Logic.cxx
12+
vtkSlicer${MODULE_NAME}Logic.h
13+
)
14+
15+
set(${KIT}_TARGET_LIBRARIES
16+
vtkSlicer${MODULE_NAME}ModuleMRML
17+
vtkSlicerMarkupsModuleLogic
18+
)
19+
20+
#-----------------------------------------------------------------------------
21+
SlicerMacroBuildModuleLogic(
22+
NAME ${KIT}
23+
EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE}
24+
INCLUDE_DIRECTORIES ${${KIT}_INCLUDE_DIRECTORIES}
25+
SRCS ${${KIT}_SRCS}
26+
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
27+
)
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*==============================================================================
2+
3+
Program: 3D Slicer
4+
5+
Portions (c) Copyright Brigham and Women's Hospital (BWH) All Rights Reserved.
6+
7+
See COPYRIGHT.txt
8+
or http://www.slicer.org/copyright/copyright.txt for details.
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
==============================================================================*/
17+
18+
// GUIWidgets Logic includes
19+
#include "vtkSlicerGUIWidgetsLogic.h"
20+
21+
// GUIWidgets MRML includes
22+
#include "vtkMRMLGUIWidgetNode.h"
23+
#include "vtkMRMLGUIWidgetDisplayNode.h"
24+
25+
// MRML includes
26+
#include <vtkMRMLScene.h>
27+
#include <vtkMRMLSelectionNode.h>
28+
29+
// Markups logic includes
30+
#include <vtkSlicerMarkupsLogic.h>
31+
32+
// VTK includes
33+
#include <vtkIntArray.h>
34+
#include <vtkNew.h>
35+
#include <vtkObjectFactory.h>
36+
37+
// STD includes
38+
#include <cassert>
39+
40+
//----------------------------------------------------------------------------
41+
vtkStandardNewMacro(vtkSlicerGUIWidgetsLogic);
42+
43+
//----------------------------------------------------------------------------
44+
vtkSlicerGUIWidgetsLogic::vtkSlicerGUIWidgetsLogic()
45+
{
46+
}
47+
48+
//----------------------------------------------------------------------------
49+
vtkSlicerGUIWidgetsLogic::~vtkSlicerGUIWidgetsLogic()
50+
{
51+
}
52+
53+
//----------------------------------------------------------------------------
54+
void vtkSlicerGUIWidgetsLogic::PrintSelf(ostream& os, vtkIndent indent)
55+
{
56+
this->Superclass::PrintSelf(os, indent);
57+
}
58+
59+
//---------------------------------------------------------------------------
60+
void vtkSlicerGUIWidgetsLogic::SetMRMLSceneInternal(vtkMRMLScene * newScene)
61+
{
62+
vtkNew<vtkIntArray> events;
63+
events->InsertNextValue(vtkMRMLScene::NodeAddedEvent);
64+
events->InsertNextValue(vtkMRMLScene::NodeRemovedEvent);
65+
events->InsertNextValue(vtkMRMLScene::EndBatchProcessEvent);
66+
this->SetAndObserveMRMLSceneEventsInternal(newScene, events.GetPointer());
67+
}
68+
69+
//---------------------------------------------------------------------------
70+
void vtkSlicerGUIWidgetsLogic::ObserveMRMLScene()
71+
{
72+
if (!this->GetMRMLScene())
73+
{
74+
return;
75+
}
76+
77+
vtkMRMLApplicationLogic* mrmlAppLogic = this->GetMRMLApplicationLogic();
78+
if (!mrmlAppLogic)
79+
{
80+
vtkErrorMacro("ObserveMRMLScene: invalid MRML Application Logic");
81+
return;
82+
}
83+
84+
vtkMRMLNode* node = this->GetMRMLScene()->GetNodeByID(this->GetSelectionNodeID().c_str());
85+
if (!node)
86+
{
87+
vtkErrorMacro("Observe MRMLScene: invalid Selection Node");
88+
return;
89+
}
90+
91+
// add known markup types to the selection node
92+
vtkMRMLSelectionNode* selectionNode = vtkMRMLSelectionNode::SafeDownCast(node);
93+
if (selectionNode)
94+
{
95+
// got into batch process mode so that an update on the mouse mode tool
96+
// bar is triggered when leave it
97+
this->GetMRMLScene()->StartState(vtkMRMLScene::BatchProcessState);
98+
99+
auto guiWidgetNode = vtkSmartPointer<vtkMRMLGUIWidgetNode>::New();
100+
selectionNode->AddNewPlaceNodeClassNameToList(
101+
guiWidgetNode->GetClassName(), guiWidgetNode->GetAddIcon(), guiWidgetNode->GetMarkupType());
102+
103+
// trigger an update on the mouse mode toolbar
104+
this->GetMRMLScene()->EndState(vtkMRMLScene::BatchProcessState);
105+
}
106+
107+
this->Superclass::ObserveMRMLScene();
108+
}
109+
110+
//-----------------------------------------------------------------------------
111+
void vtkSlicerGUIWidgetsLogic::RegisterNodes()
112+
{
113+
vtkMRMLScene* scene = this->GetMRMLScene();
114+
if (!scene)
115+
{
116+
vtkErrorMacro("RegisterNodes: Invalid MRML scene");
117+
return;
118+
}
119+
if (!scene->IsNodeClassRegistered("vtkMRMLGUIWidgetNode"))
120+
{
121+
scene->RegisterNodeClass(vtkSmartPointer<vtkMRMLGUIWidgetNode>::New());
122+
}
123+
if (!scene->IsNodeClassRegistered("vtkMRMLGUIWidgetDisplayNode"))
124+
{
125+
scene->RegisterNodeClass(vtkSmartPointer<vtkMRMLGUIWidgetDisplayNode>::New());
126+
}
127+
}
128+
129+
//---------------------------------------------------------------------------
130+
void vtkSlicerGUIWidgetsLogic::UpdateFromMRMLScene()
131+
{
132+
assert(this->GetMRMLScene() != 0);
133+
}
134+
135+
//---------------------------------------------------------------------------
136+
void vtkSlicerGUIWidgetsLogic::OnMRMLSceneNodeAdded(vtkMRMLNode* vtkNotUsed(node))
137+
{
138+
}
139+
140+
//---------------------------------------------------------------------------
141+
void vtkSlicerGUIWidgetsLogic::OnMRMLSceneNodeRemoved(vtkMRMLNode* vtkNotUsed(node))
142+
{
143+
}
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*==============================================================================
2+
3+
Program: 3D Slicer
4+
5+
Portions (c) Copyright Brigham and Women's Hospital (BWH) All Rights Reserved.
6+
7+
See COPYRIGHT.txt
8+
or http://www.slicer.org/copyright/copyright.txt for details.
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
==============================================================================*/
17+
18+
// .NAME vtkSlicerGUIWidgetsLogic - slicer logic class for volumes manipulation
19+
// .SECTION Description
20+
// This class manages the logic associated with reading, saving,
21+
// and changing propertied of the volumes
22+
23+
24+
#ifndef __vtkSlicerGUIWidgetsLogic_h
25+
#define __vtkSlicerGUIWidgetsLogic_h
26+
27+
// Slicer includes
28+
#include <vtkSlicerMarkupsLogic.h>
29+
30+
// MRML includes
31+
32+
#include "vtkSlicerGUIWidgetsModuleLogicExport.h"
33+
34+
/// \ingroup Slicer_QtModules_ExtensionTemplate
35+
class VTK_SLICER_GUIWIDGETS_MODULE_LOGIC_EXPORT vtkSlicerGUIWidgetsLogic :
36+
public vtkSlicerMarkupsLogic
37+
{
38+
public:
39+
40+
static vtkSlicerGUIWidgetsLogic *New();
41+
vtkTypeMacro(vtkSlicerGUIWidgetsLogic, vtkSlicerMarkupsLogic);
42+
void PrintSelf(ostream& os, vtkIndent indent);
43+
44+
protected:
45+
vtkSlicerGUIWidgetsLogic();
46+
virtual ~vtkSlicerGUIWidgetsLogic();
47+
48+
/// Initialize listening to MRML events
49+
virtual void SetMRMLSceneInternal(vtkMRMLScene* newScene);
50+
void ObserveMRMLScene() override;
51+
52+
/// Register MRML Node classes to Scene. Gets called automatically when the MRMLScene is attached to this logic class.
53+
virtual void RegisterNodes();
54+
virtual void UpdateFromMRMLScene();
55+
virtual void OnMRMLSceneNodeAdded(vtkMRMLNode* node);
56+
virtual void OnMRMLSceneNodeRemoved(vtkMRMLNode* node);
57+
private:
58+
59+
vtkSlicerGUIWidgetsLogic(const vtkSlicerGUIWidgetsLogic&); // Not implemented
60+
void operator=(const vtkSlicerGUIWidgetsLogic&); // Not implemented
61+
};
62+
63+
#endif

GUIWidgets/MRML/CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
project(vtkSlicer${MODULE_NAME}ModuleMRML)
2+
3+
set(KIT ${PROJECT_NAME})
4+
5+
set(${KIT}_EXPORT_DIRECTIVE "VTK_SLICER_${MODULE_NAME_UPPER}_MODULE_MRML_EXPORT")
6+
7+
set(${KIT}_INCLUDE_DIRECTORIES
8+
${vtkSlicer${MODULE_NAME}ModuleVTKWidgets_SOURCE_DIR}
9+
${vtkSlicer${MODULE_NAME}ModuleVTKWidgets_BINARY_DIR}
10+
)
11+
12+
set(${KIT}_SRCS
13+
vtkMRMLGUIWidgetNode.cxx
14+
vtkMRMLGUIWidgetDisplayNode.cxx
15+
)
16+
17+
set(${KIT}_TARGET_LIBRARIES
18+
${MRML_LIBRARIES}
19+
vtkSlicerMarkupsModuleMRML
20+
)
21+
22+
#-----------------------------------------------------------------------------
23+
SlicerMacroBuildModuleMRML(
24+
NAME ${KIT}
25+
EXPORT_DIRECTIVE ${${KIT}_EXPORT_DIRECTIVE}
26+
INCLUDE_DIRECTORIES ${${KIT}_INCLUDE_DIRECTORIES}
27+
SRCS ${${KIT}_SRCS}
28+
TARGET_LIBRARIES ${${KIT}_TARGET_LIBRARIES}
29+
)
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*==============================================================================
2+
3+
Program: 3D Slicer
4+
5+
Portions (c) Copyright Brigham and Women's Hospital (BWH) All Rights Reserved.
6+
7+
See COPYRIGHT.txt
8+
or http://www.slicer.org/copyright/copyright.txt for details.
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
16+
This file was originally developed by Csaba Pinter, EBATINCA, S.L., and
17+
development was supported by "ICEX Espana Exportacion e Inversiones" under
18+
the program "Inversiones de Empresas Extranjeras en Actividades de I+D
19+
(Fondo Tecnologico)- Convocatoria 2021"
20+
21+
==============================================================================*/
22+
23+
// MRML includes
24+
#include "vtkMRMLGUIWidgetDisplayNode.h"
25+
26+
//----------------------------------------------------------------------------
27+
vtkMRMLNodeNewMacro(vtkMRMLGUIWidgetDisplayNode);
28+
29+
//----------------------------------------------------------------------------
30+
vtkMRMLGUIWidgetDisplayNode::vtkMRMLGUIWidgetDisplayNode()
31+
{
32+
}
33+
34+
//----------------------------------------------------------------------------
35+
vtkMRMLGUIWidgetDisplayNode::~vtkMRMLGUIWidgetDisplayNode() = default;

0 commit comments

Comments
 (0)