Annotation module

class lys.widgets.canvas.interface.Annotation.CanvasAnnotation(canvas)[source]

Bases: CanvasPart

Interface to add, remove, and get annotations in canvas.

All public methods in this class can be accessed from CanvasBase.CanvasBase.

Parameters

canvas (.CanvasBase.CanvasBase) – The parent canvas.

addCrossAnnotation(pos='auto', axis='BottomLeft', **appearance)[source]

Add cross annotation.

Parameters
  • pos (length 2 sequence) – The position in the form of (x, y).

  • axis ('BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis to which the annotation is added.

  • appearance (dict) – Appearance dictionary, which is generated by AnnotationData.saveAppearance() method.

Returns

The annotation added.

Return type

CrossAnnotation

addFreeRegionAnnotation(region='auto', width='auto', axis='BottomLeft', **appearance)[source]

Add free region annotation.

Parameters
  • region (2*2 sequence) – The position of the region in the form of [(x0, y0), (x1 ,y1)]

  • width (float) – The width of the region.

  • axis ('BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis to which the annotation is added.

  • appearance (dict) – Appearance dictionary, which is generated by AnnotationData.saveAppearance() method.

Returns

The annotation added.

Return type

FreeRegionAnnotation

addInfiniteLineAnnotation(pos=None, orientation='vertical', axis='BottomLeft', **appearance)[source]

Add infinite line annotation.

Parameters
  • pos (float) – The position of the line.

  • orientation ('vertical' or 'horizontal') – The orientation of the line.

  • axis ('BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis to which the annotation is added.

  • appearance (dict) – Appearance dictionary, which is generated by AnnotationData.saveAppearance() method.

Returns

The annotation added.

Return type

InfiniteLineAnnotation

addLineAnnotation(pos='auto', axis='BottomLeft', **appearance)[source]

Add line annotation.

Parameters
  • pos (2*2 sequence) – The position of the line in the form of [(x0, y0), (x1 ,y1)]

  • axis ('BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis to which the line annotation is added.

  • appearance (dict) – Appearance dictionary, which is generated by AnnotationData.saveAppearance() method.

Returns

The annotation added.

Return type

LineAnnotation

addRectAnnotation(pos='auto', size='auto', axis='BottomLeft', **appearance)[source]

Add rectangle annotation.

Parameters
  • pos (length 2 sequence) – The position of the rectangle edge in the form of (x, y).

  • size (length 2 sequence) – The size of the rectangle in the form of (width, height).

  • axis ('BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis to which the annotation is added.

  • appearance (dict) – Appearance dictionary, which is generated by AnnotationData.saveAppearance() method.

Returns

The annotation added.

Return type

RectAnnotation

addRegionAnnotation(region=None, orientation='vertical', axis='BottomLeft', **appearance)[source]

Add region annotation.

Parameters
  • region (length 2 sequence) – The region in the form of (x1, x2).

  • orientation ('vertical' or 'horizontal') – The orientation of the annotation.

  • axis ('BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis to which the annotation is added.

  • appearance (dict) – Appearance dictionary, which is generated by AnnotationData.saveAppearance() method.

Returns

The annotation added.

Return type

RegionAnnotation

addText(text, pos='auto', axis='BottomLeft', **appearance)[source]

Add text annotation.

Parameters
  • text (str) – The text to be shown.

  • pos (length 2 sequence) – The position in the form of (x, y).

  • axis ('BottomLeft', 'BottomRight', 'TopLeft', or 'TopRight') – The axis to which the annotation is added.

  • appearance (dict) – Appearance dictionary, which is generated by AnnotationData.saveAppearance() method.

Returns

The annotation added.

Return type

TextAnnotation

annotationChanged

pyqtSignal that is emitted when annotations are added or removed.

getAnnotations(type='all')[source]

Return list of all annotations in canvas.

Parameters

type (str) – The type of annotations (‘all’, ‘text’, ‘line’, ‘infiniteLine’, ‘rect’, ‘region’, ‘freeRegion’, or ‘cross’)

Returns

list of AnnotationData.AnnotationData.

Return type

list

getCrossAnnotations()[source]

Return list of all cross annotations in canvas.

Returns

list of CrossAnnotation.CrossAnnotation.

Return type

list

getFreeRegionAnnotations()[source]

Return list of all free region annotations in canvas.

Returns

list of RegionAnnotation.FreeRegionAnnotation.

Return type

list

getInfiniteLineAnnotations()[source]

Return list of all infinite line annotations in canvas.

Returns

list of LineAnnotation.InfiniteLineAnnotation.

Return type

list

getLineAnnotations()[source]

Return list of all line annotations in canvas.

Returns

list of LineAnnotation.LineAnnotation.

Return type

list

getRectAnnotations()[source]

Return list of all rectangle annotations in canvas.

Returns

list of RectAnnotation.RectAnnotation.

Return type

list

getRegionAnnotations()[source]

Return list of all region annotations in canvas.

Returns

list of RegionAnnotation.RegionAnnotation.

Return type

list

getTextAnnotations()[source]

Return list of all text annotations in canvas.

Returns

list of TextAnnotation.TextAnnotation.

Return type

list

removeAnnotation(annot)[source]

Remove annotation from the canvas.

Parameters

annot (AnnotationData) – The annotation removed.