Module: is_dock

This page contains the documentation for the InaSAFE is_dock module.

InaSAFE Disaster risk assessment tool developed by AusAid - GUI Dialog.

Contact : ole.moller.nielsen@gmail.com

Note

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Todo

Check raster is single band

class gui.is_dock.ISDock(iface)[source]

Dock implementation class for the Risk In A Box plugin.

accept()[source]

Execute analysis when ok button is clicked.

addComboItemInOrder(theCombo, theItemText, theItemData=None)[source]

Although QComboBox allows you to set an InsertAlphabetically enum this only has effect when a user interactively adds combo items to an editable combo. This we have this little function to ensure that combos are always sorted alphabetically.

Args:
  • theCombo - combo box receiving the new item
  • theItemText - display text for the combo
  • theItemData - optional UserRole data to be associated with the item
Returns:
None

Raises:

..todo:: Move this to utilities

canvasLayersetChanged()[source]

A helper slot to update the dock combos if the canvas layerset has been changed (e.g. one or more layer visibilities changed). If self.showOnlyVisibleLayersFlag is set to False this method will simply return, doing nothing.

Args:
None
Returns:
None
Raises:
Any exceptions raised by the RIAB library will be propogated.
completed()[source]

Slot activated when the process is done.

connectLayerListener()[source]

Establish a signal/slot to listen for changes in the layers loaded in QGIS.

..seealso:: disconnectLayerListener

Args:
None
Returns:
None
Raises:
None
disableBusyCursor()[source]

Disable the hourglass cursor

disconnectLayerListener()[source]

Destroy the signal/slot to listen for changes in the layers loaded in QGIS.

..seealso:: connectLayerListener

Args:
None
Returns:
None
Raises:
None
displayHtml(theMessage)[source]

Given an html snippet, wrap it in a page header and footer and display it in the wvResults widget.

enableBusyCursor()[source]

Set the hourglass enabled.

extentToGeoArray(theExtent, theSourceCrs)[source]

Convert the supplied extent to geographic and return as as array

getExposureLayer()[source]

Obtain the name of the path to the exposure file from the userrole of the QtCombo for exposure.

getFunctions()[source]

Helper function to obtain a list of impact functions from the impact calculator.

Args:
None.
Returns:
None
Raises:
no
getHazardLayer()[source]

Obtain qgsmaplayer id from the userrole of the QtCombo for exposure and return it as a QgsMapLayer

getLayers()[source]

Helper function to obtain a list of layers currently loaded in QGIS.

On invocation, this method will populate cboHazard and cboExposure on the dialog with a list of available layers. Only singleband raster layers will be added to the hazard layer list, and only point vector layers will be added to the exposure layer list.

Args:
None.
Returns:
None
Raises:
no
hideBusy()[source]

A helper function to indicate processing is done.

htmlFooter()[source]

Get a standard html footer for wrapping content in.

htmlHeader()[source]

Get a standard html header for wrapping content in.

layerChanged(theLayer)[source]

Handler for when the QGIS active layer is changed. If the active layer is changed and it has keywords and a report, show the report..

Args:
theLayer - the QgsMapLayer instance that is now active..
Returns:
None.
Raises:
no exceptions explicitly raised.
layerWasAdded()[source]

Slot for the old (pre QGIS 1.8 api) to notify us when a layer is added. This is suboptimal since if many layers are added this slot gets called multiple times. This slot simply delegates to getLayers and is only implemented here to make the connections between the different signals and slots clearer and better documented.

layerWillBeRemoved()[source]

Slot for the old (pre QGIS 1.8 api) to notify us when a layer is removed. This is suboptimal since if many layers are removed this slot gets called multiple times. This slot simply delegates to getLayers and is only implemented here to make the connections between the different signals and slots clearer and better documented.

layersAdded(theLayers=None)[source]

Slot for the new (QGIS 1.8 and beyond api) to notify us when a group of layers is are added. This is optimal since if many layers are added this slot gets called only once. This slot simply delegates to getLayers and is only implemented here to make the connections between the different signals and slots clearer and better documented.

layersWillBeRemoved()[source]

