Skip to content

Commit

Permalink
Merge pull request #16 from ALP2023/issue-1
Browse files Browse the repository at this point in the history
Update and Clean Up Code Documentation 
  • Loading branch information
rolandhill authored Nov 19, 2023
2 parents 9416cc6 + 78a202a commit 53abc05
Show file tree
Hide file tree
Showing 10 changed files with 195 additions and 95 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/geoscience.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 20 additions & 4 deletions desurveyhole_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@

from .dialogBase import dialogBase

# Load the UI file
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'desurveyhole_dialog_base.ui'))


class DesurveyHoleDialog(QtWidgets.QDialog, dialogBase, FORM_CLASS):
"""Dialog for managing desurveyed holes."""
def __init__(self, manager, parent=None):
"""Constructor."""
"""
Constructor for DesurveyHoleDialog.
Args:
manager (DrillManager): Instance of DrillManager.
parent (QWidget): Parent widget (default is None).
"""
super(DesurveyHoleDialog, self).__init__(parent)

# Keep a reference to the DrillManager
Expand All @@ -27,27 +35,31 @@ def __init__(self, manager, parent=None):
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)

# Setup ComboBox filters
self.lbCollarLayer.setFilters(QgsMapLayerProxyModel.PointLayer)
self.lbSurveyLayer.setFilters(QgsMapLayerProxyModel.NoGeometry)

# Initialise local variables and ComboBoxes
self.checkDownDipNegative.setChecked(self.drillManager.downDipNegative)
# self.teDefaultSectionWidth.setText(str(self.drillManager.defaultSectionWidth))
# self.teDefaultSectionStep.setText(str(self.drillManager.defaultSectionStep))
self.leDesurveyLength.setText(str(self.drillManager.desurveyLength))
self.initLayer(self.drillManager.collarLayer, self.lbCollarLayer, ["collar", "hole"])
self.initLayer(self.drillManager.surveyLayer, self.lbSurveyLayer, ["survey"])


# Connect signals to slots
self.lbCollarLayer.layerChanged.connect(self.onCollarLayerChanged)
self.lbSurveyLayer.layerChanged.connect(self.onSurveyLayerChanged)

# Initialize configurations
self.onCollarLayerChanged()
self.onSurveyLayerChanged()

def onCollarLayerChanged(self):
"""Handle changes in the collar layer."""
layer = self.lbCollarLayer.currentLayer()

if layer is not None and layer.isValid():
# Set up fields for collar layer
self.fbCollarId.setLayer(layer)
self.initField(self.drillManager.collarId, self.fbCollarId, ["holeid", "bhid", "id", "hole", "name"])
self.fbCollarDepth.setLayer(layer)
Expand All @@ -63,6 +75,7 @@ def onCollarLayerChanged(self):
self.fbCollarDip.setLayer(layer)
self.initField(self.drillManager.collarDip, self.fbCollarDip, ["dip", "incl"])
else:
# Reset configurations if no valid layer is selected
self.fbCollarId.setCurrentIndex(-1)
self.fbCollarEast.setCurrentIndex(-1)
self.fbCollarNorth.setCurrentIndex(-1)
Expand All @@ -71,8 +84,10 @@ def onCollarLayerChanged(self):
self.fbCollarDip.setCurrentIndex(-1)

def onSurveyLayerChanged(self):
"""Handle changes in the survey layer."""
layer = self.lbSurveyLayer.currentLayer()
if layer is not None and layer.isValid():
# Set up fields for survey layer
self.fbSurveyId.setLayer(layer)
self.initField(self.drillManager.surveyId, self.fbSurveyId, ["holeid", "bhid", "id", "hole", "name"])
self.fbSurveyDepth.setLayer(layer)
Expand All @@ -82,6 +97,7 @@ def onSurveyLayerChanged(self):
self.fbSurveyDip.setLayer(layer)
self.initField(self.drillManager.surveyDip, self.fbSurveyDip, ["dip", "incl"])
else:
# Reset configurations if no valid layer is selected
self.fbSurveyId.setCurrentIndex(-1)
self.fbSurveyDepth.setCurrentIndex(-1)
self.fbSurveyAz.setCurrentIndex(-1)
Expand Down
38 changes: 33 additions & 5 deletions downholedata_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@

class DownholeDataDialog(QtWidgets.QDialog, dialogBase, FORM_CLASS):
def __init__(self, manager, parent=None):
"""Constructor."""
"""
Constructor for the DownholeDataDialog class.
param manager: DrillManager object.
type manager: DrillManager
param parent: Parent widget (optional).
type parent: QWidget
"""
super(DownholeDataDialog, self).__init__(parent)

# Keep a reference to the DrillManager
Expand All @@ -28,31 +35,44 @@ def __init__(self, manager, parent=None):
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)


