-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathland_wizard.py
2579 lines (1956 loc) · 132 KB
/
land_wizard.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -----------------------------------------------------------------------------------------------------------------
# See: https://north-road.com/2018/03/09/implementing-an-in-house-new-project-wizard-for-qgis/
# And: https://plugins.qgis.org/planet/user/29/tag/python/
# See: https://doc.qt.io/archives/qq/qq22-qwizard.html#registeringandusingfields for innards of a QWizard
# -----------------------------------------------------------------------------------------------------------------
# See: https://p.yusukekamiyamane.com/ for free icons
# See: https://www.pythonguis.com/faq/editing-pyqt-tableview/ for editing a table widget
import math
import os
import os.path
import pyqtgraph as pg
from qgis.gui import QgsProjectionSelectionTreeWidget
from qgis.PyQt.QtCore import QRectF, QSizeF
from qgis.PyQt.QtGui import QColor, QImage, QPixmap, QTextOption, QTransform
from qgis.PyQt.QtWidgets import QCheckBox, QComboBox, QDoubleSpinBox, QFrame, QGridLayout, QLabel, QLineEdit, QMessageBox, QPlainTextEdit, QSizePolicy, QSpinBox, QVBoxLayout, QWizard, QWizardPage
from . import config # used to pass initial settings
from .pg_toolbar import PgToolBar
from .roll_pattern import RollPattern
from .roll_survey import PaintMode, RollSurvey, SurveyList, SurveyType
current_dir = os.path.dirname(os.path.abspath(__file__))
class QHLine(QFrame):
def __init__(self, parent=None):
super().__init__(parent)
self.setFrameShape(QFrame.HLine)
self.setFrameShadow(QFrame.Sunken)
class QVLine(QFrame):
def __init__(self, parent=None):
super().__init__(parent)
self.setFrameShape(QFrame.VLine)
self.setFrameShadow(QFrame.Sunken)
# WIZARD =======================================================================
# this derived wizard class contains a survey object, that is passed to the wizard pages
class SurveyWizard(QWizard):
def __init__(self, parent=None):
super().__init__(parent)
# to access the main window and its components
self.parent = parent
# in the wizard constructor, first create the survey object for use in subsequent wizard pages
self.survey = RollSurvey()
class SurveyWizardPage(QWizardPage):
def __init__(self, parent=None):
super().__init__(parent)
self.parent = parent # to access parameters in the wizard itself
# in the page constructor, first get a reference to the survey object from the survey wizard itself
# not really needed, as we can access the survey object referring to: "parent.survey" in each page
# self.survey = parent.survey
def cleanupPage(self): # To prevent initializePage() being called when browsing backwards
pass # Default is to do absolutely nothing !
class LandSurveyWizard(SurveyWizard):
def __init__(self, parent=None):
super().__init__(parent)
self.nTemplates = 1 # nr of templates in a design. Will be affected by brick, slant & zigzag geometries
self.surveySize = QSizeF(config.deployInline, config.deployX_line) # initial survey size; determined by src area for orthogonal surveys and rec area for parallel
self.addPage(Page_1(self))
self.addPage(Page_2(self))
self.addPage(Page_3(self))
self.addPage(Page_4(self))
self.addPage(Page_5(self))
self.addPage(Page_6(self))
self.addPage(Page_7(self))
self.addPage(Page_8(self))
self.setWindowTitle('Land & OBN Seismic Survey Wizard')
self.setWizardStyle(QWizard.ClassicStyle)
# self.setOption(QWizard.IndependentPages , True) # Don't use this option as fields are no longer updated !!! Make dummy cleanupPage(self) instead
logo_image = QImage(os.path.join(current_dir, 'icon.png'))
self.setPixmap(QWizard.LogoPixmap, QPixmap.fromImage(logo_image))
# self.setOption(QWizard.NoCancelButton, True)
# self.setWindowFlags(self.windowFlags() | QtCore.Qt.CustomizeWindowHint)
# self.setWindowFlags(self.windowFlags() & ~QtCore.Qt.WindowCloseButtonHint)
# def reject(self):
# pass
# Page_1 =======================================================================
# 1. Survey type, Nr lines, and line & point intervals
class Page_1(SurveyWizardPage):
def __init__(self, parent=None):
super().__init__(parent)
self.setTitle('1. Template Properties')
self.setSubTitle('Enter survey type and template properties')
print('page 1 init')
# create some widgets
self.name = QLineEdit()
self.type = QComboBox()
self.nsl = QSpinBox()
self.nrl = QSpinBox()
self.sli = QDoubleSpinBox()
self.rli = QDoubleSpinBox()
self.spi = QDoubleSpinBox()
self.rpi = QDoubleSpinBox()
self.nsl.setRange(1, 1000)
self.nrl.setRange(1, 10000)
self.sli.setRange(0.01, 10000)
self.rli.setRange(0.01, 10000)
self.spi.setRange(0.01, 10000)
self.rpi.setRange(0.01, 10000)
self.chkLinePntAlign = QCheckBox('Match point intervals (SPI && RPI) to line intervals (SLI && RLI)')
# controls for specific survey types (orthogonal, parallel, slanted, brick, zigzag)
self.slantS = QSpinBox() # nr templates required for slant
self.slantS.setRange(1, 8)
self.slantS.setValue(5)
self.slantA = QLineEdit() # slant angle
self.slantA.setReadOnly(True) # read only
self.brickS = QDoubleSpinBox() # brick offset distance
self.brickS.setRange(0.01, 10000)
self.chkBrickMatchRpi = QCheckBox('&Align distance with RPI')
self.zigzagS = QSpinBox()
self.zigzagS.setRange(1, 3)
self.zigzagS.setValue(1)
self.chkMirrorOddEven = QCheckBox('&Mirror odd/even templates')
self.chkMirrorOddEven.setChecked(True)
# initialize the widgets
for item in SurveyList[:-1]: # skip last item from list; streamer survey
self.type.addItem(item)
self.name.setStyleSheet('QLineEdit { background-color : lightblue} ')
self.type.setStyleSheet('QComboBox { background-color : lightblue} ')
# set the page layout
layout = QGridLayout()
row = 0
layout.addWidget(QLabel('Select the correct survey <b>type</b>'), row, 0, 1, 4)
row += 1
layout.addWidget(self.type, row, 0, 1, 4)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
row += 1
layout.addWidget(QLabel('Provide an appropriate <b>description</b> for the survey (default is survey type)'), row, 0, 1, 4)
row += 1
layout.addWidget(self.name, row, 0, 1, 4)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
row += 1
layout.addWidget(QLabel('<b>Source</b> and <b>receiver</b> basic template configuration'), row, 0, 1, 4)
# » Page 2 (this page) defines nr of lines and line/point intervals of the template<br>
# » Page 3 defines the bin grid, used to combine traces for 'fold' calculations<br>
# » Page 4 defines the starting point and the length of source and receiver lines <br>
# » Page 5 defines how and how often a template is rolled to a new location<br>
# » Page 6 defines the offset range valid for binning purposes<br>
strLocal = """
The template(s) consist(s) of one or more source and receiver lines<br>
Only sources and receivers within the same template result in valid traces<br>
<br>
You can freely move forwards and backwards through the wizard. Please note:<br>
» changes made in later pages won't introduce changes in the earlier pages<br>
» changes in earlier pages can affect parameters in the later pages. E.g. :<br>
· Changing receiver line interval (RLI) may impact the salvo length (NSP)<br>
· But changing the salvo length (NSP) won't affect the receiver line interval (RLI)<br>
"""
row += 1
layout.addWidget(QLabel(strLocal), row, 0, 1, 4)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
row += 1
self.templateLabel = QLabel('Nr <b>active</b> source and receiver lines in a template')
layout.addWidget(self.templateLabel, row, 0, 1, 4)
row += 1
layout.addWidget(self.nsl, row, 0)
self.nslLabel = QLabel('<b>NSL</b> Nr Src Line(s)')
layout.addWidget(self.nslLabel, row, 1) ##
layout.addWidget(self.nrl, row, 2)
layout.addWidget(QLabel('<b>NRL</b> Nr Rec Lines [↑]'), row, 3)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
row += 1
self.lineLabel = QLabel('<b>Line</b> spacing between sources and receivers')
layout.addWidget(self.lineLabel, row, 0, 1, 4)
row += 1
layout.addWidget(self.sli, row, 0)
self.sliLabel = QLabel('<b>SLI</b> Src Line Int [m→]') ##
layout.addWidget(self.sliLabel, row, 1) ##
layout.addWidget(self.rli, row, 2)
layout.addWidget(QLabel('<b>RLI</b> Rec Line Int [m↑]'), row, 3)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
row += 1
self.pointLabel = QLabel('<b>Point</b> spacing between sources and receivers')
layout.addWidget(self.pointLabel, row, 0, 1, 4)
row += 1
layout.addWidget(self.spi, row, 0)
self.spiLabel = QLabel('<b>SLI</b> Src Point Int [m↑]') ##
layout.addWidget(self.spiLabel, row, 1)
layout.addWidget(self.rpi, row, 2)
layout.addWidget(QLabel('<b>RPI</b> Rec Point Int [m→]'), row, 3)
row += 1
layout.addWidget(self.chkLinePntAlign, row, 0, 1, 4)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
# controls for specific survey types (parallel, slanted, brick, zigzag)
row += 1
self.slantH = QLabel('<b>Slanted</b> template source configuration') # slant header
layout.addWidget(self.slantH, row, 0, 1, 4) # slant header
row += 1
self.slantL = QLabel("Nr RLI's needed to move up one complete SLI") # slant label
layout.addWidget(self.slantS, row, 0) # slant spinbox
layout.addWidget(self.slantL, row, 1, 1, 3) # slant label
row += 1
self.slantT = QLabel('Slant angle [deg] (deviation from orthogonal)') # slant text
layout.addWidget(self.slantA, row, 0) # slant spinbox
layout.addWidget(self.slantT, row, 1, 1, 3) # slant label
row += 1
self.brickH = QLabel('<b>Brick </b> template source configuration') # brick header
layout.addWidget(self.brickH, row, 0, 1, 2) # brick header
layout.addWidget(self.chkBrickMatchRpi, row, 2, 1, 2) # checkbox - match or not
row += 1
self.brickL = QLabel('<b></b>Distance of 2nd- to 1st source line [m→]') # brick label (force html)
layout.addWidget(self.brickS, row, 0) # brick spinbox
layout.addWidget(self.brickL, row, 1, 1, 2) # brick label
row += 1
self.zigzagH = QLabel('<b>Zigzag </b> template source configuration') # zigzag header
layout.addWidget(self.zigzagH, row, 0, 1, 2) # zigzag header
row += 1
self.zigzagL = QLabel('Nr zig-zags [1 - 3]') # zigzag label
layout.addWidget(self.zigzagS, row, 0) # zigzag spinbox
layout.addWidget(self.zigzagL, row, 1) # zigzag label
layout.addWidget(self.chkMirrorOddEven, row, 2, 1, 2) # checkbox - mirror or not
self.setLayout(layout)
# register fields for variable access in other Wizard Pages
# see: https://stackoverflow.com/questions/35187729/pyqt5-double-spin-box-returning-none-value
self.registerField('nsl', self.nsl, 'value') # nr source lines
self.registerField('nrl', self.nrl, 'value') # nr receiver lines
self.registerField('sli', self.sli, 'value') # source line interval
self.registerField('rli', self.rli, 'value') # receiver line interval
self.registerField('spi', self.spi, 'value') # source point interval
self.registerField('rpi', self.rpi, 'value') # receiver point interval
self.registerField('type', self.type) # Survey type
self.registerField('name', self.name) # Survey name
self.registerField('chkLinePntAlign', self.chkLinePntAlign) # Match point intervals (SPI && RPI) to line intervals (SLI && RLI)
self.registerField('nslant', self.slantS, 'value') # nr templates in a slanted survey
self.registerField('brk', self.brickS, 'value') # brick offset distance for 2nd source line
self.registerField('nzz', self.zigzagS, 'value') # nr source fleets in a zigzag survey
self.registerField('mir', self.chkMirrorOddEven) # mirror od/even templates
# connect signals to slots
self.type.currentIndexChanged.connect(self.evt_type_indexChanged)
# signals and slots for when editing is finished
self.sli.editingFinished.connect(self.evt_sli_editingFinished) # for source line interval
self.spi.editingFinished.connect(self.evt_spi_editingFinished) # for source point interval
self.rli.editingFinished.connect(self.evt_rli_editingFinished) # for receiver line interval
self.rpi.editingFinished.connect(self.evt_rpi_editingFinished) # for receiver point interval
self.chkLinePntAlign.stateChanged.connect(self.evt_align_stateChanged)
self.chkBrickMatchRpi.stateChanged.connect(self.evt_match_stateChanged)
self.slantS.valueChanged.connect(self.evt_slantS_valueChanged)
self.brickS.editingFinished.connect(self.evt_brickS_editingFinished)
# start values in the constructor, taken from config.py
self.nsl.setValue(config.nsl)
self.nrl.setValue(config.nrl)
self.sli.setValue(config.sli)
self.rli.setValue(config.rli)
self.spi.setValue(config.spi)
self.rpi.setValue(config.rpi)
self.name.setText(config.surveyName)
self.brickS.setValue(config.brick)
# variables to keep survey dimensions more or less the same, when editing
self.old_rpi = config.rpi
self.old_rli = config.rli
self.old_sli = config.sli
# hide optional controls for non-orthogonal surveys
slanted = False
self.slantH.setVisible(slanted)
self.slantS.setVisible(slanted)
self.slantL.setVisible(slanted)
self.slantA.setVisible(slanted)
self.slantT.setVisible(slanted)
brick = False
self.brickH.setVisible(brick)
self.brickS.setVisible(brick)
self.brickL.setVisible(brick)
self.chkBrickMatchRpi.setVisible(brick)
Zigzag = False
self.zigzagH.setVisible(Zigzag)
self.zigzagS.setVisible(Zigzag)
self.zigzagL.setVisible(Zigzag)
self.chkMirrorOddEven.setVisible(Zigzag)
def initializePage(self): # This routine is done each time before the page is activated
print('initialize page 1')
self.chkLinePntAlign.setChecked(True)
self.chkBrickMatchRpi.setChecked(True)
def cleanupPage(self): # needed to update previous page
print('cleanup of page 1')
def adjustBingrid(self):
rpi = self.rpi.value() # horizontal
sli = self.sli.value()
rpi = min(rpi, sli)
spi = self.spi.value() # vertical
rli = self.rli.value()
spi = min(spi, rli)
self.setField('binI', 0.5 * rpi) # need to adjust bingrid too
self.setField('binX', 0.5 * spi)
# note page(x) starts with a ZERO index; therefore pag(0) == Page_1
self.parent.page(3).evt_binImin_editingFinished(plot=False) # need to update binning area too
self.parent.page(3).evt_binIsiz_editingFinished(plot=False)
self.parent.page(3).evt_binXmin_editingFinished(plot=False)
self.parent.page(3).evt_binXsiz_editingFinished(plot=False)
def evt_align_stateChanged(self): # alignment state changed
self.evt_sli_editingFinished() # update dependent controls
self.evt_rli_editingFinished()
self.evt_spi_editingFinished()
self.evt_rpi_editingFinished()
def evt_match_stateChanged(self): # match state changed
self.evt_brickS_editingFinished() # update dependent control
def evt_type_indexChanged(self, index):
self.nsl.setValue(1) # reset nr source lines in case we came from zigzag or parallel
self.sli.setEnabled(True) # in case we disabled this earlier
self.nsl.setEnabled(True) # for instance with zigzag or parallel
self.sli.setValue(config.sli) # in case we used parallel earlier
self.old_sli = config.sli # in case we used parallel earlier
self.nsl.setValue(config.nsl)
self.setField('rlr', 1) # One line to roll
self.setField('slr', 1) # One line to roll
self.setField('sld', round(config.deployInline / (config.slr * config.sli)) + 1)
self.setField('rld', round(config.deployX_line / (config.rlr * config.rli)) + 1)
name = SurveyType(index).name # get name from enum
number = str(config.surveyNumber).zfill(3) # fill with leading zeroes
self.name.setText(f'{name}_{number}') # show the new name
# self.type = SurveyType(index) # update survey type; no need for this, done automatically
parallel = index == SurveyType.Parallel.value
if parallel:
# self.sli.setEnabled(False) # calculate sli from nsl
self.templateLabel.setText('In a <b>parallel</b> template, source points run <b>parallel</b> to the receiver lines')
self.lineLabel.setText('<b>Point</b> spacing between sources and <b>line</b> spacing between receivers')
self.pointLabel.setText('<b>Line</b> spacing between sources and <b>point</b> spacing between receivers')
self.sli.setValue(config.sli_par)
self.nsl.setValue(config.nsl_par)
self.setField('nrp', config.nrp_par)
self.nslLabel.setText('<b>NSP</b> Nr Src Points [→]')
self.sliLabel.setText('<b>SPI</b> Src Point Int [m→]') ##
self.spiLabel.setText('<b>SLI</b> Src Line Int [m↑]')
else:
self.templateLabel.setText('<b>Active</b> source and receiver lines in a template')
self.lineLabel.setText('<b>Line</b> spacing between sources and receivers')
self.pointLabel.setText('<b>point</b> spacing between sources and receivers')
self.nslLabel.setText('<b>NSL</b> Nr Src Lines [→]')
self.sliLabel.setText('<b>SLI</b> Src Line Int [m→]') ##
self.spiLabel.setText('<b>SPI</b> Src Point Int [m↑]')
slanted = index == SurveyType.Slanted.value
self.slantH.setVisible(slanted)
self.slantS.setVisible(slanted)
self.slantL.setVisible(slanted)
self.slantA.setVisible(slanted)
self.slantT.setVisible(slanted)
if slanted:
self.evt_slantS_valueChanged(self.slantS.value())
brick = index == SurveyType.Brick.value
self.brickH.setVisible(brick)
self.brickS.setVisible(brick)
self.brickL.setVisible(brick)
self.chkBrickMatchRpi.setVisible(brick)
zigzag = index == SurveyType.Zigzag.value
self.zigzagH.setVisible(zigzag)
self.zigzagS.setVisible(zigzag)
self.zigzagL.setVisible(zigzag)
self.chkMirrorOddEven.setVisible(zigzag)
if zigzag:
self.nsl.setEnabled(False) # always 1 source line
self.nsl.setValue(2)
self.sli.setEnabled(False)
rli = self.field('rli') # get variables from field names
rpi = self.field('rpi')
spi = self.field('spi')
nsp = max(round(rli / spi), 1)
self.sli.setValue(nsp * rpi)
self.update() # update GUI
def evt_sli_editingFinished(self):
nrIntervals = max(round(self.sli.value() / self.rpi.value()), 1)
rpiValue = self.sli.value() / nrIntervals
if self.chkLinePntAlign.isChecked():
if self.field('type') != SurveyType.Zigzag.value: # don't update rpi in case of zigzag
self.rpi.setValue(rpiValue) # for zigzag sli is 'fixed' by other variables
nslant = self.field('nslant') # get variable from field name
self.evt_slantS_valueChanged(nslant) # update the slant angle for slanted surveys
sld = self.field('sld') # get variables from field names
slr = self.field('slr') # get variables from field names
sizI = sld * slr * self.old_sli
sld = max(round(sizI / self.sli.value()), 1)
self.setField('sld', sld) # adjust nr source line deployments
self.old_sli = self.sli.value()
self.adjustBingrid()
def evt_rli_editingFinished(self):
nrIntervals = max(round(self.rli.value() / self.spi.value()), 1)
spiValue = self.rli.value() / nrIntervals
if self.chkLinePntAlign.isChecked():
self.spi.setValue(spiValue)
# Affects Page 4
self.setField('nsp', nrIntervals) # RLI has been altered; adjust the salvo length
if self.field('type') == SurveyType.Zigzag.value:
self.sli.setValue(nrIntervals * self.rpi.value())
# if self.field("type") == SurveyType.Parallel.value: # in case of a parallel template
# sliValue = self.rli.value() / self.nsl.value()
# self.sli.setValue(sliValue)
nslant = self.field('nslant') # get variable from field name
self.evt_slantS_valueChanged(nslant) # update the slant angle for slanted surveys
rld = self.field('rld') # get variables from field names
rlr = self.field('rlr') # get variables from field names
sizX = rld * rlr * self.old_rli
rld = max(round(sizX / self.rli.value()), 1)
self.setField('rld', rld) # adjust nr receiver line deployments
self.old_rli = self.rli.value()
self.adjustBingrid()
def evt_spi_editingFinished(self):
nsp = self.field('nsp') # get variables from field names
rli = self.rli.value()
rpi = self.rpi.value()
spi = self.spi.value()
if self.field('type') == SurveyType.Parallel.value: # in case of a parallel template
pass
# # set initial offset values
# lenS = self.parent.surveySize.width() + config.spreadlength
# nsp = round(lenS / spi) + 1 # SPI has been altered; adjust the salvo length
else:
nrIntervals = max(round(rli / spi), 1)
spiValue = rli / nrIntervals
if self.chkLinePntAlign.isChecked(): # write back the aligned value
self.spi.setValue(spiValue)
if self.field('type') == SurveyType.Zigzag.value: # need to adjust sli for zigzag
self.sli.setValue(nrIntervals * rpi)
nsp = max(round(rli / spi), 1)
self.setField('nsp', nsp) # Adjust the salvo length
self.adjustBingrid()
def evt_rpi_editingFinished(self):
nrIntervals = max(round(self.sli.value() / self.rpi.value()), 1)
rpiValue = self.sli.value() / nrIntervals
if self.chkLinePntAlign.isChecked():
self.rpi.setValue(rpiValue)
if self.field('type') == SurveyType.Zigzag.value:
nsp = self.field('nsp') # get variables from field names
self.sli.setValue(nsp * self.rpi.value())
nrp = self.field('nrp') # get variables from field names
spreadlength = nrp * self.old_rpi # current receiver line length
nrp = max(round(spreadlength / self.rpi.value()), 1) # RPI has been altered; adjust nrp
self.setField('nrp', nrp) # save its value
self.old_rpi = self.rpi.value()
self.adjustBingrid()
def evt_slantS_valueChanged(self, i):
sli = self.field('sli') # get variables from field names
rli = self.field('rli')
angle = 90.0 - math.degrees(math.atan2(i * rli, sli)) # get the slant angle (deviation from orthogonal
self.slantA.setText(f'{angle:.3f}') # put it back in the edit window
def evt_brickS_editingFinished(self):
sli = self.field('sli') # get variable from field names
brick = self.brickS.value()
brick = min(sli - 1.0, brick)
if self.chkBrickMatchRpi.isChecked():
rpi = self.field('rpi') # get variable from field names
nrIntervals = max(round(brick / rpi), 1)
if nrIntervals * rpi == sli:
nrIntervals -= 1
brick = rpi * nrIntervals
self.brickS.setValue(brick)
# Page_2 =======================================================================
# 2. Template Properties - Enter Spread and Salvo details
class Page_2(SurveyWizardPage):
def __init__(self, parent=None):
super().__init__(parent)
self.setTitle('2. Template Properties')
self.setSubTitle('Enter Spread and Salvo details')
print('page 2 init')
# to support plotting
self.rect = False
self.XisY = True
self.antA = False
self.grid = True
# variables altered when nrp, nsp change
self.offsetInshift = 0.0
self.offsetX_shift = 0.0
# create some widgets
self.nsp = QSpinBox()
self.nrp = QSpinBox()
self.offImin = QDoubleSpinBox()
self.offImax = QDoubleSpinBox()
self.offXmin = QDoubleSpinBox()
self.offXmax = QDoubleSpinBox()
self.chkNrecKnown = QCheckBox('Number channels/cable is known')
self.chkNsrcKnown = QCheckBox('Number shots/salvo is known')
self.chkNrecMatch = QCheckBox('Match number channels to SLI')
self.chkNsrcMatch = QCheckBox('Match number of shots to RLI')
# set ranges
self.nsp.setRange(1, 1000000)
self.nrp.setRange(1, 1000000)
self.offImin.setRange(-100000, 100000)
self.offImax.setRange(-100000, 100000)
self.offXmin.setRange(-100000, 100000)
self.offXmax.setRange(-100000, 100000)
self.chkNrecKnown.setChecked(True)
self.chkNsrcKnown.setChecked(True)
self.chkNrecMatch.setChecked(True)
self.chkNsrcMatch.setChecked(True)
# set the page layout
layout = QGridLayout()
row = 0
layout.addWidget(QLabel('<b>SPREAD</b> definition [nr →]'), row, 0)
layout.addWidget(QLabel('<b>SALVO</b> definition [nr ↑]'), row, 2)
row += 1
layout.addWidget(self.chkNrecMatch, row, 0, 1, 2)
layout.addWidget(self.chkNsrcMatch, row, 2, 1, 2)
row += 1
layout.addWidget(self.chkNrecKnown, row, 0, 1, 2)
layout.addWidget(self.chkNsrcKnown, row, 2, 1, 2)
row += 1
layout.addWidget(self.nrp, row, 0)
layout.addWidget(QLabel('Nr channels/cable'), row, 1)
layout.addWidget(self.nsp, row, 2)
layout.addWidget(QLabel('Nr shots/traverse'), row, 3)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
row += 1
layout.addWidget(QLabel('<b>Inline</b> [→] offset range relative <b>first</b> shot line'), row, 0, 1, 4)
row += 1
layout.addWidget(self.offImin, row, 0)
layout.addWidget(QLabel('Minimum [m]'), row, 1)
layout.addWidget(self.offImax, row, 2)
layout.addWidget(QLabel('Maximum [m]'), row, 3)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
row += 1
layout.addWidget(QLabel('<b>Crossline</b> [↑] offset range relative <b>first</b> receiver line'), row, 0, 1, 4)
row += 1
layout.addWidget(self.offXmin, row, 0)
layout.addWidget(QLabel('Minimum [m]'), row, 1)
layout.addWidget(self.offXmax, row, 2)
layout.addWidget(QLabel('Maximum [m]'), row, 3)
row += 1
layout.addWidget(QHLine(), row, 0, 1, 4)
# start values in the constructor, taken from config.py # do this in the constructor, so it is only done ONCE
self.nsp.setValue(config.nsp)
self.nrp.setValue(config.nrp)
# create a vertical box layout widget (vbl)
vbl = QVBoxLayout()
# add the so far developed QGridLayout to the QVBoxLayout (layout)
vbl.addLayout(layout)
# insert PyQtGraph plotWidget # See: https://groups.google.com/g/pyqtgraph/c/ls-9I2tHu2w
self.plotWidget = pg.PlotWidget(background='w')
self.plotWidget.setAspectLocked(True) # setting can be changed through a toolbar
self.plotWidget.showGrid(x=True, y=True, alpha=0.5) # shows the grey grid lines
self.plotWidget.setMinimumSize(150, 150) # prevent excessive widget shrinking
self.plotWidget.ctrlMenu = None # get rid of 'Plot Options'
self.plotWidget.scene().contextMenu = None # get rid of 'Export'
# self.plotWidget.getViewBox().sigRangeChangedManually.connect(
# self.mouseBeingDragged) # essential to find plotting state for LOD plotting
self.zoomBar = PgToolBar('ZoomBar', plotWidget=self.plotWidget)
self.zoomBar.actionAntiAlias.setChecked(True) # toggle Anti-alias on
# add toolbar and plotwidget to the vertical box layout
vbl.addWidget(self.zoomBar)
vbl.addWidget(self.plotWidget)
# set the combined layouts to become this page's layout
self.setLayout(vbl)
## self.nrp.setValue(round(config.spreadlength/config.rpi))
## self.nsp.setValue(round(config.rli/config.spi))
self.registerField('nsp', self.nsp, 'value')
self.registerField('nrp', self.nrp, 'value')
self.registerField('offImin', self.offImin, 'value')
self.registerField('offImax', self.offImax, 'value')
self.registerField('offXmin', self.offXmin, 'value')
self.registerField('offXmax', self.offXmax, 'value')
# connect signals to slots for checkboxes
self.chkNrecKnown.toggled.connect(self.evt_chkNrecKnown_toggled) # work from numbers or offsets
self.chkNsrcKnown.toggled.connect(self.evt_chkNsrcKnown_toggled)
self.chkNrecMatch.toggled.connect(self.evt_chkNrecMatch_toggled) # require NRP & NSP, matching to SLI & RLI
self.chkNsrcMatch.toggled.connect(self.evt_chkNsrcMatch_toggled)
# connect signals to slots for edit controls
self.nsp.editingFinished.connect(self.evt_nsp_editingFinished) # evaluate new nsp
self.nrp.editingFinished.connect(self.evt_nrp_editingFinished) # evaluate new nrp
self.offImin.editingFinished.connect(self.evt_offImin_editingFinished) # evaluate new offsets
self.offImax.editingFinished.connect(self.evt_offImax_editingFinished)
self.offXmin.editingFinished.connect(self.evt_offxmin_editingFinished)
self.offXmax.editingFinished.connect(self.evt_offXmax_editingFinished)
def initializePage(self): # This routine is done each time before the page is activated
print('initialize page 2')
# disable required edit controls
chkd = self.chkNrecKnown.isChecked()
self.nrp.setEnabled(chkd)
self.offImax.setEnabled(not chkd)
chkd = self.chkNsrcKnown.isChecked()
self.nsp.setEnabled(chkd)
self.offXmax.setEnabled(not chkd)
# get variables from field names
nrl = self.field('nrl')
nsl = self.field('nsl')
sli = self.field('sli')
rli = self.field('rli')
spi = self.field('spi')
rpi = self.field('rpi')
nsp = self.field('nsp')
nrp = self.field('nrp')
typ = self.field('type')
# first RESET the survey object, so we can start with it from scratch
self.parent.survey = RollSurvey()
# fill in the survey object information we already know now
self.parent.survey.name = self.field('name') # Survey name
self.parent.survey.type = SurveyType(typ) # Survey type Enum
nsla = self.field('nslant') # nr templates in a slanted survey
nzz = self.field('nzz') # nr source fleets in a zigzag survey
mir = self.field('mir') # mirrored zigzag survey
# set initial offset values
templateInShift = 0.5 * (nsl - 1) * sli
templateX_shift = 0.5 * (nrl - 1) * rli
self.offImin.setValue(-0.5 * (nrp - 1) * rpi + self.offsetInshift + templateInShift)
self.offImax.setValue(0.5 * (nrp - 1) * rpi + self.offsetInshift + templateInShift)
self.offXmin.setValue(-0.5 * (nsp - 1) * spi + self.offsetX_shift + templateX_shift)
self.offXmax.setValue(0.5 * (nsp - 1) * spi + self.offsetX_shift + templateX_shift)
# as of Python version 3.10, there is an official switch-case statement.
# Alas, QGIS 3.28 is using Python v3.9.5 so we have to use if ... elif ... elif etc.
self.parent.nTemplates = 1
nSrcSeeds = 1
if typ == SurveyType.Orthogonal.value:
pass
elif typ == SurveyType.Parallel.value:
pass
elif typ == SurveyType.Slanted.value:
self.parent.nTemplates = nsla # as many as needed for the slanted design
elif typ == SurveyType.Brick.value:
self.parent.nTemplates = 2 # for odd/even templates
elif typ == SurveyType.Zigzag.value:
self.parent.nTemplates = 2 if mir else 1 # for mirrored templates
nSrcSeeds = 2 * nzz # every zigzag requires 2 source seeds
else:
raise NotImplementedError('unsupported survey type.')
# Create a survey skeleton, so we can simply update survey properties, without having to instantiate underlying classes
self.parent.survey.createBasicSkeleton(nTemplates=self.parent.nTemplates, nSrcSeeds=nSrcSeeds, nRecSeeds=1) # add Block, template(s)
self.updateParentSurvey() # update the survey object
self.plot() # refresh the plot
def cleanupPage(self): # needed to update previous page
print('cleanup of page 2')
def updateParentSurvey(self):
# populate / update the survey skeleton
# source(s) first
offImin = self.field('offImin')
offXmin = self.field('offXmin')
nrl = self.field('nrl')
nsl = self.field('nsl')
sli = self.field('sli')
rli = self.field('rli')
spi = self.field('spi')
rpi = self.field('rpi')
nsp = self.field('nsp')
nrp = self.field('nrp')
typ = self.field('type')
nsla = self.field('nslant') # nr templates in a slanted survey
brk = self.field('brk') # brick offset distance
nzz = self.field('nzz') # nr source fleets in a zigzag survey
mir = self.field('mir') # mirrored zigzag survey
# populate / update the survey skeleton
# do the patterns here (instead of page 5) as pattern orientation may depend on template type (e.g. zigzag)
# source & receiver patterns
rNam = self.field('rNam')
sNam = self.field('sNam')
# orthogonal / slanted / brick source patterns
sBra = config.sBra
sBrI = config.sBrI
sEle = config.sEle
sElI = config.sElI
srcOriX = -0.5 * (sBra - 1) * sBrI
srcOriY = -0.5 * (sEle - 1) * sElI
if typ == SurveyType.Parallel.value or typ == SurveyType.Zigzag.value:
sBra = config.sEle
sBrI = config.sElI
sEle = config.sBra
sElI = config.sBrI
srcOriX = -0.5 * (sBra - 1) * sBrI
srcOriY = -0.5 * (sEle - 1) * sElI
self.setField('sBra', sBra) # update the relevant fields
self.setField('sEle', sEle) # only the source pattern
self.setField('sBrI', sBrI) # may change orientation
self.setField('sElI', sElI)
self.parent.survey.patternList[0].name = sNam
self.parent.survey.patternList[0].seedList[0].color = QColor('red')
self.parent.survey.patternList[0].seedList[0].origin.setX(srcOriX) # Seed origin
self.parent.survey.patternList[0].seedList[0].origin.setY(srcOriY) # Seed origin
self.parent.survey.patternList[0].seedList[0].grid.growList[0].steps = sBra # nr branches
self.parent.survey.patternList[0].seedList[0].grid.growList[0].increment.setX(sBrI) # branch interval
self.parent.survey.patternList[0].seedList[0].grid.growList[0].increment.setY(0.0) # horizontal
self.parent.survey.patternList[0].seedList[0].grid.growList[1].steps = sEle # nr elements
self.parent.survey.patternList[0].seedList[0].grid.growList[1].increment.setX(0.0) # vertical
self.parent.survey.patternList[0].seedList[0].grid.growList[1].increment.setY(sElI) # element interval
# receiver pattern
rBra = self.field('rBra')
rBrI = self.field('rBrI')
rEle = self.field('rEle')
rElI = self.field('rElI')
recOriX = -0.5 * (rBra - 1) * rBrI
recOriY = -0.5 * (rEle - 1) * rElI
self.parent.survey.patternList[1].name = rNam
self.parent.survey.patternList[1].seedList[0].color = QColor('blue')
self.parent.survey.patternList[1].seedList[0].origin.setX(recOriX) # Seed origin
self.parent.survey.patternList[1].seedList[0].origin.setY(recOriY) # Seed origin
self.parent.survey.patternList[1].seedList[0].grid.growList[0].steps = rBra # nr branches
self.parent.survey.patternList[1].seedList[0].grid.growList[0].increment.setX(rBrI) # branch interval
self.parent.survey.patternList[1].seedList[0].grid.growList[0].increment.setY(0.0) # horizontal
self.parent.survey.patternList[1].seedList[0].grid.growList[1].steps = rEle # nr elements
self.parent.survey.patternList[1].seedList[0].grid.growList[1].increment.setX(0.0) # vertical
self.parent.survey.patternList[1].seedList[0].grid.growList[1].increment.setY(rElI) # element interval
# calculate the boundingBpx, now the patterns have been populated
self.parent.survey.patternList[0].calcBoundingRect() # also creates the pattern figure
self.parent.survey.patternList[1].calcBoundingRect() # also creates the pattern figure
# now the patterns have been initialized, initialise the figures with the right color
# self.parent.survey.patternList[0].calcPatternPicture() # not needed; done in calcBoundingRect()
# self.parent.survey.patternList[1].calcPatternPicture() # not needed; done in calcBoundingRect()
# offsets; from start/end of salvo to start/end of spread; both inline and x-line
if typ == SurveyType.Parallel.value: # no hard values; give arbitrary inline limits
inline1 = -5975.0 # negative number
inline2 = 5975.0 # positive number
else:
inline1 = offImin # offImin is a negative number
inline2 = (nrp - 1) * rpi + inline1 # positive number
x_line1 = -(offXmin + (nsp - 1) * spi) # offXmin is a positive number
x_line2 = (nrl - 1) * rli - offXmin
self.parent.survey.offset.rctOffsets.setLeft(inline1 - 1.0) # inline offset limits
self.parent.survey.offset.rctOffsets.setRight(inline2 + 1.0)
self.parent.survey.offset.rctOffsets.setTop(x_line1 - 1.0) # x_line offset limits
self.parent.survey.offset.rctOffsets.setBottom(x_line2 + 1.0)
w = max(abs(inline1), abs(inline2)) # calc radial limit r from w & h
h = max(abs(x_line1), abs(x_line2))
r = round(math.sqrt(w * w + h * h)) + 1.0
self.parent.survey.offset.radOffsets.setX(0.0) # radial; rmin
self.parent.survey.offset.radOffsets.setY(r) # radial; rmax
# deal with different survey types
if typ == SurveyType.Orthogonal.value:
# source
if nsl > 6: # it is assumed only crossline roll is being used
nPadding = 0 # don't add extra nr recs to the rec lines
else:
nPadding = (nsl - 1) * round(sli / rpi) # lengthen rec lines with nr recs between the source lines
self.parent.survey.blockList[0].templateList[0].seedList[0].origin.setX(0.0) # Seed origin; source inline at x = 0.0
self.parent.survey.blockList[0].templateList[0].seedList[0].origin.setY(offXmin) # Seed origin; positive number
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[0].steps = 1 # nr planes
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[0].increment.setX(0.0) # n/a
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[0].increment.setY(0.0) # n/a
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[1].steps = nsl # nsl
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[1].increment.setX(sli) # sli
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[1].increment.setY(0.0) # horizontal
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[2].steps = nsp # nsp
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[2].increment.setX(0.0) # vertical
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[2].increment.setY(spi) # spi
# receiver
self.parent.survey.blockList[0].templateList[0].seedList[1].origin.setX(offImin) # Seed origin; negative number
self.parent.survey.blockList[0].templateList[0].seedList[1].origin.setY(0.0) # Seed origin; receiver x-line at 0.0
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[0].steps = 1 # nr planes
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[0].increment.setX(0.0) # n/a
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[0].increment.setY(0.0) # n/a
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[1].steps = nrl # nrl
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[1].increment.setX(0.0) # vertical
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[1].increment.setY(rli) # rli
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[2].steps = nrp + nPadding # nrp
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[2].increment.setX(rpi) # rpi
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[2].increment.setY(0.0) # horizontal
elif typ == SurveyType.Parallel.value:
# source
nPadding = 0 # no paddding required
self.parent.survey.blockList[0].templateList[0].seedList[0].origin.setX(0.0) # Seed origin
self.parent.survey.blockList[0].templateList[0].seedList[0].origin.setY(offXmin) # Seed origin
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[0].steps = 1 # nr planes
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[0].increment.setX(0.0) # n/a
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[0].increment.setY(0.0) # n/a
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[1].steps = nsp # nsp
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[1].increment.setX(0.0) # vertical
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[1].increment.setY(spi) # spi
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[2].steps = nsl # nsl
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[2].increment.setX(sli) # sli
self.parent.survey.blockList[0].templateList[0].seedList[0].grid.growList[2].increment.setY(0.0) # horizontal
# receiver
self.parent.survey.blockList[0].templateList[0].seedList[1].origin.setX(offImin) # Seed origin
self.parent.survey.blockList[0].templateList[0].seedList[1].origin.setY(0.0) # Seed origin
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[0].steps = 1 # nr planes
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[0].increment.setX(0.0) # n/a
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[0].increment.setY(0.0) # n/a
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[1].steps = nrl # nrl
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[1].increment.setX(0.0) # vertical
self.parent.survey.blockList[0].templateList[0].seedList[1].grid.growList[1].increment.setY(rli) # rli