Skip to content

Instantly share code, notes, and snippets.

View jcfr's full-sized avatar
🎯
Focusing

Jean-Christophe Fillion-Robin jcfr

🎯
Focusing
View GitHub Profile
@jcfr
jcfr / CMakeLitsts.txt
Last active December 18, 2023 20:58
Sandbox project to help understand issue discussed at https://github.com/BrownBiomechanics/Autoscoper/pull/238
cmake_minimum_required(VERSION 3.17.5)
message(STATUS "ENV{CUDA_PATH} [$ENV{CUDA_PATH}]")
message(STATUS "---- CMAKE_CUDA_COMPILER [${CMAKE_CUDA_COMPILER}]")
project(Sandbox)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
@jcfr
jcfr / build-Slicer.bat
Last active November 29, 2023 20:43
Convenience batch scripts for building Slicer, SlicerVirtualReatity and SlicerMixedReality extensions
set cmake_exe=C:\cmake-3.22.1\bin\cmake.exe
set root_dir=C:\P
set source_dir=%root_dir%\S
set build_dir=%root_dir%\S-rwdi
set build_type=RelWithDebInfo
cd %root_dir%
%cmake_exe% -G "Visual Studio 17 2022" -A x64 ^
@jcfr
jcfr / slicer_asyncio_example.py
Created September 22, 2023 20:10
Example of asyncio usage ensuring that printed messages are displayed on-time
import asyncio
import time
def app_print(*args, **kwargs):
print(*args, **kwargs)
slicer.app.processEvents()
async def say_after(delay, what):
@jcfr
jcfr / slicer_shortcut_blocker.py
Last active September 21, 2023 18:44
Block Slicer shortcuts except specific ones
class CustomAppShortcutBlocker(qt.QObject):
def eventFilter(self, object, event):
"""
Custom event filter for allowing only specific shortcuts.
"""
# See https://doc.qt.io/qt-5/qkeyevent.html#details
if event.type() == qt.QEvent.Shortcut:
# Only allow showing/hiding "Error log"
if event.key() == qt.QKeySequence("Ctrl+0"):
@jcfr
jcfr / External_python-scikit-image.cmake
Last active September 21, 2023 16:56
Example of external project for bundling "scikit-image" into a Slicer custom application
set(proj python-scikit-image)
# Set dependency list
set(${proj}_DEPENDENCIES
python
python-pip
python-setuptools
)
if(NOT DEFINED Slicer_USE_SYSTEM_${proj})
@jcfr
jcfr / slicer_mainwindow_drag_and_drop_override.py
Created September 20, 2023 19:47
Override drag and drop behavior associated with Slicer main window
class EventManager(qt.QObject):
def eventFilter(self, object, event):
"""
Custom event filter for Slicer Main Window.
Inputs: Object (QObject), Event (QEvent)
"""
if event.type() == qt.QEvent.DragEnter:
self.dragEnterEvent(event)
return True
@jcfr
jcfr / slicer_additional_dictionary.txt
Created July 7, 2023 05:29
Additonal dictionary used when running SimpleITKSpellChecking against Slicer code base
Andras
Andruejol
Aucoin
Allowlist
Arial
Backend
Blocklist
Canaria
Cancelling
Cividis
@jcfr
jcfr / github_create_resources_release.sh
Last active August 15, 2023 21:19
Convenient shell script to create an orphan release useful for hosting binary assets (e.g images) used in documentation
# SPDX-FileCopyrightText: 2023 Jean-Christophe Fillion-Robin <jcfr@kitware.com>
# SPDX-License-Identifier: BSD-3-Clause
#-----------------------------------------------------------------------------
tag_name=collection-archives
release_name=CollectionArchives
git checkout --orphan=${tag_name}
git rm -rf .
#-----------------------------------------------------------------------------
@jcfr
jcfr / slicer_lupdate_preprocess.py
Last active March 30, 2023 20:53
Rewrite tr-like function calls found in Slicer scripted modules to include the context as first argument
# SPDX-FileCopyrightText: 2023 Jean-Christophe Fillion-Robin <jcfr@kitware.com>
# SPDX-License-Identifier: BSD-3-Clause
import ast
import argparse
import errno
import os
import sys
import astor
@jcfr
jcfr / boost_fixup_rpath.sh
Created March 22, 2022 21:58
Script to patch the Boost libraries changing the occurences of `@rpath` back to a full path
#/bin/env bash
# This script allows to patch the Boost libraries changing the occurences of `@rpath`
# back to a full path specific to this dashboard.
#
# This is currently required by Slicer macOS packaging infrastructure.
set -euo pipefail
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"