Viewer Widget. Allows display of images, zooming and panning etc.

class tuiview.viewerwidget.ActiveToolChangedInfo(newTool, senderid)[source]

Container class for info pass in the activeToolChanged signal

class tuiview.viewerwidget.GeolinkInfo(senderid, easting, northing, metresperwinpix=0)[source]

Container class for the information passed in the geolinkMove and geolinkQueryPoint signals.

static fromString(jstring)[source]

Create an instance from json


Return as json

class tuiview.viewerwidget.QueryInfo(easting, northing, column, row, data, layer, modifiers)[source]

Container class for the information passed in the locationSelected signal.

class tuiview.viewerwidget.ViewerWidget(parent)[source]

The main ViewerWidget class. Should be embeddable in other applications. See the open() function for loading images.

addLayersFromJSONFile(fileobj, nlayers)[source]

Get the layer manager to read all the layer descriptions from fileobj and load these layers into this widget.

addRasterLayer(gdalDataset, stretch, lut=None, ignoreProjectionMismatch=False, quiet=False)[source]

Add the given dataset to the stack of images being displayed as a raster layer

addVectorFeatureLayer(ogrDataSource, ogrLayer, ogrFeature, color=None, quiet=None)[source]

Just a single feature vector

addVectorLayer(ogrDataSource, ogrLayer, color=None, resultSet=False, origSQL=None, quiet=False)[source]

Add the vector given by the ogrDataSource and its dependent ogrLayer to the stack of images.

doGeolinkMove(easting, northing, metresperwinpix)[source]

Call this when widget needs to be moved because of geolinking event.

doGeolinkQueryPoint(easting, northing)[source]

Call this when the widget query point has been moved in another viewer and should be updated in this one if the query tool is active.


Call this on each zoom/pan to emit the appropriate signal.


Call to change the flicker state (ie draw the top raster image or not).


Called by emitGeolinkMoved and anything else that needs the current GeolinkInfo

highlightValues(color, selectionArray=None)[source]

Applies a QColor to the LUT where selectionArray == True to the top layer and redraws. Pass None to reset


Mouse has been moved while dragging. If in zoom/pan mode we need to do something here.


Mouse has been clicked down if we are in zoom/pan mode we need to start doing stuff here


Mouse has been released, if we are in zoom/pan mode we do stuff here.

newQueryPoint(easting=None, northing=None, dspY=None, dspX=None, column=None, row=None, modifiers=None)[source]

This viewer has recorded a new query point. Or user has entered new coords in querywindow.

Calls updateQueryPoint and emits the geolinkQueryPoint signal

pass either [easting and northing] or [dspX,dspY] or [column, row]

newVectorQueryPoint(dspX, dspY, modifiers=None)[source]

New vector query point. Does the spatial query and emits the vectorLocationSelected signal with the results


Viewport needs to be redrawn. Assume that each layer’s image is current (as created by getImage()) we can just draw it with QPainter


Removes the top later


Removes a query point. keyed on the id() of the sender


Window has been resized - get new data

scrollContentsBy(dx, dy)[source]

Handle the user moving the scroll bars

setActiveTool(tool, senderid)[source]

Set active tool (one of VIEWER_TOOL_*). pass VIEWER_TOOL_NONE to disable pass the id() of the calling object. This is passed around in the activeToolChanged signal so GUI elements can recognise who asked for the change


Sets the background color for the widget

setColorTableLookup(lookupArray=None, colName=None, surrogateLUT=None, surrogateName=None)[source]

Uses the supplied lookupArray to look up image data before indexing into color table in the top layer and redraws. Pass None to reset.


Set whether we are following geolink extent of just center


Set the action for a mouse wheen event (scroll/zoom)

setNewStretch(newstretch, layer, local=False)[source]

Change the stretch being applied to the current data


set whether we are only querying displayed layers (True) or all (False)

setQueryPoint(senderid, easting, northing, color, size=None, cursor=None)[source]

Sets/Updates query point keyed on the id() of the sender


Assume images are a stacked timeseries oldest to newest. Turn on the previous one to the current topmost displayed


Assume images are a stacked timeseries oldest to newest. Turn off the current topmost displayed

updateQueryPoint(easting, northing, column, row, modifiers)[source]

Map has been clicked, get the value and emit a locationSelected signal. Called by newQueryPoint or when a geolinkQueryPoint signal has been received.


Update the scroll bars to accurately show where we are relative to the full extent


User has used mouse wheel to zoom in/out or pan depending on defined preference


Resets the zoom to full extent - should be the same as when file was opened.


Sets the zoom to native resolution wherever the current viewport is centered