Przeglądaj źródła

Polygonal loop add in gui

tags/1.6.1
Trevor Irons 5 lat temu
rodzic
commit
97f0f15389
5 zmienionych plików z 169 dodań i 166 usunięć
  1. 88
    0
      akvo/gui/addPolygonalLoop.ui
  2. BIN
      akvo/gui/akvo-about.png
  3. 70
    140
      akvo/gui/akvoGUI.py
  4. 7
    26
      akvo/gui/main.ui
  5. 4
    0
      pyuic.json

+ 88
- 0
akvo/gui/addPolygonalLoop.ui Wyświetl plik

@@ -0,0 +1,88 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<ui version="4.0">
3
+ <class>polygonalLoopAdd</class>
4
+ <widget class="QDialog" name="polygonalLoopAdd">
5
+  <property name="geometry">
6
+   <rect>
7
+    <x>0</x>
8
+    <y>0</y>
9
+    <width>515</width>
10
+    <height>446</height>
11
+   </rect>
12
+  </property>
13
+  <property name="windowTitle">
14
+   <string>Dialog</string>
15
+  </property>
16
+  <layout class="QGridLayout" name="gridLayout">
17
+   <item row="3" column="0" colspan="2">
18
+    <widget class="QTableWidget" name="loopTableWidget">
19
+     <property name="toolTip">
20
+      <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This table is used to enter coil geometries the format is as follows: each row specifies a single point on a coil. The first column is the coil index (using the GMR channel is useful), the next three colums specify the point in Northing, Easting, and Elevation. These can either be local coordinates or global ones. The final column specifies the loop radius if it is a circle or figure 8, for non circular or figure 8 loops leave this column blank. For figure-8 loops the coils do not need to be touching (see Irons and Kass, 2017). If a given index has 1 row it will be a circular loop, two rows will be a figure 8, and more than that will be a polygonal representation of the points, linearlly interpolated between them. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
21
+     </property>
22
+     <property name="sizeAdjustPolicy">
23
+      <enum>QAbstractScrollArea::AdjustToContents</enum>
24
+     </property>
25
+    </widget>
26
+   </item>
27
+   <item row="5" column="0">
28
+    <widget class="QLabel" name="label">
29
+     <property name="text">
30
+      <string>Number of Turns</string>
31
+     </property>
32
+    </widget>
33
+   </item>
34
+   <item row="5" column="1">
35
+    <widget class="QSpinBox" name="loopTurns">
36
+     <property name="minimum">
37
+      <number>1</number>
38
+     </property>
39
+    </widget>
40
+   </item>
41
+   <item row="7" column="1">
42
+    <widget class="QDialogButtonBox" name="buttonBox">
43
+     <property name="orientation">
44
+      <enum>Qt::Horizontal</enum>
45
+     </property>
46
+     <property name="standardButtons">
47
+      <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
48
+     </property>
49
+    </widget>
50
+   </item>
51
+  </layout>
52
+ </widget>
53
+ <resources/>
54
+ <connections>
55
+  <connection>
56
+   <sender>buttonBox</sender>
57
+   <signal>accepted()</signal>
58
+   <receiver>polygonalLoopAdd</receiver>
59
+   <slot>accept()</slot>
60
+   <hints>
61
+    <hint type="sourcelabel">
62
+     <x>248</x>
63
+     <y>254</y>
64
+    </hint>
65
+    <hint type="destinationlabel">
66
+     <x>157</x>
67
+     <y>274</y>
68
+    </hint>
69
+   </hints>
70
+  </connection>
71
+  <connection>
72
+   <sender>buttonBox</sender>
73
+   <signal>rejected()</signal>
74
+   <receiver>polygonalLoopAdd</receiver>
75
+   <slot>reject()</slot>
76
+   <hints>
77
+    <hint type="sourcelabel">
78
+     <x>316</x>
79
+     <y>260</y>
80
+    </hint>
81
+    <hint type="destinationlabel">
82
+     <x>286</x>
83
+     <y>274</y>
84
+    </hint>
85
+   </hints>
86
+  </connection>
87
+ </connections>
88
+</ui>

BIN
akvo/gui/akvo-about.png Wyświetl plik


+ 70
- 140
akvo/gui/akvoGUI.py Wyświetl plik

@@ -17,6 +17,7 @@ from ruamel import yaml
17 17
 from akvo.gui.main_ui import Ui_MainWindow
18 18
 from akvo.gui.addCircularLoop_ui import Ui_circularLoopAdd
19 19
 from akvo.gui.addFigure8Loop_ui import Ui_figure8LoopAdd
