def accept(self): """ This method is invoked when the OK button is pressed. If at least one parameter has been changed, all text fields are tested for valid input data. Valid data are stored in the configuration object. If a test fails, a dialog prompts the user for correction. :return: - """ if self.configuration_changed: # Replace the original value with the corresponding entry in the gui text field. new_pixel_size = str(self.input_pixel_size.text()) # Check if the float entered is within the given bounds [0., 0.02]. If the return value # is None, an error was detected. In this case give an example for a correct value. if not Miscellaneous.testfloat(new_pixel_size, 0., 0.02): Miscellaneous.show_input_error("Pixel size (mm)", "0.00375") return else: # Set the corresponding entry in the configuration object to the valuee ntered. self.c.conf.set(self.section_name, 'pixel size', new_pixel_size) # Repeat the same logic for all parameters. new_pixel_horizontal = str(self.input_pixel_horizontal.text()) if not Miscellaneous.testint(new_pixel_horizontal, 1, 20000): Miscellaneous.show_input_error("Pixel count horizontal", "1280") return else: self.c.conf.set(self.section_name, 'pixel horizontal', new_pixel_horizontal) new_pixel_vertical = str(self.input_pixel_vertical.text()) if not Miscellaneous.testint(new_pixel_vertical, 1, 20000): Miscellaneous.show_input_error("Pixel count vertical", "960") return else: self.c.conf.set(self.section_name, 'pixel vertical', new_pixel_vertical) new_repetition_count = str(self.input_repetition_count.text()) if not Miscellaneous.testint(new_repetition_count, 1, 10): Miscellaneous.show_input_error("Repetition count", "3") return else: self.c.conf.set(self.section_name, 'repetition count', new_repetition_count) new_external_margin_pixel = str(self.input_external_margin.text()) if not Miscellaneous.testint(new_external_margin_pixel, 1, 10000): Miscellaneous.show_input_error("External margin pixel", "300") return else: self.c.conf.set(self.section_name, 'external margin pixel', new_external_margin_pixel) new_tile_overlap_pixel = str(self.input_tile_overlap.text()) if not Miscellaneous.testint(new_tile_overlap_pixel, 1, 5000): Miscellaneous.show_input_error("Tile overlap pixels", "150") return else: self.c.conf.set(self.section_name, 'tile overlap pixel', new_tile_overlap_pixel) # Copy all entries of the current camera model into the "Camera" section of the # configuration object. This section is displayed in the main configuration gui # under the heading "Camera". self.c.copy_camera_configuration(self.new_name) # Close the editing gui. self.close()
def accept(self): """ This method is invoked when the OK button is pressed. If at least one parameter has been changed, all text fields are tested for valid input data. Valid data are stored in the configuration object. If a test fails, a dialog prompts the user for correction. :return: - """ if self.configuration_changed: # Read the new camera name from the corresponding entry in the gui text field. new_name = str(self.input_camera_name.text()) # Test if there is already a camera with the same name in the configuration object. if new_name in self.camlist: Miscellaneous.show_input_error("Brand / Name (duplicate)", "Name not in list") return # Test if an empty name (invalid) is given. elif new_name == '': Miscellaneous.show_input_error("Brand / Name", "ZWO ASI120MM-S") return # Read the value for the new variable from the corresponding gui text field. new_pixel_size = str(self.input_pixel_size.text()) # Check if the float entered is within the given bounds [0., 0.02]. If the return value # is None, an error was detected. In this case give an example for a correct value. if not Miscellaneous.testfloat(new_pixel_size, 0., 0.02): Miscellaneous.show_input_error("Pixel size (mm)", "0.00375") return # Repeat the same logic for all parameters. new_pixel_horizontal = str(self.input_pixel_horizontal.text()) if not Miscellaneous.testint(new_pixel_horizontal, 1, 20000): Miscellaneous.show_input_error("Pixel count horizontal", "1280") return new_pixel_vertical = str(self.input_pixel_vertical.text()) if not Miscellaneous.testint(new_pixel_vertical, 1, 20000): Miscellaneous.show_input_error("Pixel count vertical", "960") return new_repetition_count = str(self.input_repetition_count.text()) if not Miscellaneous.testint(new_repetition_count, 1, 10): Miscellaneous.show_input_error("Repetition count", "3") return new_external_margin_pixel = str(self.input_external_margin.text()) if not Miscellaneous.testint(new_external_margin_pixel, 1, 10000): Miscellaneous.show_input_error("External margin pixel", "300") return new_tile_overlap_pixel = str(self.input_tile_overlap.text()) if not Miscellaneous.testint(new_tile_overlap_pixel, 1, 5000): Miscellaneous.show_input_error("Tile overlap pixels", "150") return # Create a new section in the configuration object for this camera model and store # the parameters there. section_name = 'Camera ' + new_name self.c.conf.add_section(section_name) self.c.conf.set(section_name, 'name', new_name) self.c.conf.set(section_name, 'pixel size', new_pixel_size) self.c.conf.set(section_name, 'pixel horizontal', new_pixel_horizontal) self.c.conf.set(section_name, 'pixel vertical', new_pixel_vertical) self.c.conf.set(section_name, 'repetition count', new_repetition_count) self.c.conf.set(section_name, 'external margin pixel', new_external_margin_pixel) self.c.conf.set(section_name, 'tile overlap pixel', new_tile_overlap_pixel) # Copy all entries of the current camera model into the "Camera" section of the # configuration object. This section is displayed in the main configuration gui under # the heading "Camera". self.c.copy_camera_configuration(new_name) # Close the input gui. self.close()
def accept(self): """ If the OK button is clicked and the configuration has been changed, test all parameters for validity. In case an out-of-bound value is entered, open an error correction dialog window. :return: - """ if self.configuration_changed: # If the tesselation is changed, most of the work done so far has to be repeated. # If not at begin of execution, ask the user if this is really what he/she wants to do. if self.initialized and self.tesselation_changed: # Ask the user for confirmation. quit_msg = "The configuration change will invalidate the videos recorded so far. " \ "Do you really want to restart the recording workflow?" reply = QtWidgets.QMessageBox.question(self, 'Message', quit_msg, QtWidgets.QMessageBox.Yes, QtWidgets.QMessageBox.No) # Negative reply: Ignore changed inputs and close the editor. if reply == QtWidgets.QMessageBox.No: self.reject() # Get the input string from the GUI text field. input_string = str(self.input_longitude.text()) # Test the input value if it is within the allowed interval (here [-360., +360.]) if Miscellaneous.testfloat(input_string, -360., 360.): self.c.conf.set("Geographical Position", "longitude", input_string) else: # The value entered is out of bound, show a valid input value example. Miscellaneous.show_input_error("Longitude", "7.39720") return # Repeat the same logic for the other input fields. input_string = str(self.input_latitude.text()) if Miscellaneous.testfloat(input_string, -90., 90.): self.c.conf.set("Geographical Position", "latitude", input_string) else: Miscellaneous.show_input_error("Latitude", "50.69190") return input_string = str(self.input_elevation.text()) if Miscellaneous.testint(input_string, -100, 9000): self.c.conf.set("Geographical Position", "elevation", input_string) else: Miscellaneous.show_input_error("Elevation", "250") return self.c.conf.set("Geographical Position", "timezone", self.timezone_chooser.currentText()) input_string = str(self.input_ip_address.text()) if Miscellaneous.testipaddress(input_string): self.c.conf.set("Camera", "ip address", input_string) else: Miscellaneous.show_input_error("IP address to access FireCapture", "192.168.0.34") return input_string = str(self.input_focal_length.text()) if Miscellaneous.testfloat(input_string, 0., 100000.): self.c.conf.set("Telescope", "focal length", input_string) else: Miscellaneous.show_input_error("Focal length", "4670.") return self.c.conf.set("Telescope", "interface type", str(self.mount_interface_chooser.currentText())) self.c.conf.set("Workflow", "protocol level", self.protocol_level_chooser.currentText()) self.c.set_protocol_level() self.c.conf.set("Workflow", "protocol to file", ['True', 'False'][self.protocol_to_file_chooser.currentIndex()]) self.c.conf.set("Workflow", "focus on star", ['True', 'False'][self.focus_on_star_chooser.currentIndex()]) self.c.conf.set("Workflow", "limb first", ['True', 'False'][self.limb_first_chooser.currentIndex()]) self.c.conf.set("Workflow", "camera automation", ['True', 'False'][self.camera_automation_chooser.currentIndex()]) input_string = str(self.input_camera_trigger_delay.text()) if Miscellaneous.testfloat(input_string, 0., 60.): self.c.conf.set("Workflow", "camera trigger delay", input_string) else: Miscellaneous.show_input_error("Camera trigger delay", "10.") return input_string = str(self.input_fig_size_horizontal.text()) if Miscellaneous.testfloat(input_string, 2., 25.): self.c.conf.set("Tile Visualization", "figsize horizontal", input_string) else: Miscellaneous.show_input_error("Figure size horizontal", "10.") return input_string = str(self.input_fig_size_vertical.text()) if Miscellaneous.testfloat(input_string, 2., 25.): self.c.conf.set("Tile Visualization", "figsize vertical", input_string) else: Miscellaneous.show_input_error("Figure size vertical", "10.") return input_string = str(self.input_label_font_size.text()) if Miscellaneous.testint(input_string, 6, 16): self.c.conf.set("Tile Visualization", "label fontsize", input_string) else: Miscellaneous.show_input_error("Font size for labels", "11") return input_string = str(self.input_label_shift.text()) if Miscellaneous.testfloat(input_string, 0., 1.): self.c.conf.set("Tile Visualization", "label shift", input_string) else: Miscellaneous.show_input_error("Label shift parameter", "0.8") return input_string = str(self.input_min_autoalign_interval.text()) if Miscellaneous.testfloat(input_string, 20., 1800.): self.c.conf.set("Alignment", "min autoalign interval", input_string) else: Miscellaneous.show_input_error("Minimum auto-alignment interval", "120.") return input_string = str(self.input_max_autoalign_interval.text()) if Miscellaneous.testfloat(input_string, 30., 3600.): self.c.conf.set("Alignment", "max autoalign interval", input_string) else: Miscellaneous.show_input_error("Maximum auto-alignment interval", "900.") return input_string = str(self.input_max_alignment_error.text()) if Miscellaneous.testfloat(input_string, 10., 60.): self.c.conf.set("Alignment", "max alignment error", input_string) else: Miscellaneous.show_input_error("Max alignment error", "30.") return if self.ascomeditor_called: # If the AscomEditor was called, new parameters are already checked for validity. self.c.conf.set("ASCOM", "guiding interval", self.new_ascom_guiding_interval) self.c.conf.set("ASCOM", "wait interval", self.new_ascom_wait_interval) self.c.conf.set("ASCOM", "pulse guide speed RA", self.new_ascom_pulse_guide_speed_ra) self.c.conf.set("ASCOM", "pulse guide speed DE", self.new_ascom_pulse_guide_speed_de) self.c.conf.set("ASCOM", "telescope lookup precision", self.new_ascom_telescope_lookup_precision) self.c.conf.set('ASCOM', 'telescope driver', self.ascomeditor.new_driver_name) if self.indieditor_called: # If the IndiEditor was called, copy back the current new values. self.c.conf.set("INDI", "web browser path", self.new_web_browser_path) self.c.conf.set("INDI", "server url", self.new_indi_server_url) self.c.conf.set("INDI", "pulse guide speed index", self.new_indi_pulse_guide_speed_index) self.c.conf.set("INDI", "guiding interval", self.new_indi_guiding_interval) self.c.conf.set("INDI", "wait interval", self.new_indi_wait_interval) self.c.conf.set("INDI", "telescope lookup precision", self.new_indi_telescope_lookup_precision) # All tests passed successfully, and all parameters have been written to the # configuration object. Close the GUI window. self.close()