Sisyphe.core.sisypheTools

External packages/modules

class Sisyphe.core.sisypheTools.AngleWidget(name: str)

Description

Angle tool class. Angle-measuring 2D widget. It consists of two lines with handles at the ends.

Getter/setter methods:

  • visibility

  • opacity

  • color and selected color

  • font name, bold/italic

  • line width

  • handle size

Inheritance

(vtkDistanceWidget, NamedWidget) -> AngleWidget

Creation: 05/04/2022 Last revision: 18/12/2023

getAngle() float

Get the angle value of the current AngleWidget instance.

Returns

float

angle in degrees

getColor() list[float] | tuple[float, float, float]

Get the color attribute of the current AngleWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getHandleSize() float

Get the handle size attribute of the current AngleWidget instance.

Returns

float

handle size

getLineWidth() float

Get the line width attribute of the current AngleWidget instance.

Returns

float

line width

getOpacity() float

Get the opacity attribute of the current AngleWidget instance.

Returns

float

opacity between 0.0 (transparent) to 1.0 (opaque)

getSelectedColor() list[float] | tuple[float, float, float]

Get the selected color attribute of the current AngleWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getTextProperty() tuple[str, bool, bool]

Get the text property attribute of the current AngleWidget instance.

Returns

tuple[str, bool, bool]
  • str, fontname

  • first bool, is bold ?

  • second bool, is italic ?

getTolerance() int

Get the tolerance attribute of the current AngleWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Returns

int

tolerance in pixels

getVisibility() bool

Get the visibility attribute of the current AngleWidget instance.

Returns

bool

True if visible

setColor(c: list[float] | tuple[float, float, float]) None

Set the color attribute of the current AngleWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setDefaultRepresentation() None

Set default representation (size, color, font, opacity…) of the current AngleWidget instance.

setHandleSize(size: float) None

Set the handle size attribute of the current AngleWidget instance.

Parameters

sizefloat

handle size

setLineWidth(width: float) None

Set the line width attribute of the current AngleWidget instance.

Parameters

widthfloat

line width

setOpacity(alpha: float) None

Set the opacity attribute of the current AngleWidget instance.

Parameters

alphafloat

opacity between 0.0 (transparent) to 1.0 (opaque)

setSelectedColor(c: list[float] | tuple[float, float, float]) None

Set the selected color attribute of the current AngleWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setTextProperty(fontname: str = 'Arial', bold: bool = False, italic: bool = False) None

Set the text property attribute of the current AngleWidget instance.

Parameters

fontnamestr

font name, ‘Arial’ (default), ‘Courier’, ‘Times’ or filename

boldbool

text in bold (default False)

italicbool

text in italic (default False)

setTolerance(tol: int) None

Set the tolerance attribute of the current AngleWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Parameters

tolint

tolerance in pixels

setVisibility(v: bool) None

Show/hide the current AngleWidget instance.

Parameters

vbool

True to show

class Sisyphe.core.sisypheTools.BoxWidget(name: str)

Description

Box tool class. It is a rectangle 2D widget.

Getter/setter methods:

  • visibility

  • opacity

  • color

  • line width

  • size

Inheritance

(vtkDistanceWidget,NamedWidget) -> BoxWidget

Creation: 05/04/2022 Last revision: 18/04/2025

getColor() list[float] | tuple[float, float, float]

Get the color attribute of the current BoxWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getLineWidth() float

Get the line width attribute of the current BoxWidget instance.

Returns

float

line width

getOpacity() float

Get the opacity attribute of the current BoxWidget instance.

Returns

float

opacity between 0.0 (transparent) to 1.0 (opaque)

getPosition() tuple[float, float]

Set the position (upper left corner) of the current BoxWidget instance.

Returns

tuple[float, float]

x-axis and y-axis coordinates

getProportionalResize() bool

Get the resize behavior attribute of the current BoxWidget instance. Indicate whether resizing operations should keep the x-y directions proportional to one another.

Returns

bool

keep proportions if True

getSize() tuple[float, float]

Get the sizes (width and height) of the current BoxWidget instance.

Returns

tuple[float, float]

width and height

getTolerance() int

Get the tolerance attribute of the current BoxWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Returns

int

tolerance in pixels

getVisibility() bool

Get the visibility attribute of the current BoxWidget instance.

Returns

bool

True if visible

setColor(c: list[float] | tuple[float, float, float]) None

Set the color attribute of the current BoxWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setDefaultRepresentation() None

Set default representation (size, color, font, opacity…) of the current BoxWidget instance.

setLineWidth(width: float) None

Set the line width attribute of the current BoxWidget instance.

Parameters

widthfloat

line width

setOpacity(alpha: float) None

Set the opacity attribute of the current BoxWidget instance.

Parameters

alphafloat

opacity between 0.0 (transparent) to 1.0 (opaque)

setPosition(x: float, y: float) None

Set the position (upper left corner) of the current BoxWidget instance.

Parameters

xfloat

x-axis coordinate

yfloat

y-axis coordinate

setProportionalResize(v: bool) None

Set the resize behavior attribute of the current BoxWidget instance. Indicate whether resizing operations should keep the x-y directions proportional to one another.

Parameters

vbool

keep proportions if True

setSize(w: float, h: float) None

Set the sizes (width and height) of the current BoxWidget instance.

Parameters

wfloat

width

hfloat

height

setTolerance(tol: int) None

Set the tolerance attribute of the current BoxWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Parameters

tolint

tolerance in pixels

setVisibility(v: bool) None

Show/hide the current BoxWidget instance.

Parameters

vbool

True to show

class Sisyphe.core.sisypheTools.DistanceWidget(name: str)

Description

Distance tool class. Distance-measuring 2D widget. It consists of a line ruler between two handles at opposite end points.

Getter/setter methods:

  • visibility

  • opacity

  • color and selected color

  • font name, bold/italic

  • line width

  • handle size

Inheritance

(vtkDistanceWidget, NamedWidget) -> DistanceWidget

Creation: 05/04/2022 Last revision: 18/12/2023

getColor() list[float] | tuple[float, float, float]

Get the color attribute of the current DistanceWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getDistance() float

Get the distance value of the current DistanceWidget instance.

Returns

float

distance in mm

getHandleSize() float

Get the handle size attribute of the current DistanceWidget instance.

Returns

float

handle size

getLineWidth() float

Get the line width attribute of the current DistanceWidget instance.

Returns

float

line width

getOpacity() float

Get the opacity attribute of the current DistanceWidget instance.

Returns

float

opacity between 0.0 (transparent) to 1.0 (opaque)

getSelectedColor() list[float] | tuple[float, float, float]

Get the selected color attribute of the current DistanceWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getTextProperty() tuple[str, bool, bool]

Get the text property attribute of the current DistanceWidget instance.

Returns

tuple[str, bool, bool]
  • str, fontname

  • first bool, is bold ?

  • second bool, is italic ?

getTolerance() int

Get the tolerance attribute of the current DistanceWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Returns

int

tolerance in pixels

getVisibility() bool

Get the visibility attribute of the current DistanceWidget instance.

Returns

bool

True if visible

setColor(c: list[float] | tuple[float, float, float]) None

Set the color attribute of the current DistanceWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setDefaultRepresentation() None

Set default representation (size, color, font, opacity…) of the current DistanceWidget instance.

setHandleSize(size: float) None

Set the handle size attribute of the current DistanceWidget instance.

Parameters

sizefloat

handle size

setLineWidth(width: float) None

Set the line width attribute of the current DistanceWidget instance.

Parameters

widthfloat

line width

setOpacity(alpha: float) None

Set the opacity attribute of the current DistanceWidget instance.

Parameters

alphafloat

