Skip to content

Commit

Permalink
Fix extension build on macOS by replacing real Virtual Reality module…
Browse files Browse the repository at this point in the history
… by a placeholder

Virtual Reality is not supported on macOS. Instead of having a build error on the dashboard
and extension missing from the Extensions Manager, we now create an extension that contains
a stub module that just displays the message that Virtual Reality is not supported on the platform.

fixes #92

Co-authored-by: Jean-Christophe Fillion-Robin <[email protected]>
  • Loading branch information
lassoan and jcfr authored Apr 27, 2022
1 parent 1f118fa commit 70d5a3b
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 4 deletions.
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ set(EXTENSION_DESCRIPTION "Allows user to interact with a Slicer scene using vir
set(EXTENSION_ICONURL "https://raw.githubusercontent.com/KitwareMedical/SlicerVirtualReality/master/SlicerVirtualReality.png")
set(EXTENSION_SCREENSHOTURLS "https://www.slicer.org/w/images/4/49/SlicerVirtualReality_Screenshot1.png https://www.slicer.org/w/images/0/04/SlicerVirtualReality_Screenshot2.png")
set(EXTENSION_DEPENDS "NA") # Specified as a space separated string, a list or 'NA' if any

#-----------------------------------------------------------------------------
if(APPLE)
# Virtual Reality is not supported on macOS, create an extension that contains a stub module
# that just displays the message that Virtual Reality is not supported. This avoids having
# a build error on the extension build dashboard.
find_package(Slicer REQUIRED)
include(${Slicer_USE_FILE})
add_subdirectory(VirtualRealityStub)
include(${Slicer_EXTENSION_GENERATE_CONFIG})
include(${Slicer_EXTENSION_CPACK})
return()
endif()
#-----------------------------------------------------------------------------

set(EXTENSION_BUILD_SUBDIRECTORY inner-build)

set(SUPERBUILD_TOPLEVEL_PROJECT inner)
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@ Usage

## Setup

Currently only Windows computers are supported, as until very recently there have been no virtual reality headsets officially supported on MacOS or Linux. If you already have virtual reality capable hardware, Steam
**Platform support:** Currently the extension only works on Windows computers. Linux support is experimental: [Steam VR has limited support on linux](https://github.com/ValveSoftware/SteamVR-for-Linux/blob/master/README.md) and the Slicer extension is built for Linux but not tested. The extension is not available on macOS, as currently there are no virtual reality headsets available for macOS. If you wish to use Virtual Reality extension on Linux or macOS and you have virtual reality capable hardware and Steam VR works well on your computer then add a comment in the issue tracker ([macOS](https://github.com/KitwareMedical/SlicerVirtualReality/issues/3) / [Linux](https://github.com/KitwareMedical/SlicerVirtualReality/issues/57)).

works well on your computer, and you would like to use Slicer in virtual reality, too, then you add a comment in the issue tracker ([MacOS](https://github.com/KitwareMedical/SlicerVirtualReality/issues/3) / [Linux](https://github.com/KitwareMedical/SlicerVirtualReality/issues/57)).

If both integrated display card and high-performance GPU available in a system (typically this is the case on laptops with NVidia GPUs), then configure the graphics card application settings to use high-performance GPU for SlicerApp-real.exe (it is not necessary to use high-performance GPU for the launcher, Slicer.exe).
**Configuring graphics:** If both integrated display card and high-performance GPU are available in a system (typically this is the case on laptops with NVidia GPUs), then configure the graphics card application settings to use high-performance GPU for `SlicerApp-real.exe` (it is not necessary to use high-performance GPU for the launcher, `Slicer.exe`).

<a name="setup-htc-vive" ></a>

Expand Down
18 changes: 18 additions & 0 deletions VirtualRealityStub/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#-----------------------------------------------------------------------------
set(MODULE_NAME VirtualRealityStub)

#-----------------------------------------------------------------------------
set(MODULE_PYTHON_SCRIPTS
${MODULE_NAME}.py
)

set(MODULE_PYTHON_RESOURCES
Resources/Icons/${MODULE_NAME}.png
)

#-----------------------------------------------------------------------------
slicerMacroBuildScriptedModule(
NAME ${MODULE_NAME}
SCRIPTS ${MODULE_PYTHON_SCRIPTS}
RESOURCES ${MODULE_PYTHON_RESOURCES}
)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions VirtualRealityStub/VirtualRealityStub.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import slicer
from slicer.ScriptedLoadableModule import *

#
# VirtualRealityStub
#

class VirtualRealityStub(ScriptedLoadableModule):
def __init__(self, parent):
ScriptedLoadableModule.__init__(self, parent)
self.parent.title = "Virtual Reality"
self.parent.categories = ["Virtual Reality"]
self.parent.dependencies = []
self.parent.contributors = ["Andras Lasso (PerkLab)"]
self.parent.helpText = """
This is a placeholder module to tell the user that Virtual Reality extension is not available on the platform.
See more information in the <a href="https://github.com/KitwareMedical/SlicerVirtualReality">extension documentation</a>.
"""
self.parent.acknowledgementText = ""

#
# VirtualRealityStubWidget
#

class VirtualRealityStubWidget(ScriptedLoadableModuleWidget):
def __init__(self, parent=None):
ScriptedLoadableModuleWidget.__init__(self, parent)

def setup(self):
ScriptedLoadableModuleWidget.setup(self)

def enter(self):
"""
Called each time the user opens this module.
"""
slicer.util.messageBox("Virtual Reality is not supported on this platform.<br>"
"See <a href='https://github.com/KitwareMedical/SlicerVirtualReality#setup'>Slicer Virtual Reality extension website</a> for details.")

0 comments on commit 70d5a3b

Please sign in to comment.