viewertoolclasses

Supporting classes for tools in the ViewerWidget

class tuiview.viewertoolclasses.PolygonToolInfo(*args: Any, **kwargs: Any)[source]

Class derived from ToolInfo that contains the poly etc but has a getDisplaySelectionMask() mask to create a mask inside poly

getDisplaySelectionMask()[source]

Get a bool mask in display coords that can then be used to mask the data (would probably pay to apply getDisplayValidMask to the result)

getOGRGeometry()[source]

Return a ogr.Geometry instance

static maskFunc(x, y, cls)[source]

Function to be called via numpy.vectorize Returns whether x,y are within polygon

class tuiview.viewertoolclasses.PolylineToolInfo(*args: Any, **kwargs: Any)[source]

Class derived from ToolInfo that contains the polyline etc has method for getting profile

getOGRGeometry()[source]

Return a ogr.Geometry instance

getProfile()[source]
class tuiview.viewertoolclasses.ToolInfo(*args: Any, **kwargs: Any)[source]

Class derived from QPolygon that contains the poly that the user selected, but has some other methods

getDisplayData()[source]

Return the numpy array of the display data a list for RGB

getDisplayValidMask()[source]

Return bool numpy array where valid data (not no data and not background)

getInputModifiers()[source]
getOGRGeometry()[source]

Return a ogr.Geometry instance. Derived classes to implement

getWorldPolygon()[source]

Return a polygon of world coords

tuiview.viewertoolclasses.bresenhamline(start, end, max_iter=5)[source]

Returns a list of points from (start, end] by ray tracing a line b/w the points. Parameters: * start: An array of start points (number of points x dimension) * end: An end points (1 x dimension) or An array of end point corresponding to each start point (number of points x dimension) * max_iter: Max points to traverse. if -1, maximum number of required points are traversed

Returns: * linevox (n x dimension) A cumulative array of all points traversed by all the lines so far.

>>> s = np.array([[3, 1, 9, 0],[0, 0, 3, 0]])
>>> bresenhamline(s, np.zeros(s.shape[1]), max_iter=-1)
array([[ 3,  1,  8,  0],
       [ 2,  1,  7,  0],
       [ 2,  1,  6,  0],
       [ 2,  1,  5,  0],
       [ 1,  0,  4,  0],
       [ 1,  0,  3,  0],
       [ 1,  0,  2,  0],
       [ 0,  0,  1,  0],
       [ 0,  0,  0,  0],
       [ 0,  0,  2,  0],
       [ 0,  0,  1,  0],
       [ 0,  0,  0,  0],
       [ 0,  0, -1,  0],
       [ 0,  0, -2,  0],
       [ 0,  0, -3,  0],
       [ 0,  0, -4,  0],
       [ 0,  0, -5,  0],
       [ 0,  0, -6,  0]])