20
+from akvo.gui.addPolygonalLoop_ui import Ui_polygonalLoopAdd
20 21
 from akvo.tressel import mrsurvey 
21 22
 
22 23
 from pyLemma import LemmaCore  
@@ -205,31 +206,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
205 206
         self.ui.mplwidget_navigator.setCanvas(self.ui.mplwidget)
206 207
         #self.ui.mplwidget_navigator_2.setCanvas(self.ui.mplwidget)
207 208
 
208
-
209
-        ##########################################################################
210
-        # Loop Table 
211
-        self.ui.loopTableWidget.setRowCount(80)       
212
-        self.ui.loopTableWidget.setColumnCount(6)      
213
-        self.ui.loopTableWidget.setHorizontalHeaderLabels( ["ch. tag", \
214
-            "Northing [m]","Easting [m]","Height [m]", "Radius","Tx"] )
215
-        
216
-        for ir in range(0, self.ui.loopTableWidget.rowCount() ):
217
-            for ic in range(1, self.ui.loopTableWidget.columnCount() ):
218
-                pCell = QtWidgets.QTableWidgetItem()
219
-                #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
220
-                pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
221
-                pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
222
-                self.ui.loopTableWidget.setItem(ir, ic, pCell)
223
-
224
-        self.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged)
225
-        #self.ui.loopTableWidget.cellPressed.connect(self.loopCellChanged) 
226
-        self.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked) 
227
-        #self.ui.loopTableWidget.cellPressed.connect(self.loopCellClicked) 
228
-
229
-        self.ui.loopTableWidget.setDragDropOverwriteMode(False)
230
-        self.ui.loopTableWidget.setDragEnabled(False)
231
-        #self.ui.loopTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
232
-
233 209
         self.ui.txRxTable.setColumnCount(4)
234 210
         self.ui.txRxTable.setRowCount(0)
235 211
         self.ui.txRxTable.setHorizontalHeaderLabels( ["Label", "Geom.","Turns","Tx/Rx"] )
@@ -388,9 +364,71 @@ class ApplicationWindow(QtWidgets.QMainWindow):
388 364
                     ns = dialog.ui.segments.value()
389 365
                     #cwise = dialog.ui.cwiseBox.currentIndex()
390 366
                     print(cn1, ce1, cn2, ce2, ht, rad, turns, ns)   
367
+            
368
+            if self.ui.loopGeom.currentText() == "polygon":
369
+                
370
+                dialog = QtWidgets.QDialog()
371
+                dialog.ui = Ui_polygonalLoopAdd()
372
+                dialog.ui.setupUi(dialog)
373
+
374
+                ##########################################################################
375
+                # Loop Table 
376
+                dialog.ui.loopTableWidget.setRowCount(80)       
377
+                dialog.ui.loopTableWidget.setColumnCount(3)  
378
+                #dialog.ui.loopTableWidget.horizontalHeader().setSectionResizeMode(0, QtGui.Qt.QHeaderView.Stretch)  
379
+                dialog.ui.loopTableWidget.setHorizontalHeaderLabels( \
380
+                    ["Northing [m]","Easting [m]","Height [m]"])
381
+
391 382
  
383
+                for ir in range(0, dialog.ui.loopTableWidget.rowCount() ):
384
+                    for ic in range(0, 3): #dialog.ui.loopTableWidget.columnCount() ):
385
+                        pCell = QtWidgets.QTableWidgetItem()
386
+                        #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
387
+                        #pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
388
+                        #pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
389
+                        dialog.ui.loopTableWidget.setItem(ir, ic, pCell)
390
+
391
+                #dialog.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged)
392
+                #dialog.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked) 
393
+                
394
+                #self.ui.loopTableWidget.cellPressed.connect(self.loopCellChanged) 
395
+                #self.ui.loopTableWidget.cellPressed.connect(self.loopCellClicked) 
396
+
397
+                dialog.ui.loopTableWidget.setDragDropOverwriteMode(False)
398
+                dialog.ui.loopTableWidget.setDragEnabled(False)
399
+                #self.ui.loopTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
400
+
401
+                dialog.ui.loopTableWidget.resizeColumnsToContents()       
402
+                dialog.exec_()
403
+                dialog.show()
404
+
405
+                
406
+                if dialog.result():
407
+                    self.loops[self.ui.loopLabel.text()] = FDEM1D.PolygonalWireAntenna()
408
+                    self.loops[self.ui.loopLabel.text()].SetNumberOfTurns( dialog.ui.loopTurns.value() )
409
+
410
+               
411
+                    npts = 0 
412
+                    for ir in range(0, dialog.ui.loopTableWidget.rowCount() ):
413
+                        if len(dialog.ui.loopTableWidget.item(ir, 0).text()) == 0:
414
+                            break
415
+                        npts += 1 
416
+                    self.loops[self.ui.loopLabel.text()].SetNumberOfPoints( npts )
417
+                    for ir in range( 0, npts ):
418
+                        self.loops[self.ui.loopLabel.text()].SetPoint(ir, eval(dialog.ui.loopTableWidget.item(ir, 0).text()),  \
419
+                                                                          eval(dialog.ui.loopTableWidget.item(ir, 1).text()),  \
420
+                                                                          eval(dialog.ui.loopTableWidget.item(ir, 2).text())   \
421
+                                                                     ) 
422
+                    self.loops[self.ui.loopLabel.text()].SetNumberOfFrequencies(1)
423
+                    self.loops[self.ui.loopLabel.text()].SetCurrent(1.)
424
+
425
+
392 426
             # general across all types   
