Skip to content

Commit 996cdb8

Browse files
committed
fix: fault fault topology working
1 parent 65b91cd commit 996cdb8

2 files changed

Lines changed: 134 additions & 56 deletions

File tree

loopstructural/gui/modelling/fault_adjacency_tab.py

Lines changed: 53 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
from ast import arg
2-
from PyQt5.QtWidgets import QTabWidget, QVBoxLayout, QWidget, QLabel, QTableWidget, QTableWidgetItem, QPushButton, QGroupBox
31
from PyQt5.QtCore import Qt
4-
from enum import Enum
2+
from PyQt5.QtWidgets import (
3+
QGroupBox,
4+
QLabel,
5+
QPushButton,
6+
QTableWidget,
7+
QTableWidgetItem,
8+
QTabWidget,
9+
QVBoxLayout,
10+
QWidget,
11+
)
12+
13+
from LoopStructural.modelling.core.fault_topology import FaultRelationshipType
514

6-
class FaultRelationshipType(Enum):
7-
NO_EDGE = "no_edge"
8-
ABUTTING = "abutting"
9-
FAULTED = "faulted"
1015

1116
class FaultAdjacencyTab(QWidget):
1217
def __init__(self, parent=None, data_manager=None):
@@ -17,9 +22,9 @@ def __init__(self, parent=None, data_manager=None):
1722
# Initialize the UI components for fault adjacency
1823
self.init_ui()
1924
# self.data_manager.set
25+
2026
def init_ui(self):
2127
"""Initialize the user interface components for fault adjacency."""
22-
2328

2429
# Create collapsible group boxes for the tables
2530
self.fault_table_group = QGroupBox("Fault Adjacency Table", self)
@@ -45,7 +50,7 @@ def init_ui(self):
4550
"Rows: stratigraphic units\n"
4651
"Columns: faults\n"
4752
"Toggle cell colour to indicate interaction:\n"
48-
"Red: unit is faulted by fault\n"
53+
"Red: unit is faulted by fault\n"
4954
"White: no interaction"
5055
)
5156
self.strat_fault_instructions_label = QLabel(self.strat_fault_instructions)
@@ -57,10 +62,13 @@ def init_ui(self):
5762
self.data_manager._stratigraphic_column.attach(self.update)
5863
self.data_manager._fault_topology.attach(self.update)
5964

60-
def _update(self, event,*args,**kwargs):
61-
if args[0] == "fault_relationship_updated" or args[0] == "stratigraphy_fault_relationship_updated":
65+
def _update(self, event, *args, **kwargs):
66+
if (
67+
args[0] == "fault_relationship_updated"
68+
or args[0] == "stratigraphy_fault_relationship_updated"
69+
):
6270
return
63-
71+
6472
self.update_fault_adjacency_table()
6573
self.update_stratigraphic_units_table()
6674

@@ -72,7 +80,7 @@ def change_button_color(self, button, row, col):
7280
relationship = FaultRelationshipType.FAULTED
7381
elif "green" in current_color:
7482
new_color = "white"
75-
relationship = FaultRelationshipType.NO_EDGE
83+
relationship = FaultRelationshipType.NONE
7684
else:
7785
new_color = "red"
7886
relationship = FaultRelationshipType.ABUTTING
@@ -84,7 +92,9 @@ def change_button_color(self, button, row, col):
8492

8593
def update_fault_adjacency_table(self):
8694
"""Update the fault adjacency table with QPushButtons."""
87-
faults = self.data_manager._fault_topology.faults # Assuming faults is a list of fault names
95+
faults = (
96+
self.data_manager._fault_topology.faults
97+
) # Assuming faults is a list of fault names
8898
if not faults:
8999
self.fault_table_group.hide()
90100
return
@@ -110,18 +120,32 @@ def update_fault_adjacency_table(self):
110120
self.table.setItem(row, col, item)
111121
else:
112122
button = QPushButton()
113-
if self.data_manager._fault_topology.get_fault_relationship(faults[row], faults[col]) == FaultRelationshipType.FAULTED:
123+
if (
124+
self.data_manager._fault_topology.get_fault_relationship(
125+
faults[row], faults[col]
126+
)
127+
== FaultRelationshipType.FAULTED
128+
):
114129
button.setStyleSheet("background-color: green;")
115-
elif self.data_manager._fault_topology.get_fault_relationship(faults[row], faults[col]) == FaultRelationshipType.ABUTTING:
130+
elif (
131+
self.data_manager._fault_topology.get_fault_relationship(
132+
faults[row], faults[col]
133+
)
134+
== FaultRelationshipType.ABUTTING
135+
):
116136
button.setStyleSheet("background-color: red;")
117137
else:
118138
button.setStyleSheet("background-color: white;")
119-
button.clicked.connect(lambda _, b=button, r=row, c=col: self.change_button_color(b, r, c))
139+
button.clicked.connect(
140+
lambda _, b=button, r=row, c=col: self.change_button_color(b, r, c)
141+
)
120142
self.table.setCellWidget(row, col, button)
121143

122144
def update_stratigraphic_units_table(self):
123145
"""Update the stratigraphic units table with QPushButtons."""
124-
faults = self.data_manager._fault_topology.faults # Assuming faults is a list of fault names
146+
faults = (
147+
self.data_manager._fault_topology.faults
148+
) # Assuming faults is a list of fault names
125149
group_units_pairs = self.data_manager._stratigraphic_column.get_group_unit_pairs()
126150

127151
if not faults or not group_units_pairs:
@@ -145,13 +169,18 @@ def update_stratigraphic_units_table(self):
145169
for row in range(len(units)):
146170
for col in range(len(faults)):
147171
button = QPushButton()
148-
if self.data_manager._fault_topology.get_fault_stratigraphic_relationship(units[row], faults[col]):
172+
if self.data_manager._fault_topology.get_fault_stratigraphic_relationship(
173+
units[row], faults[col]
174+
):
149175
button.setStyleSheet("background-color: red;")
150176
else:
151177
# Default to white if no relationship or not faulted
152178
button.setStyleSheet("background-color: white;")
153-
button.clicked.connect(lambda _, b=button, r=row, c=col: self.change_button_colour_binary(b, r, c))
179+
button.clicked.connect(
180+
lambda _, b=button, r=row, c=col: self.change_button_colour_binary(b, r, c)
181+
)
154182
self.stratigraphic_table.setCellWidget(row, col, button)
183+
155184
def change_button_colour_binary(self, button, row, col):
156185
"""Cycle the button color between red, green, and black."""
157186

@@ -162,6 +191,8 @@ def change_button_colour_binary(self, button, row, col):
162191
else:
163192
button.setStyleSheet("background-color: red;")
164193
flag = True
165-
fault = self.data_manager._fault_topology.faults[col]
194+
fault = self.data_manager._fault_topology.faults[col]
166195
unit = self.data_manager._stratigraphic_column.get_group_unit_pairs()[row]
167-
self.data_manager._fault_topology.update_fault_stratigraphy_relationship(unit[1], fault, flag)
196+
self.data_manager._fault_topology.update_fault_stratigraphy_relationship(
197+
unit[1], fault, flag
198+
)

0 commit comments

Comments
 (0)