| 1 |
|
| 2 |
""" |
| 3 |
Copyright (c) 2019 Rolf Hempel, [email protected] |
| 4 |
|
| 5 |
This file is part of the PlanetarySystemStacker tool (PSS). |
| 6 |
https://github.com/Rolf-Hempel/PlanetarySystemStacker |
| 7 |
|
| 8 |
PSS is free software: you can redistribute it and/or modify |
| 9 |
it under the terms of the GNU General Public License as published by |
| 10 |
the Free Software Foundation, either version 3 of the License, or |
| 11 |
(at your option) any later version. |
| 12 |
|
| 13 |
This program is distributed in the hope that it will be useful, |
| 14 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
GNU General Public License for more details. |
| 17 |
|
| 18 |
You should have received a copy of the GNU General Public License |
| 19 |
along with PSS. If not, see <http://www.gnu.org/licenses/>. |
| 20 |
|
| 21 |
""" |
| 22 |
|
| 23 |
from PyQt5 import QtWidgets, QtCore |
| 24 |
from PyQt5.QtGui import QIntValidator |
| 25 |
from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QVBoxLayout, QLabel |
| 26 |
|
| 27 |
from configuration import ConfigurationParameters |
| 28 |
from parameter_configuration import Ui_ConfigurationDialog |
| 29 |
|
| 30 |
|
| 31 |
class ConfigurationEditor(QtWidgets.QFrame, Ui_ConfigurationDialog): |
| 32 |
""" |
| 33 |
Update the parameters used by PlanetarySystemStacker which are stored in the configuration |
| 34 |
object. The interaction with the user is through the ConfigurationDialog class. |
| 35 |
""" |
| 36 |
|
| 37 |
def __init__(self, parent_gui, parent=None): |
| 38 |
QtWidgets.QFrame.__init__(self, parent) |
| 39 |
self.setupUi(self) |
| 40 |
|
| 41 |
self.setFrameShape(QtWidgets.QFrame.Panel) |
| 42 |
self.setFrameShadow(QtWidgets.QFrame.Sunken) |
| 43 |
self.setObjectName("configuration_editor") |
| 44 |
|
| 45 |
self.setFixedSize(900, 600) |
| 46 |
|
| 47 |
self.parent_gui = parent_gui |
| 48 |
self.configuration = parent_gui.configuration |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
self.configuration.go_back_to_activity = None |
| 53 |
self.configuration.configuration_changed = False |
| 54 |
|
| 55 |
|
| 56 |
self.config_copy = ConfigurationParameters() |
| 57 |
self.config_copy.copy_from_config_object(self.configuration) |
| 58 |
|
| 59 |
self.buttonBox.accepted.connect(self.accept) |
| 60 |
self.buttonBox.rejected.connect(self.reject) |
| 61 |
|
| 62 |
|
| 63 |
self.fgw_slider_value.valueChanged['int'].connect(self.fgw_changed) |
| 64 |
self.fdb_comboBox.addItem('Auto detect color') |
| 65 |
self.fdb_comboBox.addItem('Grayscale') |
| 66 |
self.fdb_comboBox.addItem('RGB') |
| 67 |
self.fdb_comboBox.addItem('BGR') |
| 68 |
self.fdb_comboBox.addItem('Force Bayer RGGB') |
| 69 |
self.fdb_comboBox.addItem('Force Bayer GRBG') |
| 70 |
self.fdb_comboBox.addItem('Force Bayer GBRG') |
| 71 |
self.fdb_comboBox.addItem('Force Bayer BGGR') |
| 72 |
self.fdb_comboBox.activated[str].connect(self.fdb_changed) |
| 73 |
self.fdbm_comboBox.addItem('Bilinear') |
| 74 |
self.fdbm_comboBox.addItem('Variable Number of Gradients') |
| 75 |
self.fdbm_comboBox.addItem('Edge Aware') |
| 76 |
self.fdbm_comboBox.activated[str].connect(self.fdbm_changed) |
| 77 |
self.fn_checkBox.stateChanged.connect(self.fn_changed) |
| 78 |
self.fnt_slider_value.valueChanged['int'].connect(self.fnt_changed) |
| 79 |
self.afm_comboBox.addItem('Surface') |
| 80 |
self.afm_comboBox.addItem('Planet') |
| 81 |
self.afm_comboBox.activated[str].connect(self.afm_changed) |
| 82 |
self.afa_checkBox.stateChanged.connect(self.afa_changed) |
| 83 |
self.afrsf_slider_value.valueChanged['int'].connect(self.afrsf_changed) |
| 84 |
self.afsw_slider_value.valueChanged['int'].connect(self.afsw_changed) |
| 85 |
self.afafp_slider_value.valueChanged['int'].connect(self.afafp_changed) |
| 86 |
self.efs_checkBox.stateChanged.connect(self.efs_changed) |
| 87 |
self.fco_checkBox.stateChanged.connect(self.fco_changed) |
| 88 |
self.gpwptf_checkBox.stateChanged.connect(self.gpwptf_changed) |
| 89 |
self.gpspwr_checkBox.stateChanged.connect(self.gpspwr_changed) |
| 90 |
self.gppl_spinBox.valueChanged['int'].connect(self.gppl_changed) |
| 91 |
self.gpbl_combobox.addItem('auto') |
| 92 |
self.gpbl_combobox.addItem('0') |
| 93 |
self.gpbl_combobox.addItem('1') |
| 94 |
self.gpbl_combobox.addItem('2') |
| 95 |
self.gpbl_combobox.addItem('3') |
| 96 |
self.gpbl_combobox.addItem('4') |
| 97 |
self.gpbl_combobox.activated[str].connect(self.gpbl_changed) |
| 98 |
self.mr_checkBox.stateChanged.connect(self.mr_changed) |
| 99 |
self.mr_lineEdit.setValidator(QIntValidator(1, 2147483647)) |
| 100 |
self.mr_lineEdit.textChanged.connect(self.mr_text_changed) |
| 101 |
self.gpif_comboBox.addItem('png') |
| 102 |
self.gpif_comboBox.addItem('tiff') |
| 103 |
self.gpif_comboBox.addItem('fits') |
| 104 |
self.gpif_comboBox.activated[str].connect(self.gpif_changed) |
| 105 |
self.aphbw_slider_value.valueChanged['int'].connect(self.aphbw_changed) |
| 106 |
self.apsw_slider_value.valueChanged['int'].connect(self.apsw_changed) |
| 107 |
self.apst_slider_value.valueChanged['int'].connect(self.apst_changed) |
| 108 |
self.apbt_slider_value.valueChanged['int'].connect(self.apbt_changed) |
| 109 |
self.apfp_comboBox.addItem('Percent of frames to be stacked') |
| 110 |
self.apfp_comboBox.addItem('Number of frames to be stacked') |
| 111 |
self.apfp_comboBox.activated[str].connect(self.apfp_state_changed) |
| 112 |
self.apfp_spinBox.valueChanged['int'].connect(self.apfp_value_changed) |
| 113 |
self.spp_checkBox.stateChanged.connect(self.spp_changed) |
| 114 |
self.ipfn_checkBox.stateChanged.connect(self.ipfn_changed) |
| 115 |
self.nfs_checkBox.stateChanged.connect(self.nfs_changed) |
| 116 |
self.pfs_checkBox.stateChanged.connect(self.pfs_changed) |
| 117 |
self.apbs_checkBox.stateChanged.connect(self.apbs_changed) |
| 118 |
self.nap_checkBox.stateChanged.connect(self.nap_changed) |
| 119 |
self.sfdfs_comboBox.addItem('Off') |
| 120 |
self.sfdfs_comboBox.addItem('1.5x') |
| 121 |
self.sfdfs_comboBox.addItem('2x') |
| 122 |
self.sfdfs_comboBox.addItem('3x') |
| 123 |
self.sfdfs_comboBox.activated[str].connect(self.sfdfs_changed) |
| 124 |
|
| 125 |
self.restore_standard_values.clicked.connect(self.restore_standard_parameters) |
| 126 |
|
| 127 |
self.initialize_widgets_and_local_parameters() |
| 128 |
|
| 129 |
def initialize_widgets_and_local_parameters(self): |
| 130 |
""" |
| 131 |
Initialize GUI widgets with current configuration parameter values. |
| 132 |
|
| 133 |
:return: - |
| 134 |
""" |
| 135 |
|
| 136 |
self.fgw_slider_value.setValue(int((self.config_copy.frames_gauss_width + 1) / 2)) |
| 137 |
self.fgw_label_display.setText(str(self.config_copy.frames_gauss_width)) |
| 138 |
index = self.fdb_comboBox.findText(self.config_copy.frames_debayering_default, |
| 139 |
QtCore.Qt.MatchFixedString) |
| 140 |
if index >= 0: |
| 141 |
self.fdb_comboBox.setCurrentIndex(index) |
| 142 |
index = self.fdbm_comboBox.findText(self.config_copy.frames_debayering_method, |
| 143 |
QtCore.Qt.MatchFixedString) |
| 144 |
if index >= 0: |
| 145 |
self.fdbm_comboBox.setCurrentIndex(index) |
| 146 |
index = self.afm_comboBox.findText(self.config_copy.align_frames_mode, |
| 147 |
QtCore.Qt.MatchFixedString) |
| 148 |
if index >= 0: |
| 149 |
self.afm_comboBox.setCurrentIndex(index) |
| 150 |
self.afm_activate_deactivate_widgets() |
| 151 |
self.afa_checkBox.setChecked(self.config_copy.align_frames_automation) |
| 152 |
self.afrsf_slider_value.setValue( |
| 153 |
int(100. / self.config_copy.align_frames_rectangle_scale_factor)) |
| 154 |
self.afrsf_label_display.setText( |
| 155 |
str(int(100. / self.config_copy.align_frames_rectangle_scale_factor))) |
| 156 |
self.afsw_slider_value.setValue(self.config_copy.align_frames_search_width) |
| 157 |
self.afsw_label_display.setText(str(self.config_copy.align_frames_search_width)) |
| 158 |
self.afafp_slider_value.setValue(self.config_copy.align_frames_average_frame_percent) |
| 159 |
self.afafp_label_display.setText(str(self.config_copy.align_frames_average_frame_percent)) |
| 160 |
self.efs_checkBox.setChecked(self.config_copy.frames_add_selection_dialog) |
| 161 |
self.fco_checkBox.setChecked(self.config_copy.align_frames_fast_changing_object) |
| 162 |
self.gpwptf_checkBox.setChecked(self.config_copy.global_parameters_write_protocol_to_file) |
| 163 |
self.gpspwr_checkBox.setChecked( |
| 164 |
self.config_copy.global_parameters_store_protocol_with_result) |
| 165 |
self.gppl_spinBox.setValue(self.config_copy.global_parameters_protocol_level) |
| 166 |
if self.config_copy.global_parameters_buffering_level != -1: |
| 167 |
self.gpbl_combobox.setCurrentIndex(self.config_copy.global_parameters_buffering_level+1) |
| 168 |
else: |
| 169 |
self.gpbl_combobox.setCurrentIndex(0) |
| 170 |
|
| 171 |
self.mr_lineEdit.setText(str(self.config_copy.global_parameters_maximum_memory_amount)) |
| 172 |
self.mr_checkBox.setChecked(self.config_copy.global_parameters_maximum_memory_active) |
| 173 |
self.make_mr_label_visible(self.config_copy.global_parameters_maximum_memory_active) |
| 174 |
self.mr_label.setStyleSheet('color: red') |
| 175 |
if not self.config_copy.global_parameters_maximum_memory_active: |
| 176 |
self.mr_lineEdit.setEnabled(False) |
| 177 |
|
| 178 |
index = self.gpif_comboBox.findText(self.config_copy.global_parameters_image_format, |
| 179 |
QtCore.Qt.MatchFixedString) |
| 180 |
if index >= 0: |
| 181 |
self.gpif_comboBox.setCurrentIndex(index) |
| 182 |
self.ipfn_checkBox.setChecked(self.config_copy.global_parameters_parameters_in_filename) |
| 183 |
self.nfs_checkBox.setChecked(self.config_copy.global_parameters_stack_number_frames) |
| 184 |
self.pfs_checkBox.setChecked(self.config_copy.global_parameters_stack_percent_frames) |
| 185 |
self.apbs_checkBox.setChecked(self.config_copy.global_parameters_ap_box_size) |
| 186 |
self.nap_checkBox.setChecked(self.config_copy.global_parameters_ap_number) |
| 187 |
|
| 188 |
self.aphbw_slider_value.setValue(self.config_copy.alignment_points_half_box_width * 2) |
| 189 |
self.aphbw_label_display.setText(str(self.config_copy.alignment_points_half_box_width * 2)) |
| 190 |
self.apsw_slider_value.setValue(self.config_copy.alignment_points_search_width) |
| 191 |
self.apsw_label_display.setText(str(self.config_copy.alignment_points_search_width)) |
| 192 |
self.apst_slider_value.setValue(round(self.config_copy.alignment_points_structure_threshold * 100)) |
| 193 |
self.apst_label_display.setText(str(self.config_copy.alignment_points_structure_threshold)) |
| 194 |
self.apbt_slider_value.setValue(self.config_copy.alignment_points_brightness_threshold) |
| 195 |
self.apbt_label_display.setText(str(self.config_copy.alignment_points_brightness_threshold)) |
| 196 |
if self.config_copy.alignment_points_frame_percent != -1: |
| 197 |
self.apfp_comboBox.setCurrentIndex(0) |
| 198 |
self.apfp_spinBox.setMaximum(100) |
| 199 |
self.apfp_spinBox.setValue(self.config_copy.alignment_points_frame_percent) |
| 200 |
else: |
| 201 |
self.apfp_comboBox.setCurrentIndex(1) |
| 202 |
self.apfp_spinBox.setMaximum(1000000) |
| 203 |
self.apfp_spinBox.setValue(self.config_copy.alignment_points_frame_number) |
| 204 |
self.spp_checkBox.setChecked(self.config_copy.global_parameters_include_postprocessing) |
| 205 |
self.fn_checkBox.setChecked(self.config_copy.frames_normalization) |
| 206 |
self.fn_activate_deactivate_widgets() |
| 207 |
self.fnt_slider_value.setValue(self.config_copy.frames_normalization_threshold) |
| 208 |
self.fnt_label_display.setText(str(self.config_copy.frames_normalization_threshold)) |
| 209 |
self.ipfn_activate_deactivate_widgets() |
| 210 |
index = self.sfdfs_comboBox.findText(self.config_copy.stack_frames_drizzle_factor_string, |
| 211 |
QtCore.Qt.MatchFixedString) |
| 212 |
if index >= 0: |
| 213 |
self.sfdfs_comboBox.setCurrentIndex(index) |
| 214 |
|
| 215 |
def fgw_changed(self, value): |
| 216 |
""" |
| 217 |
When the widget changes its value, update the corresponding entry in the configuration copy. |
| 218 |
Please note that for some parameters the representations differ. |
| 219 |
|
| 220 |
The methods following this one do the same for all other configuration parameters. |
| 221 |
|
| 222 |
:param value: New value sent by widget |
| 223 |
:return: - |
| 224 |
""" |
| 225 |
|
| 226 |
self.config_copy.frames_gauss_width = 2 * value - 1 |
| 227 |
self.fgw_label_display.setText(str(self.config_copy.frames_gauss_width)) |
| 228 |
|
| 229 |
def fdb_changed(self, value): |
| 230 |
self.config_copy.frames_debayering_default = value |
| 231 |
|
| 232 |
def fdbm_changed(self, value): |
| 233 |
self.config_copy.frames_debayering_method = value |
| 234 |
|
| 235 |
def afm_changed(self, value): |
| 236 |
self.config_copy.align_frames_mode = value |
| 237 |
self.afm_activate_deactivate_widgets() |
| 238 |
|
| 239 |
def afm_activate_deactivate_widgets(self): |
| 240 |
""" |
| 241 |
Special case: Depending on the "frame stabilization mode" selected, some other parameters |
| 242 |
do not make sense, so they are greyed out (for case 'Planet'). |
| 243 |
|
| 244 |
:return:- |
| 245 |
""" |
| 246 |
|
| 247 |
if self.config_copy.align_frames_mode == 'Planet': |
| 248 |
self.afa_checkBox.setEnabled(False) |
| 249 |
self.afrsf_label_display.setEnabled(False) |
| 250 |
self.afrsf_slider_value.setEnabled(False) |
| 251 |
self.afrsf_label_parameter.setEnabled(False) |
| 252 |
self.afsw_label_parameter.setEnabled(False) |
| 253 |
self.afsw_slider_value.setEnabled(False) |
| 254 |
self.afsw_label_display.setEnabled(False) |
| 255 |
else: |
| 256 |
self.afa_checkBox.setEnabled(True) |
| 257 |
self.afrsf_label_display.setEnabled(True) |
| 258 |
self.afrsf_slider_value.setEnabled(True) |
| 259 |
self.afrsf_label_parameter.setEnabled(True) |
| 260 |
self.afsw_label_parameter.setEnabled(True) |
| 261 |
self.afsw_slider_value.setEnabled(True) |
| 262 |
self.afsw_label_display.setEnabled(True) |
| 263 |
|
| 264 |
def fn_activate_deactivate_widgets(self): |
| 265 |
if self.config_copy.frames_normalization: |
| 266 |
self.fnt_label_display.setEnabled(True) |
| 267 |
self.fnt_slider_value.setEnabled(True) |
| 268 |
self.fnt_label_parameter.setEnabled(True) |
| 269 |
else: |
| 270 |
self.fnt_label_display.setEnabled(False) |
| 271 |
self.fnt_slider_value.setEnabled(False) |
| 272 |
self.fnt_label_parameter.setEnabled(False) |
| 273 |
|
| 274 |
def ipfn_activate_deactivate_widgets(self): |
| 275 |
if self.config_copy.global_parameters_parameters_in_filename: |
| 276 |
self.nfs_checkBox.setEnabled(True) |
| 277 |
self.pfs_checkBox.setEnabled(True) |
| 278 |
self.apbs_checkBox.setEnabled(True) |
| 279 |
self.nap_checkBox.setEnabled(True) |
| 280 |
else: |
| 281 |
self.nfs_checkBox.setEnabled(False) |
| 282 |
self.pfs_checkBox.setEnabled(False) |
| 283 |
self.apbs_checkBox.setEnabled(False) |
| 284 |
self.nap_checkBox.setEnabled(False) |
| 285 |
|
| 286 |
def afa_changed(self, state): |
| 287 |
self.config_copy.align_frames_automation = (state == QtCore.Qt.Checked) |
| 288 |
|
| 289 |
def afrsf_changed(self, value): |
| 290 |
self.config_copy.align_frames_rectangle_scale_factor = 100. / value |
| 291 |
|
| 292 |
def afsw_changed(self, value): |
| 293 |
self.config_copy.align_frames_search_width = value |
| 294 |
|
| 295 |
def afafp_changed(self, value): |
| 296 |
self.config_copy.align_frames_average_frame_percent = value |
| 297 |
|
| 298 |
def efs_changed(self, state): |
| 299 |
self.config_copy.frames_add_selection_dialog = (state == QtCore.Qt.Checked) |
| 300 |
|
| 301 |
def fco_changed(self, state): |
| 302 |
self.config_copy.align_frames_fast_changing_object = (state == QtCore.Qt.Checked) |
| 303 |
|
| 304 |
def gpwptf_changed(self, state): |
| 305 |
self.config_copy.global_parameters_write_protocol_to_file = (state == QtCore.Qt.Checked) |
| 306 |
|
| 307 |
def gpspwr_changed(self, state): |
| 308 |
self.config_copy.global_parameters_store_protocol_with_result = (state == QtCore.Qt.Checked) |
| 309 |
|
| 310 |
def gppl_changed(self, value): |
| 311 |
self.config_copy.global_parameters_protocol_level = value |
| 312 |
|
| 313 |
def gpbl_changed(self, value): |
| 314 |
if value == "auto": |
| 315 |
self.config_copy.global_parameters_buffering_level = -1 |
| 316 |
else: |
| 317 |
self.config_copy.global_parameters_buffering_level = int(value) |
| 318 |
|
| 319 |
def mr_activate(self, state): |
| 320 |
if state: |
| 321 |
self.config_copy.global_parameters_maximum_memory_active = True |
| 322 |
|
| 323 |
self.gpbl_combobox.setCurrentText('auto') |
| 324 |
self.gpbl_combobox.setEnabled(False) |
| 325 |
self.mr_lineEdit.setEnabled(True) |
| 326 |
else: |
| 327 |
self.config_copy.global_parameters_maximum_memory_active = False |
| 328 |
self.config_copy.global_parameters_buffering_level = -1 |
| 329 |
self.gpbl_combobox.setEnabled(True) |
| 330 |
self.mr_lineEdit.setEnabled(False) |
| 331 |
|
| 332 |
def make_mr_label_visible(self, state): |
| 333 |
if state: |
| 334 |
text = "PlanetarySystemStacker takes no responsibility for enough memory being " \ |
| 335 |
"available.\r\n" + "Setting the memory limit too high may cause degraded OS " \ |
| 336 |
"performance and/or process crashes." |
| 337 |
else: |
| 338 |
text = "" |
| 339 |
self.mr_label.setText(text) |
| 340 |
|
| 341 |
def mr_changed(self, state): |
| 342 |
max_memory_active = (state == QtCore.Qt.Checked) |
| 343 |
self.mr_activate(max_memory_active) |
| 344 |
self.make_mr_label_visible(max_memory_active) |
| 345 |
|
| 346 |
def mr_text_changed(self, state): |
| 347 |
try: |
| 348 |
value = int(state) |
| 349 |
if value > 0: |
| 350 |
self.config_copy.global_parameters_maximum_memory_amount = value |
| 351 |
else: |
| 352 |
self.mr_lineEdit.setText( |
| 353 |
str(self.config_copy.global_parameters_maximum_memory_amount)) |
| 354 |
raise ValueError |
| 355 |
except ValueError: |
| 356 |
return |
| 357 |
|
| 358 |
def gpif_changed(self, value): |
| 359 |
self.config_copy.global_parameters_image_format = value |
| 360 |
|
| 361 |
def aphbw_changed(self, value): |
| 362 |
self.config_copy.alignment_points_half_box_width = int(value / 2) |
| 363 |
|
| 364 |
def apsw_changed(self, value): |
| 365 |
self.config_copy.alignment_points_search_width = value |
| 366 |
|
| 367 |
def apst_changed(self, value): |
| 368 |
self.config_copy.alignment_points_structure_threshold = value / 100. |
| 369 |
self.apst_label_display.setText(str(self.config_copy.alignment_points_structure_threshold)) |
| 370 |
|
| 371 |
def apbt_changed(self, value): |
| 372 |
self.config_copy.alignment_points_brightness_threshold = value |
| 373 |
|
| 374 |
def apfp_state_changed(self, value): |
| 375 |
self.apfp_spinBox.blockSignals(True) |
| 376 |
if value == 'Percent of frames to be stacked': |
| 377 |
self.apfp_spinBox.setMaximum(100) |
| 378 |
if self.config_copy.alignment_points_frame_percent > 0: |
| 379 |
self.apfp_spinBox.setValue(self.config_copy.alignment_points_frame_percent) |
| 380 |
else: |
| 381 |
self.apfp_spinBox.setValue(0) |
| 382 |
self.apfp_spinBox.clear() |
| 383 |
else: |
| 384 |
self.apfp_spinBox.setMaximum(1000000) |
| 385 |
if self.config_copy.alignment_points_frame_number > 0: |
| 386 |
self.apfp_spinBox.setValue(self.config_copy.alignment_points_frame_number) |
| 387 |
else: |
| 388 |
self.apfp_spinBox.setValue(0) |
| 389 |
self.apfp_spinBox.clear() |
| 390 |
self.apfp_spinBox.blockSignals(False) |
| 391 |
|
| 392 |
def apfp_value_changed(self, value): |
| 393 |
if self.apfp_comboBox.currentIndex() == 0: |
| 394 |
self.config_copy.alignment_points_frame_percent = value |
| 395 |
else: |
| 396 |
self.config_copy.alignment_points_frame_number = value |
| 397 |
|
| 398 |
def spp_changed(self, state): |
| 399 |
self.config_copy.global_parameters_include_postprocessing = (state == QtCore.Qt.Checked) |
| 400 |
|
| 401 |
def fn_changed(self, state): |
| 402 |
self.config_copy.frames_normalization = (state == QtCore.Qt.Checked) |
| 403 |
self.fn_activate_deactivate_widgets() |
| 404 |
|
| 405 |
def fnt_changed(self, value): |
| 406 |
self.config_copy.frames_normalization_threshold = value |
| 407 |
self.fnt_label_display.setText(str(self.config_copy.frames_normalization_threshold)) |
| 408 |
|
| 409 |
def ipfn_changed(self, state): |
| 410 |
self.config_copy.global_parameters_parameters_in_filename = (state == QtCore.Qt.Checked) |
| 411 |
self.ipfn_activate_deactivate_widgets() |
| 412 |
|
| 413 |
def nfs_changed(self, state): |
| 414 |
self.config_copy.global_parameters_stack_number_frames = (state == QtCore.Qt.Checked) |
| 415 |
|
| 416 |
def pfs_changed(self, state): |
| 417 |
self.config_copy.global_parameters_stack_percent_frames = (state == QtCore.Qt.Checked) |
| 418 |
|
| 419 |
def apbs_changed(self, state): |
| 420 |
self.config_copy.global_parameters_ap_box_size = (state == QtCore.Qt.Checked) |
| 421 |
|
| 422 |
def nap_changed(self, state): |
| 423 |
self.config_copy.global_parameters_ap_number = (state == QtCore.Qt.Checked) |
| 424 |
|
| 425 |
def sfdfs_changed(self, value): |
| 426 |
self.config_copy.stack_frames_drizzle_factor_string = value |
| 427 |
|
| 428 |
def restore_standard_parameters(self): |
| 429 |
""" |
| 430 |
Reset configuration parameters and GUI widget settings to standard values. Mark |
| 431 |
configuration as changed. This may be too pessimistic, if standard values were not changed |
| 432 |
before. |
| 433 |
|
| 434 |
:return: |
| 435 |
""" |
| 436 |
|
| 437 |
self.config_copy.set_defaults() |
| 438 |
self.initialize_widgets_and_local_parameters() |
| 439 |
|
| 440 |
def accept(self): |
| 441 |
""" |
| 442 |
If the OK button is clicked and the configuration has been changed, check if values have |
| 443 |
been changed and assign the new values to configuration parameters. |
| 444 |
|
| 445 |
:return: - |
| 446 |
""" |
| 447 |
|
| 448 |
go_back_to_activities = [] |
| 449 |
|
| 450 |
if self.config_copy.alignment_points_frame_percent != \ |
| 451 |
self.configuration.alignment_points_frame_percent or \ |
| 452 |
self.config_copy.alignment_points_frame_number != \ |
| 453 |
self.configuration.alignment_points_frame_number: |
| 454 |
|
| 455 |
if self.apfp_comboBox.currentIndex() == 0 and \ |
| 456 |
self.config_copy.alignment_points_frame_percent > 0: |
| 457 |
self.configuration.alignment_points_frame_percent = \ |
| 458 |
self.config_copy.alignment_points_frame_percent |
| 459 |
self.configuration.alignment_points_frame_number = -1 |
| 460 |
self.configuration.configuration_changed = True |
| 461 |
go_back_to_activities.append('Select stack size') |
| 462 |
elif self.apfp_comboBox.currentIndex() == 1 and \ |
| 463 |
self.config_copy.alignment_points_frame_number > 0: |
| 464 |
self.configuration.alignment_points_frame_percent = -1 |
| 465 |
self.configuration.alignment_points_frame_number = \ |
| 466 |
self.config_copy.alignment_points_frame_number |
| 467 |
self.configuration.configuration_changed = True |
| 468 |
go_back_to_activities.append('Select stack size') |
| 469 |
|
| 470 |
if self.config_copy.alignment_points_brightness_threshold != \ |
| 471 |
self.configuration.alignment_points_brightness_threshold: |
| 472 |
self.configuration.alignment_points_brightness_threshold = \ |
| 473 |
self.config_copy.alignment_points_brightness_threshold |
| 474 |
self.configuration.configuration_changed = True |
| 475 |
go_back_to_activities.append('Set alignment points') |
| 476 |
|
| 477 |
if self.config_copy.alignment_points_structure_threshold != \ |
| 478 |
self.configuration.alignment_points_structure_threshold: |
| 479 |
self.configuration.alignment_points_structure_threshold = \ |
| 480 |
self.config_copy.alignment_points_structure_threshold |
| 481 |
self.configuration.configuration_changed = True |
| 482 |
go_back_to_activities.append('Set alignment points') |
| 483 |
|
| 484 |
if self.config_copy.alignment_points_search_width != \ |
| 485 |
self.configuration.alignment_points_search_width: |
| 486 |
self.configuration.alignment_points_search_width = \ |
| 487 |
self.config_copy.alignment_points_search_width |
| 488 |
self.configuration.configuration_changed = True |
| 489 |
go_back_to_activities.append('Set alignment points') |
| 490 |
|
| 491 |
if self.config_copy.alignment_points_half_box_width != \ |
| 492 |
self.configuration.alignment_points_half_box_width: |
| 493 |
self.configuration.alignment_points_half_box_width = \ |
| 494 |
self.config_copy.alignment_points_half_box_width |
| 495 |
self.configuration.configuration_changed = True |
| 496 |
go_back_to_activities.append('Set alignment points') |
| 497 |
|
| 498 |
if self.config_copy.align_frames_average_frame_percent != \ |
| 499 |
self.configuration.align_frames_average_frame_percent: |
| 500 |
self.configuration.align_frames_average_frame_percent = \ |
| 501 |
self.config_copy.align_frames_average_frame_percent |
| 502 |
self.configuration.configuration_changed = True |
| 503 |
go_back_to_activities.append('Align frames') |
| 504 |
|
| 505 |
if self.config_copy.align_frames_search_width != \ |
| 506 |
self.configuration.align_frames_search_width: |
| 507 |
self.configuration.align_frames_search_width = \ |
| 508 |
self.config_copy.align_frames_search_width |
| 509 |
self.configuration.configuration_changed = True |
| 510 |
go_back_to_activities.append('Align frames') |
| 511 |
|
| 512 |
if self.config_copy.align_frames_rectangle_scale_factor != \ |
| 513 |
self.configuration.align_frames_rectangle_scale_factor: |
| 514 |
self.configuration.align_frames_rectangle_scale_factor = \ |
| 515 |
self.config_copy.align_frames_rectangle_scale_factor |
| 516 |
self.configuration.configuration_changed = True |
| 517 |
go_back_to_activities.append('Align frames') |
| 518 |
|
| 519 |
if self.config_copy.align_frames_automation != self.configuration.align_frames_automation: |
| 520 |
self.configuration.align_frames_automation = self.config_copy.align_frames_automation |
| 521 |
self.configuration.configuration_changed = True |
| 522 |
go_back_to_activities.append('Align frames') |
| 523 |
|
| 524 |
if self.config_copy.align_frames_mode != self.configuration.align_frames_mode: |
| 525 |
self.configuration.align_frames_mode = self.config_copy.align_frames_mode |
| 526 |
self.configuration.configuration_changed = True |
| 527 |
go_back_to_activities.append('Align frames') |
| 528 |
|
| 529 |
if self.config_copy.frames_gauss_width != self.configuration.frames_gauss_width: |
| 530 |
self.configuration.frames_gauss_width = self.config_copy.frames_gauss_width |
| 531 |
self.configuration.configuration_changed = True |
| 532 |
go_back_to_activities.append('Read frames') |
| 533 |
|
| 534 |
if self.config_copy.frames_debayering_default != self.configuration.frames_debayering_default: |
| 535 |
self.configuration.frames_debayering_default = self.config_copy.frames_debayering_default |
| 536 |
self.configuration.configuration_changed = True |
| 537 |
go_back_to_activities.append('Read frames') |
| 538 |
|
| 539 |
if self.config_copy.frames_debayering_method != self.configuration.frames_debayering_method: |
| 540 |
self.configuration.frames_debayering_method = self.config_copy.frames_debayering_method |
| 541 |
self.configuration.configuration_changed = True |
| 542 |
go_back_to_activities.append('Read frames') |
| 543 |
|
| 544 |
if self.config_copy.frames_normalization != self.configuration.frames_normalization: |
| 545 |
self.configuration.frames_normalization = self.config_copy.frames_normalization |
| 546 |
self.configuration.configuration_changed = True |
| 547 |
go_back_to_activities.append('Compute frame qualities') |
| 548 |
|
| 549 |
if self.config_copy.frames_normalization_threshold != \ |
| 550 |
self.configuration.frames_normalization_threshold: |
| 551 |
self.configuration.frames_normalization_threshold = \ |
| 552 |
self.config_copy.frames_normalization_threshold |
| 553 |
self.configuration.configuration_changed = True |
| 554 |
go_back_to_activities.append('Compute frame qualities') |
| 555 |
|
| 556 |
if self.config_copy.frames_add_selection_dialog != \ |
| 557 |
self.configuration.frames_add_selection_dialog: |
| 558 |
self.configuration.frames_add_selection_dialog = \ |
| 559 |
self.config_copy.frames_add_selection_dialog |
| 560 |
self.configuration.configuration_changed = True |
| 561 |
|
| 562 |
if self.config_copy.align_frames_fast_changing_object != \ |
| 563 |
self.configuration.align_frames_fast_changing_object: |
| 564 |
self.configuration.align_frames_fast_changing_object = \ |
| 565 |
self.config_copy.align_frames_fast_changing_object |
| 566 |
self.configuration.configuration_changed = True |
| 567 |
go_back_to_activities.append('Align frames') |
| 568 |
|
| 569 |
if self.config_copy.global_parameters_store_protocol_with_result != \ |
| 570 |
self.configuration.global_parameters_store_protocol_with_result: |
| 571 |
self.configuration.global_parameters_store_protocol_with_result = \ |
| 572 |
self.config_copy.global_parameters_store_protocol_with_result |
| 573 |
self.configuration.configuration_changed = True |
| 574 |
|
| 575 |
if self.config_copy.global_parameters_write_protocol_to_file != \ |
| 576 |
self.configuration.global_parameters_write_protocol_to_file: |
| 577 |
self.configuration.global_parameters_write_protocol_to_file = \ |
| 578 |
self.config_copy.global_parameters_write_protocol_to_file |
| 579 |
self.configuration.configuration_changed = True |
| 580 |
|
| 581 |
if self.config_copy.global_parameters_protocol_level != \ |
| 582 |
self.configuration.global_parameters_protocol_level: |
| 583 |
self.configuration.global_parameters_protocol_level = \ |
| 584 |
self.config_copy.global_parameters_protocol_level |
| 585 |
self.configuration.configuration_changed = True |
| 586 |
|
| 587 |
if self.config_copy.global_parameters_buffering_level != \ |
| 588 |
self.configuration.global_parameters_buffering_level: |
| 589 |
self.configuration.global_parameters_buffering_level = \ |
| 590 |
self.config_copy.global_parameters_buffering_level |
| 591 |
self.configuration.configuration_changed = True |
| 592 |
|
| 593 |
if self.config_copy.global_parameters_maximum_memory_active != \ |
| 594 |
self.configuration.global_parameters_maximum_memory_active: |
| 595 |
self.configuration.global_parameters_maximum_memory_active = \ |
| 596 |
self.config_copy.global_parameters_maximum_memory_active |
| 597 |
self.configuration.configuration_changed = True |
| 598 |
|
| 599 |
if self.config_copy.global_parameters_maximum_memory_amount != \ |
| 600 |
self.configuration.global_parameters_maximum_memory_amount: |
| 601 |
self.configuration.global_parameters_maximum_memory_amount = \ |
| 602 |
self.config_copy.global_parameters_maximum_memory_amount |
| 603 |
self.configuration.configuration_changed = True |
| 604 |
|
| 605 |
if self.config_copy.global_parameters_include_postprocessing != \ |
| 606 |
self.configuration.global_parameters_include_postprocessing: |
| 607 |
self.configuration.global_parameters_include_postprocessing = \ |
| 608 |
self.config_copy.global_parameters_include_postprocessing |
| 609 |
self.configuration.configuration_changed = True |
| 610 |
|
| 611 |
if self.config_copy.global_parameters_image_format != \ |
| 612 |
self.configuration.global_parameters_image_format: |
| 613 |
self.configuration.global_parameters_image_format = \ |
| 614 |
self.config_copy.global_parameters_image_format |
| 615 |
self.configuration.configuration_changed = True |
| 616 |
|
| 617 |
if self.config_copy.global_parameters_parameters_in_filename != \ |
| 618 |
self.configuration.global_parameters_parameters_in_filename: |
| 619 |
self.configuration.global_parameters_parameters_in_filename = \ |
| 620 |
self.config_copy.global_parameters_parameters_in_filename |
| 621 |
self.configuration.configuration_changed = True |
| 622 |
|
| 623 |
if self.config_copy.global_parameters_stack_number_frames != \ |
| 624 |
self.configuration.global_parameters_stack_number_frames: |
| 625 |
self.configuration.global_parameters_stack_number_frames = \ |
| 626 |
self.config_copy.global_parameters_stack_number_frames |
| 627 |
self.configuration.configuration_changed = True |
| 628 |
|
| 629 |
if self.config_copy.global_parameters_stack_percent_frames != \ |
| 630 |
self.configuration.global_parameters_stack_percent_frames: |
| 631 |
self.configuration.global_parameters_stack_percent_frames = \ |
| 632 |
self.config_copy.global_parameters_stack_percent_frames |
| 633 |
self.configuration.configuration_changed = True |
| 634 |
|
| 635 |
if self.config_copy.global_parameters_ap_box_size != \ |
| 636 |
self.configuration.global_parameters_ap_box_size: |
| 637 |
self.configuration.global_parameters_ap_box_size = \ |
| 638 |
self.config_copy.global_parameters_ap_box_size |
| 639 |
self.configuration.configuration_changed = True |
| 640 |
|
| 641 |
if self.config_copy.global_parameters_ap_number != \ |
| 642 |
self.configuration.global_parameters_ap_number: |
| 643 |
self.configuration.global_parameters_ap_number = \ |
| 644 |
self.config_copy.global_parameters_ap_number |
| 645 |
self.configuration.configuration_changed = True |
| 646 |
|
| 647 |
if self.config_copy.stack_frames_drizzle_factor_string != self.configuration.stack_frames_drizzle_factor_string: |
| 648 |
self.configuration.stack_frames_drizzle_factor_string = self.config_copy.stack_frames_drizzle_factor_string |
| 649 |
self.configuration.configuration_changed = True |
| 650 |
go_back_to_activities.append('Stack frames') |
| 651 |
|
| 652 |
|
| 653 |
self.configuration.set_derived_parameters() |
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
if go_back_to_activities: |
| 658 |
self.parent_gui.signal_set_go_back_activity.emit(go_back_to_activities) |
| 659 |
|
| 660 |
self.close() |
| 661 |
|
| 662 |
def reject(self): |
| 663 |
""" |
| 664 |
The Cancel button is pressed, discard the changes and close the GUI window. |
| 665 |
:return: - |
| 666 |
""" |
| 667 |
|
| 668 |
self.configuration.configuration_changed = False |
| 669 |
self.configuration.go_back_to_activity = None |
| 670 |
self.close() |
| 671 |
|
| 672 |
def closeEvent(self, event): |
| 673 |
|
| 674 |
|
| 675 |
if not self.configuration.config_file_exists or self.configuration.configuration_changed: |
| 676 |
self.configuration.write_config() |
| 677 |
|
| 678 |
self.parent_gui.display_widget(None, display=False) |
| 679 |
self.close() |