393 427
             if dialog.result():
428
+
429
+                yml = open( self.ui.loopLabel.text() + ".yml", 'w' )
430
+                print( self.loops[self.ui.loopLabel.text()], file=yml)
431
+
394 432
                 # update the table 
395 433
                 self.ui.txRxTable.setRowCount( len(self.loops.keys()) )
396 434
                     
@@ -495,74 +533,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
495 533
 
496 534
         self.ui.layerTableWidget.cellChanged.connect(self.sigmaCellChanged) 
497 535
 
498
-    def loopCellClicked(self, item):
499
-        print("checkstate", item.checkState(),item.row())
500
-
501
-        #self.ui.loopTableWidget.itemClicked.disconnect(self.loopCellClicked)
502
-        jj = item.column() 
503
-        ii = item.row()
504
-        tp = type(self.ui.loopTableWidget.item(ii, 0))
505
-        print("tp", tp, ii, jj)
506
-        if str(tp) == "<class 'NoneType'>": 
507
-            return 
508
-        #print("Clicked", ii, jj)
509
-        if jj == 5 and self.ui.loopTableWidget.item(ii, 0).text() in self.loops.keys():
510
-            #print("jj=5")
511
-            self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"] = self.ui.loopTableWidget.item(ii, 5).checkState()
512
-            # update surrogates  
513
-            print("updating surrogates")
514
-            for point in self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["points"][1:]:
515
-                pCell = self.ui.loopTableWidget.item(point, 5)
516
-                if self.ui.loopTableWidget.item(ii, 5).checkState():
517
-                    pCell.setCheckState(QtCore.Qt.Checked);
518
-                else:
519
-                    pCell.setCheckState(QtCore.Qt.Unchecked);
520
- 
521
-            #print( "loops",  self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"]) 
522
-         
523
-        #self.ui.loopTableWidget.itemClicked.connect(self.loopCellClicked) 
524
-
525
-    def loopCellChanged(self):
526
-        
527
-        self.ui.loopTableWidget.cellChanged.disconnect(self.loopCellChanged) 
528
-        jj = self.ui.loopTableWidget.currentColumn()
529
-        ii = self.ui.loopTableWidget.currentRow()
530
-
531
-        if jj == 0 and len( self.ui.loopTableWidget.item(ii, jj).text().strip()) == 0:
532
-            for jjj in range(jj+1,jj+6): 
533
-                pCell = self.ui.loopTableWidget.item(ii, jjj)
534
-                pCell.setBackground( QtGui.QColor("white") )
535
-                pCell.setFlags( QtCore.Qt.NoItemFlags | QtCore.Qt.ItemIsUserCheckable   ) # not selectable 
536
-        elif jj == 0 and len( self.ui.loopTableWidget.item(ii, jj).text().strip() ): # ch. tag modified
537
-            for jjj in range(jj+1,jj+5): 
538
-                pCell = self.ui.loopTableWidget.item(ii, jjj)
539
-                pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
540
-                pCell.setBackground( QtGui.QColor("lightblue") )
541
-            if self.ui.loopTableWidget.item(ii, jj).text() not in self.loops.keys():
542
-                # This is a new loop ID 
543
-                self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ] = {}
544
-                self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["Tx"] = self.ui.loopTableWidget.item(ii, 5).checkState()
545
-                self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["points"] = [ii] 
546
-                # Transmitter cell 
547
-                pCell = self.ui.loopTableWidget.item(ii, jj+5)
548
-                pCell.setCheckState(QtCore.Qt.Unchecked)
549
-                pCell.setFlags( QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled  )
550
-                pCell.setBackground( QtGui.QColor("lightblue") ) 
551
-            else:
552
-                # This is an existing loop ID 
553
-                self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ]["points"].append( ii ) 
554
-                pCell = self.ui.loopTableWidget.item(ii, jj+5)
555
-                pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
556
-                if self.loops[ self.ui.loopTableWidget.item(ii, 0).text() ]["Tx"]:
557
-                    pCell.setCheckState(QtCore.Qt.Checked);
558
-                else:
559
-                    pCell.setCheckState(QtCore.Qt.Unchecked);
560
-                #pCell.setFlags( )
561
-                pCell.setBackground( QtGui.QColor("lightblue") )
562
-
563
-        self.plotLoops()
564
-        self.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged) 
565
-
566 536
     def plotLoops2(self):
