Skip to content

Commit e895791

Browse files
authored
Merge pull request #729 from bnmajor/properties
Properties
2 parents 6e14f46 + 51946c4 commit e895791

File tree

1 file changed

+108
-0
lines changed

1 file changed

+108
-0
lines changed

itkwidgets/viewer.py

+108
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,28 @@ async def get_image_blend_mode(self) -> asyncio.Future | str:
480480
"""
481481
return await self.viewer_rpc.itk_viewer.getImageBlendMode()
482482

483+
@property
484+
@fetch_value
485+
async def color_map(self) -> asyncio.Future | str:
486+
"""Get the color map for the current component/channel.
487+
488+
:return: The future for the coroutine, to be updated with the current
489+
color map.
490+
:rtype: asyncio.Future | str
491+
"""
492+
return await self.viewer_rpc.itk_viewer.getImageColorMap()
493+
@color_map.setter
494+
@fetch_value
495+
async def color_map(self, color_map: str) -> None:
496+
"""Set the color map for the current component/channel. Queue the
497+
function to be run in the background thread once the plugin API is
498+
available.
499+
500+
:param color_map: Color map for the current image. default: 'Grayscale'
501+
:type color_map: str
502+
"""
503+
self.queue_request('setImageColorMap', color_map)
504+
483505
@fetch_value
484506
def set_image_color_map(self, color_map: str) -> None:
485507
"""Set the color map for the current component/channel. Queue the
@@ -500,6 +522,28 @@ async def get_image_color_map(self) -> asyncio.Future | str:
500522
"""
501523
return await self.viewer_rpc.itk_viewer.getImageColorMap()
502524

525+
@property
526+
@fetch_value
527+
async def color_range(self) -> asyncio.Future | List[float]:
528+
"""Get the range of the data values mapped to colors for the given
529+
image.
530+
531+
:return: _description_
532+
:rtype: asyncio.Future | List[float]
533+
"""
534+
return await self.viewer_rpc.itk_viewer.getImageColorRange()
535+
@color_range.setter
536+
@fetch_value
537+
async def color_range(self, range: List[float]) -> None:
538+
"""The range of the data values mapped to colors for the given image.
539+
Queue the function to be run in the background thread once the plugin
540+
API is available.
541+
542+
:param range: The [min, max] range of the data values
543+
:type range: List[float]
544+
"""
545+
self.queue_request('setImageColorRange', range)
546+
503547
@fetch_value
504548
def set_image_color_range(self, range: List[float]) -> None:
505549
"""The range of the data values mapped to colors for the given image.
@@ -567,6 +611,26 @@ async def vmax(self, vmax: float) -> None:
567611
"""
568612
self.queue_request('setImageColorRangeMax', vmax)
569613

614+
@property
615+
@fetch_value
616+
async def color_bounds(self) -> asyncio.Future | List[float]:
617+
"""Get the range of the data values for color maps.
618+
619+
:return: The future for the coroutine, to be updated with the
620+
[min, max] range of the data values.
621+
:rtype: asyncio.Future | List[float]
622+
"""
623+
return await self.viewer_rpc.itk_viewer.getImageColorRangeBounds()
624+
@color_bounds.setter
625+
@fetch_value
626+
async def color_bounds(self, range: List[float]) -> None:
627+
"""Set the range of the data values for color maps. Queue the function
628+
to be run in the background thread once the plugin API is available.
629+
630+
:param range: The [min, max] range of the data values.
631+
:type range: List[float]
632+
"""
633+
self.queue_request('setImageColorRangeBounds', range)
570634

571635
@fetch_value
572636
def set_image_color_range_bounds(self, range: List[float]) -> None:
@@ -613,6 +677,28 @@ async def get_image_component_visibility(
613677
"""
614678
return await self.viewer_rpc.itk_viewer.getImageComponentVisibility(component)
615679

680+
@property
681+
@fetch_value
682+
async def gradient_opacity(self) -> asyncio.Future | float:
683+
"""Get the gradient opacity for composite volume rendering.
684+
685+
:return: The future for the coroutine, to be updated with the gradient
686+
opacity.
687+
:rtype: asyncio.Future | float
688+
"""
689+
return await self.viewer_rpc.itk_viewer.getImageGradientOpacity()
690+
@gradient_opacity.setter
691+
@fetch_value
692+
async def gradient_opacity(self, opacity: float) -> None:
693+
"""Set the gradient opacity for composite volume rendering. Queue
694+
the function to be run in the background thread once the plugin API is
695+
available.
696+
697+
:param opacity: Gradient opacity in the range (0.0, 1.0]. default: 0.5
698+
:type opacity: float
699+
"""
700+
self.queue_request('setImageGradientOpacity', opacity)
701+
616702
@fetch_value
617703
def set_image_gradient_opacity(self, opacity: float) -> None:
618704
"""Set the gradient opacity for composite volume rendering. Queue
@@ -633,6 +719,28 @@ async def get_image_gradient_opacity(self) -> asyncio.Future | float:
633719
"""
634720
return await self.viewer_rpc.itk_viewer.getImageGradientOpacity()
635721

722+
@property
723+
@fetch_value
724+
async def gradient_opacity_scale(self) -> asyncio.Future | float:
725+
"""Get the gradient opacity scale for composite volume rendering.
726+
727+
:return: The future for the coroutine, to be updated with the current
728+
gradient opacity scale.
729+
:rtype: asyncio.Future | float
730+
"""
731+
return await self.viewer_rpc.itk_viewer.getImageGradientOpacityScale()
732+
@gradient_opacity_scale.setter
733+
@fetch_value
734+
async def gradient_opacity_scale(self, min: float) -> None:
735+
"""Set the gradient opacity scale for composite volume rendering. Queue
736+
the function to be run in the background thread once the plugin API is
737+
available.
738+
739+
:param min: Gradient opacity scale in the range (0.0, 1.0] default: 0.5
740+
:type min: float
741+
"""
742+
self.queue_request('setImageGradientOpacityScale', min)
743+
636744
@fetch_value
637745
def set_image_gradient_opacity_scale(self, min: float) -> None:
638746
"""Set the gradient opacity scale for composite volume rendering. Queue

0 commit comments

Comments
 (0)