opacity between 0.0 (transparent) to 1.0 (opaque)

setSelectedColor(c: list[float] | tuple[float, float, float]) None

Set the selected color attribute of the current DistanceWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setTextProperty(fontname: str = 'Arial', bold: bool = False, italic: bool = False) None

Set the text property attribute of the current DistanceWidget instance.

Parameters

fontnamestr

font name, ‘Arial’ (default), ‘Courier’, ‘Times’ or filename

boldbool

text in bold (default False)

italicbool

text in italic (default False)

setTolerance(tol: int) None

Set the tolerance attribute of the current DistanceWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Parameters

tolint

tolerance in pixels

setVisibility(v: bool) None

Show/hide the current DistanceWidget instance.

Parameters

vbool

True to show

class Sisyphe.core.sisypheTools.HandleWidget(name: str, legend: str = 'Target')

Description

Target tool class.

This is a 3D widget that includes:

  • a cross-shaped handle widget

  • a text widget displaying a prefix, a name, a suffix and a legend

  • a sphere widget as safety zone

Scope of methods:

  • getter/setter methods

    • prefix, text, suffix and legend displayed

    • font (name, size, bold, italic)

    • visibility

    • opacity

    • color and selected color

    • line width

    • handle size

    • tolerance

    • surface rendering properties

  • plane projection

  • projection on mesh surface

  • various distances

  • IO methods

Inheritance

(vtkDistanceWidget, NamedWidget) -> HandleWidget

Creation: 05/04/2022 Last revision: 31/03/2025

copyAttributesFrom(tool: HandleWidget) None

Set the current HandleWidget instance attributes from another HandleWidget.

Parameters

toolHandleWidget

copy attributes from this widget

copyAttributesTo(tool: HandleWidget) None

Copy the current HandleWidget instance attributes to another HandleWidget.

Parameters

toolHandleWidget

copy attributes to this widget

createXML(doc: Document, currentnode: Element) None

Write the current HandleWidget instance attributes to xml document instance.

Parameters

docminidom.Document

xml document

currentnodeminidom.Element

xml root node

deepCopy() HandleWidget

Deep copy of the current HandleWidget instance.

Returns

HandleWidget

widget copy

getAmbient() float

Get the ambient lighting coefficient of the current HandleWidget instance.

Returns

float

ambient lighting coefficient (between 0.0 and 1.0)

getColor() list[float] | tuple[float, float, float]

Get the color attribute of the current HandleWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getDistanceToHandleWidget(hw: HandleWidget) float

Get the distance between the current HandleWidget instance and another HandleWidget.

Parameters

hw : HandleWidget

Returns

float

distance in mm

getDistanceToLine(p1: list[float] | tuple[float, float, float], p2: list[float] | tuple[float, float, float]) list[float | list[float] | tuple[float, float, float]]

Get the minimum distance between the current HandleWidget instance and a line.

Parameters

p1tuple[float, float, float] | list[float]

p1, first point to define line equation

p2tuple[float, float, float] | list[float]

p2, second point to define line equation

Returns

