def on_scaleCheckBox_clicked(self): """ set the earthquake symbols to proportional or standard based on checkbox state """ layer = QgsMapLayerRegistry.instance().mapLayersByName("earthquakes")[0] field = self.scaleComboBox.currentText() state = self.scaleCheckBox.checkState() #If checkbox is checked, then set proportional symbols based on the field chosen if state: self.scaleComboBox.setEnabled(True) self.label_17.setEnabled(True) self.label_16.setEnabled(True) if field == "Magnitude": expression = "(Magnitude^3)/10" elif field == "latitude": expression = "abs(latitude)/5" else: expression = "abs(longitude)/5" colourManager().propSymbols(layer, expression) #turn off proportional symbols else: colourManager().propSymbols(layer, "2") self.scaleComboBox.setEnabled(False) self.label_17.setEnabled(False) self.label_16.setEnabled(False)
def on_AddAttractionLayer_clicked(self): """ add the tourist attraction layer to the mao """ #check layer is valid attractions = AddLayers().CheckAddLayers(self.attractionLineEdit, "tourist_attraction") # add layer to map canvas QgsMapLayerRegistry.instance().addMapLayer(attractions) #if valid, populate the combobox on the next page with types of attraction if attractions is not None: attractionTypes = colourManager().getAttributes("LEGEND", attractions) self.fieldComboBox.addItems(attractionTypes) colorList = [QColor('#8dd3c7'), QColor('#ffffb3'), QColor('#bebada'), QColor('#fb8072'), QColor('#80b1d3'), QColor('#fdb462'), QColor('#b3de69'), QColor('#fccde5'), QColor('#d9d9d9'), QColor('#bc80bd'), QColor('#ccebc5'), QColor('#ffed6f'), QColor('#6699ff'),QColor('#ff1975'),QColor('#3399ff')] catList = [] #apply a default colour scheme to the attractions based on attraction type for attraction in attractionTypes: colorIndex = attractionTypes.index(attraction) symbol = QgsSymbolV2.defaultSymbol(attractions.geometryType()) symbol.setColor(colorList[colorIndex]) cat = QgsRendererCategoryV2(attraction, symbol , str(attraction)) catList.append(cat) renderer = QgsCategorizedSymbolRendererV2("LEGEND", catList) attractions.setRendererV2(renderer) #refresh map canvas and legend iface.mapCanvas().refresh() iface.legendInterface().refreshLayerSymbology(attractions) #make a legend table in the plugin colourManager().makeClassTable(attractions, "LEGEND", self.AttractionTableView)
def on_StyleTypecomboBox_activated(self, p0): """ Enable or disable the column/colour ramp comboBoxes or the colour selection button depending on what style type is selected """ style = self.StyleTypecomboBox.currentText() Countries = QgsMapLayerRegistry.instance().mapLayersByName("countries")[0] if style == "Single Colour": # Disable the categorised colour categories self.ColourRampcomboBox.setEnabled(False) self.ColumncomboBox.setEnabled(False) self.colourRampLabel.setEnabled(False) self.columnLabel.setEnabled(False) #enable the single colour button self.ChangeColourButton.setEnabled(True) #set the renderer to single symbol (i.e. all the same) symbol = QgsSymbolV2.defaultSymbol(Countries.geometryType()) Countries.setRendererV2(QgsSingleSymbolRendererV2(symbol)) #refresh the within-plugin legend model = QStandardItemModel(0, 0) model.clear() self.categoryTableView.setModel(model) else: #Enable the categorised colour categories self.ColourRampcomboBox.setEnabled(True) self.ColumncomboBox.setEnabled(True) self.colourRampLabel.setEnabled(True) self.columnLabel.setEnabled(True) # disable the single colour button self.ChangeColourButton.setEnabled(False) #Populate the countries column comboBox with the layer fields that you can style by self.ColumncomboBox.clear() self.ColumncomboBox_2.clear() self.ColumncomboBox_3.clear() fields = Countries.pendingFields() fieldList = [] for field in fields: fieldList.append(field.name()) self.ColumncomboBox.addItems(fieldList[3:]) self.ColumncomboBox_2.addItems(fieldList[3:]) self.ColumncomboBox_3.addItems(fieldList[3:]) #Ensure that the pop_group item is displayed by default self.ColumncomboBox_2.setCurrentIndex(2) #Populate the color ramp combobox with the names of the Color Brewer color ramp schemes self.ColourRampcomboBox.clear() self.ColourRampcomboBox_2.clear() rampNames = QgsVectorColorBrewerColorRampV2.listSchemeNames() for name in rampNames: self.ColourRampcomboBox.addItem(name) self.ColourRampcomboBox_2.addItem(name) self.ColourRampcomboBox_3.addItem(name) #self.makeClassTable() tableViews = [self.categoryTableView, self.categoryTableView_2] colourManager().makeClassTable(Countries, self.ColumncomboBox, tableViews)
def on_lineColourButton_clicked(self): """ Allow the user to select a single colour for the rivers layer """ #get the layer name layerName = self.lineLyrComboBox.currentText() #update the colour of the layer symbols colourManager().updateSingleColour(layerName)
def on_buttonBox_accepted(self): """ Slot documentation goes here. """ if self.svgDict != None: MagicMarkers().setSVG("tourist_attraction", self.attribute , self.scene, self.svgDict) attractions = QgsMapLayerRegistry.instance().mapLayersByName("tourist_attraction")[0] colourManager().makeClassTable(attractions, "LEGEND", self.tableView) self.close()
def on_scaleComboBox_activated(self, p0): """ scale earthquake symbols based on the field chosen in scaleComboBox """ layer = QgsMapLayerRegistry.instance().mapLayersByName("earthquakes")[0] field = self.scaleComboBox.currentText() #set expression for proportional areas based on chosen field if field == "Magnitude": expression = "(Magnitude^3)/10" elif field == "latitude": expression = "abs(latitude)/5" else: expression = "abs(longitude)/5" #make symbols proportional colourManager().propSymbols(layer, expression)
def on_bufferColourButton_clicked(self): """ change the colour of the buffer layer """ #set up message box msgBox=QMessageBox() msgBox.setIcon(3) #If a buffer layer has been created, update the colours if self.bufferLayer is not None: colourManager().updateSingleColour(self.bufferLayer) #if not bring up a message box else: msgBox.setText("Could not re-colour the layer") msgBox.setInformativeText(" QGISforSchools cannot find the buffer layer. Try going back a step and making a new one.") msgBox.exec_() SpatialQuery().populateSrcBox(self.inputComboBox_2, self.refComboBox) SpatialQuery().populateSrcBox(self.lyrComboBox)
def on_ColumncomboBox_3_activated(self, p0): """ Change classified values based on selected column """ colourManager().changeColumnColor("countries", self.ColumncomboBox_3, self.ColourRampcomboBox_3) colourManager().changeColumnColor("obesity", self.obesityColumncomboBox, self.ColourRampcomboBox_3) colourManager().make3ClassTable("countries", "obesity", self.ColumncomboBox_3, self.obesityColumncomboBox, self.obesityTableView)
def on_ColourRampcomboBox_3_activated(self, p0): """ classify the chosen field and colour each class based on the colour ramp selected """ colourManager().changeColumnColor("countries", self.ColumncomboBox_3, self.ColourRampcomboBox_3) colourManager().changeColumnColor("obesity", self.obesityColumncomboBox, self.ColourRampcomboBox_3) colourManager().make3ClassTable("countries", "obesity", self.ColumncomboBox_3, self.obesityColumncomboBox, self.obesityTableView)
def on_ColourRampcomboBox_activated(self, p0): """ classify the chosen field and colour each class based on the colour ramp selected """ tableViews = self.earthquakeTableView colourManager().setGraduatedColour("earthquakes", self.ColumncomboBox, self.ColourRampcomboBox, 5, tableViews)
def on_ChangeColourButton_clicked(self): """ Allow the user to select a single colour for the Countries layer """ colourManager().updateSingleColour("countries")
def on_ColumncomboBox_2_activated(self, p0): """ Change classified values based on selected column """ tableViews = [self.categoryTableView, self.categoryTableView_2] colourManager().changeColumnColor("countries", self.ColumncomboBox_2, self.ColourRampcomboBox_2, tableViews)
def on_ColourRampcomboBox_2_activated(self, p0): """ classify the chosen field and colour each class based on the colour ramp selected """ tableViews = [self.categoryTableView, self.categoryTableView_2] colourManager().changeColumnColor("countries", self.ColumncomboBox_2, self.ColourRampcomboBox_2, tableViews)
def on_woodColourButton_clicked(self): """ Allow the user to select a single colour for the woodland layer """ colourManager().updateSingleColour("woodland", True)
def on_ColumncomboBox_activated(self, p0): """ Change classified values based on selected column """ tableViews = self.earthquakeTableView colourManager().setGraduatedColour("earthquakes", self.ColumncomboBox, self.ColourRampcomboBox, 5, tableViews)
def on_stationColour_clicked(self): """ Allow the user to select a single colour for the station points """ colourManager().updateSingleColour("railway_station")
def on_urbanColourButton_clicked(self): """ Allow the user to select a single colour for the buildings layer """ colourManager().updateSingleColour("buildings", True)
def on_riverColourButton_clicked(self): """ Allow the user to select a single colour for the rivers layer """ colourManager().updateSingleColour("rivers")