# Initialise and set filters for layers lists.
self.lbDesurveyLayer.setFilters(QgsMapLayerProxyModel.LineLayer)
self.initLayer(self.drillManager.desurveyLayer, self.lbDesurveyLayer, ["desurvey"])

# Initialise layers and UI elements.
self.lbDataLayer.setFilters(QgsMapLayerProxyModel.NoGeometry)
self.initLayer(self.drillManager.dataLayer, self.lbDataLayer, ["lith", "geol"])
self.checkSelectAll.setChecked(True)


# Connect signals to slots.
self.lbDataLayer.layerChanged.connect(self.onDataLayerChanged)
self.checkSelectAll.toggled.connect(self.onSelectAllChecked)

# Trigger initial data and setup dialog based on the current data layer.
self.onDataLayerChanged()

def onDataLayerChanged(self):
"""
Handle changes in the selected data layer.
This method is called when the user selects a different data layer.
"""
layer = self.lbDataLayer.currentLayer()

if layer is not None and layer.isValid():
# Set up the data ID field combo box
self.fbDataId.setLayer(layer)
self.initField(self.drillManager.dataId, self.fbDataId, ["holeid", "id", "hole", "name"])
# Set up the data "from" field combo box
self.fbDataFrom.setLayer(layer)
self.initField(self.drillManager.dataFrom, self.fbDataFrom, ["from", "start", "depth"])
# Set up the data "to" field combo box
self.fbDataTo.setLayer(layer)
self.initField(self.drillManager.dataTo, self.fbDataTo, ["to","end"])
#Clear the Suffix text
# Clear the Suffix text
self.teSuffix.clear()
#Load the list widget
# Load the list widget with fields from the selected layer
self.listFields.clear()
for field in layer.fields():
item = QtWidgets.QListWidgetItem()
Expand All @@ -68,9 +88,17 @@ def onDataLayerChanged(self):
self.listFields.clear()

def onSelectAllChecked(self):
"""
Handles the "Select All" checkbox state change.
This method is called when the user checks or unchecks the "Select All" checkbox.
"""
self.selectAll(self.listFields, self.checkSelectAll.isChecked())

def setSuffix(self):
"""
Set the Suffix text based on the selected data layer's name.
"""
str = self.lbDataLayer.currentLayer().name()
loc = str.find("_")
if loc > -1:
Expand Down
22 changes: 17 additions & 5 deletions downholestructure_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,21 @@

from .dialogBase import dialogBase

# Load the UI file
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), 'downholestructure_dialog_base.ui'))


class DownholeStructureDialog(QtWidgets.QDialog, dialogBase, FORM_CLASS):
"""Dialog for managing downhole structures."""
def __init__(self, manager, parent=None):
"""Constructor."""
"""
Constructor for DownholeStructureDialog.
Args:
manager (DrillManager): Instance of DrillManager.
parent (QWidget): Parent widget (default is None).
"""
super(DownholeStructureDialog, self).__init__(parent)

# Keep a reference to the DrillManager
Expand All @@ -26,24 +34,26 @@ def __init__(self, manager, parent=None):
# After setupUI you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
# widgets-and-dialogs-with-auto-connect
self.setupUi(self)


# Set up initial configurations
self.lbDesurveyLayer.setFilters(QgsMapLayerProxyModel.LineLayer)
self.initLayer(self.drillManager.desurveyLayer, self.lbDesurveyLayer, ["desurvey"])

self.lbDataLayer.setFilters(QgsMapLayerProxyModel.NoGeometry)
self.initLayer(self.drillManager.structureLayer, self.lbDataLayer, ["struc"])
self.checkSelectAll.setChecked(True)

self.leSymbolSize.setText(str(self.drillManager.structureScale))

# Connect signals to slots
self.lbDataLayer.layerChanged.connect(self.onDataLayerChanged)
self.checkSelectAll.toggled.connect(self.onSelectAllChecked)

# Initialize configurations
self.onDataLayerChanged()

def onDataLayerChanged(self):
"""Handle changes in the data layer."""
layer = self.lbDataLayer.currentLayer()
if layer is not None and layer.isValid():
self.fbDataId.setLayer(layer)
Expand All @@ -54,6 +64,7 @@ def onDataLayerChanged(self):
self.initField(self.drillManager.structureAlpha, self.fbDataAlpha, ["alpha"])
self.fbDataBeta.setLayer(layer)
self.initField(self.drillManager.structureBeta, self.fbDataBeta, ["beta"])

#Load the list widget
self.listFields.clear()
for field in layer.fields():
Expand All @@ -70,4 +81,5 @@ def onDataLayerChanged(self):
self.listFields.clear()

def onSelectAllChecked(self):
"""Handle 'Select All' checkbox state changes."""
self.selectAll(self.listFields, self.checkSelectAll.isChecked())
Loading

0 comments on commit 53abc05

Please sign in to comment.