mitk-python 2026.12rc1__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. mitk/MitkCore/MitkDICOMImageIO.dll +0 -0
  2. mitk/MitkCore/MitkDICOMPMIO.dll +0 -0
  3. mitk/MitkCore/MitkDICOMRTIO.dll +0 -0
  4. mitk/MitkCore/MitkDICOMSegIO.dll +0 -0
  5. mitk/MitkCore/MitkIOExt.dll +0 -0
  6. mitk/MitkCore/MitkModelFitIOServices.dll +0 -0
  7. mitk/MitkCore/MitkMultilabelIO.dll +0 -0
  8. mitk/MitkCore/MitkPlanarFigureIO.dll +0 -0
  9. mitk/MitkCore/MitkROIIO.dll +0 -0
  10. mitk/MitkCore/MitkSceneSerializationIO.dll +0 -0
  11. mitk/MitkCore/MitkSegmentationIO.dll +0 -0
  12. mitk/MitkDICOM/MitkCESTIO.dll +0 -0
  13. mitk/MitkModelFit/MitkModelFitModelsServices.dll +0 -0
  14. mitk/MitkModelFit/MitkPharmacokineticModelsServices.dll +0 -0
  15. mitk/__init__.py +78 -0
  16. mitk/mitk.cp313-win_amd64.pyd +0 -0
  17. mitk/mxn/__init__.py +17 -0
  18. mitk/mxn/layout/__init__.py +115 -0
  19. mitk/mxn/layout/_builders.py +239 -0
  20. mitk/mxn/layout/_io.py +66 -0
  21. mitk/mxn/layout/_model.py +1204 -0
  22. mitk/mxn/layout/_presets.py +93 -0
  23. mitk/mxn/layout/_repr.py +205 -0
  24. mitk/mxn/layout/_selector.py +363 -0
  25. mitk/mxn/layout/_validation.py +348 -0
  26. mitk/mxn/layout/_vocabulary.py +100 -0
  27. mitk/property_view.py +123 -0
  28. mitk_python-2026.12rc1.dist-info/DELVEWHEEL +2 -0
  29. mitk_python-2026.12rc1.dist-info/METADATA +67 -0
  30. mitk_python-2026.12rc1.dist-info/RECORD +193 -0
  31. mitk_python-2026.12rc1.dist-info/WHEEL +4 -0
  32. mitk_python-2026.12rc1.dist-info/top_level.txt +1 -0
  33. mitk_python.libs/ITKCommon-5.4.dll +0 -0
  34. mitk_python.libs/ITKIOBMP-5.4.dll +0 -0
  35. mitk_python.libs/ITKIOBioRad-5.4.dll +0 -0
  36. mitk_python.libs/ITKIOBruker-5.4.dll +0 -0
  37. mitk_python.libs/ITKIOGDCM-5.4.dll +0 -0
  38. mitk_python.libs/ITKIOGE-5.4.dll +0 -0
  39. mitk_python.libs/ITKIOGIPL-5.4.dll +0 -0
  40. mitk_python.libs/ITKIOHDF5-5.4.dll +0 -0
  41. mitk_python.libs/ITKIOIPL-5.4.dll +0 -0
  42. mitk_python.libs/ITKIOImageBase-5.4.dll +0 -0
  43. mitk_python.libs/ITKIOJPEG-5.4.dll +0 -0
  44. mitk_python.libs/ITKIOJPEG2000-5.4.dll +0 -0
  45. mitk_python.libs/ITKIOLSM-5.4.dll +0 -0
  46. mitk_python.libs/ITKIOMINC-5.4.dll +0 -0
  47. mitk_python.libs/ITKIOMRC-5.4.dll +0 -0
  48. mitk_python.libs/ITKIOMeta-5.4.dll +0 -0
  49. mitk_python.libs/ITKIONIFTI-5.4.dll +0 -0
  50. mitk_python.libs/ITKIONRRD-5.4.dll +0 -0
  51. mitk_python.libs/ITKIOPNG-5.4.dll +0 -0
  52. mitk_python.libs/ITKIOStimulate-5.4.dll +0 -0
  53. mitk_python.libs/ITKIOTIFF-5.4.dll +0 -0
  54. mitk_python.libs/ITKIOVTK-5.4.dll +0 -0
  55. mitk_python.libs/ITKLabelMap-5.4.dll +0 -0
  56. mitk_python.libs/ITKOptimizers-5.4.dll +0 -0
  57. mitk_python.libs/ITKQuadEdgeMesh-5.4.dll +0 -0
  58. mitk_python.libs/ITKRegionGrowing-5.4.dll +0 -0
  59. mitk_python.libs/ITKSmoothing-5.4.dll +0 -0
  60. mitk_python.libs/ITKStatistics-5.4.dll +0 -0
  61. mitk_python.libs/ITKTransform-5.4.dll +0 -0
  62. mitk_python.libs/MitkAlgorithmsExt.dll +0 -0
  63. mitk_python.libs/MitkCEST.dll +0 -0
  64. mitk_python.libs/MitkContourModel.dll +0 -0
  65. mitk_python.libs/MitkCore.dll +0 -0
  66. mitk_python.libs/MitkCppMicroServices.dll +0 -0
  67. mitk_python.libs/MitkDICOM.dll +0 -0
  68. mitk_python.libs/MitkDICOMPM.dll +0 -0
  69. mitk_python.libs/MitkDICOMQI.dll +0 -0
  70. mitk_python.libs/MitkDataTypesExt.dll +0 -0
  71. mitk_python.libs/MitkLog.dll +0 -0
  72. mitk_python.libs/MitkMapperExt.dll +0 -0
  73. mitk_python.libs/MitkModelFit.dll +0 -0
  74. mitk_python.libs/MitkMultilabel.dll +0 -0
  75. mitk_python.libs/MitkPharmacokinetics.dll +0 -0
  76. mitk_python.libs/MitkPlanarFigure.dll +0 -0
  77. mitk_python.libs/MitkROI.dll +0 -0
  78. mitk_python.libs/MitkRT.dll +0 -0
  79. mitk_python.libs/MitkSceneSerialization.dll +0 -0
  80. mitk_python.libs/MitkSceneSerializationBase.dll +0 -0
  81. mitk_python.libs/MitkSegmentation.dll +0 -0
  82. mitk_python.libs/MitkSurfaceInterpolation.dll +0 -0
  83. mitk_python.libs/MitkVolumeVisualization.dll +0 -0
  84. mitk_python.libs/PocoFoundation.dll +0 -0
  85. mitk_python.libs/PocoZip.dll +0 -0
  86. mitk_python.libs/ann.dll +0 -0
  87. mitk_python.libs/dcmdata.dll +0 -0
  88. mitk_python.libs/dcmfg.dll +0 -0
  89. mitk_python.libs/dcmimage.dll +0 -0
  90. mitk_python.libs/dcmimgle.dll +0 -0
  91. mitk_python.libs/dcmiod.dll +0 -0
  92. mitk_python.libs/dcmpmap.dll +0 -0
  93. mitk_python.libs/dcmrt.dll +0 -0
  94. mitk_python.libs/dcmseg.dll +0 -0
  95. mitk_python.libs/dcmsr.dll +0 -0
  96. mitk_python.libs/gdcmCommon.dll +0 -0
  97. mitk_python.libs/gdcmDICT.dll +0 -0
  98. mitk_python.libs/gdcmDSED.dll +0 -0
  99. mitk_python.libs/gdcmIOD.dll +0 -0
  100. mitk_python.libs/gdcmMSFF.dll +0 -0
  101. mitk_python.libs/gdcmcharls.dll +0 -0
  102. mitk_python.libs/gdcmexpat.dll +0 -0
  103. mitk_python.libs/gdcmjpeg12.dll +0 -0
  104. mitk_python.libs/gdcmjpeg16.dll +0 -0
  105. mitk_python.libs/gdcmjpeg8.dll +0 -0
  106. mitk_python.libs/gdcmopenjp2.dll +0 -0
  107. mitk_python.libs/gdcmzlib.dll +0 -0
  108. mitk_python.libs/itkGrowCut-5.4.dll +0 -0
  109. mitk_python.libs/itkhdf5-shared-5.4.dll +0 -0
  110. mitk_python.libs/itkhdf5_cpp-shared-5.4.dll +0 -0
  111. mitk_python.libs/lz4.dll +0 -0
  112. mitk_python.libs/msvcp140.dll +0 -0
  113. mitk_python.libs/oficonv.dll +0 -0
  114. mitk_python.libs/oflog.dll +0 -0
  115. mitk_python.libs/ofstd.dll +0 -0
  116. mitk_python.libs/tbb12.dll +0 -0
  117. mitk_python.libs/vcomp140.dll +0 -0
  118. mitk_python.libs/vtkCommonCache-9.7.dll +0 -0
  119. mitk_python.libs/vtkCommonColor-9.7.dll +0 -0
  120. mitk_python.libs/vtkCommonComputationalGeometry-9.7.dll +0 -0
  121. mitk_python.libs/vtkCommonCore-9.7.dll +4 -0
  122. mitk_python.libs/vtkCommonDataModel-9.7.dll +0 -0
  123. mitk_python.libs/vtkCommonExecutionModel-9.7.dll +0 -0
  124. mitk_python.libs/vtkCommonMath-9.7.dll +0 -0
  125. mitk_python.libs/vtkCommonMisc-9.7.dll +0 -0
  126. mitk_python.libs/vtkCommonSystem-9.7.dll +0 -0
  127. mitk_python.libs/vtkCommonTransforms-9.7.dll +0 -0
  128. mitk_python.libs/vtkDICOMParser-9.7.dll +0 -0
  129. mitk_python.libs/vtkFiltersCellGrid-9.7.dll +0 -0
  130. mitk_python.libs/vtkFiltersCore-9.7.dll +0 -0
  131. mitk_python.libs/vtkFiltersExtraction-9.7.dll +0 -0
  132. mitk_python.libs/vtkFiltersGeneral-9.7.dll +0 -0
  133. mitk_python.libs/vtkFiltersGeneric-9.7.dll +0 -0
  134. mitk_python.libs/vtkFiltersGeometry-9.7.dll +0 -0
  135. mitk_python.libs/vtkFiltersHybrid-9.7.dll +0 -0
  136. mitk_python.libs/vtkFiltersHyperTree-9.7.dll +0 -0
  137. mitk_python.libs/vtkFiltersModeling-9.7.dll +0 -0
  138. mitk_python.libs/vtkFiltersParallel-9.7.dll +0 -0
  139. mitk_python.libs/vtkFiltersReduction-9.7.dll +0 -0
  140. mitk_python.libs/vtkFiltersSources-9.7.dll +0 -0
  141. mitk_python.libs/vtkFiltersStatistics-9.7.dll +0 -0
  142. mitk_python.libs/vtkFiltersTexture-9.7.dll +0 -0
  143. mitk_python.libs/vtkFiltersVerdict-9.7.dll +0 -0
  144. mitk_python.libs/vtkIOCellGrid-9.7.dll +0 -0
  145. mitk_python.libs/vtkIOCore-9.7.dll +0 -0
  146. mitk_python.libs/vtkIOGeometry-9.7.dll +0 -0
  147. mitk_python.libs/vtkIOHDF-9.7.dll +0 -0
  148. mitk_python.libs/vtkIOImage-9.7.dll +0 -0
  149. mitk_python.libs/vtkIOLegacy-9.7.dll +0 -0
  150. mitk_python.libs/vtkIOPLY-9.7.dll +0 -0
  151. mitk_python.libs/vtkIOXML-9.7.dll +0 -0
  152. mitk_python.libs/vtkIOXMLParser-9.7.dll +0 -0
  153. mitk_python.libs/vtkImagingColor-9.7.dll +0 -0
  154. mitk_python.libs/vtkImagingCore-9.7.dll +0 -0
  155. mitk_python.libs/vtkImagingGeneral-9.7.dll +0 -0
  156. mitk_python.libs/vtkImagingMath-9.7.dll +0 -0
  157. mitk_python.libs/vtkImagingSources-9.7.dll +0 -0
  158. mitk_python.libs/vtkImagingStencil-9.7.dll +0 -0
  159. mitk_python.libs/vtkInteractionStyle-9.7.dll +0 -0
  160. mitk_python.libs/vtkParallelCore-9.7.dll +0 -0
  161. mitk_python.libs/vtkParallelDIY-9.7.dll +0 -0
  162. mitk_python.libs/vtkRenderingAnnotation-9.7.dll +0 -0
  163. mitk_python.libs/vtkRenderingContext2D-9.7.dll +0 -0
  164. mitk_python.libs/vtkRenderingContextOpenGL2-9.7.dll +0 -0
  165. mitk_python.libs/vtkRenderingCore-9.7.dll +0 -0
  166. mitk_python.libs/vtkRenderingFreeType-9.7.dll +0 -0
  167. mitk_python.libs/vtkRenderingHyperTreeGrid-9.7.dll +0 -0
  168. mitk_python.libs/vtkRenderingLabel-9.7.dll +0 -0
  169. mitk_python.libs/vtkRenderingOpenGL2-9.7.dll +0 -0
  170. mitk_python.libs/vtkRenderingUI-9.7.dll +0 -0
  171. mitk_python.libs/vtkRenderingVolume-9.7.dll +0 -0
  172. mitk_python.libs/vtkRenderingVolumeOpenGL2-9.7.dll +0 -0
  173. mitk_python.libs/vtkexpat-9.7.dll +0 -0
  174. mitk_python.libs/vtkfmt-9.7.dll +0 -0
  175. mitk_python.libs/vtkfreetype-9.7.dll +0 -0
  176. mitk_python.libs/vtkglad-9.7.dll +0 -0
  177. mitk_python.libs/vtkhdf5-9.7.dll +0 -0
  178. mitk_python.libs/vtkhdf5_hl-9.7.dll +0 -0
  179. mitk_python.libs/vtkjpeg-9.7.dll +0 -0
  180. mitk_python.libs/vtkjsoncpp-9.7.dll +0 -0
  181. mitk_python.libs/vtkkissfft-9.7.dll +0 -0
  182. mitk_python.libs/vtkloguru-9.7.dll +0 -0
  183. mitk_python.libs/vtklz4-9.7.dll +0 -0
  184. mitk_python.libs/vtklzma-9.7.dll +0 -0
  185. mitk_python.libs/vtkmetaio-9.7.dll +0 -0
  186. mitk_python.libs/vtkpng-9.7.dll +0 -0
  187. mitk_python.libs/vtkpugixml-9.7.dll +0 -0
  188. mitk_python.libs/vtkscn-9.7.dll +0 -0
  189. mitk_python.libs/vtksys-9.7.dll +0 -0
  190. mitk_python.libs/vtktiff-9.7.dll +0 -0
  191. mitk_python.libs/vtktoken-9.7.dll +0 -0
  192. mitk_python.libs/vtkverdict-9.7.dll +0 -0
  193. mitk_python.libs/vtkzlib-9.7.dll +0 -0
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
mitk/__init__.py ADDED
@@ -0,0 +1,78 @@
1
+ """""" # start delvewheel patch
2
+ def _delvewheel_patch_1_12_0():
3
+ import os
4
+ if os.path.isdir(libs_dir := os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir, 'mitk_python.libs'))):
5
+ os.add_dll_directory(libs_dir)
6
+
7
+
8
+ _delvewheel_patch_1_12_0()
9
+ del _delvewheel_patch_1_12_0
10
+ # end delvewheel patch
11
+
12
+ import glob as _glob
13
+ import os as _os
14
+ import sys as _sys
15
+
16
+ _pkg_dir = _os.path.dirname(_os.path.abspath(__file__))
17
+
18
+ # Detect a wheel install by locating the bundled native-library directory.
19
+ # delvewheel (Windows) and auditwheel (Linux) create it as a sibling of the
20
+ # package, named after the distribution (e.g. "mitk_python.libs"); delocate
21
+ # (macOS) creates a ".dylibs" directory inside the package. The sibling name
22
+ # tracks the PyPI distribution name, so match it by prefix instead of
23
+ # hardcoding it. In a build-tree install none of these exist and the
24
+ # wheel-only environment setup below is skipped.
25
+ _libs_dir = _os.path.join(_pkg_dir, ".dylibs")
26
+ if not _os.path.isdir(_libs_dir):
27
+ _siblings = _glob.glob(_os.path.join(_os.path.dirname(_pkg_dir), "mitk*.libs"))
28
+ if _siblings:
29
+ _libs_dir = _siblings[0]
30
+ _is_wheel = _os.path.isdir(_libs_dir)
31
+
32
+ if _is_wheel:
33
+ # Tell PreloadPython activator to skip (Python is already loaded).
34
+ _os.environ["PYMITK"] = "1"
35
+
36
+ # Tell CppMicroServices where to find auto-load module subdirectories.
37
+ _os.environ["US_AUTOLOAD_PATHS"] = _pkg_dir
38
+
39
+ # Windows: register DLL search directory for bundled native libraries.
40
+ # add_dll_directory covers Python extension loading (pyd files), while
41
+ # PATH is needed for CppMicroServices auto-load which uses LoadLibrary.
42
+ if _sys.platform == "win32":
43
+ _os.add_dll_directory(_libs_dir)
44
+ _os.environ["PATH"] = _libs_dir + _os.pathsep + _os.environ.get("PATH", "")
45
+ # Linux: auditwheel sets the extension RPATH to the sibling .libs dir.
46
+ # macOS: delocate rewrites @loader_path references.
47
+ elif _sys.platform == "win32":
48
+ # In an MITK installation, the package lives in python/Lib/site-packages
49
+ # and MITK's DLLs in bin/. Python resolves the DLLs of an extension module
50
+ # only from registered directories, and CppMicroServices loads auto-load
51
+ # modules from bin/ through PATH. Within an MITK executable both are
52
+ # already loaded, so this only matters for the bundled interpreter.
53
+ _bin_dir = _os.path.normpath(_os.path.join(_pkg_dir, "..", "..", "..", "..", "bin"))
54
+ if _os.path.isfile(_os.path.join(_bin_dir, "MitkCore.dll")):
55
+ _os.add_dll_directory(_bin_dir)
56
+ _os.environ["PATH"] = _bin_dir + _os.pathsep + _os.environ.get("PATH", "")
57
+
58
+ from .mitk import *
59
+
60
+
61
+ def _rebind_module_names():
62
+ # Rewrite __module__ on exposed names so tooling renders mitk.X rather
63
+ # than mitk.mitk.X (the inner "mitk" is the pybind11 extension). Covers
64
+ # classes and free functions; pybind11 enum values inherit __module__
65
+ # from their enum type, which is itself rebound here.
66
+ from . import mitk as ext
67
+ for obj in vars(ext).values():
68
+ if getattr(obj, "__module__", None) == "mitk.mitk":
69
+ try:
70
+ obj.__module__ = "mitk"
71
+ except (AttributeError, TypeError):
72
+ pass
73
+
74
+
75
+ _rebind_module_names()
76
+ del _rebind_module_names
77
+
78
+ __version__ = "2026.12rc1"
Binary file
mitk/mxn/__init__.py ADDED
@@ -0,0 +1,17 @@
1
+ # ============================================================================
2
+ #
3
+ # The Medical Imaging Interaction Toolkit (MITK)
4
+ #
5
+ # Copyright (c) German Cancer Research Center (DKFZ)
6
+ # All rights reserved.
7
+ #
8
+ # Use of this source code is governed by a 3-clause BSD license that can be
9
+ # found in the LICENSE file.
10
+ #
11
+ # ============================================================================
12
+
13
+ # Namespace marker for the `mitk.mxn` sub-namespace.
14
+ #
15
+ # Empty by design. Future MxN-related Python subpackages
16
+ # (`mitk.mxn.runtime`, ...) live here; the parent package keeps their import
17
+ # paths stable and grouping discoverable.
@@ -0,0 +1,115 @@
1
+ # ============================================================================
2
+ #
3
+ # The Medical Imaging Interaction Toolkit (MITK)
4
+ #
5
+ # Copyright (c) German Cancer Research Center (DKFZ)
6
+ # All rights reserved.
7
+ #
8
+ # Use of this source code is governed by a 3-clause BSD license that can be
9
+ # found in the LICENSE file.
10
+ #
11
+ # ============================================================================
12
+
13
+ """``mitk.mxn.layout`` -- typed Python DSL for MxN multi-widget layouts.
14
+
15
+ A self-contained, transport-free Python DSL for constructing, inspecting,
16
+ validating, and round-tripping MxN multi-widget layout documents. It writes
17
+ version 3.0 (``mxn-layout-v3.schema.json``), the version
18
+ ``QmitkMxNMultiWidget::SerializeLayout`` and the shipped presets write, and
19
+ ``QmitkMxNMultiWidget::ApplyLayout`` loads what it writes, provided the
20
+ window ids carry that editor's name as prefix (``mxn__`` for the standard
21
+ MxN editor). It reads 3.0 and 2.0; a 2.0 document is upgraded to 3.0.
22
+
23
+ Window identity vs. display label
24
+ ---------------------------------
25
+ Every window has a required ``id`` (qualified form ``<editor_name>__<bare_id>``,
26
+ e.g. ``mxn__widget0``) and an optional ``name`` (free-form display label).
27
+ Routing -- REST URL paths, engine-side render-window names, persisted state
28
+ keys -- uses ``id`` exclusively. The DSL never adds, strips, or otherwise
29
+ translates a prefix; the qualified form is canonical everywhere.
30
+
31
+ Public surface
32
+ --------------
33
+ - :class:`MxNLayoutDocument`, :class:`Split`, :class:`LayoutWindow`,
34
+ :class:`Group`, :class:`Link` -- typed dataclasses.
35
+ - :func:`grid`, :func:`three_up`, :func:`two_rows_each_direction`,
36
+ :func:`single_window` -- split-returning builders.
37
+ - :data:`PRESETS`, :func:`preset`, :func:`list_presets` -- named registry.
38
+ - :func:`load_preset`, :func:`save_preset` -- file I/O.
39
+ - :class:`MxNWindowSelector` -- pandas-style filter + bulk transform.
40
+ - Vocabulary: :class:`LinkDimension`, :class:`ViewDirection`,
41
+ :class:`RenderMode`, :data:`LAYOUT_VERSION`, :data:`DEFAULT_GROUP_NAME`,
42
+ :data:`DEFAULT_GROUP`, :data:`DEFAULT_EDITOR_NAME`,
43
+ :data:`NAMESPACE_DELIMITER`, :data:`WINDOW_ID_PATTERN`,
44
+ :data:`GROUP_NAME_PATTERN`, :data:`GROUP_COLOR_PATTERN`,
45
+ :data:`GLOBAL_GROUP_NAME`.
46
+ """
47
+
48
+ from __future__ import annotations
49
+
50
+ from ._builders import grid, single_window, three_up, two_rows_each_direction
51
+ from ._io import load_preset, save_preset
52
+ from ._model import (
53
+ DEFAULT_GROUP,
54
+ Group,
55
+ LayoutWindow,
56
+ Link,
57
+ LinkLike,
58
+ LinkValue,
59
+ MxNLayoutDocument,
60
+ Split,
61
+ )
62
+ from ._presets import PRESETS, list_presets, preset
63
+ from ._selector import MxNWindowSelector
64
+ from ._vocabulary import (
65
+ DEFAULT_EDITOR_NAME,
66
+ DEFAULT_GROUP_NAME,
67
+ GLOBAL_GROUP_NAME,
68
+ GROUP_COLOR_PATTERN,
69
+ GROUP_NAME_PATTERN,
70
+ LAYOUT_VERSION,
71
+ NAMESPACE_DELIMITER,
72
+ WINDOW_ID_PATTERN,
73
+ LinkDimension,
74
+ RenderMode,
75
+ ViewDirection,
76
+ )
77
+
78
+
79
+ __all__ = [
80
+ # Vocabulary
81
+ "LAYOUT_VERSION",
82
+ "DEFAULT_GROUP_NAME",
83
+ "DEFAULT_GROUP",
84
+ "DEFAULT_EDITOR_NAME",
85
+ "NAMESPACE_DELIMITER",
86
+ "WINDOW_ID_PATTERN",
87
+ "GROUP_NAME_PATTERN",
88
+ "GROUP_COLOR_PATTERN",
89
+ "GLOBAL_GROUP_NAME",
90
+ "LinkDimension",
91
+ "ViewDirection",
92
+ "RenderMode",
93
+ # Model
94
+ "Group",
95
+ "Link",
96
+ "LinkValue",
97
+ "LinkLike",
98
+ "LayoutWindow",
99
+ "Split",
100
+ "MxNLayoutDocument",
101
+ # Selector
102
+ "MxNWindowSelector",
103
+ # Builders
104
+ "grid",
105
+ "three_up",
106
+ "two_rows_each_direction",
107
+ "single_window",
108
+ # Presets
109
+ "PRESETS",
110
+ "preset",
111
+ "list_presets",
112
+ # File I/O
113
+ "load_preset",
114
+ "save_preset",
115
+ ]
@@ -0,0 +1,239 @@
1
+ # ============================================================================
2
+ #
3
+ # The Medical Imaging Interaction Toolkit (MITK)
4
+ #
5
+ # Copyright (c) German Cancer Research Center (DKFZ)
6
+ # All rights reserved.
7
+ #
8
+ # Use of this source code is governed by a 3-clause BSD license that can be
9
+ # found in the LICENSE file.
10
+ #
11
+ # ============================================================================
12
+
13
+ """Ergonomic split-returning builders for the common layouts.
14
+
15
+ Builders return :class:`Split`. Callers wanting a complete document wrap
16
+ with ``MxNLayoutDocument.create(root=..., name=...)``. The earlier two-tier
17
+ (split + document) is collapsed: convenience cost is one line per script,
18
+ and the smaller surface halves the test matrix.
19
+
20
+ Builders synthesise qualified ids as
21
+ ``f"{editor_name}{NAMESPACE_DELIMITER}{bare_id_stem}{i}"``. With defaults
22
+ (``editor_name='mxn'``, ``bare_id_stem='widget'``, ``start_index=0``) this
23
+ yields ``mxn__widget0``, ``mxn__widget1``, ... -- the convention the engine
24
+ emits via ``QmitkMxNMultiWidget::SerializeLayout``.
25
+
26
+ Builder windows link like a 2D window of the shipped presets: slice and
27
+ crosshair to :data:`GLOBAL_GROUP_NAME`, so they follow the application's
28
+ position, and windowing and lut to their selection group. To let a window
29
+ navigate on its own, unlink its slice and crosshair together.
30
+ """
31
+
32
+ from __future__ import annotations
33
+
34
+ from collections.abc import Sequence
35
+ from itertools import count
36
+
37
+ from ._model import DEFAULT_GROUP, Group, LayoutWindow, Split
38
+ from ._vocabulary import (
39
+ DEFAULT_EDITOR_NAME,
40
+ GLOBAL_GROUP_NAME,
41
+ NAMESPACE_DELIMITER,
42
+ ViewDirection,
43
+ )
44
+
45
+
46
+ _GRID_VIEW_CYCLE: tuple[ViewDirection, ...] = (
47
+ ViewDirection.AXIAL,
48
+ ViewDirection.SAGITTAL,
49
+ ViewDirection.CORONAL,
50
+ )
51
+
52
+
53
+ def _qualify(editor_name: str, bare_id_stem: str, index: int) -> str:
54
+ return f"{editor_name}{NAMESPACE_DELIMITER}{bare_id_stem}{index}"
55
+
56
+
57
+ def _window(
58
+ id_qualified: str,
59
+ view_direction: ViewDirection | str,
60
+ name: str | None,
61
+ selection: str | Group,
62
+ look: str | Group,
63
+ ) -> LayoutWindow:
64
+ return LayoutWindow.create(
65
+ id=id_qualified,
66
+ view_direction=view_direction,
67
+ name=name,
68
+ selection=selection,
69
+ slice=GLOBAL_GROUP_NAME,
70
+ crosshair=GLOBAL_GROUP_NAME,
71
+ windowing=look,
72
+ lut=look,
73
+ )
74
+
75
+
76
+ def grid(
77
+ rows: int,
78
+ cols: int,
79
+ *,
80
+ view_directions: Sequence[ViewDirection] | None = None,
81
+ group: str | Group = DEFAULT_GROUP,
82
+ editor_name: str = DEFAULT_EDITOR_NAME,
83
+ bare_id_stem: str = "widget",
84
+ start_index: int = 0,
85
+ display_names: Sequence[str | None] | None = None,
86
+ ) -> Split:
87
+ """Build a ``rows`` x ``cols`` grid of windows.
88
+
89
+ Outer split is vertical (rows), inner splits are horizontal (cells in
90
+ each row).
91
+
92
+ Args:
93
+ rows: Number of rows (>= 1).
94
+ cols: Number of columns (>= 1).
95
+ view_directions: Per-cell view directions, length ``rows * cols``.
96
+ When omitted, cycles through axial/sagittal/coronal.
97
+ group: Selection group every cell links to; windowing and lut link
98
+ to it too. Accepts a group name string or a ``Group`` instance.
99
+ editor_name: Editor-name segment for synthesised ids; almost all
100
+ callers leave this at ``'mxn'``.
101
+ bare_id_stem: Prefix of the bare-id segment (the index is
102
+ appended).
103
+ start_index: Starting index for synthesised ids; lets callers
104
+ compose multiple grids without id collisions.
105
+ display_names: Per-cell display labels, length ``rows * cols``.
106
+ Entries that are ``None`` produce no ``name`` field.
107
+ """
108
+ if isinstance(rows, bool) or not isinstance(rows, int) or rows < 1:
109
+ raise ValueError(f"rows must be a positive int, got {rows!r}")
110
+ if isinstance(cols, bool) or not isinstance(cols, int) or cols < 1:
111
+ raise ValueError(f"cols must be a positive int, got {cols!r}")
112
+
113
+ cell_count = rows * cols
114
+
115
+ if view_directions is None:
116
+ views = [
117
+ _GRID_VIEW_CYCLE[i % len(_GRID_VIEW_CYCLE)]
118
+ for i in range(cell_count)
119
+ ]
120
+ else:
121
+ if len(view_directions) != cell_count:
122
+ raise ValueError(
123
+ f"view_directions has length {len(view_directions)}; "
124
+ f"expected {cell_count} (rows*cols)"
125
+ )
126
+ views = list(view_directions)
127
+
128
+ if display_names is None:
129
+ names = [None] * cell_count
130
+ else:
131
+ if len(display_names) != cell_count:
132
+ raise ValueError(
133
+ f"display_names has length {len(display_names)}; "
134
+ f"expected {cell_count} (rows*cols)"
135
+ )
136
+ names = list(display_names)
137
+
138
+ counter = count(start_index)
139
+ cells_by_row: list[list[LayoutWindow]] = []
140
+ for r in range(rows):
141
+ cells: list[LayoutWindow] = []
142
+ for c in range(cols):
143
+ cell_idx = r * cols + c
144
+ window_index = next(counter)
145
+ cells.append(
146
+ _window(
147
+ _qualify(editor_name, bare_id_stem, window_index),
148
+ views[cell_idx],
149
+ names[cell_idx],
150
+ group,
151
+ group,
152
+ )
153
+ )
154
+ cells_by_row.append(cells)
155
+
156
+ # Collapse degenerate splits so the output matches what a human
157
+ # author would write: a 1xN grid is a single horizontal split,
158
+ # an Mx1 grid is a single vertical split, an MxN grid is a vertical
159
+ # of horizontals.
160
+ if rows == 1:
161
+ return Split.horizontal(*cells_by_row[0])
162
+ if cols == 1:
163
+ return Split.vertical(*[row[0] for row in cells_by_row])
164
+ return Split.vertical(*[Split.horizontal(*row) for row in cells_by_row])
165
+
166
+
167
+ def three_up(
168
+ *,
169
+ group: str | Group = DEFAULT_GROUP,
170
+ editor_name: str = DEFAULT_EDITOR_NAME,
171
+ bare_id_stem: str = "widget",
172
+ start_index: int = 0,
173
+ ) -> Split:
174
+ """Three windows side by side: axial, sagittal, coronal."""
175
+ return grid(
176
+ 1,
177
+ 3,
178
+ group=group,
179
+ editor_name=editor_name,
180
+ bare_id_stem=bare_id_stem,
181
+ start_index=start_index,
182
+ )
183
+
184
+
185
+ def two_rows_each_direction(
186
+ *,
187
+ group_top: str | Group = DEFAULT_GROUP,
188
+ group_bottom: str | Group = "row2",
189
+ shared_look: bool = False,
190
+ editor_name: str = DEFAULT_EDITOR_NAME,
191
+ bare_id_stem: str = "widget",
192
+ start_index: int = 0,
193
+ ) -> Split:
194
+ """Two horizontal rows; each row has axial / sagittal / coronal.
195
+
196
+ Top row links to ``group_top``, bottom row to ``group_bottom``. By
197
+ default the top is the ``main`` group and the bottom is its own
198
+ ``row2`` group, so each row can show its own data. Every window follows
199
+ the application's position. By default each row's windowing and lut
200
+ link to the row's own group, so each row keeps its own level/window and
201
+ colormap; with ``shared_look`` both rows link them to ``group_top``.
202
+ """
203
+ counter = count(start_index)
204
+
205
+ def row(selection: str | Group) -> Split:
206
+ look = group_top if shared_look else selection
207
+ cells = [
208
+ _window(_qualify(editor_name, bare_id_stem, next(counter)), vd, None, selection, look)
209
+ for vd in _GRID_VIEW_CYCLE
210
+ ]
211
+ return Split.horizontal(*cells)
212
+
213
+ return Split.vertical(row(group_top), row(group_bottom))
214
+
215
+
216
+ def single_window(
217
+ view_direction: ViewDirection | str = ViewDirection.AXIAL,
218
+ *,
219
+ id_qualified: str | None = None,
220
+ editor_name: str = DEFAULT_EDITOR_NAME,
221
+ bare_id_stem: str = "widget",
222
+ start_index: int = 0,
223
+ display_name: str | None = None,
224
+ group: str | Group = DEFAULT_GROUP,
225
+ ) -> Split:
226
+ """A single-window layout, wrapped in a horizontal split.
227
+
228
+ Args:
229
+ view_direction: Anatomical plane.
230
+ id_qualified: Optional explicit qualified id. Must be the canonical
231
+ qualified form (``"mxn__alpha"``); a bare id (``"alpha"``)
232
+ raises ``ValueError`` from the regex check. When ``None``
233
+ (default), synthesises ``f"{editor_name}__{bare_id_stem}{start_index}"``.
234
+ display_name: Optional display label for the cell.
235
+ group: Selection group; windowing and lut link to it too.
236
+ """
237
+ if id_qualified is None:
238
+ id_qualified = _qualify(editor_name, bare_id_stem, start_index)
239
+ return Split.horizontal(_window(id_qualified, view_direction, display_name, group, group))
mitk/mxn/layout/_io.py ADDED
@@ -0,0 +1,66 @@
1
+ # ============================================================================
2
+ #
3
+ # The Medical Imaging Interaction Toolkit (MITK)
4
+ #
5
+ # Copyright (c) German Cancer Research Center (DKFZ)
6
+ # All rights reserved.
7
+ #
8
+ # Use of this source code is governed by a 3-clause BSD license that can be
9
+ # found in the LICENSE file.
10
+ #
11
+ # ============================================================================
12
+
13
+ """File I/O helpers for layout JSON documents.
14
+
15
+ The module intentionally stays thin: the heavy lifting lives in
16
+ ``MxNLayoutDocument.from_json`` / ``MxNLayoutDocument.to_json``.
17
+ """
18
+
19
+ from __future__ import annotations
20
+
21
+ import json
22
+ from collections.abc import Mapping
23
+ from pathlib import Path
24
+ from typing import Any
25
+
26
+ from ._model import MxNLayoutDocument
27
+
28
+
29
+ def load_preset(path: str | Path) -> MxNLayoutDocument:
30
+ """Read a JSON file from disk and parse it via
31
+ :meth:`MxNLayoutDocument.from_json`.
32
+
33
+ Up-front version mismatch raises a clear ``ValueError`` before any
34
+ structural parsing -- see ``MxNLayoutDocument.from_json``.
35
+ """
36
+ text = Path(path).read_text(encoding="utf-8")
37
+ return MxNLayoutDocument.from_json(text)
38
+
39
+
40
+ def save_preset(
41
+ path: str | Path,
42
+ doc: MxNLayoutDocument | Mapping[str, Any],
43
+ ) -> None:
44
+ """Write ``doc`` as JSON to disk.
45
+
46
+ Accepts either a typed :class:`MxNLayoutDocument` (preferred) or a
47
+ raw mapping previously produced by :meth:`MxNLayoutDocument.to_json`.
48
+ For a typed document, calls :meth:`MxNLayoutDocument.to_json` first,
49
+ which validates it; a mapping is written as given, without a check.
50
+ Output uses ``indent=2`` and explicit (schema-aligned) key ordering;
51
+ ``sort_keys`` is **not** enabled because we want ``version, name?,
52
+ groups, root`` rather than alphabetic order.
53
+ """
54
+ payload: Mapping[str, Any]
55
+ if isinstance(doc, MxNLayoutDocument):
56
+ payload = doc.to_json()
57
+ elif isinstance(doc, Mapping):
58
+ payload = doc
59
+ else:
60
+ raise ValueError(
61
+ f"doc must be MxNLayoutDocument or Mapping, got {type(doc).__name__}"
62
+ )
63
+ Path(path).write_text(
64
+ json.dumps(payload, indent=2, sort_keys=False, ensure_ascii=False) + "\n",
65
+ encoding="utf-8",
66
+ )