Browse Source

improvements, table is getting smarter about loop transmission

add-license-1
T-bone 6 years ago
parent
commit
9eadeab0d6
1 changed files with 33 additions and 32 deletions
  1. 33
    32
      akvo/gui/akvoGUI.py

+ 33
- 32
akvo/gui/akvoGUI.py View File

@@ -172,13 +172,14 @@ class ApplicationWindow(QtWidgets.QMainWindow):
172 172
         self.ui.mplwidget_navigator_2.setCanvas(self.ui.mplwidget_2)
173 173
 
174 174
         ##########################################################################
175
-        # modelling Table 
175
+        # Loop Table 
176 176
         self.ui.loopTableWidget.setRowCount(80)       
177 177
         self.ui.loopTableWidget.setColumnCount(6)      
178
-        self.ui.loopTableWidget.setHorizontalHeaderLabels( ["ch. tag", "Northing [m]","Easting [m]","Height [m]", "Radius","Tx"] )
178
+        self.ui.loopTableWidget.setHorizontalHeaderLabels( ["ch. tag", \
179
+            "Northing [m]","Easting [m]","Height [m]", "Radius","Tx"] )
179 180
         
180
-        for ir in range(1, self.ui.loopTableWidget.rowCount() ):
181
-            for ic in range( self.ui.loopTableWidget.columnCount() ):
181
+        for ir in range(0, self.ui.loopTableWidget.rowCount() ):
182
+            for ic in range(1, self.ui.loopTableWidget.columnCount() ):
182 183
                 pCell = QtWidgets.QTableWidgetItem()
183 184
                 #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
184 185
                 pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
@@ -189,7 +190,9 @@ class ApplicationWindow(QtWidgets.QMainWindow):
189 190
         self.ui.loopTableWidget.setDragDropOverwriteMode(False)
190 191
         self.ui.loopTableWidget.setDragEnabled(True)
191 192
         self.ui.loopTableWidget.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
192
-        
193
+
194
+        self.loops = {}        
195
+
193 196
         ##########################################################################
194 197
         # layer Table 
195 198
         self.ui.layerTableWidget.setRowCount(80)       
@@ -204,8 +207,8 @@ class ApplicationWindow(QtWidgets.QMainWindow):
204 207
         pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
205 208
         pCell.setBackground( QtGui.QColor("lightgrey").lighter(110) )
206 209
         self.ui.layerTableWidget.setItem(0, 1, pCell)
207
-        for ir in range(1, 80):
208
-            for ic in range(0, 3):
210
+        for ir in range(1, self.ui.layerTableWidget.rowCount() ):
211
+            for ic in range(0, self.ui.layerTableWidget.columnCount() ):
209 212
                 pCell = QtWidgets.QTableWidgetItem()
210 213
                 #pCell.setFlags(QtCore.Qt.ItemIsEnabled | QtCore.Qt.ItemIsSelectable)
211 214
                 pCell.setFlags(QtCore.Qt.NoItemFlags) # not selectable 
@@ -283,35 +286,33 @@ class ApplicationWindow(QtWidgets.QMainWindow):
283 286
 
284 287
 
285 288
     def loopCellChanged(self):
286
-        # TODO consider building the model whenever this is called. Would be nice to be able to 
287
-        # do that. Would require instead dist of T2 I guess. 
289
+       
290
+        self.ui.loopTableWidget.cellChanged.disconnect(self.loopCellChanged) 
291
+        
288 292
         jj = self.ui.loopTableWidget.currentColumn()
289 293
         ii = self.ui.loopTableWidget.currentRow()
290
-            
291
-        #if self.ui.loopTableWidget.item(ii, jj) == None:
292
-        #    return
293 294
 
294
-        if jj == 5:
295
-            pass
296
-            #pCell = QtWidgets.QTableWidgetItem()
297
-            #pCell.setFlags(QtCore.Qt.ItemIsEnabled)
298
-            #pCell.setBackground( QtGui.QColor("lightblue") ) #.lighter(110))
299
-            #self.ui.loopTableWidget.setItem(ii, jj, pCell)
300
-            #pCell4 = self.ui.layerTableWidget.item(ii, jj)
301
-            #print(pCell4)
302
-            #pCell4.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
303
-            #pCell4.setBackground( QtGui.QColor("lightblue") ) #.lighter(110))
304
-#         try:
305
-#             eval (str( self.ui.loopTableWidget.item(ii, jj).text() ))
306
-#         except:
307
-#             if jj != 0:
308
-#                 Error = QtWidgets.QMessageBox()
309
-#                 Error.setWindowTitle("Error!")
310
-#                 Error.setText("Non-numeric value encountered")
311
-#                 Error.setDetailedText("Modelling parameters must be able to be cast into numeric values.")
312
-#                 Error.exec_()
313
-            
295
+        if jj == 0: # ch. tag modified
296
+
297
+            for jjj in range(jj+1,jj+5): 
298
+                pCell = self.ui.loopTableWidget.item(ii, jjj)
299
+                pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEditable | QtCore.Qt.ItemIsEnabled )
300
+                pCell.setBackground( QtGui.QColor("lightblue") )
301
+            if self.ui.loopTableWidget.item(ii, jj).text() not in self.loops.keys():
302
+                self.loops[ self.ui.loopTableWidget.item(ii, jj).text() ] = {}
303
+                print (self.loops.keys())
304
+                # Transmitter cell 
305
+                pCell = self.ui.loopTableWidget.item(ii, jj+5)
306
+                pCell.setCheckState(QtCore.Qt.Unchecked);
307
+                pCell.setFlags( QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled )
308
+                pCell.setBackground( QtGui.QColor("lightblue") ) 
309
+            else:
310
+                pCell = self.ui.loopTableWidget.item(ii, jj+5)
311
+                pCell.setCheckState(QtCore.Qt.Unchecked);
312
+                #pCell.setFlags( )
313
+                pCell.setBackground( QtGui.QColor("lightblue") ) 
314 314
         self.plotLoops()
315
+        self.ui.loopTableWidget.cellChanged.connect(self.loopCellChanged) 
315 316
 
316 317
     def plotLoops(self):
317 318
                

Loading…
Cancel
Save