|
1 | 1 | import os |
2 | 2 |
|
3 | 3 | from PyQt5.QtWidgets import QWidget |
4 | | -from qgis.core import QgsMapLayerProxyModel |
| 4 | +from qgis.core import QgsMapLayerProxyModel, QgsWkbTypes |
5 | 5 | from qgis.PyQt import uic |
6 | 6 | from PyQt5.QtCore import Qt |
7 | 7 |
|
@@ -30,12 +30,49 @@ def __init__(self, parent=None, data_manager=None): |
30 | 30 | self.orientationType.currentIndexChanged.connect(self.onOrientationTypeChanged) |
31 | 31 | self.data_manager.set_basal_contacts_callback(self.set_basal_contacts) |
32 | 32 | self.data_manager.set_structural_orientations_callback(self.set_orientations_layer) |
| 33 | + self.basal_contacts_use_z = False |
| 34 | + self.structural_points_use_z = False |
| 35 | + self.useBasalContactsZCoordinatesCheckBox.stateChanged.connect(lambda : self.enableBasalContactsZCheckBox(self.useBasalContactsZCoordinatesCheckBox.isChecked())) |
| 36 | + self.useBasalContactsZCoordinatesCheckBox.stateChanged.connect(self.onStructuralDataFieldChanged) |
| 37 | + self.useStructuralPointsZCoordinatesCheckBox.stateChanged.connect(lambda : self.enableStructuralPointsZCheckBox(self.useStructuralPointsZCoordinatesCheckBox.isChecked())) |
| 38 | + self.useStructuralPointsZCoordinatesCheckBox.stateChanged.connect(self.onStructuralDataFieldChanged) |
| 39 | + |
| 40 | + def enableBasalContactsZCheckBox(self, enable): |
| 41 | + self.useBasalContactsZCoordinatesCheckBox.setEnabled(enable) |
| 42 | + if enable: |
| 43 | + self.useBasalContactsZCoordinatesCheckBox.setChecked(self.basal_contacts_use_z) |
| 44 | + else: |
| 45 | + self.useBasalContactsZCoordinatesCheckBox.setChecked(False) |
| 46 | + def enableStructuralPointsZCheckBox(self, enable): |
| 47 | + self.useStructuralPointsZCoordinatesCheckBox.setEnabled(enable) |
| 48 | + if enable: |
| 49 | + self.useStructuralPointsZCoordinatesCheckBox.setChecked(self.structural_points_use_z) |
| 50 | + else: |
| 51 | + self.useStructuralPointsZCoordinatesCheckBox.setChecked(False) |
33 | 52 | def set_basal_contacts(self, layer, unitname_field=None): |
34 | 53 | self.basalContactsLayer.setLayer(layer) |
| 54 | + if layer is not None and layer.isValid(): |
| 55 | + if layer.wkbType() != QgsWkbTypes.Unknown: |
| 56 | + has_z = QgsWkbTypes.hasZ(layer.wkbType()) |
| 57 | + self.data_manager.logger(message=f"Layer {layer.name()} has Z coordinate: {has_z}",log_level=2) |
| 58 | + self.enableBasalContactsZCheckBox(has_z) |
| 59 | + else: |
| 60 | + self.data_manager.logger(message="Unknown geometry type.",log_level=2) |
| 61 | + else: |
| 62 | + self.enableBasalContactsZCheckBox(False) |
35 | 63 | if unitname_field: |
36 | 64 | self.unitNameField.setField(unitname_field) |
37 | 65 | def set_orientations_layer(self, layer, strike_field=None, dip_field=None, unitname_field=None, orientation_type=None): |
38 | 66 | self.structuralDataLayer.setLayer(layer) |
| 67 | + if layer is not None and layer.isValid(): |
| 68 | + if layer.wkbType() != QgsWkbTypes.Unknown: |
| 69 | + has_z = QgsWkbTypes.hasZ(layer.wkbType()) |
| 70 | + self.data_manager.logger(message=f"Layer {layer.name()} has Z coordinate: {has_z}",level=2) |
| 71 | + self.enableStructuralPointsZCheckBox(has_z) |
| 72 | + else: |
| 73 | + self.data_manager.logger(message="Unknown geometry type.",level=2) |
| 74 | + else: |
| 75 | + self.enableStructuralPointsZCheckBox(False) |
39 | 76 | if strike_field: |
40 | 77 | self.orientationField.setField(strike_field) |
41 | 78 | if dip_field: |
@@ -64,17 +101,19 @@ def onStructuralDataLayerChanged(self, layer): |
64 | 101 | self.orientationField.currentField(), |
65 | 102 | self.dipField.currentField(), |
66 | 103 | self.structuralDataUnitName.currentField(), |
| 104 | + use_z_coordinate=self.structural_points_use_z, |
67 | 105 | ) |
68 | 106 | def onStructuralDataFieldChanged(self, field): |
69 | 107 | self.data_manager.set_structural_orientations( |
70 | 108 | self.structuralDataLayer.currentLayer(), |
71 | 109 | self.orientationField.currentField(), |
72 | 110 | self.dipField.currentField(), |
73 | 111 | self.structuralDataUnitName.currentField(), |
74 | | - self.orientationType.currentText() |
| 112 | + self.orientationType.currentText(), |
| 113 | + use_z_coordinate=self.structural_points_use_z |
75 | 114 | ) |
76 | 115 | # self.updateDataManager() |
77 | 116 | def onUnitFieldChanged(self, field): |
78 | | - self.data_manager.set_basal_contacts(self.basalContactsLayer.currentLayer(), field) |
| 117 | + self.data_manager.set_basal_contacts(self.basalContactsLayer.currentLayer(), field, use_z_coordinate=self.basal_contacts_use_z) |
79 | 118 |
|
80 | 119 | # self.updateDataManager() |
0 commit comments