def test_checkAggregationAttribute1Attr(self):
        """Aggregation attribute is chosen correctly when there is only
        one attr available."""
        myFileList = ['kabupaten_jakarta_singlepart_1_good_attr.shp']
        #add additional layers
        load_layers(myFileList, clear_flag=False, data_directory=TESTDATA)
        myAttrKey = breakdown_defaults('AGGR_ATTR_KEY')

        # with 1 good aggregation attribute using
        # kabupaten_jakarta_singlepart_1_good_attr.shp
        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart 1 good attr')
        assert myResult, myMessage
        # Press RUN
        # noinspection PyCallByClass,PyTypeChecker
        DOCK.accept()
        DOCK.runtimeKeywordsDialog.accept()
        print myAttrKey
        print DOCK.aggregator.attributes
        myAttribute = DOCK.aggregator.attributes[myAttrKey]
        myMessage = ('The aggregation should be KAB_NAME. Found: %s' %
                     myAttribute)
        self.assertEqual(myAttribute, 'KAB_NAME', myMessage)
    def test_on_radPostprocessing_toggled(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = breakdown_defaults()
        myDialog = KeywordsDialog(PARENT, IFACE, layer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        myButton.click()
        myMessage = ('Toggling the postprocessing radio did not add a '
                     'category to the keywords list.')
        assert myDialog.get_value_for_key(
            'category') == 'postprocessing', myMessage

        myMessage = ('Toggling the postprocessing radio did not add an '
                     'aggregation attribute to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['AGGR_ATTR_KEY']) == 'KAB_NAME', myMessage

        myMessage = ('Toggling the postprocessing radio did not add a '
                     'female ratio attribute to the keywords list.')

        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == myDialog.tr('Use default'), \
            myMessage

        myMessage = ('Toggling the postprocessing radio did not add a '
                     'female ratio default value to the keywords list.')
        assert float(myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_KEY'])) == myDefaults['FEM_RATIO'], myMessage
Beispiel #3
0
    def test_on_radPostprocessing_toggled(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = breakdown_defaults()
        myDialog = KeywordsDialog(PARENT, IFACE, layer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        myButton.click()
        myMessage = ('Toggling the postprocessing radio did not add a '
                     'category to the keywords list.')
        assert myDialog.get_value_for_key(
            'category') == 'postprocessing', myMessage

        myMessage = ('Toggling the postprocessing radio did not add an '
                     'aggregation attribute to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['AGGR_ATTR_KEY']) == 'KAB_NAME', myMessage

        myMessage = ('Toggling the postprocessing radio did not add a '
                     'female ratio attribute to the keywords list.')

        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == myDialog.tr('Use default'), \
            myMessage

        myMessage = ('Toggling the postprocessing radio did not add a '
                     'female ratio default value to the keywords list.')
        assert float(myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_KEY'])) == myDefaults['FEM_RATIO'], myMessage
Beispiel #4
0
    def test_check_aggregation_single_attribute(self):
        """Aggregation attribute is chosen correctly when there is only
        one attr available."""
        file_list = ['kabupaten_jakarta_singlepart_1_good_attr.shp']
        #add additional layers
        load_layers(file_list, clear_flag=False)
        attribute_key = breakdown_defaults('AGGR_ATTR_KEY')

        # with 1 good aggregation attribute using
        # kabupaten_jakarta_singlepart_1_good_attr.shp
        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart 1 good attr')
        assert result, message
        # Press RUN
        # noinspection PyCallByClass,PyTypeChecker
        DOCK.accept()
        DOCK.runtime_keywords_dialog.accept()
        print attribute_key
        print DOCK.aggregator.attributes
        attribute = DOCK.aggregator.attributes[attribute_key]
        message = ('The aggregation should be KAB_NAME. Found: %s' % attribute)
        self.assertEqual(attribute, 'KAB_NAME', message)
    def test_on_dsbFemaleRatioDefault_valueChanged(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = breakdown_defaults()
        myDialog = KeywordsDialog(PARENT, IFACE, layer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        myButton.click()
        myFemaleRatioAttrBox = myDialog.cboFemaleRatioAttribute

        #set to Don't use
        myIndex = myFemaleRatioAttrBox.findText(
            myDialog.tr('Don\'t use'))
        myMessage = (myDialog.tr('Don\'t use') + ' not found')
        assert (myIndex != -1), myMessage
        myFemaleRatioAttrBox.setCurrentIndex(myIndex)

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not add it to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == myDialog.tr('Don\'t use'), \
            myMessage

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not disable dsbFemaleRatioDefault.')
        myIsEnabled = myDialog.dsbFemaleRatioDefault.isEnabled()
        assert not myIsEnabled, myMessage

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not remove the keyword.')
        assert (myDialog.get_value_for_key(myDefaults['FEM_RATIO']) is None), \
            myMessage

        #set to TEST_REAL
        myIndex = myFemaleRatioAttrBox.findText('TEST_REAL')
        myMessage = 'TEST_REAL not found'
        assert (myIndex != -1), myMessage
        myFemaleRatioAttrBox.setCurrentIndex(myIndex)

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not add it to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == 'TEST_REAL', myMessage

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not disable dsbFemaleRatioDefault.')
        myIsEnabled = myDialog.dsbFemaleRatioDefault.isEnabled()
        assert not myIsEnabled, myMessage

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not remove the keyword.')
        assert (myDialog.get_value_for_key(myDefaults['FEM_RATIO']) is
                None), myMessage
Beispiel #6
0
    def test_on_dsbFemaleRatioDefault_valueChanged(self):
        """Test hazard radio button toggle behaviour works"""
        myLayer = makePolygonLayer()
        myDefaults = breakdown_defaults()
        myDialog = KeywordsDialog(PARENT, IFACE, layer=myLayer)
        myButton = myDialog.radPostprocessing
        myButton.setChecked(False)
        myButton.click()
        myFemaleRatioAttrBox = myDialog.cboFemaleRatioAttribute

        #set to Don't use
        myIndex = myFemaleRatioAttrBox.findText(myDialog.tr('Don\'t use'))
        myMessage = (myDialog.tr('Don\'t use') + ' not found')
        assert (myIndex != -1), myMessage
        myFemaleRatioAttrBox.setCurrentIndex(myIndex)

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not add it to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == myDialog.tr('Don\'t use'), \
            myMessage

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not disable dsbFemaleRatioDefault.')
        myIsEnabled = myDialog.dsbFemaleRatioDefault.isEnabled()
        assert not myIsEnabled, myMessage

        myMessage = ('Toggling the female ratio attribute combo to'
                     ' "Don\'t use" did not remove the keyword.')
        assert (myDialog.get_value_for_key(myDefaults['FEM_RATIO']) is None), \
            myMessage

        #set to TEST_REAL
        myIndex = myFemaleRatioAttrBox.findText('TEST_REAL')
        myMessage = 'TEST_REAL not found'
        assert (myIndex != -1), myMessage
        myFemaleRatioAttrBox.setCurrentIndex(myIndex)

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not add it to the keywords list.')
        assert myDialog.get_value_for_key(
            myDefaults['FEM_RATIO_ATTR_KEY']) == 'TEST_REAL', myMessage

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not disable dsbFemaleRatioDefault.')
        myIsEnabled = myDialog.dsbFemaleRatioDefault.isEnabled()
        assert not myIsEnabled, myMessage

        myMessage = ('Toggling the female ratio attribute combo to "TEST_REAL"'
                     ' did not remove the keyword.')
        assert (myDialog.get_value_for_key(myDefaults['FEM_RATIO']) is
                None), myMessage
 def test_getDefaults(self):
     """Test defaults for post processing can be obtained properly."""
     myExpectedDefaults = {
         'FEM_RATIO_KEY': 'female ratio default',
         'YOUTH_RATIO': 0.263,
         'ELDER_RATIO': 0.078,
         'NO_DATA': 'No data',
         'FEM_RATIO': 0.5,
         'AGGR_ATTR_KEY': 'aggregation attribute',
         'FEM_RATIO_ATTR_KEY': 'female ratio attribute',
         'ADULT_RATIO': 0.659}
     myDefaults = breakdown_defaults()
     myMessage = 'Defaults: got %s, expected %s' % (
         myDefaults, myExpectedDefaults)
     assert (myDefaults == myExpectedDefaults), myMessage
Beispiel #8
0
 def test_getDefaults(self):
     """Test defaults for post processing can be obtained properly."""
     myExpectedDefaults = {
         'FEM_RATIO_KEY': 'female ratio default',
         'YOUTH_RATIO': 0.263,
         'ELDER_RATIO': 0.078,
         'NO_DATA': 'No data',
         'FEM_RATIO': 0.5,
         'AGGR_ATTR_KEY': 'aggregation attribute',
         'FEM_RATIO_ATTR_KEY': 'female ratio attribute',
         'ADULT_RATIO': 0.659
     }
     myDefaults = breakdown_defaults()
     myMessage = 'Defaults: got %s, expected %s' % (myDefaults,
                                                    myExpectedDefaults)
     assert (myDefaults == myExpectedDefaults), myMessage
Beispiel #9
0
    def setUp(self):
        """Fixture run before all tests"""

        self.maxDiff = None  # show full diff for assert errors

        os.environ['LANG'] = 'en'
        DOCK.show_only_visible_layers_flag = True
        load_standard_layers()
        DOCK.cboHazard.setCurrentIndex(0)
        DOCK.cboExposure.setCurrentIndex(0)
        DOCK.cboFunction.setCurrentIndex(0)
        DOCK.run_in_thread_flag = False
        DOCK.show_only_visible_layers_flag = False
        DOCK.set_layer_from_title_flag = False
        DOCK.zoom_to_impact_flag = False
        DOCK.hide_exposure_flag = False
        DOCK.show_intermediate_layers = False
        set_jakarta_extent()

        self.keywordIO = KeywordIO()
        self.defaults = breakdown_defaults()
    def setUp(self):
        """Fixture run before all tests"""

        self.maxDiff = None  # show full diff for assert errors

        os.environ['LANG'] = 'en'
        DOCK.showOnlyVisibleLayersFlag = True
        load_standard_layers()
        DOCK.cboHazard.setCurrentIndex(0)
        DOCK.cboExposure.setCurrentIndex(0)
        DOCK.cboFunction.setCurrentIndex(0)
        DOCK.runInThreadFlag = False
        DOCK.showOnlyVisibleLayersFlag = False
        DOCK.setLayerNameFromTitleFlag = False
        DOCK.zoomToImpactFlag = False
        DOCK.hideExposureFlag = False
        DOCK.showIntermediateLayers = False
        set_jakarta_extent()

        self.keywordIO = KeywordIO()
        self.defaults = breakdown_defaults()
Beispiel #11
0
    def setUp(self):
        """Fixture run before all tests"""

        self.maxDiff = None  # show full diff for assert errors

        os.environ['LANG'] = 'en'
        DOCK.show_only_visible_layers_flag = True
        load_standard_layers()
        DOCK.cboHazard.setCurrentIndex(0)
        DOCK.cboExposure.setCurrentIndex(0)
        DOCK.cboFunction.setCurrentIndex(0)
        DOCK.run_in_thread_flag = False
        DOCK.show_only_visible_layers_flag = False
        DOCK.set_layer_from_title_flag = False
        DOCK.zoom_to_impact_flag = False
        DOCK.hide_exposure_flag = False
        DOCK.show_intermediate_layers = False
        set_jakarta_extent()

        self.keywordIO = KeywordIO()
        self.defaults = breakdown_defaults()
Beispiel #12
0
    def test_aggregation_attribute_in_keywords(self):
        """Aggregation attribute is chosen correctly when present in keywords.
        """
        attribute_key = breakdown_defaults('AGGR_ATTR_KEY')

        # with KAB_NAME aggregation attribute defined in .keyword using
        # kabupaten_jakarta_singlepart.shp
        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart',
            aggregation_enabled_flag=True)
        assert result, message
        # Press RUN
        DOCK.accept()
        DOCK.runtime_keywords_dialog.accept()
        attribute = DOCK.aggregator.attributes[attribute_key]
        message = ('The aggregation should be KAB_NAME. Found: %s' % attribute)
        self.assertEqual(attribute, 'KAB_NAME', message)
Beispiel #13
0
    def test_aggregation_attribute_in_keywords(self):
        """Aggregation attribute is chosen correctly when present in keywords.
        """
        attribute_key = breakdown_defaults('AGGR_ATTR_KEY')

        # with KAB_NAME aggregation attribute defined in .keyword using
        # kabupaten_jakarta_singlepart.shp
        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart',
            aggregation_enabled_flag=True)
        assert result, message
        # Press RUN
        DOCK.accept()
        DOCK.runtime_keywords_dialog.accept()
        attribute = DOCK.aggregator.attributes[attribute_key]
        message = ('The aggregation should be KAB_NAME. Found: %s' % attribute)
        self.assertEqual(attribute, 'KAB_NAME', message)
    def test_checkAggregationAttributeNoneAttr(self):
        """Aggregation attribute is chosen correctly when None in keywords."""

        myFileList = ['kabupaten_jakarta_singlepart_with_None_keyword.shp']
        #add additional layers
        load_layers(myFileList, clear_flag=False, data_directory=TESTDATA)
        myAttrKey = breakdown_defaults('AGGR_ATTR_KEY')
        # with None aggregation attribute defined in .keyword using
        # kabupaten_jakarta_singlepart_with_None_keyword.shp
        myResult, myMessage = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart with None keyword')
        assert myResult, myMessage
        # Press RUN
        DOCK.accept()
        DOCK.runtimeKeywordsDialog.accept()
        myAttribute = DOCK.aggregator.attributes[myAttrKey]
        myMessage = ('The aggregation should be None. Found: %s' % myAttribute)
        assert myAttribute is None, myMessage
Beispiel #15
0
    def test_check_aggregation_none_in_keywords(self):
        """Aggregation attribute is chosen correctly when None in keywords."""

        file_list = ['kabupaten_jakarta_singlepart_with_None_keyword.shp']
        #add additional layers
        load_layers(file_list, clear_flag=False)
        attribute_key = breakdown_defaults('AGGR_ATTR_KEY')
        # with None aggregation attribute defined in .keyword using
        # kabupaten_jakarta_singlepart_with_None_keyword.shp
        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart with None keyword')
        assert result, message
        # Press RUN
        DOCK.accept()
        DOCK.runtime_keywords_dialog.accept()
        attribute = DOCK.aggregator.attributes[attribute_key]
        message = ('The aggregation should be None. Found: %s' % attribute)
        assert attribute is None, message
Beispiel #16
0
    def test_check_aggregation_none_in_keywords(self):
        """Aggregation attribute is chosen correctly when None in keywords."""

        file_list = ['kabupaten_jakarta_singlepart_with_None_keyword.shp']
        #add additional layers
        load_layers(file_list, clear_flag=False)
        attribute_key = breakdown_defaults('AGGR_ATTR_KEY')
        # with None aggregation attribute defined in .keyword using
        # kabupaten_jakarta_singlepart_with_None_keyword.shp
        result, message = setup_scenario(
            DOCK,
            hazard='A flood in Jakarta like in 2007',
            exposure='People',
            function='Need evacuation',
            function_id='Flood Evacuation Function',
            aggregation_layer='kabupaten jakarta singlepart with None keyword')
        assert result, message
        # Press RUN
        DOCK.accept()
        DOCK.runtime_keywords_dialog.accept()
        attribute = DOCK.aggregator.attributes[attribute_key]
        message = ('The aggregation should be None. Found: %s' % attribute)
        assert attribute is None, message
Beispiel #17
0
    def __init__(self, parent, iface, dock=None, layer=None):
        """Constructor for the dialog.

        .. note:: In QtDesigner the advanced editor's predefined keywords
           list should be shown in english always, so when adding entries to
           cboKeyword, be sure to choose :safe_qgis:`Properties<<` and untick
           the :safe_qgis:`translatable` property.

        :param parent: Parent widget of this dialog.
        :type parent: QWidget

        :param iface: Quantum GIS QGisAppInterface instance.
        :type iface: QGisAppInterface

        :param dock: Dock widget instance that we can notify of changes to
            the keywords. Optional.
        :type dock: Dock
        """

        QtGui.QDialog.__init__(self, parent)
        self.setupUi(self)
        self.setWindowTitle(
            self.tr('InaSAFE %s Keywords Editor') % (get_version()))
        self.keywordIO = KeywordIO()
        # note the keys should remain untranslated as we need to write
        # english to the keywords file. The keys will be written as user data
        # in the combo entries.
        # .. seealso:: http://www.voidspace.org.uk/python/odict.html
        self.standardExposureList = OrderedDict([
            ('population', self.tr('population')),
            ('structure', self.tr('structure')),
            ('Not Set', self.tr('Not Set'))
        ])
        self.standardHazardList = OrderedDict([
            ('earthquake [MMI]', self.tr('earthquake [MMI]')),
            ('tsunami [m]', self.tr('tsunami [m]')),
            ('tsunami [wet/dry]', self.tr('tsunami [wet/dry]')),
            ('tsunami [feet]', self.tr('tsunami [feet]')),
            ('flood [m]', self.tr('flood [m]')),
            ('flood [wet/dry]', self.tr('flood [wet/dry]')),
            ('flood [feet]', self.tr('flood [feet]')),
            ('tephra [kg2/m2]', self.tr('tephra [kg2/m2]')),
            ('volcano', self.tr('volcano')), ('Not Set', self.tr('Not Set'))
        ])
        # Save reference to the QGIS interface and parent
        self.iface = iface
        self.parent = parent
        self.dock = dock

        self.lstKeywords.itemClicked.connect(self.edit_key_value_pair)

        # Set up help dialog showing logic.
        self.helpDialog = None
        helpButton = self.buttonBox.button(QtGui.QDialogButtonBox.Help)
        helpButton.clicked.connect(self.show_help)

        # set some inital ui state:
        self.defaults = breakdown_defaults()
        self.pbnAdvanced.setChecked(True)
        self.pbnAdvanced.toggle()
        self.radPredefined.setChecked(True)
        self.dsbFemaleRatioDefault.blockSignals(True)
        self.dsbFemaleRatioDefault.setValue(self.defaults['FEM_RATIO'])
        self.dsbFemaleRatioDefault.blockSignals(False)
        #myButton = self.buttonBox.button(QtGui.QDialogButtonBox.Ok)
        #myButton.setEnabled(False)
        if layer is None:
            self.layer = self.iface.activeLayer()
        else:
            self.layer = layer
        if self.layer:
            self.load_state_from_keywords()

        # add a reload from keywords button
        reloadButton = self.buttonBox.addButton(
            self.tr('Reload'), QtGui.QDialogButtonBox.ActionRole)
        reloadButton.clicked.connect(self.load_state_from_keywords)
    def __init__(self, parent, iface, dock=None, layer=None):
        """Constructor for the dialog.

        .. note:: In QtDesigner the advanced editor's predefined keywords
           list should be shown in english always, so when adding entries to
           cboKeyword, be sure to choose :safe_qgis:`Properties<<` and untick
           the :safe_qgis:`translatable` property.

        :param parent: Parent widget of this dialog.
        :type parent: QWidget

        :param iface: Quantum GIS QGisAppInterface instance.
        :type iface: QGisAppInterface

        :param dock: Dock widget instance that we can notify of changes to
            the keywords. Optional.
        :type dock: Dock
        """

        QtGui.QDialog.__init__(self, parent)
        self.setupUi(self)
        self.setWindowTitle(self.tr("InaSAFE %s Keywords Editor") % (get_version()))
        self.keywordIO = KeywordIO()
        # note the keys should remain untranslated as we need to write
        # english to the keywords file. The keys will be written as user data
        # in the combo entries.
        # .. seealso:: http://www.voidspace.org.uk/python/odict.html
        self.standardExposureList = OrderedDict(
            [
                ("population", self.tr("population")),
                ("structure", self.tr("structure")),
                ("Not Set", self.tr("Not Set")),
            ]
        )
        self.standardHazardList = OrderedDict(
            [
                ("earthquake [MMI]", self.tr("earthquake [MMI]")),
                ("tsunami [m]", self.tr("tsunami [m]")),
                ("tsunami [wet/dry]", self.tr("tsunami [wet/dry]")),
                ("tsunami [feet]", self.tr("tsunami [feet]")),
                ("flood [m]", self.tr("flood [m]")),
                ("flood [wet/dry]", self.tr("flood [wet/dry]")),
                ("flood [feet]", self.tr("flood [feet]")),
                ("tephra [kg2/m2]", self.tr("tephra [kg2/m2]")),
                ("volcano", self.tr("volcano")),
                ("Not Set", self.tr("Not Set")),
            ]
        )
        # Save reference to the QGIS interface and parent
        self.iface = iface
        self.parent = parent
        self.dock = dock

        self.lstKeywords.itemClicked.connect(self.edit_key_value_pair)

        # Set up help dialog showing logic.
        self.helpDialog = None
        helpButton = self.buttonBox.button(QtGui.QDialogButtonBox.Help)
        helpButton.clicked.connect(self.show_help)

        # set some inital ui state:
        self.defaults = breakdown_defaults()
        self.pbnAdvanced.setChecked(True)
        self.pbnAdvanced.toggle()
        self.radPredefined.setChecked(True)
        self.dsbFemaleRatioDefault.blockSignals(True)
        self.dsbFemaleRatioDefault.setValue(self.defaults["FEM_RATIO"])
        self.dsbFemaleRatioDefault.blockSignals(False)
        # myButton = self.buttonBox.button(QtGui.QDialogButtonBox.Ok)
        # myButton.setEnabled(False)
        if layer is None:
            self.layer = self.iface.activeLayer()
        else:
            self.layer = layer
        if self.layer:
            self.load_state_from_keywords()

        # add a reload from keywords button
        reloadButton = self.buttonBox.addButton(self.tr("Reload"), QtGui.QDialogButtonBox.ActionRole)
        reloadButton.clicked.connect(self.load_state_from_keywords)