567 537
         self.ui.mplwidget.reAxH(1)
568 538
 
@@ -582,52 +552,6 @@ class ApplicationWindow(QtWidgets.QMainWindow):
582 552
         del self.loops[ self.ui.txRxTable.item( self.ui.txRxTable.currentRow(), 0).text() ]
583 553
         self.ui.txRxTable.removeRow(self.ui.txRxTable.currentRow()) 
584 554
 
585
-    def plotLoops(self):
586
-       
587
-        self.ui.mplwidget.reAxH(1)
588
-        #self.ui.mplwidget.ax1.clear() 
589
-        #self.ui.mplwidget.ax2.clear()
590
-        nor = dict()
591
-        eas = dict()
592
-        dep = dict() 
593
-        for ii in range( self.ui.loopTableWidget.rowCount() ):
594
-            for jj in range( self.ui.loopTableWidget.columnCount() ):
595
-                tp = type(self.ui.loopTableWidget.item(ii, jj))
596
-                if str(tp) == "<class 'NoneType'>":  
597
-                    pass 
598
-                elif not len(self.ui.loopTableWidget.item(ii, jj).text()): 
599
-                    pass
600
-                else:
601
-                    if jj == 0: 
602
-                        idx = self.ui.loopTableWidget.item(ii, 0).text()
603
-                        if idx not in nor.keys():
604
-                            nor[idx] = list()
605
-                            eas[idx] = list()
606
-                            dep[idx] = list()
607
-                    if jj == 4:
608
-                        # circular loop 
609
-                        m2pi = np.linspace(0,2*np.pi,10)
610
-                        rad = 30.
611
-                        nor[idx] = np.concatenate((np.array(nor[idx]),  rad * np.sin(m2pi))) 
612
-                        eas[idx] = np.concatenate((np.array(eas[idx]),  rad * np.cos(m2pi))) 
613
-                        dep[idx] = np.concatenate((np.array(dep[idx]),  np.ones(len(m2pi)))) 
614
-                        print("nor", nor[idx]) 
615
-                    if jj == 1: 
616
-                        nor[idx].append( eval(self.ui.loopTableWidget.item(ii, 1).text()) )
617
-                    elif jj == 2:
618
-                        eas[idx].append( eval(self.ui.loopTableWidget.item(ii, 2).text()) )
619
-                    elif jj == 3:
620
-                        dep[idx].append( eval(self.ui.loopTableWidget.item(ii, 3).text()) )
621
-
622
-        for ii in nor.keys():            
623
-            try:    
624
-                self.ui.mplwidget.ax1.plot(  np.array(nor[ii]), np.array(eas[ii])  )
625
-            except:
626
-                pass 
627
-        #self.ui.mplwidget.figure.axes().set
628
-        self.ui.mplwidget.ax1.set_aspect('equal') #, adjustable='box')
629
-        self.ui.mplwidget.draw()
630
-
631 555
     def about(self):
632 556
         # TODO proper popup with info
633 557
         #self.w = MyPopup("""About Akvo \n
@@ -635,9 +559,10 @@ class ApplicationWindow(QtWidgets.QMainWindow):
635 559
         #""")
636 560
         #self.w.setGeometry(100, 100, 400, 200)
637 561
         #self.w.show()
562
+        #print("ABOUT")
638 563
 
639 564
         # Just a splash screen for now
640
-        logo = pkg_resources.resource_filename(__name__, 'akvo_about.png')
565
+        logo = pkg_resources.resource_filename(__name__, 'akvo-about.png')
641 566
         pixmap = QtGui.QPixmap(logo)
642 567
         self.splash = QtWidgets.QSplashScreen(pixmap, QtCore.Qt.WindowStaysOnTopHint)
643 568
         self.splash.show()
@@ -1406,6 +1331,11 @@ class ApplicationWindow(QtWidgets.QMainWindow):
1406 1331
         self.YamlNode.META["B_0"]["intensity"] = self.ui.intensitySpinBox.value()
