Newer
Older

Benjamin Jakimow
committed
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
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'imagechipviewsettings_widget_base.ui'
#
# Created: Mon Oct 26 16:10:40 2015
# by: PyQt4 UI code generator 4.10.2
#
# WARNING! All changes made in this file will be lost!
'''
/***************************************************************************
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
***************************************************************************/
'''
import os
from PyQt4 import uic
from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
sys.path.append(os.path.dirname(__file__))
def loadFormClass(name_ui):
FORM_CLASS, _ = uic.loadUiType(os.path.join(
os.path.dirname(__file__), name_ui), resource_suffix='')
return FORM_CLASS
FORM_CLASS_BANDVIEWSETTINGS = loadFormClass('bandviewsettings_widget_base.ui')
FORM_CLASS_IMAGECHIPVIEWSETTINGS = loadFormClass('imagechipviewsettings_widget_base.ui')
class ImageChipViewSettings(QGroupBox, FORM_CLASS_IMAGECHIPVIEWSETTINGS):
#define signals
removeView = pyqtSignal()
def __init__(self, SensorConfiguration, parent=None):
"""Constructor."""
super(ImageChipViewSettings, self).__init__(parent)
# Set up the user interface from Designer.
# After setupUI you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)
self.SensorConfiguration = SensorConfiguration
self.setTitle(SensorConfiguration.sensor_name)
self.tb_range_r_min.setValidator(QDoubleValidator())
self.tb_range_g_min.setValidator(QDoubleValidator())
self.tb_range_b_min.setValidator(QDoubleValidator())
self.tb_range_r_max.setValidator(QDoubleValidator())
self.tb_range_g_max.setValidator(QDoubleValidator())
self.tb_range_b_max.setValidator(QDoubleValidator())
self._initBands(self.SensorConfiguration.band_names)
def ua_setMask(self, state):
useMask = state != 0
for w in [self.bt_color, self.label_maskexpression, self.tb_maskexpression]:
w.setEnabled(useMask)
def ua_setMaskColor(self, color):
if color is None:
color = QColorDialog.getColor()
if color is not None:
self.maskcolor = color
r = color.red()
g = color.green()
b = color.blue()
style = "background:rgb({},{},{})".format(r,g,b)
self.bt_color.setStyleSheet(style)
self.bt_color.update()
def getMaskColor(self):
return (self.maskcolor.red(), self.maskcolor.green(), self.maskcolor.blue())
def useMaskValues(self):
return self.cb_useMask.isChecked()
def _initBands(self, band_names):
cb_R = self.cb_r
cb_G = self.cb_g
cb_B = self.cb_b
for i, bandname in enumerate(band_names):
cb_R.addItem(bandname, i+1)
cb_G.addItem(bandname, i+1)
cb_B.addItem(bandname, i+1)
if len(self.SensorConfiguration.band_names) >= 3:
cb_R.setCurrentIndex(2)
cb_G.setCurrentIndex(1)
cb_B.setCurrentIndex(0)
def setBands(self,bands):
assert len(bands) == 3
for b in bands:
assert type(b) is int and b > 0
assert b <= len(self.SensorConfiguration.band_names), 'TimeSeries is not initializes/has no bands to show'
self.cb_r.setCurrentIndex(bands[0]-1)
self.cb_g.setCurrentIndex(bands[1]-1)
self.cb_b.setCurrentIndex(bands[2]-1)
s = ""
pass
def getBands(self):
bands = [self.cb_r.currentIndex()+1, \
self.cb_g.currentIndex()+1, \
self.cb_b.currentIndex()+1]
return bands
def getRanges(self):
range_r = [float(self.tb_range_r_min.text()), float(self.tb_range_r_max.text())]
range_g = [float(self.tb_range_g_min.text()), float(self.tb_range_g_max.text())]
range_b = [float(self.tb_range_b_min.text()), float(self.tb_range_b_max.text())]
return (range_r, range_g, range_b)
def getSettings(self):
s = ""
class BandViewSettings(QGroupBox, FORM_CLASS_BANDVIEWSETTINGS):
#define signals
removeView = pyqtSignal()
def __init__(self, SensorConfiguration, parent=None):
"""Constructor."""
super(BandViewSettings, self).__init__(parent)
# Set up the user interface from Designer.
# After setupUI you can access any designer object by doing
# self.<objectname>, and you can use autoconnect slots - see
# http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html
# #widgets-and-dialogs-with-auto-connect
self.setupUi(self)
self.SensorConfiguration = SensorConfiguration
self.setTitle(SensorConfiguration.sensor_name)
self.tb_range_min.setValidator(QDoubleValidator())
self.tb_range_max.setValidator(QDoubleValidator())
self._initBands(self.SensorConfiguration.band_names)
def ua_setMask(self, state):
raise NotImplementedError()
useMask = state != 0
for w in [self.bt_color, self.label_maskexpression, self.tb_maskexpression]:
w.setEnabled(useMask)
def ua_setMaskColor(self, color):
raise NotImplementedError()
if color is None:
color = QColorDialog.getColor()
if color is not None:
self.maskcolor = color
r = color.red()
g = color.green()
b = color.blue()
style = "background:rgb({},{},{})".format(r,g,b)
self.bt_color.setStyleSheet(style)
self.bt_color.update()
def getMaskColor(self):
raise NotImplementedError()
return (self.maskcolor.red(), self.maskcolor.green(), self.maskcolor.blue())
def useMaskValues(self):
return self.cb_useMask.isChecked()
def _initBands(self, band_names):
cb_R = self.cb_r
cb_G = self.cb_g
cb_B = self.cb_b
for i, bandname in enumerate(band_names):
cb_R.addItem(bandname, i+1)
cb_G.addItem(bandname, i+1)
cb_B.addItem(bandname, i+1)
if len(self.SensorConfiguration.band_names) >= 3:
cb_R.setCurrentIndex(2)
cb_G.setCurrentIndex(1)
cb_B.setCurrentIndex(0)
def setBands(self,bands):
assert len(bands) == 3
for b in bands:
assert type(b) is int and b > 0
assert b <= len(self.SensorConfiguration.band_names), 'TimeSeries is not initializes/has no bands to show'
self.cb_r.setCurrentIndex(bands[0]-1)
self.cb_g.setCurrentIndex(bands[1]-1)
self.cb_b.setCurrentIndex(bands[2]-1)
s = ""
pass
def getBands(self):
bands = [self.cb_r.currentIndex()+1, \
self.cb_g.currentIndex()+1, \
self.cb_b.currentIndex()+1]
return bands
def getRanges(self):
range = [float(self.tb_range_min.text()), float(self.tb_range_max.text())]
#provide a range for each channel
return (range, range, range)
def getSettings(self):
s = ""
if __name__ == '__main__':
import PyQt4.Qt
app=PyQt4.Qt.QApplication([])
W = QDialog()
W.setLayout(QHBoxLayout())
L = W.layout()
import sensecarbon_tsv
S = sensecarbon_tsv.SensorConfiguration(6,30,30)
w = BandViewSettings(S)
L.addWidget(w)
W.show()
sys.exit(app.exec_())
print('Done')