本文整理汇总了Python中viewer.Viewer.active_tool方法的典型用法代码示例。如果您正苦于以下问题:Python Viewer.active_tool方法的具体用法?Python Viewer.active_tool怎么用?Python Viewer.active_tool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类viewer.Viewer
的用法示例。
在下文中一共展示了Viewer.active_tool方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: EarthMineQGIS
# 需要导入模块: from viewer import Viewer [as 别名]
# 或者: from viewer.Viewer import active_tool [as 别名]
#.........这里部分代码省略.........
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)
self.marker.setYaw(yaw)
@pyqtSlot(str, str)
def getInfo(self, layerid, featureid):
featureid = int(featureid)
activelayer = self.iface.activeLayer()
if not activelayer:
return
activetool = self.viewer.active_tool()
if not activetool in ["Info", "Select"]:
return
# Only show information for the active layer
if not layerid == activelayer.id():
return
layer = layer_by_id(layerid)
if activetool == "Select":
layer.setSelectedFeatures([featureid])
elif activetool == "Info":
rq = QgsFeatureRequest(featureid)
feature = layer.getFeatures(rq).next()
dlg = get_feature_form(layer, feature)
if dlg.dialog().exec_():
self.canvas.refresh()
@pyqtSlot(str, str, float, float, bool)
def featureMoved(self, layerid, featureid, lat, lng, end):
layer = layer_by_id(layerid)
transform = self.coordinatetransform(layer)
point = transform.transform(lng, lat)
if not end:
self.movingband.show()
self.movingband.setToGeometry(QgsGeometry.fromPoint(point), layer)
self.movingband.updatePosition()
self.movingband.update()
else:
self.movingband.hide()
feature = feature_by_id(layer, featureid)
startpoint = feature.geometry().asPoint()
dx = point.x() - startpoint.x()