1407 1332
         self.YamlNode.META["Field Notes"] = self.ui.txtComments.toPlainText()
1408 1333
 
1334
+        self.YamlNode.META["Loops"] = OrderedDict()
1335
+        for loop in self.loops:
1336
+            print(self.loops[loop])
1337
+            self.YamlNode.META["Loops"][loop] = loop + ".yml" 
1338
+
1409 1339
         self.Log()
1410 1340
 
1411 1341
     def bandPassFilter(self):

+ 7
- 26
akvo/gui/main.ui Wyświetl plik

@@ -3578,22 +3578,12 @@ background: dark grey;
3578 3578
                  </item>
3579 3579
                  <item>
3580 3580
                   <property name="text">
3581
-                   <string>figure-8</string>
3582
-                  </property>
3583
-                 </item>
3584
-                 <item>
3585
-                  <property name="text">
3586
-                   <string>square-8</string>
3587
-                  </property>
3588
-                 </item>
3589
-                 <item>
3590
-                  <property name="text">
3591
-                   <string>New Item</string>
3581
+                   <string>polygon</string>
3592 3582
                   </property>
3593 3583
                  </item>
3594 3584
                  <item>
3595 3585
                   <property name="text">
3596
-                   <string>polygon</string>
3586
+                   <string>figure-8</string>
3597 3587
                   </property>
3598 3588
                  </item>
3599 3589
                 </widget>
@@ -3864,8 +3854,8 @@ background: dark grey;
3864 3854
               <rect>
3865 3855
                <x>0</x>
3866 3856
                <y>0</y>
3867
-               <width>96</width>
3868
-               <height>26</height>
3857
+               <width>100</width>
3858
+               <height>30</height>
3869 3859
               </rect>
3870 3860
              </property>
3871 3861
              <attribute name="label">
@@ -3877,8 +3867,8 @@ background: dark grey;
3877 3867
               <rect>
3878 3868
                <x>0</x>
3879 3869
                <y>0</y>
3880
-               <width>96</width>
3881
-               <height>26</height>
3870
+               <width>411</width>
3871
+               <height>67</height>
3882 3872
               </rect>
3883 3873
              </property>
3884 3874
              <attribute name="label">
@@ -3929,15 +3919,7 @@ background: red;
3929 3919
             <property name="title">
3930 3920
              <string>Surface Loops</string>
3931 3921
             </property>
3932
-            <layout class="QVBoxLayout" name="verticalLayout_8">
3933
-             <item>
3934
-              <widget class="QTableWidget" name="loopTableWidget">
3935
-               <property name="toolTip">
3936
-                <string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;This table is used to enter coil geometries the format is as follows: each row specifies a single point on a coil. The first column is the coil index (using the GMR channel is useful), the next three colums specify the point in Northing, Easting, and Elevation. These can either be local coordinates or global ones. The final column specifies the loop radius if it is a circle or figure 8, for non circular or figure 8 loops leave this column blank. For figure-8 loops the coils do not need to be touching (see Irons and Kass, 2017). If a given index has 1 row it will be a circular loop, two rows will be a figure 8, and more than that will be a polygonal representation of the points, linearlly interpolated between them. &lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
3937
-               </property>
3938
-              </widget>
3939
-             </item>
3940
-            </layout>
3922
+            <layout class="QVBoxLayout" name="verticalLayout_8"/>
3941 3923
            </widget>
3942 3924
           </widget>
3943 3925
           <widget class="QWidget" name="LogTab">
@@ -4005,7 +3987,6 @@ p, li { white-space: pre-wrap; }
4005 3987
     <addaction name="actionOpen_GMR"/>
4006 3988
     <addaction name="separator"/>
4007 3989
     <addaction name="actionOpen_Preprocessed_Dataset"/>
4008
-    <addaction name="actionOpen_VC_Preprocessed_dataset"/>
4009 3990
     <addaction name="separator"/>
4010 3991
     <addaction name="actionSave_Preprocessed_Dataset"/>
4011 3992
     <addaction name="actionExport_Preprocessed_Dataset"/>

+ 4
- 0
pyuic.json Wyświetl plik

@@ -11,6 +11,10 @@
11 11
         [
12 12
             "akvo/gui/addFigure8Loop.ui",
13 13
             "akvo/gui"
14
+        ],
15
+        [
16
+            "akvo/gui/addPolygonalLoop.ui",
17
+            "akvo/gui"
14 18
         ]
15 19
     ],
16 20
     "pyrcc": "pyrcc5",

Ładowanie…
Anuluj
Zapisz