Slot for the new (QGIS 1.8 and beyond api) to notify us when a group of layers is are removed. This is optimal since if many layers are removed this slot gets called only once. This slot simply delegates to getLayers and is only implemented here to make the connections between the different signals and slots clearer and better documented.

on_cboExposure_currentIndexChanged(theIndex)[source]

Automatic slot executed when the Exposure combo is changed so that we can see if the ok button should be enabled.

Note

Don’t use the @pyqtSlot() decorator for autoslots!

Args:
None.
Returns:
None.
Raises:
No exceptions explicitly raised.
on_cboFunction_currentIndexChanged(theIndex)[source]

Automatic slot executed when the Function combo is changed so that we can see if the ok button should be enabled.

Note

Don’t use the @pyqtSlot() decorator for autoslots!

Args:
None.
Returns:
None.
Raises:
no exceptions explicitly raised.
on_cboHazard_currentIndexChanged(theIndex)[source]

Automatic slot executed when the Hazard combo is changed so that we can see if the ok button should be enabled.

Note

Don’t use the @pyqtSlot() decorator for autoslots!

Args:
None.
Returns:
None.
Raises:
No exceptions explicitly raised.
optimalClip()[source]

A helper function to perform an optimal clip of the input data. Optimal extent should be considered as the intersection between the three inputs. The inasafe library will perform various checks to ensure that the extent is tenable, includes data from both etc.

The result of this function will be two layers which are clipped and resampled if needed, and in the EPSG:4326 geographic coordinate reference system.

Args:
None
Returns:
A two-tuple containing the paths to the clipped hazard and exposure layers.
Raises:
Any exceptions raised by the InaSAFE library will be propogated.
printMap()[source]

Slot to print map when print map button pressed.

Args:
None
Returns:
None
Raises:
Any exceptions raised by the InaSAFE library will be propogated.
readImpactLayer(myEngineImpactLayer)[source]

Helper function to read and validate layer.

Args
myEngineImpactLayer: Layer object as provided by the inasafe engine
Returns
validated qgis layer or None
Raises
Exception if layer is not valid
readSettings()[source]

Set the dock state from QSettings. Do this on init and after changing options in the options dialog.

Args:
None
Returns:
None
Raises:
None
restoreFunctionState(theOriginalFunction)[source]

Restore the function combo to a known state.

Args:
theOriginalFunction - name of function that should be selected
Returns:
None
Raises:
Any exceptions raised by the RIAB library will be propogated.
restoreState()[source]

Restore the state of the dock to the last known state.

Args:
None
Returns:
None
Raises:
Any exceptions raised by the InaSAFE library will be propogated.
saveState()[source]

Save the current state of the ui to an internal class member so that it can be restored again easily.

Args:
None
Returns:
None
Raises:
Any exceptions raised by the InaSAFE library will be propogated.
setOkButtonStatus()[source]

Helper function to set the ok button status if the form is valid and disable it if it is not.

Args:
None.
Returns:
None.
Raises:
no exceptions explicitly raised.
setupCalculator()[source]

Initialise the ISImpactCalculator based on the current state of the ui.

showBusy(theTitle=None, theMessage=None, theProgress=0)[source]

A helper function to indicate the plugin is processing.

Args:
  • theTitle - an optional title for the status update. Should be plain text only
  • theMessage - an optional message to pass to the busy indicator. Can be an html snippet.
  • theProgress - a number between 0 and 100 indicating % complete
Returns:
None
Raises:
Any exceptions raised by the RIAB library will be propagated.

..note:: Uses bootstrap css for progress bar.

showHelp()[source]

Load the help text into the wvResults widget

validate()[source]

Helper method to evaluate the current state of the dialog and determine if it is appropriate for the OK button to be enabled or not.

Note

The enabled state of the OK button on the dialog will NOT be updated (set True or False) depending on the outcome of the UI readiness tests performed - only True or False will be returned by the function.

Args:
None.
Returns:

A two-tuple consisting of:

  • Boolean reflecting the results of the valudation tests.
  • A message indicating any reason why the validation may have failed.

Example:

flag,myMessage = self.validate()
Raises:
no exceptions explicitly raised
viewportGeoArray()[source]

Obtain the map canvas current extent in EPSG:4326

Previous topic

Module: is_plugin

Next topic

Module: is_map

This Page