本文整理汇总了Python中qgis.PyQt.QtGui.QColor类的典型用法代码示例。如果您正苦于以下问题:Python QColor类的具体用法?Python QColor怎么用?Python QColor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QColor类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: runTestForLayer
def runTestForLayer(self, layer, testname):
tempdir = tempfile.mkdtemp()
layer = QgsVectorLayer(layer, 'Layer', 'ogr')
QgsProject.instance().addMapLayer(layer)
self.iface.mapCanvas().setExtent(layer.extent())
geom = next(layer.getFeatures()).geometry()
highlight = QgsHighlight(self.iface.mapCanvas(), geom, layer)
color = QColor(Qt.red)
highlight.setColor(color)
highlight.setWidth(2)
color.setAlpha(50)
highlight.setFillColor(color)
highlight.show()
image = QImage(QSize(400, 400), QImage.Format_ARGB32)
image.fill(Qt.white)
painter = QPainter()
painter.begin(image)
self.iface.mapCanvas().render(painter)
painter.end()
control_image = os.path.join(tempdir, 'highlight_{}.png'.format(testname))
image.save(control_image)
checker = QgsRenderChecker()
checker.setControlPathPrefix("highlight")
checker.setControlName("expected_highlight_{}".format(testname))
checker.setRenderedImage(control_image)
self.assertTrue(checker.compareImages("highlight_{}".format(testname)))
shutil.rmtree(tempdir)
开发者ID:ufolr,项目名称:QGIS,代码行数:31,代码来源:test_qgshighlight.py
示例2: __init__
def __init__(self):
self.iface = iface
self.srs_wgs84 = QgsCoordinateReferenceSystem(4326)
self.transform_decorator = QgsCoordinateTransform(self.srs_wgs84, self.srs_wgs84)
self.rb = QgsRubberBand(self.iface.mapCanvas(), QGisGeometryType.Point)
self.rb.setColor(QColor('magenta'))
self.rb.setIconSize(12)
self.features_rb = QgsRubberBand(self.iface.mapCanvas(), QGisGeometryType.Point)
magenta_transp = QColor('#3388ff')
magenta_transp.setAlpha(120)
self.features_rb.setColor(magenta_transp)
self.features_rb.setIconSize(12)
self.features_rb.setWidth(2)
开发者ID:nextgis,项目名称:quickmapservices,代码行数:16,代码来源:rb_result_renderer.py
示例3: __init__
def __init__(self):
QWidget.__init__(self)
self.setWindowTitle(self.tr('Qdraw - Settings'))
self.setFixedSize(320, 100)
self.center()
# default color
self.color = QColor(60, 151, 255, 255)
self.sld_opacity = QSlider(Qt.Horizontal, self)
self.sld_opacity.setRange(0, 255)
self.sld_opacity.setValue(255)
self.sld_opacity.tracking = True
self.sld_opacity.valueChanged.connect(self.handler_opacitySliderValue)
self.lbl_opacity = QLabel(self.tr('Opacity') + ': 100%', self)
self.dlg_color = QColorDialog(self)
btn_chColor = QPushButton(self.tr('Change the drawing color'), self)
btn_chColor.clicked.connect(self.handler_chColor)
vbox = QVBoxLayout()
vbox.addWidget(self.lbl_opacity)
vbox.addWidget(self.sld_opacity)
vbox.addWidget(btn_chColor)
self.setLayout(vbox)
开发者ID:jeremyk6,项目名称:qdraw,代码行数:26,代码来源:qdrawsettings.py
示例4: renderTile
def renderTile(self, x, y, feedback, make_trans):
"""
Render one tile
:param x: The x index of the current tile
:param y: The y index of the current tile
"""
if make_trans:
background_color = QColor(255, 255, 255, 0)
self.image.fill(background_color.rgba())
else:
background_color = QColor(255, 255, 255)
self.image.fill(background_color.rgb())
painter = QPainter(self.image)
self.settings.setExtent(QgsRectangle(
self.extent.xMinimum() + x * self.mupp * self.tile_size,
self.extent.yMaximum() - (y + 1) * self.mupp * self.tile_size,
self.extent.xMinimum() + (x + 1) * self.mupp * self.tile_size,
self.extent.yMaximum() - y * self.mupp * self.tile_size))
job = QgsMapRendererCustomPainterJob(self.settings, painter)
job.renderSynchronously()
painter.end()
# Needs not to be deleted or Windows will kill it too early...
tmpfile = tempfile.NamedTemporaryFile(suffix='.png', delete=False)
try:
self.image.save(tmpfile.name)
src_ds = osgeo.gdal.Open(tmpfile.name)
self.dataset.WriteRaster(x * self.tile_size, y * self.tile_size,
self.tile_size, self.tile_size,
src_ds.ReadRaster(0, 0, self.tile_size,
self.tile_size))
except Exception as e:
feedback.reportError(str(e))
finally:
del src_ds
tmpfile.close()
os.unlink(tmpfile.name)
开发者ID:lynxlynxlynx,项目名称:Quantum-GIS,代码行数:43,代码来源:Rasterize.py
示例5: testSingleBandPseudoColorRenderer_Exact
def testSingleBandPseudoColorRenderer_Exact(self):
# get min and max of the band to renderer
bandNo = 3
stats = self.raster_layer.dataProvider().bandStatistics(bandNo, QgsRasterBandStats.Min | QgsRasterBandStats.Max)
minValue = stats.minimumValue
maxValue = stats.maximumValue
# create shader for the renderer
shader = QgsRasterShader(minValue, maxValue)
colorRampShaderFcn = QgsColorRampShader(minValue, maxValue)
colorRampShaderFcn.setColorRampType(QgsColorRampShader.Exact)
colorRampShaderFcn.setClassificationMode(QgsColorRampShader.Continuous)
colorRampShaderFcn.setClip(True)
items = []
for index in range(10):
items.append(QgsColorRampShader.ColorRampItem(index, QColor('#{0:02d}{0:02d}{0:02d}'.format(index)), "{}".format(index)))
colorRampShaderFcn.setColorRampItemList(items)
shader.setRasterShaderFunction(colorRampShaderFcn)
# create instance to test
rasterRenderer = QgsSingleBandPseudoColorRenderer(self.raster_layer.dataProvider(), bandNo, shader)
self.raster_layer.setRenderer(rasterRenderer)
# do test
dom, root = self.rendererToSld(self.raster_layer.renderer())
self.assertNoOpacity(root)
self.assertChannelBand(root, 'sld:GrayChannel', '{}'.format(bandNo))
# check ColorMapEntry classes
colorMap = root.elementsByTagName('sld:ColorMap')
colorMap = colorMap.item(0).toElement()
self.assertFalse(colorMap.isNull())
self.assertEqual(colorMap.attribute('type'), 'values')
self.assertFalse(colorMap.hasAttribute('extendend'))
colorMapEntries = colorMap.elementsByTagName('sld:ColorMapEntry')
self.assertEqual(colorMapEntries.count(), 10)
for index in range(colorMapEntries.count()):
colorMapEntry = colorMapEntries.at(index).toElement()
self.assertEqual(colorMapEntry.attribute('quantity'), '{}'.format(index))
self.assertEqual(colorMapEntry.attribute('label'), '{}'.format(index))
self.assertEqual(colorMapEntry.attribute('opacity'), '')
self.assertEqual(colorMapEntry.attribute('color'), '#{0:02d}{0:02d}{0:02d}'.format(index))
# add check that is set ColoMap extended="true" if colormap is bigger that 255 entries
# !NOTE! can't reuse previous shader => segmentation fault
shader = QgsRasterShader(minValue, maxValue)
colorRampShaderFcn = QgsColorRampShader(minValue, maxValue)
colorRampShaderFcn.setColorRampType(QgsColorRampShader.Exact)
colorRampShaderFcn.setClassificationMode(QgsColorRampShader.Continuous)
colorRampShaderFcn.setClip(True)
items = []
for index in range(255):
items.append(QgsColorRampShader.ColorRampItem(index, QColor.fromHsv(index, 255, 255, 255), "{}".format(index)))
colorRampShaderFcn.setColorRampItemList(items)
shader.setRasterShaderFunction(colorRampShaderFcn)
# create instance to test
rasterRenderer = QgsSingleBandPseudoColorRenderer(self.raster_layer.dataProvider(), bandNo, shader)
开发者ID:yoichigmf,项目名称:QGIS,代码行数:54,代码来源:test_qgsrasterrerderer_createsld.py
示例6: __init__
def __init__(self, methodName):
"""Run once on class initialization."""
unittest.TestCase.__init__(self, methodName)
# create composition
self.mComposition = QgsComposition(QgsProject.instance())
self.mComposition.setPaperSize(297, 210)
self.mComposerShape = QgsComposerShape(20, 20, 150, 100, self.mComposition)
self.mComposerShape.setBackgroundColor(QColor.fromRgb(255, 150, 0))
self.mComposition.addComposerShape(self.mComposerShape)
开发者ID:enzogis,项目名称:QGIS,代码行数:11,代码来源:test_qgscomposershapes.py
示例7: initGui
def initGui(self):
# Create action that will start plugin configuration
self.action = QAction(
QIcon(self.plugin_dir + "/icon.svg"),
u"Distribution Map Generator...", self.iface.mainWindow())
# connect the action to the run method
self.action.triggered.connect(self.run)
self.dlg.ui.buttonBox.accepted.connect(self.confirm)
# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu(u"&Distribution Map Generator", self.action)
# Set colour for output background colour chooser:
self.BACKGROUND_COLOUR = QColor(192,192,255)
self.dlg.ui.frmColour.setStyleSheet("QWidget { background-color: %s }"
% self.BACKGROUND_COLOUR.name())
开发者ID:rudivs,项目名称:DistroMap,代码行数:17,代码来源:distromap.py
示例8: envelope2layer
def envelope2layer(self, envelope):
"""Transform metadata envelope into a QGIS layer."""
# layer
md_lyr = QgsVectorLayer("Polygon?crs=epsg:4326",
"Metadata envelope",
"memory")
md_lyr.setLayerTransparency(75)
symbols = md_lyr.rendererV2().symbols()
symbol = symbols[0]
symbol.setColor(QColor.fromRgb(255,20,147))
if envelope.get("type") == "Polygon":
# parse coordinates
coords = envelope.get("coordinates")[0]
poly_pts = [QgsPoint(round(i[0], 3),
round(i[1], 3))
for i in coords]
# add geometry to layer
poly = QgsFeature()
poly.setGeometry(QgsGeometry.fromPolygon([poly_pts]))
md_lyr.dataProvider().addFeatures([poly])
md_lyr.updateExtents()
elif envelope.get("type") == "MultiPolygon":
coords = envelope.get("bbox")
bbox = QgsRectangle(round(coords[0], 3),
round(coords[1], 3),
round(coords[2], 3),
round(coords[3], 3),)
poly = QgsFeature()
poly.setGeometry(QgsGeometry.fromWkt(bbox.asWktPolygon()))
md_lyr.dataProvider().addFeatures([poly])
md_lyr.updateExtents()
elif envelope.get("type") == "Point":
return md_lyr
else:
pass
# method ending
return md_lyr
开发者ID:isogeo,项目名称:isogeo-plugin-qgis,代码行数:38,代码来源:metadata_display.py
示例9: QdrawSettings
class QdrawSettings(QWidget):
"""Window used to change settings (transparency/color)"""
settingsChanged = pyqtSignal()
def __init__(self):
QWidget.__init__(self)
self.setWindowTitle(self.tr('Qdraw - Settings'))
self.setFixedSize(320, 100)
self.center()
# default color
self.color = QColor(60, 151, 255, 255)
self.sld_opacity = QSlider(Qt.Horizontal, self)
self.sld_opacity.setRange(0, 255)
self.sld_opacity.setValue(255)
self.sld_opacity.tracking = True
self.sld_opacity.valueChanged.connect(self.handler_opacitySliderValue)
self.lbl_opacity = QLabel(self.tr('Opacity') + ': 100%', self)
self.dlg_color = QColorDialog(self)
btn_chColor = QPushButton(self.tr('Change the drawing color'), self)
btn_chColor.clicked.connect(self.handler_chColor)
vbox = QVBoxLayout()
vbox.addWidget(self.lbl_opacity)
vbox.addWidget(self.sld_opacity)
vbox.addWidget(btn_chColor)
self.setLayout(vbox)
def tr(self, message):
return QCoreApplication.translate('Qdraw', message)
def handler_opacitySliderValue(self, val):
self.color.setAlpha(val)
self.lbl_opacity.setText(
self.tr('Opacity')+': '+str(int((float(val) / 255) * 100))+'%')
self.settingsChanged.emit()
def handler_chColor(self):
color = self.dlg_color.getColor(self.color)
if color.isValid():
color.setAlpha(self.color.alpha())
self.color = color
self.settingsChanged.emit()
self.close()
def getColor(self):
return self.color
def center(self):
screen = QDesktopWidget().screenGeometry()
size = self.geometry()
self.move((screen.width() - size.width()) / 2,
(screen.height() - size.height()) / 2)
def closeEvent(self, e):
self.clear()
e.accept()
def clear(self):
return
开发者ID:jeremyk6,项目名称:qdraw,代码行数:63,代码来源:qdrawsettings.py
示例10: __init__
def __init__(self, map_theme, layer, extent, tile_size, mupp, output,
make_trans, map_settings, project):
"""
:param map_theme:
:param extent:
:param layer:
:param tile_size:
:param mupp:
:param output:
:param map_settings: Map canvas map settings used for some fallback
values and CRS
"""
self.extent = extent
self.mupp = mupp
self.tile_size = tile_size
driver = self.getDriverForFile(output)
if not driver:
raise QgsProcessingException(
u'Could not load GDAL driver for file {}'.format(output))
crs = map_settings.destinationCrs()
self.x_tile_count = math.ceil(extent.width() / mupp / tile_size)
self.y_tile_count = math.ceil(extent.height() / mupp / tile_size)
xsize = self.x_tile_count * tile_size
ysize = self.y_tile_count * tile_size
if make_trans:
no_bands = 4
else:
no_bands = 3
self.dataset = driver.Create(output, xsize, ysize, no_bands)
self.dataset.SetProjection(str(crs.toWkt()))
self.dataset.SetGeoTransform(
[extent.xMinimum(), mupp, 0, extent.yMaximum(), 0, -mupp])
self.image = QImage(QSize(tile_size, tile_size), QImage.Format_ARGB32)
self.settings = QgsMapSettings()
self.settings.setOutputDpi(self.image.logicalDpiX())
self.settings.setOutputImageFormat(QImage.Format_ARGB32)
self.settings.setDestinationCrs(crs)
self.settings.setOutputSize(self.image.size())
self.settings.setFlag(QgsMapSettings.Antialiasing, True)
self.settings.setFlag(QgsMapSettings.RenderMapTile, True)
self.settings.setFlag(QgsMapSettings.UseAdvancedEffects, True)
r = project.readNumEntry('Gui', '/CanvasColorRedPart', 255)[0]
g = project.readNumEntry('Gui', '/CanvasColorGreenPart', 255)[0]
b = project.readNumEntry('Gui', '/CanvasColorBluePart', 255)[0]
if make_trans:
self.bgColor = QColor(r, g, b, 0)
else:
self.bgColor = QColor(r, g, b)
self.settings.setBackgroundColor(self.bgColor)
if QgsProject.instance().mapThemeCollection().hasMapTheme(map_theme):
self.settings.setLayers(
QgsProject.instance().mapThemeCollection(
).mapThemeVisibleLayers(
map_theme))
self.settings.setLayerStyleOverrides(
QgsProject.instance().mapThemeCollection(
).mapThemeStyleOverrides(
map_theme))
elif layer:
self.settings.setLayers([layer])
else:
self.settings.setLayers(map_settings.layers())
开发者ID:telwertowski,项目名称:Quantum-GIS,代码行数:76,代码来源:Rasterize.py
示例11: TileSet
class TileSet():
"""
A set of tiles
"""
def __init__(self, map_theme, layer, extent, tile_size, mupp, output,
make_trans, map_settings, project):
"""
:param map_theme:
:param extent:
:param layer:
:param tile_size:
:param mupp:
:param output:
:param map_settings: Map canvas map settings used for some fallback
values and CRS
"""
self.extent = extent
self.mupp = mupp
self.tile_size = tile_size
driver = self.getDriverForFile(output)
if not driver:
raise QgsProcessingException(
u'Could not load GDAL driver for file {}'.format(output))
crs = map_settings.destinationCrs()
self.x_tile_count = math.ceil(extent.width() / mupp / tile_size)
self.y_tile_count = math.ceil(extent.height() / mupp / tile_size)
xsize = self.x_tile_count * tile_size
ysize = self.y_tile_count * tile_size
if make_trans:
no_bands = 4
else:
no_bands = 3
self.dataset = driver.Create(output, xsize, ysize, no_bands)
self.dataset.SetProjection(str(crs.toWkt()))
self.dataset.SetGeoTransform(
[extent.xMinimum(), mupp, 0, extent.yMaximum(), 0, -mupp])
self.image = QImage(QSize(tile_size, tile_size), QImage.Format_ARGB32)
self.settings = QgsMapSettings()
self.settings.setOutputDpi(self.image.logicalDpiX())
self.settings.setOutputImageFormat(QImage.Format_ARGB32)
self.settings.setDestinationCrs(crs)
self.settings.setOutputSize(self.image.size())
self.settings.setFlag(QgsMapSettings.Antialiasing, True)
self.settings.setFlag(QgsMapSettings.RenderMapTile, True)
self.settings.setFlag(QgsMapSettings.UseAdvancedEffects, True)
r = project.readNumEntry('Gui', '/CanvasColorRedPart', 255)[0]
g = project.readNumEntry('Gui', '/CanvasColorGreenPart', 255)[0]
b = project.readNumEntry('Gui', '/CanvasColorBluePart', 255)[0]
if make_trans:
self.bgColor = QColor(r, g, b, 0)
else:
self.bgColor = QColor(r, g, b)
self.settings.setBackgroundColor(self.bgColor)
if QgsProject.instance().mapThemeCollection().hasMapTheme(map_theme):
self.settings.setLayers(
QgsProject.instance().mapThemeCollection(
).mapThemeVisibleLayers(
map_theme))
self.settings.setLayerStyleOverrides(
QgsProject.instance().mapThemeCollection(
).mapThemeStyleOverrides(
map_theme))
elif layer:
self.settings.setLayers([layer])
else:
self.settings.setLayers(map_settings.layers())
def render(self, feedback, make_trans):
for x in range(self.x_tile_count):
for y in range(self.y_tile_count):
if feedback.isCanceled():
return
cur_tile = x * self.y_tile_count + y
num_tiles = self.x_tile_count * self.y_tile_count
self.renderTile(x, y, feedback, make_trans)
feedback.setProgress(int((cur_tile / num_tiles) * 100))
def renderTile(self, x, y, feedback, make_trans):
"""
Render one tile
:param x: The x index of the current tile
:param y: The y index of the current tile
"""
#.........这里部分代码省略.........
开发者ID:telwertowski,项目名称:Quantum-GIS,代码行数:101,代码来源:Rasterize.py
示例12: add_layers
def add_layers(self):#not tested and not ready, must fix basic styles (preferrably colors based on some definition dicitonary
MyGroup = self.root.insertGroup(0, "stratigraphy_layers_for_qgis2threejs")#verify this is inserted at top
canvas = self.iface.mapCanvas()
list_with_all_strat_layer = []
for key in self.strat_layers_dict:
list_with_all_strat_layer.append(key)
#print list_with_all_strat_layer#debug
list_with_all_strat_layer.append('strat_obs_p_for_qgsi2threejs')
colors = []
layer_list = []
utils.add_layers_to_list(layer_list, list_with_all_strat_layer, geometrycolumn='geometry',
dbconnection=self.dbconnection)
for strat_layer_view in list_with_all_strat_layer:
try:
supplied_color = self.symbolcolors_dict[strat_layer_view]
except KeyError:
color = None
else:
try:
# matplotlib 2
color = mpl.colors.to_rgbsupplied_color()
except AttributeError:
try:
# matplotlib 1
converter = mpl.colors.ColorConverter()
color = converter.to_rgb(supplied_color)
color = [x * 255 for x in color]
except Exception as e:
utils.MessagebarAndLog.warning(
bar_msg=ru(QCoreApplication.translate('PrepareForQgis2Threejs', 'Setting color from dict failed')),
log_msg=ru(QCoreApplication.translate('PrepareForQgis2Threejs', 'Error msg %s'))%str(e))
color = None
colors.append(color)
for idx, layer in enumerate(layer_list):#now loop over all the layers, add them to canvas and set colors
if not layer.isValid():
try:
print(layer.name() + ' is not valid layer')
except:
pass
pass
else:
# TODO: Made this a comment, but there might be some hidden feature thats still needed!
#map_canvas_layer_list.append(QgsMapCanvasLayer(layer))
#now try to load the style file
stylefile = os.path.join(os.sep,os.path.dirname(__file__),"..","definitions",layer.name() + ".qml")
try:
layer.loadNamedStyle(stylefile)
except:
try:
print("Loading stylefile %s failed."%stylefile)
except:
pass
color = colors[idx]
if color:
current_symbol = layer.renderer().symbol()
current_symbol.setColor(QColor.fromRgb(color[0], color[1], color[2]))
QgsProject.instance().addMapLayers([layer],False)
MyGroup.insertLayer(0,layer)
#finally refresh canvas
canvas.refresh()
开发者ID:jkall,项目名称:qgis-midvatten-plugin,代码行数:72,代码来源:prepareforqgis2threejs.py
示例13: DistroMap
class DistroMap(object):
def __init__(self, iface):
# Save reference to the QGIS interface
self.iface = iface
# initialize plugin directory
self.plugin_dir = QFileInfo(QgsApplication.qgisSettingsDirPath()).path() + "/python/plugins/distromap"
# initialize locale
localePath = ""
locale = QSettings().value("locale/userLocale")[0:2]
if QFileInfo(self.plugin_dir).exists():
localePath = self.plugin_dir + "/i18n/distromap_" + locale + ".qm"
if QFileInfo(localePath).exists():
self.translator = QTranslator()
self.translator.load(localePath)
if qVersion() > '4.3.3':
QCoreApplication.installTranslator(self.translator)
# Create the dialog (after translation) and keep reference
self.dlg = DistroMapDialog()
def confirm(self):
# runs when OK button is pressed
# initialise input parameters
self.BASE_LAYER = self.dlg.ui.comboBase.currentItemData()
self.SECONDARY_LAYER = self.dlg.ui.comboSecondary.currentItemData()
self.SURFACE_LAYER = self.dlg.ui.comboSurface.currentItemData()
self.LOCALITIES_LAYER = self.dlg.ui.comboLocalities.currentItemData()
self.TAXON_FIELD_INDEX = self.dlg.ui.comboTaxonField.currentItemData()[0]
self.GRID_LAYER = self.dlg.ui.comboGrid.currentItemData()
self.X_MIN = float(self.dlg.ui.leMinX.text())
self.Y_MIN = float(self.dlg.ui.leMinY.text())
self.X_MAX = float(self.dlg.ui.leMaxX.text())
self.Y_MAX = float(self.dlg.ui.leMaxY.text())
self.OUT_WIDTH = self.dlg.ui.spnOutWidth.value()
self.OUT_HEIGHT = self.dlg.ui.spnOutHeight.value()
self.OUT_DIR = self.dlg.ui.leOutDir.text()
try:
self.getUniqueValues()
except:
message = "Could not get unique values from localities layer. "
message += "Check that the localities layer and taxon identifier "
message += "field are properly specified."
QMessageBox.information(self.dlg,"Distribution Map Generator",
message)
return
question = "This will generate " + str(self.UNIQUE_COUNT)
question += " maps. Are you sure you want to continue?"
reply = QMessageBox.question(self.dlg,'Distribution Map Generator',
question,
QMessageBox.Yes | QMessageBox.No, QMessageBox.Yes)
self.GRID_INDEX = QgsSpatialIndex()
for feat in getLayerFromId(self.GRID_LAYER).getFeatures():
self.GRID_INDEX.insertFeature(feat)
if reply == QMessageBox.Yes:
try:
self.process()
except QgsCsException:
return
except Exception as ex:
log(ex)
return
QMessageBox.information(self.dlg,"Distribution Map Generator",
"Map processing complete.")
self.dlg.ui.progressBar.setValue(0)
QDialog.accept(self.dlg)
else:
return
def initGui(self):
# Create action that will start plugin configuration
self.action = QAction(
QIcon(self.plugin_dir + "/icon.svg"),
u"Distribution Map Generator...", self.iface.mainWindow())
# connect the action to the run method
self.action.triggered.connect(self.run)
self.dlg.ui.buttonBox.accepted.connect(self.confirm)
# Add toolbar button and menu item
self.iface.addToolBarIcon(self.action)
self.iface.addPluginToMenu(u"&Distribution Map Generator", self.action)
# Set colour for output background colour chooser:
self.BACKGROUND_COLOUR = QColor(192,192,255)
self.dlg.ui.frmColour.setStyleSheet("QWidget { background-color: %s }"
% self.BACKGROUND_COLOUR.name())
def unload(self):
# Remove the plugin menu item and icon
self.iface.removePluginMenu(u"&Distribution Map Generator", self.action)
self.iface.removeToolBarIcon(self.action)
def loadTaxonFields(self):
#.........这里部分代码省略.........
开发者ID:rudivs,项目名称:DistroMap,代码行数:101,代码来源:distromap.py
示例14: setPointsReplicasColor
def setPointsReplicasColor(self, color):
self.pointsReplicasColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.pointsReplicasColor )
self.pointsReplicasColorBtn.setIcon( QIcon(pixmap) )
开发者ID:faunalia,项目名称:ps-speed,代码行数:5,代码来源:graph_settings_dialog.py
示例15: GraphSettings_Dlg
class GraphSettings_Dlg(QDialog, Ui_Dialog):
def __init__(self, parent=None):
QDialog.__init__(self, parent)
self.setupUi(self)
self.titleBoldBtn.hide()
self.titleItalicBtn.hide()
self.labelsBoldBtn.hide()
self.labelsItalicBtn.hide()
# remove fonts matplotlib doesn't load
for index in range(self.titleFontCombo.count()-1, -1, -1):
found = False
family = unicode( self.titleFontCombo.itemText( index ) )
try:
props = self.findFont( {'family':family} )
if family == props['family']:
found = True
except Exception:
pass
if not found:
self.titleFontCombo.removeItem( index )
self.labelsFontCombo.removeItem( index )
self.initProps()
self.titleColorBtn.clicked.connect(self.chooseTitleColor)
self.labelsColorBtn.clicked.connect(self.chooseLabelsColor)
self.pointsColorBtn.clicked.connect(self.choosePointsColor)
self.pointsReplicasColorBtn.clicked.connect(self.choosePointsReplicasColor)
self.linesColorBtn.clicked.connect(self.chooseLinesColor)
self.linesThrendColorBtn.clicked.connect(self.chooseLinesThrendColor)
def choosePointsColor(self):
dlg = QColorDialog(self.pointsColor, self)
if dlg.exec_():
self.setPointsColor( dlg.selectedColor() )
dlg.deleteLater()
def setPointsColor(self, color):
self.pointsColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.pointsColor )
self.pointsColorBtn.setIcon( QIcon(pixmap) )
def pointsProps(self):
props = {
'marker' : 's',
'color' : self.pointsColor.name()
}
return props
def setPointsProps(self, props):
self.setPointsColor( props.get('color', 'black') )
def choosePointsReplicasColor(self):
dlg = QColorDialog(self.pointsReplicasColor, self)
if dlg.exec_():
self.setPointsReplicasColor( dlg.selectedColor() )
dlg.deleteLater()
def setPointsReplicasColor(self, color):
self.pointsReplicasColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.pointsReplicasColor )
self.pointsReplicasColorBtn.setIcon( QIcon(pixmap) )
def pointsReplicasProps(self):
props = {
'marker' : 's',
'color' : self.pointsReplicasColor.name(),
}
return props
def setPointsReplicasProps(self, props):
self.setPointsReplicasColor( props.get('color', 'blue') )
def chooseLinesColor(self):
dlg = QColorDialog(self.linesColor, self)
if dlg.exec_():
self.setLinesColor( dlg.selectedColor() )
dlg.deleteLater()
def setLinesColor(self, color):
self.linesColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.linesColor )
self.linesColorBtn.setIcon( QIcon(pixmap) )
def linesProps(self):
props = {
'color' : self.linesColor.name()
}
return props
def setLinesProps(self, props):
self.setLinesColor( props.get('color', 'black') )
def chooseLinesThrendColor(self):
#.........这里部分代码省略.........
开发者ID:faunalia,项目名称:ps-speed,代码行数:101,代码来源:graph_settings_dialog.py
示例16: setLabelsColor
def setLabelsColor(self, color):
self.labelsColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.labelsColor )
self.labelsColorBtn.setIcon( QIcon(pixmap) )
开发者ID:faunalia,项目名称:ps-speed,代码行数:5,代码来源:graph_settings_dialog.py
示例17: setTitleColor
def setTitleColor(self, color):
self.titleColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.titleColor )
self.titleColorBtn.setIcon( QIcon(pixmap) )
开发者ID:faunalia,项目名称:ps-speed,代码行数:5,代码来源:graph_settings_dialog.py
示例18: setLinesThrendColor
def setLinesThrendColor(self, color):
self.linesThrendColor = QColor( color )
pixmap = QPixmap( 20,20 )
pixmap.fill( self.linesThrendColor )
self.linesThrendColorBtn.setIcon( QIcon(pixmap) )
开发者ID:faunalia,项目名称:ps-speed,代码行数:5,代码来源:graph_settings_dialog.py
示例19: paint
def paint(self, painter, option, widget=None):
rect = QRectF(-(ModelerGraphicItem.BOX_WIDTH + 2) / 2.0,
-(ModelerGraphicItem.BOX_HEIGHT + 2) / 2.0,
ModelerGraphicItem.BOX_WIDTH + 2,
ModelerGraphicItem.BOX_HEIGHT + 2)
if isinstance(self.element, QgsProcessingModelParameter):
color = QColor(238, 242, 131)
stroke = QColor(234, 226, 118)
selected = QColor(116, 113, 68)
elif isinstance(self.element, QgsProcessingModelChildAlgorithm):
color = QColor(255, 255, 255)
stroke = Qt.gray
selected = QColor(50, 50, 50)
else:
color = QColor(172, 196, 114)
stroke = QColor(90, 140, 90)
selected = QColor(42, 65, 42)
if self.isSelected():
stroke = selected
color = color.darker(110)
painter.setPen(QPen(stroke, 0)) # 0 width "cosmetic" pen
painter.setBrush(QBrush(color, Qt.SolidPattern))
painter.drawRect(rect)
font = QFont('Verdana', 8)
font.setPixelSize(12)
painter.setFont(font)
painter.setPen(QPen(Qt.black))
text = self.getAdjustedText(self.text)
if isinstance(self.element, QgsProcessingModelChildAlgorithm) and not self.element.isActive():
painter.setPen(QPen(Qt.gray))
text = text + "\n(deactivated)"
fm = QFontMetricsF(font)
text = self.getAdjustedText(self.text)
h = fm.ascent()
pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, ModelerGraphicItem.BOX_HEIGHT / 2.0 - h + 1)
painter.drawText(pt, text)
painter.setPen(QPen(Qt.black))
if isinstance(self.element, QgsProcessingModelChildAlgorithm):
h = -(fm.height() * 1.2)
h = h - ModelerGraphicItem.BOX_HEIGHT / 2.0 + 5
pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h)
painter.drawText(pt, 'In')
i = 1
if not self.element.parametersCollapsed():
for param in [p for p in self.element.algorithm().parameterDefinitions() if not p.isDestination()]:
if not param.flags() & QgsProcessingParameterDefinition.FlagHidden:
text = self.getAdjustedText(param.description())
h = -(fm.height() * 1.2) * (i + 1)
h = h - ModelerGraphicItem.BOX_HEIGHT / 2.0 + 5
pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 33, h)
painter.drawText(pt, text)
i += 1
h = fm.height() * 1.1
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 25, h)
painter.drawText(pt, 'Out')
if not self.element.outputsCollapsed():
for i, out in enumerate(self.element.algorithm().outputDefinitions()):
text = self.getAdjustedText(out.description())
h = fm.height() * 1.2 * (i + 2)
h = h + ModelerGraphicItem.BOX_HEIGHT / 2.0
pt = QPointF(-ModelerGraphicItem.BOX_WIDTH / 2 + 33, h)
painter.drawText(pt, text)
if self.pixmap:
painter.drawPixmap(-(ModelerGraphicItem.BOX_WIDTH / 2.0) + 3, -8,
self.pixmap)
elif self.picture:
painter.drawPicture(-(ModelerGraphicItem.BOX_WIDTH / 2.0) + 3, -8,
self.picture)
开发者ID:blazek,项目名称:QGIS,代码行数:70,代码来源:ModelerGraphicItem.py
示例20: initGui
def initGui(self):
# create action that will start plugin configuration
self.action = QAction(
QIcon(":icons/qgsazimuth.png"),
"Azimuth and distance",
self.iface.mainWindow(),
)
self.action.setWhatsThis("Azimuth and distance")
self.action.triggered.connect(self.run)
self.bandpoint = QgsRubberBand(self.canvas, QgsWkbTypes.PointGeometry)
self.bandpoint.setIcon(QgsRubberBand.ICON_CROSS)
self.bandpoint.setColor(QColor.fromRgb(255, 50, 255))
self.bandpoint.setWidth(3)
self.bandpoint.setIconSize(20)
# add toolbar button and menu item
self.iface.addPluginToMenu("&Topography", self.action)
self.iface.addToolBarIcon(self.action)
self.dock = Dock(self.iface.mainWindow())
self.iface.addDockWidget(Qt.BottomDockWidgetArea, self.dock)
self.dock.hide()
self.pluginGui = self.dock.widget()
self.dock.closed.connect(self.cleanup)
self.pluginGui.pushButton_vertexAdd.clicked.connect(self.addRow)
self.pluginGui.pushButton_vertexInsert.clicked.connect(self.insertRow)
self.pluginGui.pushButton_segListRowDel.clicked.connect(self.delRow)
self.pluginGui.pushButton_segListLoad.clicked.connect(self.loadList)
self.pluginGui.pushButton_segListClear.clicked.connect(self.clearList)
self.pluginGui.pushButton_objectDraw.clicked.connect(self.addgeometry)
self.pluginGui.pushButton_startCapture.clicked.connect(self.startgetpoint)
self.pluginGui.pushButton_segListSave.clicked.connect(self.saveList)
self.pluginGui.pushButton_useLast.clicked.connect(self.use_last_vertex)
self.pluginGui.pickAngle1_button.clicked.connect(self.select_angle1)
self.pluginGui.pickAngle2_button.clicked.connect(self.select_angle2)
self.pluginGui.clearMarkers_button.clicked.connect(self.clear_markers)
self.pluginGui.copyDiff_button.clicked.connect(self.copy_diff_offset)
# self.pluginGui.table_segmentList.cellChanged.connect(self.render_temp_band)
self.pluginGui.table_segmentList.setCurrentCell(0, 0)
self.tool = GetCoordTool(self.canvas)
self.tool.finished.connect(self.getpoint)
self.tool.locationChanged.connect(self.pluginGui.update_startpoint)
self.tool.locationChanged.connect(self.update_marker_location)
self.angletool = LineTool(self.canvas)
self.angletool.geometryComplete.connect(self.update_angle1)
self.angletool.locationChang
|
请发表评论