66from gui .views .py_files .lhssettings import Ui_Dialog
77
88
9+ class SamplesNumberValidator (QIntValidator ):
10+ def __init__ (self , app_data : DataStorage , bottom : int , top : int ,
11+ parent : None ) -> None :
12+ super ().__init__ (bottom = bottom , top = top , parent = parent )
13+ self .lhs_settings = app_data .doe_lhs_settings
14+
15+ def fixup (self , inp : str ) -> str :
16+ if inp == '' :
17+ inp = str (self .lhs_settings ['n_samples' ])
18+ return super ().fixup (inp )
19+
20+
21+ class IterNumberValidator (QIntValidator ):
22+ def __init__ (self , app_data : DataStorage , bottom : int , top : int ,
23+ parent : None ) -> None :
24+ super ().__init__ (bottom = bottom , top = top , parent = parent )
25+ self .lhs_settings = app_data .doe_lhs_settings
26+
27+ def fixup (self , inp : str ) -> str :
28+ if inp == '' :
29+ inp = str (self .lhs_settings ['n_iter' ])
30+ return super ().fixup (inp )
31+
32+
933class LhsSettingDialog (QDialog ):
1034 def __init__ (self , application_database : DataStorage ):
1135 # ------------------------ Internal Variables -------------------------
@@ -23,8 +47,12 @@ def __init__(self, application_database: DataStorage):
2347 self .ui .checkBoxIncVertices .setChecked (lhs_settings ['inc_vertices' ])
2448
2549 # validators
26- n_samples_validator = QIntValidator (3 , 1e4 , self .ui .lineEditNSamples )
27- n_iter_validator = QIntValidator (2 , 50 , self .ui .lineEditNIter )
50+ n_samples_validator = SamplesNumberValidator (
51+ self .app_data , 3 , 1e4 , self .ui .lineEditNSamples
52+ )
53+ n_iter_validator = IterNumberValidator (
54+ self .app_data , 2 , 50 , self .ui .lineEditNIter
55+ )
2856
2957 self .ui .lineEditNSamples .setValidator (n_samples_validator )
3058 self .ui .lineEditNIter .setValidator (n_iter_validator )
@@ -41,6 +69,11 @@ def set_lhs_settings(self):
4169
4270 self .app_data .doe_lhs_settings = pd .Series (lhs_set )
4371
72+ def on_n_samples_edited (self ):
73+ if self .ui .lineEditNSamples .text () == '' :
74+ lhs_settings = self .app_data .doe_lhs_settings
75+ self .ui .lineEditNSamples .setText (str (lhs_settings ['n_samples' ]))
76+
4477
4578if __name__ == "__main__" :
4679 import sys
0 commit comments