1+ import os
2+ import random
3+
4+ from PyQt5 .QtCore import QVariant
5+ import numpy as np
16from qgis .PyQt import uic
27from qgis .PyQt .QtGui import QColor
3- from qgis .core import QgsMapLayerProxyModel
4-
5- from PyQt5 .QtCore import QSize
6-
78from qgis .PyQt .QtWidgets import (
8- QWidget ,
9- QListWidgetItem ,
10- QTableWidgetItem ,
11- QLabel ,
9+ QCheckBox ,
10+ QColorDialog ,
11+ QComboBox ,
1212 QDoubleSpinBox ,
13- QSpinBox ,
1413 QFileDialog ,
14+ QLabel ,
15+ QListWidgetItem ,
1516 QPushButton ,
16- QColorDialog ,
17- QCheckBox ,
18- QComboBox ,
17+ QWidget ,
1918)
20- from qgis .core import QgsProject , QgsEllipse , QgsPoint , QgsVectorLayer , QgsFeature
21- import random
22- import os
19+ from qgis .core import (
20+ QgsEllipse ,
21+ QgsFeature ,
22+ QgsField ,
23+ QgsMapLayerProxyModel ,
24+ QgsFieldProxyModel ,
25+ QgsPoint ,
26+ QgsProject ,
27+ QgsVectorLayer ,
28+ )
29+
30+ from LoopStructural .utils import random_hex_colour
31+
2332from ...main import QgsProcessInputData
2433from ...main .geometry .calculateLineAzimuth import calculateAverageAzimuth
2534from ...main .rasterFromModel import callableToRaster
26- from LoopStructural .utils import random_hex_colour
27- from qgis .core import QgsField
28- from PyQt5 .QtCore import QVariant
29- import numpy as np
35+ from ...main .callableToLayer import callableToLayer
36+
3037
3138# from .feature_widget import FeatureWidget
3239# from LoopStructural.visualisation import Loop3DView
@@ -75,6 +82,13 @@ def _set_layer_filters(self):
7582 # evaluate on feature layer
7683 self .evaluateFeatureLayerSelector .setFilters (QgsMapLayerProxyModel .PointLayer )
7784 self .evaluateFeatureLayerSelector .setAllowEmptyLayer (True )
85+ # orientation field can only be double or int
86+ self .orientationField .setFilters (QgsFieldProxyModel .Numeric )
87+ self .dipField .setFilters (QgsFieldProxyModel .Numeric )
88+ # fault dip field can only be double or int
89+ self .faultDipField .setFilters (QgsFieldProxyModel .Numeric )
90+ # fault displacement field can only be double or int
91+ self .faultDisplacementField .setFilters (QgsFieldProxyModel .Numeric )
7892
7993 def _connectSignals (self ):
8094 self .basalContactsLayer .layerChanged .connect (self .onBasalContactsChanged )
@@ -178,7 +192,7 @@ def onInitialiseModel(self):
178192
179193 processor = QgsProcessInputData (
180194 basal_contacts = self .basalContactsLayer .currentLayer (),
181- stratigraphic_column = self ._units ,
195+ groups = self .groups ,
182196 fault_trace = self .faultTraceLayer .currentLayer (),
183197 fault_properties = self ._faults ,
184198 structural_data = self .structuralDataLayer .currentLayer (),
@@ -258,11 +272,24 @@ def onAddFaultDisplacmentsToProject(self):
258272 pass
259273
260274 def onEvaluateModelOnLayer (self ):
261- pass
275+ layer = self . evaluateModelOnLayerSelector . currentLayer ()
262276
263- def onEvaluateFeatureOnLayer (self ):
277+ callableToLayer (
278+ lambda xyz : self .model .evaluate_model (xyz ),
279+ layer ,
280+ self .DtmLayer .currentLayer (),
281+ 'unit_id' ,
282+ )
264283
265- callableOnLayer (layer , callable )
284+ def onEvaluateFeatureOnLayer (self ):
285+ feature_name = self .evaluateFeatureFeatureSelector .currentText ()
286+ layer = self .evaluateFeatureLayerSelector .currentLayer ()
287+ callableToLayer (
288+ lambda xyz : self .model .evaluate_feature_value (feature_name , xyz ),
289+ layer ,
290+ self .DtmLayer .currentLayer (),
291+ feature_name ,
292+ )
266293 pass
267294
268295 def onAddModelledLithologiesToProject (self ):
@@ -275,7 +302,7 @@ def onAddModelledLithologiesToProject(self):
275302 dtm = self .DtmLayer .currentLayer (),
276303 bounding_box = bounding_box ,
277304 crs = QgsProject .instance ().crs (),
278- layer_name = f 'modelled_lithologies' ,
305+ layer_name = 'modelled_lithologies' ,
279306 )
280307 if feature_layer .isValid ():
281308 QgsProject .instance ().addMapLayer (feature_layer )
@@ -343,17 +370,21 @@ def onUnitFieldChanged(self, field):
343370 list (unique_values ),
344371 [
345372 {
346- 'thickness' : attributes [ u ][ 'thickness' ]
347- if 'thickness' in attributes [u ]
348- else 10.0 ,
373+ 'thickness' : (
374+ attributes [ u ][ 'thickness' ] if 'thickness' in attributes [u ] else 10.0
375+ ) ,
349376 'order' : int (attributes [u ]['order' ]) if 'order' in attributes [u ] else i ,
350377 'name' : u ,
351- 'colour' : str (attributes [u ]['colour' ])
352- if 'colour' in attributes [u ]
353- else colours [i ],
354- 'contact' : str (attributes [u ]['contact' ])
355- if 'contact' in attributes [u ]
356- else 'Conformable' ,
378+ 'colour' : (
379+ str (attributes [u ]['colour' ])
380+ if 'colour' in attributes [u ]
381+ else colours [i ]
382+ ),
383+ 'contact' : (
384+ str (attributes [u ]['contact' ])
385+ if 'contact' in attributes [u ]
386+ else 'Conformable'
387+ ),
357388 }
358389 for i , u in enumerate (unique_values )
359390 ],
@@ -371,6 +402,11 @@ def initFaultSelector(self):
371402 def initFaultNetwork (self ):
372403 # faultNetwork
373404 self .faultNetworkTable .clear ()
405+ self .faultNetworkTable .setRowCount (0 )
406+ self .faultNetworkTable .setColumnCount (0 )
407+ self .faultStratigraphyTable .clear ()
408+ self .faultStratigraphyTable .setRowCount (0 )
409+ self .faultStratigraphyTable .setColumnCount (0 )
374410 if not self ._faults :
375411 return
376412
@@ -402,8 +438,7 @@ def initFaultNetwork(self):
402438 self .faultNetworkTable .resizeRowsToContents ()
403439
404440 self .faultStratigraphyTable .clear ()
405- if not self ._faults :
406- return
441+
407442
408443 faults = list (self ._faults .keys ())
409444 groups = [g ['name' ] for g in self .groups ]
@@ -565,12 +600,8 @@ def pick_color():
565600 unconformity .addItem ('Onlap' )
566601 if 'contact' in value :
567602 unconformity .setCurrentText (value ['contact' ])
568- unconformity .currentIndexChanged .connect (
569- lambda index , unit = unit : self ._units [unit ].update (
570- {'contact' : unconformity .currentText ()}
571- )
572- )
573- unconformity .currentIndexChanged .connect (self .stratigraphicColumnChanged )
603+
604+ unconformity .currentTextChanged .connect (lambda text , unit = unit : self .stratigraphicColumnChanged (text ,unit ))
574605
575606 self .stratigraphicColumnContainer .addWidget (unconformity , i , 5 )
576607 up .clicked .connect (create_lambda (i , - 1 ))
@@ -579,9 +610,12 @@ def pick_color():
579610 spin_box .valueChanged .connect (
580611 lambda value , unit = unit : self .onThicknessChanged (unit , value )
581612 )
582- self .stratigraphicColumnChanged ( 0 )
613+ self .updateGroups ( )
583614
584- def stratigraphicColumnChanged (self , index ):
615+ def stratigraphicColumnChanged (self , text ,unit ):
616+ self ._units [unit ]['contact' ] = text
617+ self .updateGroups ()
618+ def updateGroups (self ):
585619 columns = self ._getSortedStratigraphicColumn ()
586620
587621 self .groups = []
@@ -593,7 +627,9 @@ def stratigraphicColumnChanged(self, index):
593627 self .groups .append ({'name' : f'group_{ ii } ' , 'units' : group })
594628 ii += 1
595629 group = []
630+
596631 self .groups .append ({'name' : f'group_{ ii } ' , 'units' : group })
632+ self .initFaultNetwork ()
597633
598634 def onOrderChanged (self , old_index , new_index ):
599635 if new_index < 0 or new_index >= len (self ._units ):
0 commit comments