list[float | list[float | tuple[float, float]]
  • first element: minimum distance in mm

  • second element: coordinates of the closest point in the line

getDistanceToLineWidget(lw: LineWidget) list[float | list[float] | tuple[float, float, float]]

Get the minimum distance between the current HandleWidget instance and a LineWidget.

Parameters

lw : LineWidget

Returns

list[float | tuple[float, float, float] | list[float]]
  • first element: minimum distance in mm

  • second element: coordinates of the closest point in the line

getDistanceToPlane(p: vtkPlane | vtkImageSlice | SliceViewWidget) float

Get the distance between the current HandleWidget instance and a plane along its normal direction.

Parameters

pvtk.vtkPlane | vtk.vtkImageSlice | Sisyphe.widgets.sliceViewWidgets.SliceViewWidget

plane

Returns

float

distance in mm

getDistanceToPoint(p: list[float] | tuple[float, float, float]) float

Get the distance between the current HandleWidget instance and a point.

Parameters

p : tuple[float, float, float] | list[float]

Returns

float

distance in mm

classmethod getFileExt() str

Get HandleWidget file extension.

Returns

str

‘.xpoint’

classmethod getFilterExt() str

Get HandleWidget filter used by QFileDialog.getOpenFileName() and QFileDialog.getSaveFileName().

Returns

str

‘PySisyphe Target tool (.xpoint)’

getFontBold() bool

Check whether the text of the current HandleWidget instance is displayed in bold.

Returns

bool

True if text displayed in bold

getFontFamily() str

Get the font used to display the text of the current HandleWidget instance.

Returns

str

font name ‘Arial’ (default), ‘Courier’, ‘Times’ or font file name

getFontItalic() bool

Check whether the text of the current HandleWidget instance is displayed in italic.

Returns

bool

True if text displayed in italic

getFontSize() int

Get the font size used to display the text of the current HandleWidget instance.

Returns

int

font size

getHandleSize() float

Get the handle size attribute of the current HandleWidget instance.

Returns

float

handle size

getInterpolation() int

Get the shading interpolation method (as int code) of the current HandleWidget instance.

Returns

int

shading interpolation code (0 ‘Flat’, 1 ‘Gouraud’, 2 ‘Phong’, 3 ‘PBR’)

getLegend() str

Get the legend attribute of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Returns

str

tool text legend

getLineWidth() float

Get the line width attribute of the current HandleWidget instance.

Returns

float

line width

getMetallic() float

Get the metallic coefficient of the current HandleWidget instance. Usually this value is either 0.0 or 1.0 for real material but any value in between is valid. This parameter is only used by PBR Interpolation (Default is 0.0).

Returns

float

metallic coefficient

getOpacity() float

Get the opacity attribute of the current HandleWidget instance.

Returns

float

opacity between 0.0 (transparent) to 1.0 (opaque)

getPosition() list[float] | tuple[float, float, float]

Get the position of the current HandleWidget instance.

Returns

tuple[float, float, float] | list[float]

position in world coordinates

getPrefix() str

Get the prefix attribute of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Returns

str

tool text prefix

getRoughness() float

Get the roughness coefficient of the current HandleWidget instance. This value has to be between 0.0 (glossy) and 1.0 (rough). A glossy material has reflections and a high specular part. This parameter is only used by PBR Interpolation (Default 0.5)

Returns

float

between 0.0 (glossy) and 1.0 (rough)

getSelectedColor() list[float] | tuple[float, float, float]

Get the selected color attribute of the current HandleWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getSpecular() float

Get the specular lighting coefficient of the current HandleWidget instance.

Returns

float

specular lighting coefficient (between 0.0 and 1.0)

getSpecularPower() float

Get the specular power of the current HandleWidget instance.

Returns

float

specular power (between 0.0 and 50.0)

getSphereProperties() vtkProperty

Get the safety zone sphere properties of the current HandleWidget instance.

Returns

vtkProperty

sphere properties

getSphereRadius() float

Get the safety zone radius (sphere widget) of the current HandleWidget instance.

Returns

float

safety zone radius in mm

getSphereVisibility() bool

Get the safety zone (sphere widget) visibility of the current HandleWidget instance.

Returns

bool

True if text is visible

getSuffix() str

Get the suffix attribute of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Returns

str

tool text suffix

getText() str

Get the text of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Returns

str

tool text

getTextOffset() tuple[int, int]

Get the relative position of text in relation to handle in the current HandleWidget instance.

Parameters

tuple[int, int]
  • first value, x-axis relative position in pixel unit (+ right, - left)

  • second value, y-axis relative position in pixel unit (+ bottom, - top)

getTextProperty() tuple[str, bool, bool]

Set the font properties used to display the text of the current HandleWidget instance.

Returns

tuple[str, bool, bool]
  • str, fontname

  • first bool, is bold ?

  • second bool, is italic ?

getTextVisibility() bool

Get the text visibility of the current HandleWidget instance.

Returns

bool

True if text is visible

getTolerance() int

Get the tolerance attribute of the current HandleWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Returns

int

tolerance in pixels

getVisibility() bool

Get the visibility attribute of the current HandleWidget instance.

Returns

bool

True if visible

isDynamic()

Check whether the current LineWidget instance is dynamic i.e. position processed from other tools (relative or weighted position)

Returns

bool

True if dynamic

isStatic()

Check whether the current LineWidget instance is static i.e. absolute position

Returns

bool

True if static

load(filename: str) None

Load the current HandleWidget instance from a PySisyphe Target tool (.xpoint) file.

Parameters

filenamestr

PySisyphe Target tool file name

meshSurfaceProjection(plane: vtkPlane | vtkImageSlice | SliceViewWidget, mesh: SisypheMesh) int

Projects the current instance of the HandleWidget onto the surface of a mesh along the normal direction of a plane.

Parameters

planevtk.vtkPlane | vtk.vtkImageSlice | Sisyphe.widgets.sliceViewWidgets.SliceViewWidget

plane used to define normal direction

meshSisyphe.core.sisypheMesh.SisypheMesh

projection mesh

parseXML(doc: Document)

Read the current HandleWidget instance attributes from xml document instance.

Parameters

docminidom.Document

xml document

parseXMLNode(currentnode: Element) None

Read the current HandleWidget instance attributes from xml document instance.

Parameters

currentnodeminidom.Element

xml root node

planeProjection(plane: vtkPlane | vtkImageSlice | SliceViewWidget) None

Projecting the current HandleWidget instance onto a plane along its normal direction.

Parameters

planevtk.vtkPlane | vtk.vtkImageSlice | Sisyphe.widgets.sliceViewWidgets.SliceViewWidget

projection plane

saveAs(filename: str) None

Save the current HandleWidget instance to a PySisyphe Target tool (.xpoint) file.

Parameters

filenamestr

PySisyphe Target tool file name

setAmbient(v: float) None

Set the ambient lighting coefficient of the current HandleWidget instance.

Parameters

vfloat

ambient lighting coefficient (between 0.0 and 1.0)

setColor(c: list[float] | tuple[float, float, float]) None

Set the color attribute of the current HandleWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setDefaultRepresentation() None

Set default representation (size, color, font, opacity…) of the current HandleWidget instance.

setDynamic()

Set the current LineWidget instance as dynamic i.e. position processed from other tools (relative or weighted position).

setFontBold(v: bool) None

Display the text of the current HandleWidget instance in bold.

Parameters

vbool

displays in bold if True

setFontFamily(fontname: str = 'Arial') None

Set the font used to display the text of the current HandleWidget instance.

Parameters

fontnamestr

font name ‘Arial’ (default), ‘Courier’, ‘Times’ or font file name

setFontItalic(v: bool) None

Display the text of the current HandleWidget instance in italic.

Parameters

vbool

displays in italic if True

setFontSize(size: int) None

Set the font size used to display the text of the current HandleWidget instance.

Parameters

sizeint

font size

setHandleSize(size: float) None

Set the handle size attribute of the current HandleWidget instance.

Parameters

sizefloat

handle size

setInterpolation(inter: int) None

Set the shading interpolation method of the current HandleWidget instance, as int code.

Parameters

interint

shading interpolation code (0 ‘Flat’, 1 ‘Gouraud’, 2 ‘Phong’, 3 ‘PBR’)

setLegend(txt: str = 'Target') None

Set the legend attribute of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

txtstr

tool text legend

setLineWidth(width: float) None

Set the line width attribute of the current HandleWidget instance.

Parameters

widthfloat

line width

setMetallic(v: float) None

Set the metallic coefficient of the current HandleWidget instance. Usually this value is either 0.0 or 1.0 for real material but any value in between is valid. This parameter is only used by PBR Interpolation (Default is 0.0).

Parameters

vfloat

metallic coefficient

setName(name: str) None

Set the name attribute of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

namestr

tool text name

setOpacity(alpha: float) None

Set the opacity attribute of the current HandleWidget instance.

Parameters

alphafloat

opacity between 0.0 (transparent) to 1.0 (opaque)

setPosition(p: list[float] | tuple[float, float, float]) None

Set the position of the current HandleWidget instance.

Parameters

ptuple[float, float, float] | list[float]

position in world coordinates

setPrefix(txt: str = '') None

Set the prefix attribute of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

txtstr

tool text prefix

setRoughness(v: float) None

Set the roughness coefficient of the current HandleWidget instance. This value has to be between 0.0 (glossy) and 1.0 (rough). A glossy material has reflections and a high specular part. This parameter is only used by PBR Interpolation (Default 0.5)

Parameters

vfloat

between 0.0 (glossy) and 1.0 (rough)

setSelectedColor(c: list[float] | tuple[float, float, float]) None

Set the selected color attribute of the current HandleWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setSpecular(v: float) None

Set the specular lighting coefficient of the current HandleWidget instance.

Parameters

vfloat

specular lighting coefficient (between 0.0 and 1.0)

setSpecularPower(v: float) None

Set the specular power of the current HandleWidget instance.

Parameters

vfloat

specular power (between 0.0 and 50.0)

setSphereProperties(p: vtkProperty) None

Set the safety zone sphere properties of the current HandleWidget instance.

Parameters

pvtkProperty

sphere properties

setSphereRadius(radius: float) None

Set the safety zone radius (sphere widget) of the current HandleWidget instance.

Parameters

radiusfloat

safety zone radius in mm

setSphereVisibility(v: bool) None

Show/hide safety zone (sphere widget) of the current HandleWidget instance.

Parameters

vbool

True to show text

setStatic()

Set the current LineWidget instance as static i.e. absolute position.

setSuffix(txt: str = '') None

Set the suffix attribute of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

txtstr

tool text suffix

setText(txt: str) None

Set the text of the current HandleWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

txtstr

tool text

setTextOffset(r: tuple[int, int] | list[int]) None

Set the relative position of text in relation to handle in the current HandleWidget instance.

Parameters

rtuple[int, int] | list[int]
  • first value, x-axis relative position in pixel unit (+ right, - left)

  • second value, y-axis relative position in pixel unit (+ bottom, - top)

setTextProperty(fontname: str = 'Arial', bold: bool = False, italic: bool = False) None

Set the font properties used to display the text of the current HandleWidget instance.

Parameters

fontnamestr

font name ‘Arial’ (default), ‘Courier’, ‘Times’ or font file name

boldbool

True to display in bold (default False)

italicbool

True to display in italic (default False)

setTextVisibility(v: bool) None

Show/hide the text of the current HandleWidget instance.

Parameters

vbool

True to show text

setTolerance(tol: int) None

Set the tolerance attribute of the current HandleWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Parameters

tolint

tolerance in pixels

setVisibility(v: bool) None

Show/hide the current HandleWidget instance.

Parameters

vbool

True to show

updateContourActor(plane: vtkPlane) None

Update sphere rendering on a 2D cutting plane. This method is called by private VTK events methods.

Parameters

planevtkPlane

cutting plane

class Sisyphe.core.sisypheTools.LineWidget(name: str, legend: list[str] | tuple[str, str] = ('Target', 'Entry'))

Trajectory tool class.

This is a 3D widget that includes:

  • three cross-shaped handle widgets, two at the extremities (target and entry points) and one at the middle

  • two text widgets displaying a prefix, a name, a suffix and a legend at the extremities

  • a tube widget as safety zone

Scope of methods:

  • getter/setter methods

    • prefix, text, suffix and legend displayed

    • font (name, size, bold, italic)

    • visibility

    • opacity

    • color and selected color

    • line width

    • handle size

    • tolerance

    • surface rendering properties

  • plane projection

  • projection on mesh surface

  • various distances

  • IO methods

(vtkDistanceWidget, NamedWidget) -> LineWidget

Creation: 05/04/2022 Last revision: 31/03/2025

copyAttributesFrom(tool: LineWidget) None

Set the current LineWidget instance attributes from another LineWidget.

Parameters

toolLineWidget

copy attributes from this widget

copyAttributesTo(tool: LineWidget) None

Copy the current LineWidget instance attributes to another LineWidget.

Parameters

toolLineWidget

copy attributes to this widget

createXML(doc: Document, currentnode: Element) None

Write the current LineWidget instance attributes to xml document instance.

Parameters

docminidom.Document

xml document

currentnodeminidom.Element

xml root node

deepCopy() LineWidget

Deep copy of the current LineWidget instance.

Returns

LineWidget

line copy

extendPosition1(mm: float) None

Extend/reduce LineWidget length on the target side.

Parameters

mmfloat
  • reduce or + extend in mm

extendPosition1ToMeshCenter(mesh: SisypheMesh) None

Move the target point of the current LineWidget instance to the center of a mesh (vtk.vtkActor center).

Parameters

meshSisyphe.core.sisypheMesh.SisypheMesh

mesh to use

extendPosition1ToMeshCenterOfMass(mesh: SisypheMesh) None

Move the target point of the current LineWidget instance to the center of mass of a mesh.

Parameters

meshSisyphe.core.sisypheMesh.SisypheMesh

mesh to use

extendPosition1ToMeshSurface(mesh: SisypheMesh) int

Projecting the target point of the current LineWidget instance onto a mesh surface along the trajectory direction.

Parameters

meshSisyphe.core.sisypheMesh.SisypheMesh

projection mesh

Returns

int

number of intersections (0 if no intersection)

extendPosition1ToPlane(plane: vtkPlane | vtkImageSlice | SliceViewWidget) None

Projecting the target point of the current LineWidget instance onto a plane along the trajectory direction.

Parameters

planevtk.vtkPlane | vtk.vtkImageSlice | Sisyphe.widgets.sliceViewWidgets.SliceViewWidget

projection plane

extendPosition2(mm: float) None

Extend/reduce LineWidget length on the entry side.

Parameters

mmfloat
  • reduce or + extend in mm

extendPosition2ToMeshCenter(mesh: SisypheMesh) None

Move the entry point of the current LineWidget instance to the center of a mesh (vtk.vtkActor center).

Parameters

meshSisyphe.core.sisypheMesh.SisypheMesh

mesh to use

extendPosition2ToMeshCenterOfMass(mesh: SisypheMesh) None

Move the entry point of the current LineWidget instance to the center of mass of a mesh.

Parameters

meshSisyphe.core.sisypheMesh.SisypheMesh

mesh to use

extendPosition2ToMeshSurface(mesh: SisypheMesh) int

Projecting the entry point of the current LineWidget instance onto a mesh surface along the trajectory direction.

Parameters

meshSisyphe.core.sisypheMesh.SisypheMesh

projection mesh

Returns

int

number of intersections (0 if no intersection)

extendPosition2ToPlane(plane: vtkPlane | vtkImageSlice | SliceViewWidget) None

Projecting the entry point of the current LineWidget instance onto a plane along the trajectory direction.

Parameters

planevtk.vtkPlane | vtk.vtkImageSlice | Sisyphe.widgets.sliceViewWidgets.SliceViewWidget

projection plane

getAmbient() float

Get the ambient lighting coefficient of the current LineWidget instance.

Returns

float

ambient lighting coefficient (between 0.0 and 1.0)

getColor() list[float] | tuple[float, float, float]

Get the color attribute of the current LineWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getDistancesToHandleWidget(hw: HandleWidget) list[float]

Get some distances between a HandleWidget and the current LineWidget instance.

Parameters

hwHandleWidget

point coordinates

Returns

list[float]
  • first element, distance between handle parameter and target point

  • second element, distance between handle parameter and entry point

  • third element, minimum distance between handle parameter and line

getDistancesToLine(p1: list[float] | tuple[float, float, float], p2: list[float] | tuple[float, float, float]) list[float | list[float] | tuple[float, float, float]]

Get some distances between a line and the current LineWidget instance.

Parameters

p1tuple[float, float, float] | float[float, float, float]

point coordinates

p2tuple[float, float, float] | float[float, float, float]

point coordinates, these two points define the line

Returns

list[float | list[float]]
  • first element, distance between line parameter and target point

  • second element, distance between line parameter and entry point

  • third element, distance between line parameter and LineWidget line

  • fourth element, distance between p1 parameter and target point

  • fifth element, distance between p1 parameter and entry point

  • sixth element, distance between p2 parameter and target point

  • seventh element, distance between p2 parameter and entry point

  • ninth element, coordinates of the closest point on line parameter

  • tenth element, coordinates of the closest point on LineWidget line

getDistancesToLineWidget(lw: LineWidget) list[float | list[float] | tuple[float, float, float]]

Get some distances between a LineWidget and the current LineWidget instance.

Parameters

lwLineWidget

line

Returns

list[float | list[float]]
  • first element, distance between LineWidget parameter and current target point

  • second element, distance between LineWidget parameter and current entry point

  • third element, distance between LineWidget parameter and current LineWidget line

  • fourth element, distance between LineWidget target parameter and current target point

  • fifth element, distance between LineWidget target parameter and current entry point

  • sixth element, distance between LineWidget entry parameter and current target point

  • seventh element, distance between LineWidget entry parameter and current entry point

  • ninth element, coordinates of the closest point on LineWidget parameter

  • tenth element, coordinates of the closest point on current LineWidget line

getDistancesToPlane(p: vtkPlane | vtkImageSlice | SliceViewWidget) list[float | vectorFloat3]

Get some distances between a plane and the current LineWidget instance.

Parameters

pvtk.vtkPlane | vtk.vtkImageSlice | Sisyphe.widgets.sliceViewWidgets.SliceViewWidget

plane

Returns

list[float | list[float]]
  • first element, distance between plane parameter and target point

  • second element, distance between plane parameter and entry point

  • third element, coordinates of the line projection on the plane

getDistancesToPoint(p: list[float] | tuple[float, float, float]) list[float]

Get some distances between a point and the current LineWidget instance.

Parameters

ptuple[float, float, float] | list[float]

point cooridnates

Returns

list[float]
  • first element, distance between parameter point and target point

  • second element, distance between parameter point and entry point

  • third element, minimum distance between parameter point and line

classmethod getFileExt() str

Get LineWidget file extension.

Returns

str

‘.xline’

classmethod getFilterExt() str

Get LineWidget filter used by QFileDialog.getOpenFileName() and QFileDialog.getSaveFileName().

Returns

str

‘PySisyphe Trajectory tool (.xline)’

getFontBold() bool

Check whether the text of the current LineWidget instance is displayed in bold.

Returns

bool

True if text displayed in bold

getFontFamily() str

Get the font used to display the text of the current LineWidget instance.

Returns

str

font name ‘Arial’ (default), ‘Courier’, ‘Times’ or font file name

getFontItalic() bool

Check whether the text of the current LineWidget instance is displayed in italic.

Returns

bool

True if text displayed in italic

getFontSize() int

Get the font size used to display the text of the currentLineWidget instance.

Returns

int

font size

getHandleLineWidth() float

Get the handle line width attribute of the current LineWidget instance.

Returns

float

handle line width

getHandleSize() float

Get the handle size attribute of the current LineWidget instance.

Returns

float

handle size

getInterpolation() int

Get the shading interpolation method (as int code) of the current LineWidget instance.

Returns

int

shading interpolation code (0 ‘Flat’, 1 ‘Gouraud’, 2 ‘Phong’, 3 ‘PBR’)

getLegend() list[str]

Get the legend attribute of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Returns

list[str]
  • first element, target text legend

  • second element, entry text legend

getLength() float

Get the trajectory length of the current LineWidget instance.

Returns

float

trajectory length in mm

getLineToLineDistance(p1: list[float] | tuple[float, float, float], p2: list[float] | tuple[float, float, float]) float

Get the distance between a line and the current LineWidget instance.

Parameters

p1tuple[float, float, float] | float[float, float, float]

point coordinates

p2tuple[float, float, float] | float[float, float, float]

point coordinates, these two points define the line

Returns

float

minimal perpendicular distance metric between two line segments

getLineWidth() float

Get the line width attribute of the current LineWidget instance.

Returns

float

line width

getMetallic() float

Get the metallic coefficient of the current LineWidget instance. Usually this value is either 0.0 or 1.0 for real material but any value in between is valid. This parameter is only used by PBR Interpolation (Default is 0.0).

Returns

float

getOpacity() float

Get the opacity attribute of the current LineWidget instance.

Returns

float

opacity between 0.0 (transparent) to 1.0 (opaque)

getPointSize() float

Set the size of the target and entry points of the current LineWidget instance.

Returns

float

target and entry points size in mm

getPosition1() list[float] | tuple[float, float, float]

Get the target point position of the current LineWidget instance.

Returns

tuple[float, float, float] | list[float]

target point position in world coordinates

getPosition2() list[float] | tuple[float, float, float]

Get the entry point position of the current LineWidget instance.

Returns

tuple[float, float, float] | list[float]

entry point position in world coordinates

getPrefix() list[str]

Get the prefix attribute of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Returns

list[str]
  • first element, target text prefix

  • second element, entry text prefix

getRenderLineAsTube() bool

Check whether the line of the current LineWidget instance is rendered as tube.

Returns

bool

True if render line as tube

getRenderPointsAsSpheres() bool

Check whether the points (target/entry) of the current LineWidget instance are rendered as spheres.

Returns

bool

True if render point as sphere

getRoughness() float

Get the roughness coefficient of the current LineWidget instance. This value has to be between 0.0 (glossy) and 1.0 (rough). A glossy material has reflections and a high specular part. This parameter is only used by PBR Interpolation (Default 0.5)

Returns

float

between 0.0 (glossy) and 1.0 (rough)

getSelectedColor() list[float] | tuple[float, float, float]

Get the selected color attribute of the current LineWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getSpecular() float

Get the specular lighting coefficient of the current LineWidget instance.

Returns

float

specular lighting coefficient (between 0.0 and 1.0)

getSpecularPower() float

Get the specular power of the current LineWidget instance.

Returns

float

specular power (between 0.0 and 50.0)

getSuffix() list[str]

Get the suffix attribute of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Returns

list[str]
  • first element, target text suffix

  • second element, entry text suffix

getText() list[str]

Get the text attribute of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Returns

list[str]
  • first element, target text

  • second element, entry text

getTextOffset() tuple[int, int]

Get the relative position of text in relation to handle in the current LineWidget instance.

Parameters

tuple[int, int]
  • first value, x-axis relative position in pixel unit (+ right, - left)

  • second value, y-axis relative position in pixel unit (+ bottom, - top)

getTextProperty() tuple[str, bool, bool]

Set the font properties used to display the text of the current HandleWidget instance.

Returns

tuple[str, bool, bool]
  • first element, font name ‘Arial’ (default), ‘Courier’, ‘Times’ or font file name

  • second element, bold ?

  • third element, italic ?

getTextVisibility() bool

Get the text visibility of the current LineWidget instance.

Returns

bool

True if text is visible

getTolerance() int

Get the tolerance attribute of the current LineWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Returns

int

tolerance in pixels

getTrajectoryAngles(deg: bool = True) list[float] | tuple[float, float]

Get the trajectory angles of the current LineWidget instance.

There are two angles:

  • sagittal (rotation around x-axis, -180.0° to +180.0°)

  • coronal (rotation around y-axis, -90.0° to +90.0°)

Parameters

degbool

angles in degrees if True (default), in radians otherwise

Returns

list[float]
  • first element, sagittal angle

  • second element, coronal angle

getTubeProperties() vtkProperty

Get the safety zone (tube widget) properties of the current HandleWidget instance.

Returns

vtkProperty

tube properties

getTubeRadius() float

Get the safety zone radius (tube widget) of the current LineWidget instance.

Returns

float

safety zone radius in mm

getTubeVisibility() bool

Get the safety zone (tube widget) visibility of the current LineWidget instance.

Returns

bool

True if text is visible

getVector(length: float = 1.0) list[float] | tuple[float, float, float]

Get the direction vector of the current LineWidget instance.

Parameters

lengthfloat

vector norm in mm (unit vector, default 1.0)

Returns

list[float]

direction vector

getVisibility() bool

Get the visibility attribute of the current LineWidget instance.

Returns

bool

True if visible

isDynamic() bool

Check whether the current HandleWidget instance is dynamic i.e. position processed from other tools (relative or weighted position)

Returns

bool

True if dynamic

isStatic() bool

Check whether the current HandleWidget instance is static i.e. absolute position

Returns

bool

True if static

load(filename: str) None

Load the current LineWidget instance from a PySisyphe Trajectory tool (.xline) file.

Parameters

filenamestr

PySisyphe Trajectory tool file name

parseXML(doc: Document) None

Read the current LineWidget instance attributes from xml document instance.

Parameters

docminidom.Document

xml document

parseXMLNode(currentnode: Element) None

Read the current LineWidget instance attributes from xml document instance.

Parameters

currentnodeminidom.Element

xml root node

saveAs(filename: str) None

Save the current LineWidget instance to a PySisyphe Trajectory tool (.xline) file.

Parameters

filenamestr

PySisyphe Trajectory tool file name

setAmbient(v: float) None

Set the ambient lighting coefficient of the current LineWidget instance.

Parameters

vfloat

ambient lighting coefficient (between 0.0 and 1.0)

setColor(c: list[float] | tuple[float, float, float]) None

Set the color attribute of the current LineWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setDefaultRepresentation() None

Set default representation (size, color, font, opacity…) of the current LineWidget instance.

setDynamic() None

Set the current HandleWidget instance as dynamic i.e. position processed from other tools (relative or weighted position).

setFontBold(v: bool) None

Display the text of the current LineWidget instance in bold.

Parameters

vbool

displays in bold if True

setFontFamily(fontname: str = 'Arial') None

Set the font used to display the text of the current LineWidget instance.

Parameters

fontnamestr

font name ‘Arial’ (default), ‘Courier’, ‘Times’ or font file name

setFontItalic(v: bool) None

Display the text of the current LineWidget instance in italic.

Parameters

vbool

displays in italic if True

setFontSize(size: int) None

Set the font size used to display the text of the current LineWidget instance.

Parameters

sizeint

font size

setHandleLineWidth(size: float) None

Set the handle line width attribute of the current LineWidget instance.

Parameters

sizefloat

handle line width

setHandleSize(size: float) None

Set the handle size attribute of the current LineWidget instance.

Parameters

sizefloat

handle size

setInterpolation(inter: int) None

Set the shading interpolation method of the current LineWidget instance, as int code.

Parameters

interint

shading interpolation code (0 ‘Flat’, 1 ‘Gouraud’, 2 ‘Phong’, 3 ‘PBR’)

setLegend(txt: tuple[str, str] | list[str] = ('', '')) None

Set the legend attribute of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

txttuple[str, str] | list[str]
  • first element, target text legend (default empty str)

  • second element, entry text legend (default empty str)

setLineWidth(width: float) None

Set the line width attribute of the current LineWidget instance.

Parameters

widthfloat

line width

setMetallic(v: float) None

Set the metallic coefficient of the current LineWidget instance. Usually this value is either 0.0 or 1.0 for real material but any value in between is valid. This parameter is only used by PBR Interpolation (Default is 0.0).

Parameters

v : float

setName(name: str) None

Set the name attribute of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

namestr

tool text name

setOpacity(alpha: float) None

Set the opacity attribute of the current LineWidget instance.

Parameters

alphafloat

opacity between 0.0 (transparent) to 1.0 (opaque)

setPointSize(size: float) None

Set the size of the target and entry points of the current LineWidget instance.

Parameters

sizefloat

target and entry points size in mm

setPosition1(p: list[float] | tuple[float, float, float]) None

Set the target point position of the current LineWidget instance.

Parameters

ptuple[float, float, float] | list[float]

target point position in world coordinates

setPosition2(p: list[float] | tuple[float, float, float]) None

Set the entry point position of the current LineWidget instance.

Parameters

ptuple[float, float, float] | list[float]

entry point position in world coordinates

setPrefix(txt: tuple[str, str] | list[str] = ('', '')) None

Set the prefix attribute of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

txttuple[str, str] | list[str]
  • first element, target text prefix (default empty str)

  • second element, entry text prefix (default empty str)

setRenderLineAsTube(v: bool) None

Enable/disable rendering line of the current LineWidget instance as tube.

Parameters

vbool

render line as tube if True

setRenderPointsAsSpheres(v: bool) None

Enable/disable rendering points (target/entry) of the current LineWidget instance as sphere.

Parameters

vbool

render point as sphere if True

setRoughness(v: float) None

Set the roughness coefficient of the current LineWidget instance. This value has to be between 0.0 (glossy) and 1.0 (rough). A glossy material has reflections and a high specular part. This parameter is only used by PBR Interpolation (Default 0.5)

Parameters

vfloat

between 0.0 (glossy) and 1.0 (rough)

setSelectedColor(c: list[float] | tuple[float, float, float]) None

Set the selected color attribute of the current LineWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setSpecular(v: float) None

Set the specular lighting coefficient of the current LineWidget instance.

Parameters

vfloat

specular lighting coefficient (between 0.0 and 1.0)

setSpecularPower(v: float) None

Set the specular power of the current LineWidget instance.

Parameters

vfloat

specular power (between 0.0 and 50.0)

setStatic() None

Set the current HandleWidget instance as static i.e. absolute position.

setSuffix(txt: tuple[str, str] | list[str] = ('', '')) None

Set the suffix attribute of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

txttuple[str, str] | list[str]
  • first element, target text suffix (default empty str)

  • second element, entry text suffix (default empty str)

setText(txt: list[str]) None

Set the text of the current LineWidget instance. The text widget displays a prefix, a name, a suffix and a legend.

Parameters

list[str]
  • first element, target text

  • second element, entry text

setTextOffset(r: tuple[int, int] | list[int]) None

Set the relative position of text in relation to handle in the current LineWidget instance.

Parameters

rtuple[int, int] | list[int]
  • first value, x-axis relative position in pixel unit (+ right, - left)

  • second value, y-axis relative position in pixel unit (+ bottom, - top)

setTextProperty(fontname: str = 'Arial', bold: bool = False, italic: bool = False) None

Set the font properties used to display the text of the current LineWidget instance.

Parameters

fontnamestr

font name ‘Arial’ (default), ‘Courier’, ‘Times’ or font file name

boldbool

True to display in bold (default False)

italicbool

True to display in italic (default False)

setTextVisibility(v: bool) None

Show/hide the text of the current LineWidget instance.

Parameters

vbool

True to show text

setTolerance(tol: int) None

Set the tolerance attribute of the current LineWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Parameters

tolint

tolerance in pixels

setTrajectoryAngles(r: list[float] | tuple[float, float], length: float = 50.0, deg: bool = True) None

Set the trajectory angles of the current LineWidget instance.

There are two angles:

  • sagittal (rotation around x-axis, -180.0° to +180.0°)

  • coronal (rotation around y-axis, -90.0° to +90.0°)

Parameters

rtuple[float, float] | list[float]
  • first element, sagittal angle (rotation around x-axis, -180.0° to +180.0°)

  • second element, coronal angle (rotation around y-axis, -90.0° to +90.0°)

lengthfloat

trajectory length in mm (default 50.0)

degbool

angles in degrees if True (default), in radians otherwise

setTubeProperties(p: vtkProperty) None

Set the safety zone (tube widget) properties of the current LineWidget instance.

Parameters

pvtkProperty

tube properties

setTubeRadius(radius: float) None

Set the safety zone radius (tube widget) of the current LineWidget instance.

Parameters

radiusfloat

safety zone radius in mm

setTubeVisibility(v: bool)

Show/hide safety zone (tube widget) of the current LineWidget instance.

Parameters

vbool

True to show text

setVisibility(v: bool) None

Show/hide the current LineWidget instance.

Parameters

vbool

True to show

updateContourActor(plane: vtkPlane) None

Update tube rendering on a 2D cutting plane. This method is called by private VTK events methods.

Parameters

planevtkPlane

cutting plane

class Sisyphe.core.sisypheTools.NamedWidget(name: str = '')

Description

Ancestor class for all tool classes.

Getter/setter methods:
  • tool name

  • type of tool, 2D or 3D

Inheritance

object -> NamedObject

Creation: 05/04/2022 Last revision: 18/12/2023

getName() str

Get the name attribute of the current NamedWidget instance.

Returns

str

tool name

hasName() bool

Check whether the name attribute of the current NamedWidget instance is defined.

Returns

bool

True if tool name is defined

isSliceDisplay() bool

Check whether the type attribute of the current NamedWidget instance is 2D.

Returns

bool

True if tool type is 2D

isVolumeDisplay() bool

Check whether the type attribute of the current NamedWidget instance is 3D.

Returns

bool

True if tool type is 3D

setName(name: str) None

Set the name attribute of the current NamedWidget instance.

Parameters

namestr

tool name

setSliceDisplay() None

Set the type attribute of the NamedWidget instance constructor to 2D.

setVolumeDisplay() None

Set the type attribute of the NamedWidget instance constructor to 3D.

class Sisyphe.core.sisypheTools.OrthogonalDistanceWidget(name: str)

Description

Orthogonal distance tool class (two orthogonal rulers). It consists of two orthogonal line rulers with handles at the end points.

Getter/setter methods:

  • visibility

  • opacity

  • color and selected color

  • font name, bold/italic

  • line width

  • handle size

Inheritance

(vtkDistanceWidget, NamedWidget) -> OrthogonalDistanceWidget

Creation: 05/04/2022 Last revision: 18/12/2023

getColor() list[float] | tuple[float, float, float]

Get the color attribute of the current OrthogonalDistanceWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getDistances() tuple[float, float]

Get the distance values of the current OrthogonalDistanceWidget instance.

Returns

tuple[float, float]

distances in mm

getHandleSize() float

Get the handle size attribute of the current OrthogonalDistanceWidget instance.

Returns

float

handle size

getLineWidth() float

Get the line width attribute of the current OrthogonalDistanceWidget instance.

Returns

float

line width

getOpacity() float

Get the opacity attribute of the current OrthogonalDistanceWidget instance.

Returns

float

opacity between 0.0 (transparent) to 1.0 (opaque)

getSelectedColor() list[float] | tuple[float, float, float]

Get the selected color attribute of the current OrthogonalDistanceWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getTextProperty() tuple[str, bool, bool]

Get the text property attribute of the current OrthogonalDistanceWidget instance.

Returns

tuple[str, bool, bool]
  • str, fontname

  • first bool, is bold ?

  • second bool, is italic ?

getTolerance() int

Get the tolerance attribute of the current OrthogonalDistanceWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Returns

int

tolerance in pixels

getVisibility() bool

Get the visibility attribute of the current OrthogonalDistanceWidget instance.

Returns

bool

True if visible

setColor(c: list[float] | tuple[float, float, float]) None

Set the color attribute of the current OrthogonalDistanceWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setDefaultRepresentation() None

Set default representation (size, color, font, opacity…) of the current OrthogonalDistanceWidget instance.

setHandleSize(size: float) None

Set the handle size attribute of the current OrthogonalDistanceWidget instance.

Parameters

sizefloat

handle size

setLineWidth(width: float) None

Set the line width attribute of the current OrthogonalDistanceWidget instance.

Parameters

widthfloat

line width

setOpacity(alpha: float) None

Set the opacity attribute of the current OrthogonalDistanceWidget instance.

Parameters

alphafloat

opacity between 0.0 (transparent) to 1.0 (opaque)

setSelectedColor(c: list[float] | tuple[float, float, float]) None

Set the selected color attribute of the current OrthogonalDistanceWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setTextProperty(fontname: str = 'Arial', bold: bool = False, italic: bool = False) None

Set the text property attribute of the current OrthogonalDistanceWidget instance.

Parameters

fontnamestr

font name, ‘Arial’ (default), ‘Courier’, ‘Times’ or filename

boldbool

text in bold (default False)

italicbool

text in italic (default False)

setTolerance(tol: int) None

Set the tolerance attribute of the current OrthogonalDistanceWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Parameters

tolint

tolerance in pixels

setVisibility(v: bool) None

Show/hide the current OrthogonalDistanceWidget instance.

Parameters

vbool

True to show

class Sisyphe.core.sisypheTools.TextWidget(name: str)

Description

Text tool class. It is a text 2D widget.

Getter/setter methods:

  • visibility

  • opacity

  • color and selected color

  • font name, bold/italic

  • text displayed

Inheritance

(vtkDistanceWidget, NamedObject) -> TextWidget

Creation: 05/04/2022 Last revision: 18/12/2023

getColor() list[float] | tuple[float, float, float]

Get the color attribute of the current TextWidget instance.

Returns

tuple[float, float, float]

color, red, green, blue components (between 0.0 and 1.0)

getOpacity() float

Get the opacity attribute of the current TextWidget instance.

Returns

float

opacity between 0.0 (transparent) to 1.0 (opaque)

getPosition() list[float] | tuple[float, float]

Set the position (upper left corner) of the current TextWidget instance.

Returns

tuple[float, float]

x-axis and y-axis coordinates

getText() str

Get the text of the current TextWidget instance.

Returns

str

widget text

getTextProperty() tuple[str, bool, bool]

Get the text property attribute of the current TextWidget instance.

Returns

tuple[str, bool, bool]
  • str, fontname

  • first bool, is bold ?

  • second bool, is italic ?

getTolerance() int

Get the tolerance attribute of the current TextWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Returns

int

tolerance in pixels

getVisibility() bool

Get the visibility attribute of the current TextWidget instance.

Returns

bool

True if visible

setColor(c: list[float] | tuple[float, float, float]) None

Set the color attribute of the current TextWidget instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setDefaultRepresentation() None

Set default representation (size, color, font, opacity…) of the current TextWidget instance.

setOpacity(alpha: float) None

Set the opacity attribute of the current TextWidget instance.

Parameters

alphafloat

opacity between 0.0 (transparent) to 1.0 (opaque)

setPosition(x: float, y: float) None

Set the position (upper left corner) of the current TextWidget instance.

Parameters

xfloat

x-axis coordinate

yfloat

y-axis coordinate

setText(txt: str) None

Set the text of the current TextWidget instance.

Parameters

txtstr

widget text

setTextProperty(fontname: str = 'Arial', bold: bool = False, italic: bool = False) None

Set the text property attribute of the current TextWidget instance.

Parameters

fontnamestr

font name, ‘Arial’ (default), ‘Courier’, ‘Times’ or filename

boldbool

text in bold (default False)

italicbool

text in italic (default False)

setTolerance(tol: int) None

Set the tolerance attribute of the current TextWidget instance. Distance tolerance (in pixels) between tool and mouse cursor for interaction.

Parameters

tolint

tolerance in pixels

setVisibility(v: bool) None

Show/hide the current TextWidget instance.

Parameters

vbool

True to show

class Sisyphe.core.sisypheTools.ToolWidgetCollection(volume: SisypheVolume | None = None, interactor: vtkRenderWindowInteractor | None = None)

Description

Named list container of tool instances. Container key to address elements can be an int index or a str name.

Scope of methods:

  • getter/setter methods

    • reference ID, all tools in the container are defined in the space of a reference SisypheVolume whose ID is the reference ID.

    • file name

  • container methods

  • display properties of the tool elements

  • tool element creation

  • IO methods

Inheritance

object -> ToolWidgetCollection

Creation: 05/04/2022 Last revision: 19/12/2023

append(value: NamedWidget)

Append a tool element in the current ToolWidgetCollection instance container.

Parameters

valueNamedWidget

tool to append

clear() None

Remove all elements from the current ToolWidgetCollection instance container (empty).

copy() ToolWidgetCollection

Copy the current ToolWidgetCollection instance container (Shallow copy of elements).

Returns

ToolWidgetCollection

shallow copy collection

copyToList() list[NamedWidget]

Copy the current ToolWidgetCollection instance container to a list (Shallow copy of elements).

Returns

list[NamedWidget]

shallow copy collection

count() int

Get the number of tool elements in the current ToolWidgetCollection instance container.

Returns

int

number of tool elements

createXML(doc: Document) None

Write the current ToolWidgetCollection instance attributes to xml document instance.

Parameters

docminidom.Document

xml document

getColor() list[float] | tuple[float, float, float]

Get the tool elements color of the current ToolWidgetCollection instance.

Returns

tuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

classmethod getFileExt() str

Get ToolWidgetCollection file extension.

Returns

str

‘.xtools’

getFilename() str

Get the file name attribute of the current ToolWidgetCollection instance.

Returns

str

file name

classmethod getFilterExt() str

Get ToolWidgetCollection filter used by QFileDialog.getOpenFileName() and QFileDialog.getSaveFileName().

Returns

str

‘PySisyphe tool collection (.xtools)’

getFontFamily() str

Get the font used to display the tool elements text of the current ToolWidgetCollection instance.

Returns

str

font name ‘Arial’ (default), ‘Courier’, ‘Times’ or font file name

getLineWidth() float

Get the tool elements line width of the current ToolWidgetCollection instance.

Returns

float

line width

getList() list[NamedWidget]

Get the list attribute of the current ToolWidgetCollection instance container (Shallow copy of the elements).

Returns

list[NamedWidget]

shallow copy collection

getOpacity() float

Get the tool elements opacity of the current ToolWidgetCollection instance.

Returns

float

opacity (between 0.0 and 1.0)

getReferenceID() str

Get reference ID attribute of the current ToolWidgetCollection instance. All tools in the container are defined in the space of a reference SisypheVolume whose ID is the reference ID.

Returns

str

reference ID

getSelectedColor() list[float] | tuple[float, float, float]

Get the tool elements selected color of the current ToolWidgetCollection instance.

Returns

tuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

hasFilename() bool

Check if the file name attribute of the current ToolWidgetCollection instance is defined (not empty str).

Returns

bool

True if file name is defined

hasInteractor() bool

Check whether the interactor attribute of the current ToolWidgetCollection instance is defined (not None). vtk.vtkRenderWindowInteractor manage vtk events of the tool widgets.

Returns

bool

True if interactor is defined

hasReferenceID() bool

Check if the reference ID attribute of the current ToolWidgetCollection instance is defined (not empty str).

Returns

bool

True if reference ID is defined

hasSameID(ID: str | SisypheVolume)

Check that the ID parameter is identical to the ID attribute of the current ToolWidgetCollection instance.

Parameters

ID : str | Sisyphe.core.sisypheVolume.SisypheVolume

Returns

bool

True if IDs are identical

index(value: str | NamedWidget)

Index of a tool element in the current ToolWidgetCollection instance container.

Parameters

valuestr | NamedWidget

tool name or NamedWidget

Returns

int

index

insert(key: int | str | NamedWidget, value: NamedWidget)

Insert a tool element at the position given by the key in the current ToolWidgetCollection instance container.

Parameters

keyint | str | NamedWidget
  • int, index

  • str, tool name index

  • NamedWidget, tool index

valueNamedWidget

tool to insert

isEmpty() bool

Checks if ToolWidgetCollection instance container is empty.

Returns

bool

True if empty

keys() list[str]

Get the list of keys in the current ToolWidgetCollection instance container.

Returns

list[str]

list of keys in the container

load(filename: str = '') None

Load the current ToolWidgetCollection instance from a PySisyphe tool collection (.xtools) file. If the filename parameter is empty (default), the file name attribute of the current ToolWidgetCollection instance is used.

Parameters

filenamestr

PySisyphe tool collection file name.

newAngleWidget(name: str = '') AngleWidget

Create a new AngleWidget instance and addBundle it to the current ToolWidgetCollection.

Parameters

namestr

tool name (default empty str)

Returns

AngleWidget

new widget

newBoxWidget(p: list[float] | tuple[float, float], name: str = '') BoxWidget

Create a new BoxWidget instance and addBundle it to the current ToolWidgetCollection.

Parameters

ptuple[float, float] | list[float]

widget position, top/left corner, vtk display 2D coordinates

namestr

tool name (default empty str)

Returns

BoxWidget

new widget

newDistanceWidget(name: str = '') DistanceWidget

Create a new DistanceWidget instance and addBundle it to the current ToolWidgetCollection.

Parameters

namestr

tool name (default empty str)

Returns

DistanceWidget

new widget

newHandleWidget(p: list[float] | tuple[float, float, float], name: str = '') HandleWidget

Create a new HandleWidget instance and addBundle it to the current ToolWidgetCollection.

Parameters

ptuple[float, float, float] | list[float]

widget position, world coordinates

namestr

tool name (default empty str)

Returns

HandleWidget

new widget

newLineWidget(p1: list[float] | tuple[float, float, float], p2: list[float] | tuple[float, float, float], name: str = '') LineWidget

Create a new LineWidget instance and addBundle it to the current ToolWidgetCollection.

Parameters

p1tuple[float, float, float] | list[float]

target point position, world coordinates

p2tuple[float, float, float] | list[float]

entry point position, world coordinates

namestr

tool name (default empty str)

Returns

LineWidget

new widget

newOrthogonalDistanceWidget(name: str = '') OrthogonalDistanceWidget

Create a new OrthogonalDistanceWidget instance and addBundle it to the current ToolWidgetCollection.

Parameters

namestr

tool name (default empty str)

Returns

OrthogonalDistanceWidget

new widget

newTextWidget(p: list[float] | tuple[float, float], text: str, name: str = '') TextWidget

Create a new TextWidget instance and addBundle it to the current ToolWidgetCollection.

Parameters

ptuple[float, float] | list[float]

widget position, vtk display 2D coordinates

textstr

widget text attribute

namestr

tool name (default empty str)

Returns

TextWidget

new widget

parseXML(doc: Document) None

Read the current oolWidgetCollection instance attributes from xml document instance.

Parameters

docminidom.Document

xml document

pop(key: int | str | NamedWidget | None = None)

Remove a tool element from the current ToolWidgetCollection instance container and return it. If key is None, removes and returns the last element.

Parameters

keyint | str | NamedWidget | None
  • int, index of the tool to remove

  • str, tool name of the NamedWidget to remove

  • NamedWidget to remove

  • None, remove the last element

Returns

NamedWidget

element removed from the container

remove(value: NamedWidget) None

Remove a tool element from the current ToolWidgetCollection instance container.

Parameters

valueint | str | NamedWidget
  • int, index of the tool to remove

  • str, tool name of the NamedWidget to remove

  • NamedWidget to remove

reverse() None

Reverses the order of the elements in the current ToolWidgetCollection instance container.

save(filename: str = '') None

Save the current ToolWidgetCollection instance to a PySisyphe tool collection (.xtools) file. If the filename parameter is empty (default), the file name attribute of the current ToolWidgetCollection instance is used.

Parameters

filenamestr

PySisyphe tool collection file name

saveAs(filename: str) None

Save the current ToolWidgetCollection instance to a PySisyphe tool collection (.xtools) file.

Parameters

filenamestr

PySisyphe tool collection file name

select(key: int | str) None

Select a tool element of the current ToolWidgetCollection. This tool is displayed with the selected color.

Parameters

keyint | str
  • int, index

  • str, tool name

setColor(c: list[float] | tuple[float, float, float]) None

Set the tool elements color of the current ToolWidgetCollection instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

setFilenameFromVolume(img: SisypheVolume) None

Set the file name attribute of the current ToolWidgetCollection instance from a volume.

Parameters

img : Sisyphe.core.sisypheVolume.SisypheVolume

setFontFamily(v: str = 'Arial') None

Set the font used to display the tool elements text of the current ToolWidgetCollection instance.

Parameters

vstr

font name ‘Arial’ (default), ‘Courier’, ‘Times’ or ttf font file name (*.ttf)

setInteractor(interactor: vtkRenderWindowInteractor) None

Set the interactor attribute of the current ToolWidgetCollection instance. vtk.vtkRenderWindowInteractor manage vtk events of the tool widgets.

Parameters

interactorvtk.vtkRenderWindowInteractor

interactor to copy

setLineWidth(v: float) None

Set the tool elements line width of the current ToolWidgetCollection instance.

Parameters

vfloat

line width

setOpacity(v: float) None

Set the tool elements opacity of the current ToolWidgetCollection instance.

Parameters

vfloat

opacity (between 0.0 and 1.0)

setReferenceID(ID: str | SisypheVolume) None

Set reference ID attribute of the current ToolWidgetCollection instance. All tools in the container are defined in the space of a reference SisypheVolume whose ID is the reference ID.

Parameters

IDstr | Sisyphe.core.sisypheVolume.SisypheVolume
  • str, ID

  • Sisyphe.core.sisypheVolume.SisypheVolume, ID attribute of the SisypheVolume

setSelectedColor(c: list[float] | tuple[float, float, float])

Set the tool elements selected color of the current ToolWidgetCollection instance.

Parameters

ctuple[float, float, float] | list[float]

color, red, green, blue components (between 0.0 and 1.0)

sort(reverse: bool = False) None

Sort elements of the current ToolWidgetCollection instance container. Sorting is based on the name attribute of the tool elements, in the ascending order.

Parameters

reversebool

sorting in reverse order