本文整理汇总了Python中viewer.Viewer.set_selection方法的典型用法代码示例。如果您正苦于以下问题:Python Viewer.set_selection方法的具体用法?Python Viewer.set_selection怎么用?Python Viewer.set_selection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viewer.Viewer
的用法示例。
在下文中一共展示了Viewer.set_selection方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EarthMineQGIS
# 需要导入模块: from viewer import Viewer [as 别名]
# 或者: from viewer.Viewer import set_selection [as 别名]
#.........这里部分代码省略.........
so no other methods apart from startViewer will be handled.
"""
settings = self.earthmine_settings()
self.viewer.startViewer(settings)
@pyqtSlot()
def viewerReady(self):
"""
Called once the viewer is loaded and ready to get location events.
"""
self.disconnect_signals()
self.connect_signals()
self.iface.projectRead.connect(self.connect_signals)
self.canvas.layersChanged.connect(self.layers_changed)
self.canvas.selectionChanged.connect(self.selection_changed)
self.canvas.selectionChanged.connect(self.viewer.selection_changed)
QgsMapLayerRegistry.instance().layersRemoved.connect(self.layers_removed)
QgsMapLayerRegistry.instance().layerWasAdded.connect(self.connect_layer_signals)
self.center_on_canvas()
self.viewer.activelayercombo.setLayer(self.iface.activeLayer())
def center_on_canvas(self):
point = self.canvas.extent().center()
transform = self.coordinatetransform()
point = transform.transform(point, QgsCoordinateTransform.ReverseTransform)
self.viewer.set_location(point)
self.viewer.infoaction.toggle()
def selection_changed(self, layer):
ids = [feature.id() for feature in layer.selectedFeatures()]
if not ids:
self.viewer.clear_selection(layer.id())
else:
self.viewer.set_selection(layer.id(), ids)
def layers_changed(self):
layerstates = self.layers_with_states()
for layer, visible in layerstates:
layerid = layer.id()
viewerloaded = self.viewer.layer_loaded(layerid)
QgsMessageLog.instance().logMessage(layerid, "Earthmine")
QgsMessageLog.instance().logMessage("Viewer State:" + str(viewerloaded), "Earthmine")
QgsMessageLog.instance().logMessage("QGIS State:" + str(visible), "Earthmine")
if (viewerloaded and visible) or (not viewerloaded and not visible):
QgsMessageLog.instance().logMessage("Ignoring as states match", "Earthmine")
continue
if viewerloaded and not visible:
QgsMessageLog.instance().logMessage(
"Clearing layer because viewer loaded and disabled in QGIS", "Earthmine"
)
self.viewer.clear_layer_features(layerid)
continue
if not viewerloaded and visible:
QgsMessageLog.instance().logMessage("Loading layer", "Earthmine")
self.load_layer_features(layers=[layer])
continue
def layers_removed(self, layers):
for layerid in layers:
self.viewer.clear_layer_features(layerid)
@pyqtSlot(str, float, float)
def viewChanged(self, event, yaw, angle):
self.marker.setAngle(angle)