def get_color(self): """ Returns the colour of the 'pushButton_colour' Button """ button = self.dialog.pushButton_colour return QtGui.QPalette(button.palette()).color( QtGui.QPalette.Button).getRgbF()
def __init__(self, parent=None, settings_dict=None, wms_connected=False): """ Arguments: parent -- Qt widget that is parent to this widget. settings_dict -- dictionary containing topview options. """ super(MSS_TV_MapAppearanceDialog, self).__init__(parent) self.setupUi(self) if settings_dict is None: settings_dict = {"draw_graticule": True, "draw_coastlines": True, "fill_waterbodies": True, "fill_continents": True, "draw_flighttrack": True, "label_flighttrack": True, "colour_water": (0, 0, 0, 0), "colour_land": (0, 0, 0, 0), "colour_ft_vertices": (0, 0, 0, 0), "colour_ft_waypoints": (0, 0, 0, 0)} settings_dict["fill_waterbodies"] = True # removing water bodies does not work properly self.wms_connected = wms_connected # check parent.wms_connected to disable cbFillWaterBodies and cbFillContinents if self.wms_connected: self.cbFillContinents.setChecked(False) self.cbFillWaterBodies.setChecked(False) self.cbFillContinents.setEnabled(False) self.cbFillContinents.setStyleSheet("color: black") self.cbFillWaterBodies.setStyleSheet("color: black") else: self.cbFillWaterBodies.setChecked(settings_dict["fill_waterbodies"]) self.cbFillWaterBodies.setEnabled(False) self.cbFillContinents.setChecked(settings_dict["fill_continents"]) self.cbFillContinents.setEnabled(True) self.cbDrawGraticule.setChecked(settings_dict["draw_graticule"]) self.cbDrawCoastlines.setChecked(settings_dict["draw_coastlines"]) self.cbDrawFlightTrack.setChecked(settings_dict["draw_flighttrack"]) self.cbLabelFlightTrack.setChecked(settings_dict["label_flighttrack"]) for button, ids in [(self.btWaterColour, "colour_water"), (self.btLandColour, "colour_land"), (self.btWaypointsColour, "colour_ft_waypoints"), (self.btVerticesColour, "colour_ft_vertices")]: palette = QtGui.QPalette(button.palette()) colour = QtGui.QColor() colour.setRgbF(*settings_dict[ids]) palette.setColor(QtGui.QPalette.Button, colour) button.setPalette(palette) # Connect colour button signals. self.btWaterColour.clicked.connect(functools.partial(self.setColour, "water")) self.btLandColour.clicked.connect(functools.partial(self.setColour, "land")) self.btWaypointsColour.clicked.connect(functools.partial(self.setColour, "ft_waypoints")) self.btVerticesColour.clicked.connect(functools.partial(self.setColour, "ft_vertices"))
def set_tangentpoint_colour(self): """Slot for the colour buttons: Opens a QColorDialog and sets the new button face colour. """ button = self.btTangentsColour palette = QtGui.QPalette(button.palette()) colour = palette.color(QtGui.QPalette.Button) colour = QtWidgets.QColorDialog.getColor(colour) if colour.isValid(): palette.setColor(QtGui.QPalette.Button, colour) button.setPalette(palette) self.update_settings()
def get_settings(self): """ """ settings_dict = { "draw_graticule": self.cbDrawGraticule.isChecked(), "draw_coastlines": self.cbDrawCoastlines.isChecked(), "fill_waterbodies": self.cbFillWaterBodies.isChecked(), "fill_continents": self.cbFillContinents.isChecked(), "draw_flighttrack": self.cbDrawFlightTrack.isChecked(), "label_flighttrack": self.cbLabelFlightTrack.isChecked(), "colour_water": QtGui.QPalette(self.btWaterColour.palette()).color(QtGui.QPalette.Button).getRgbF(), "colour_land": QtGui.QPalette(self.btLandColour.palette()).color(QtGui.QPalette.Button).getRgbF(), "colour_ft_vertices": QtGui.QPalette(self.btVerticesColour.palette()).color(QtGui.QPalette.Button).getRgbF(), "colour_ft_waypoints": QtGui.QPalette(self.btWaypointsColour.palette()).color(QtGui.QPalette.Button).getRgbF(), } return settings_dict
def get_settings(self): """Return settings dictionary with values from the GUI elements. """ settings_dict = { "vertical_extent": (float(self.sbPbot.value()), float(self.sbPtop.value())), "vertical_axis": self.cbVerticalAxis.currentText(), "flightlevels": self.get_flight_levels(), "draw_ceiling": self.cbDrawCeiling.isChecked(), "draw_flightlevels": self.cbDrawFlightLevels.isChecked(), "draw_flighttrack": self.cbDrawFlightTrack.isChecked(), "fill_flighttrack": self.cbFillFlightTrack.isChecked(), "label_flighttrack": self.cbLabelFlightTrack.isChecked(), "colour_ft_vertices": QtGui.QPalette(self.btVerticesColour.palette()).color(QtGui.QPalette.Button).getRgbF(), "colour_ft_waypoints": QtGui.QPalette(self.btWaypointsColour.palette()).color(QtGui.QPalette.Button).getRgbF(), "colour_ft_fill": QtGui.QPalette(self.btFillColour.palette()).color(QtGui.QPalette.Button).getRgbF(), "colour_ceiling": QtGui.QPalette(self.btCeilingColour.palette()).color(QtGui.QPalette.Button).getRgbF(), } return settings_dict
def __init__(self, parent=None, view=None): """ Arguments: parent -- Qt widget that is parent to this widget. view -- reference to mpl canvas class """ super(RemoteSensingControlWidget, self).__init__(parent) self.setupUi(self) self.view = view self.load = Loader(MSS_CONFIG_PATH, verbose=False) self.planets = self.load('de421.bsp') self.timescale = self.load.timescale(builtin=True) # don't download files, use shipped files button = self.btTangentsColour palette = QtGui.QPalette(button.palette()) colour = QtGui.QColor() colour.setRgbF(1, 0, 0, 1) palette.setColor(QtGui.QPalette.Button, colour) button.setPalette(palette) self.dsbTangentHeight.setValue(10.) self.dsbObsAngleAzimuth.setValue(90.) self.dsbObsAngleElevation.setValue(-1.0) # update plot on every value change self.cbDrawTangents.stateChanged.connect(self.update_settings) self.cbShowSolarAngle.stateChanged.connect(self.update_settings) self.btTangentsColour.clicked.connect(self.set_tangentpoint_colour) self.dsbTangentHeight.valueChanged.connect(self.update_settings) self.dsbObsAngleAzimuth.valueChanged.connect(self.update_settings) self.dsbObsAngleElevation.valueChanged.connect(self.update_settings) self.cbSolarBody.currentIndexChanged.connect(self.update_settings) self.cbSolarAngleType.currentIndexChanged.connect(self.update_settings) self.lbSolarCmap.setText( "Solar angle colours, dark to light: reds (0-15), violets (15-45), greens (45-180)" ) self.solar_cmap = ListedColormap([(1.00, 0.00, 0.00, 1.0), (1.00, 0.45, 0.00, 1.0), (1.00, 0.75, 0.00, 1.0), (0.47, 0.10, 1.00, 1.0), (0.72, 0.38, 1.00, 1.0), (1.00, 0.55, 1.00, 1.0), (0.00, 0.70, 0.00, 1.0), (0.33, 0.85, 0.33, 1.0), (0.65, 1.00, 0.65, 1.0)]) self.solar_norm = BoundaryNorm( [0, 5, 10, 15, 25, 35, 45, 90, 135, 180], self.solar_cmap.N) self.update_settings()
def compute_tangent_lines(self, bmap, wp_vertices, wp_heights): """ Computes Tangent points of limb sounders aboard the aircraft Args: bmap: Projection of TopView wp_vertices: waypoints of the flight path wp_heights: altitude of the waypoints of flight path Returns: LineCollection of dotted lines at tangent point locations """ x, y = list(zip(*wp_vertices)) wp_lons, wp_lats = bmap(x, y, inverse=True) fine_lines = [ bmap.gcpoints2(wp_lons[i], wp_lats[i], wp_lons[i + 1], wp_lats[i + 1], del_s=10., map_coords=False) for i in range(len(wp_lons) - 1) ] line_heights = [ np.linspace(wp_heights[i], wp_heights[i + 1], num=len(fine_lines[i][0])) for i in range(len(fine_lines)) ] # fine_lines = list of tuples with x-list and y-list for each segment tplines = [ self.tangent_point_coordinates( fine_lines[i][0], fine_lines[i][1], line_heights[i], cut_height=self.dsbTangentHeight.value()) for i in range(len(fine_lines)) ] dirlines = self.direction_coordinates(wp_lons, wp_lats) lines = tplines + dirlines for i, line in enumerate(lines): for j, (lon, lat) in enumerate(line): line[j] = bmap(lon, lat) lines[i] = line return LineCollection( lines, colors=QtGui.QPalette(self.btTangentsColour.palette()).color( QtGui.QPalette.Button).getRgbF(), zorder=2, animated=True, linewidth=3, linestyles=[':'] * len(tplines) + ['-'] * len(dirlines))
def paint(self, painter, option, index): """Colours waypoints with a minor waypoint number (i.e. intermediate waypoints generated by the flight performance service) in red. """ wpnumber_minor = index.model().waypoint_data( index.row()).wpnumber_minor if wpnumber_minor is not None and wpnumber_minor > 0: newpalette = QtGui.QPalette(option.palette) colour = QtGui.QColor(170, 0, 0) # dark red newpalette.setColor(QtGui.QPalette.Text, colour) colour = QtGui.QColor(255, 255, 0) # yellow newpalette.setColor(QtGui.QPalette.HighlightedText, colour) option.palette = newpalette QtWidgets.QItemDelegate.paint(self, painter, option, index)
def open_customize_kml_dialog(self): file = self.listWidget.currentItem().text() # Set the colour of the Colour button to the colour of specific KML plot if self.dict_files[file]["color"] is not None: palette = QtGui.QPalette(self.dialog.pushButton_colour.palette()) colour = QtGui.QColor() colour.setRgbF(*self.set_color(file)) palette.setColor(QtGui.QPalette.Button, colour) self.dialog.pushButton_colour.setPalette(palette) # Set the linewidth value to the linewidth of specific KML plot if self.dict_files[file]["linewidth"] is not None: self.dialog.dsb_linewidth.setValue(self.set_linewidth(file)) self.dialog.show()
def select_color(self): """ Stores current selected file; select colour using Palette """ file = self.listWidget.currentItem().text() button = self.dialog.pushButton_colour palette = QtGui.QPalette(button.palette()) colour = palette.color(QtGui.QPalette.Button) colour = QtWidgets.QColorDialog.getColor( colour) # opens select colour palette if colour.isValid(): palette.setColor(QtGui.QPalette.Button, colour) button.setPalette(palette) # finally sets the colour of the button self.set_attribute_color(file)
def setColour(self, which): """Slot for the colour buttons: Opens a QColorDialog and sets the new button face colour. """ if which == "water": button = self.btWaterColour elif which == "land": button = self.btLandColour elif which == "ft_vertices": button = self.btVerticesColour elif which == "ft_waypoints": button = self.btWaypointsColour palette = QtGui.QPalette(button.palette()) colour = palette.color(QtGui.QPalette.Button) colour = QtWidgets.QColorDialog.getColor(colour) if colour.isValid(): palette.setColor(QtGui.QPalette.Button, colour) button.setPalette(palette)
def setColour(self, which): """Slot for the colour buttons: Opens a QColorDialog and sets the new button face colour. """ if which == "ft_fill": button = self.btFillColour elif which == "ft_vertices": button = self.btVerticesColour elif which == "ft_waypoints": button = self.btWaypointsColour elif which == "ceiling": button = self.btCeilingColour palette = QtGui.QPalette(button.palette()) colour = palette.color(QtGui.QPalette.Button) colour = QtWidgets.QColorDialog.getColor(colour) if colour.isValid(): if which == "ft_fill": # Fill colour is transparent with an alpha value of 0.15. If # you like to change this, modify the PathInteractor class. colour.setAlphaF(0.15) palette.setColor(QtGui.QPalette.Button, colour) button.setPalette(palette)
def __init__(self, parent=None, settings_dict=None): """ Arguments: parent -- Qt widget that is parent to this widget. settings_dict -- dictionary containing sideview options. """ _translate = QtCore.QCoreApplication.translate super(MSS_SV_OptionsDialog, self).__init__(parent) self.setupUi(self) default_settings_dict = { "vertical_extent": (1050, 180), "vertical_axis": "pressure", "flightlevels": [300, 320, 340], "draw_flightlevels": True, "draw_flighttrack": True, "fill_flighttrack": True, "label_flighttrack": True, "colour_ft_vertices": (0, 0, 0, 0), "colour_ft_waypoints": (0, 0, 0, 0), "colour_ft_fill": (0, 0, 0, 0), "draw_ceiling": True, "colour_ceiling": (0.1, 0.5, 0.1, 0), } suffixes = [' hpa', ' km', ' hft'] if settings_dict is not None: default_settings_dict.update(settings_dict) settings_dict = default_settings_dict self.setBotTopLimits(settings_dict["vertical_axis"]) self.sbPbot.setValue(settings_dict["vertical_extent"][0]) self.sbPtop.setValue(settings_dict["vertical_extent"][1]) flightlevels = settings_dict["flightlevels"] self.tableWidget.setRowCount(len(flightlevels)) flightlevels.sort() for i, level in enumerate(flightlevels): tableitem = QtWidgets.QTableWidgetItem(str(int(level))) self.tableWidget.setItem(i, 0, tableitem) for i in range(self.cbVerticalAxis.count()): if self.cbVerticalAxis.itemText(i) == settings_dict["vertical_axis"]: self.cbVerticalAxis.setCurrentIndex(i) self.sbPbot.setSuffix(_translate("SideViewOptionsDialog", suffixes[i])) self.sbPtop.setSuffix(_translate("SideViewOptionsDialog", suffixes[i])) self.cbDrawFlightLevels.setChecked(settings_dict["draw_flightlevels"]) self.cbDrawFlightTrack.setChecked(settings_dict["draw_flighttrack"]) self.cbFillFlightTrack.setChecked(settings_dict["fill_flighttrack"]) self.cbLabelFlightTrack.setChecked(settings_dict["label_flighttrack"]) self.cbDrawCeiling.setChecked(settings_dict["draw_ceiling"]) for button, ids in [(self.btFillColour, "colour_ft_fill"), (self.btWaypointsColour, "colour_ft_waypoints"), (self.btVerticesColour, "colour_ft_vertices"), (self.btCeilingColour, "colour_ceiling")]: palette = QtGui.QPalette(button.palette()) colour = QtGui.QColor() colour.setRgbF(*settings_dict[ids]) palette.setColor(QtGui.QPalette.Button, colour) button.setPalette(palette) # Connect colour button signals. self.cbVerticalAxis.view().pressed.connect(self.verticalunitsclicked) self.btFillColour.clicked.connect(functools.partial(self.setColour, "ft_fill")) self.btWaypointsColour.clicked.connect(functools.partial(self.setColour, "ft_waypoints")) self.btVerticesColour.clicked.connect(functools.partial(self.setColour, "ft_vertices")) self.btCeilingColour.clicked.connect(functools.partial(self.setColour, "ceiling")) self.btAdd.clicked.connect(self.addItem) self.btDelete.clicked.connect(self.deleteSelected) self.tableWidget.itemChanged.connect(self.itemChanged)
def __init__(self, parent=None, view=None): super(KMLOverlayControlWidget, self).__init__(parent) self.setupUi(self) self.view = view # canvas self.kml = None self.patch = None # patch refers to plottings on the map self.dict_files = { } # Dictionary of files added; key : patch , color , linewidth # Connect slots and signals. self.btSelectFile.clicked.connect(self.get_file) self.pushButton_remove.clicked.connect(self.remove_file) self.pushButton_select_all.clicked.connect(self.select_all) self.pushButton_unselect_all.clicked.connect(self.unselect_all) self.pushButton_merge.clicked.connect(self.merge_file) self.labelStatusBar.setText( "Status: Click on Add KML Files to get started.") self.dialog = CustomizeKMLWidget( self) # create object of dialog UI Box self.listWidget.itemDoubleClicked.connect( self.open_customize_kml_dialog) self.dialog.pushButton_colour.clicked.connect(self.select_color) self.listWidget.itemChanged.connect( self.load_file) # list of files in ListWidget self.settings_tag = "kmldock" settings = load_settings_qsettings( self.settings_tag, { "filename": "", "linewidth": 5, "colour": (0, 0, 0, 1), "saved_files": {} }) # initial settings self.directory_location = settings["filename"] self.dialog.dsb_linewidth.setValue(settings["linewidth"]) # Restore previously opened files if settings["saved_files"] is not None: delete_files = [] # list to store non-existing files self.dict_files = settings["saved_files"] for file in self.dict_files: if os.path.isfile(file) is True: self.create_list_item(file) else: delete_files.append(file) # add non-existent files to list logging.info(file + " does not exist in the directory anymore") for file in delete_files: del self.dict_files[ file] # remove non-existent files from dictionary self.load_file() palette = QtGui.QPalette(self.dialog.pushButton_colour.palette()) colour = QtGui.QColor() colour.setRgbF(*settings["colour"]) palette.setColor(QtGui.QPalette.Button, colour) self.dialog.pushButton_colour.setPalette( palette) # sets the last colour before closing KML Overlay self.dialog.dsb_linewidth.valueChanged.connect(self.select_linewidth)