### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe_qgis »

# Module: safe_qgis.dock

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 `safe_qgis.dock.``Dock`(iface)

  Dock implementation class for the Risk In A Box plugin.

  `accept`()

    Execute analysis when ok button is clicked.

  `addComboItemInOrder`(theCombo, theItemText, theItemData=None)

    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

  `addPostprocessingOutput`(output)

    adds text to the postprocessingOutput

    Args:
      - output: the output from a postprocessor to add to the global

      output. It should be valid HTML but no checks are enforced.

    Returns: None

  `aggregateResults`(progress)

    Aggregation postprocessing step, this delas with the gui stuff and calls _aggregateResults to do the actual aggregation work Args: progress %to show in the progressbar

    Returns: None

  `canvasLayersetChanged`()

    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`()

    Slot activated when the process is done.

  `connectLayerListener`()

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

    ..seealso:: disconnectLayerListener

    Args:
      None
    Returns:
      None
    Raises:
      None
  `disableBusyCursor`()

    Disable the hourglass cursor

  `disconnectLayerListener`()

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

    ..seealso:: connectLayerListener

    Args:
      None
    Returns:
      None
    Raises:
      None
  `displayHtml`(theMessage)

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

  `enableBusyCursor`()

    Set the hourglass enabled.

  `extentToGeoArray`(theExtent, theSourceCrs)

    Convert the supplied extent to geographic and return as as array

  `getAggregationLayer`()

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

    Args: None

    Returns:
      - None if no aggregation is selected or cboAggregation is
    disabled
      - else a polygon layer
  `getExposureLayer`()

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

  `getFunctionID`(theIndex=None)

    Get the canonical impact function ID for the currently selected function (or the specified combo entry if theIndex is supplied. Args:

    > theIndex int - Optional index position in the combo that you
    >   want the function id for. Defaults to None. If not set / None the currently selected combo item’s function id will be returned.

    Returns:
      myFunctionID str - String that identifies the function
    Raises:
      None
  `getFunctions`()

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

    Args:
      None.
    Returns:
      None
    Raises:
      no
  `getHazardLayer`()

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

  `getLayers`()

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

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

    Args:
      None.
    Returns:
      None
    Raises:
      no
  `getPostprocessingOutput`()

    gets the of the postprocessingOutput

    Args: None

    Returns: a string concatenation of the list elements

  `hideBusy`()

    A helper function to indicate processing is done.

  `htmlFooter`()

    Get a standard html footer for wrapping content in.

  `htmlHeader`()

    Get a standard html header for wrapping content in.

  `initPostprocessingOutput`()
    initializes and clears self.postprocessingOutput. needs to run at the
      end of startPostprocessing

    Returns: None

  `layerChanged`(theLayer)

    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`()

    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`()

    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)

    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`()

    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)

    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)

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

    Args:
      None.
    Returns:
      None.
    Raises:
      no exceptions explicitly raised.
  `on_cboHazard_currentIndexChanged`(theIndex)

    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.
  `on_toolFunctionOptions_clicked`()

    Automatic slot executed when the tool button for configuring impact functions is clicked (when available) to open the dialog

    Args:
      None.
    Returns:
      None.
    Raises:
      no exceptions explicitly raised.
  `optimalClip`()

    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`()

    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)

    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`()

    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)

    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`()

    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`()

    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`()

    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.
  `setToolFunctionOptionsButton`()

    Helper function to set the tool function button status if there is function parameters to configure then enable it, otherwise disable it.

    Args:
      None.
    Returns:
      None.
    Raises:
      no exceptions explicitly raised.
  `setupCalculator`()

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

    Args: None

    Returns: None

    Raises: Propogates any error from :func:optimalClip()

  `showBusy`(theTitle=None, theMessage=None, theProgress=0)

    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`()

    Load the help text into the wvResults widget

  `startPostprocessing`()

    Called on self.runner SIGNAL(‘done()’) starts all postprocessing steps Args: None

    Returns: None

  `validate`()

    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`()

    Obtain the map canvas current extent in EPSG:4326

This module forms part of the InaSAFE tool.

### Navigation

- index
- modules
- next
- previous
- Home »
- Contents »
- InaSAFE’s API documentation »
- Package::safe_qgis »