Skip to content
Permalink
Browse files
Mark topology group visibility off
This is really a workaround to http://hub.qgis.org/issues/6938
  • Loading branch information
Sandro Santilli committed Jan 2, 2013
1 parent a385162 commit 103942391d2e3d7589850db4576f4769f2b42d46
Showing with 22 additions and 7 deletions.
  1. +22 −7 python/plugins/db_manager/db_plugins/postgis/plugins/qgis_topoview/__init__.py
@@ -92,20 +92,22 @@ def run(item, action, mainwindow):
prevRenderFlagState = iface.mapCanvas().renderFlag()
iface.mapCanvas().setRenderFlag( False )
try:
# NOTE: -1 parent is a request to always add to the root
# See http://hub.qgis.org/issues/6879
supergroup = legend.addGroup(u'Topology "%s"' % toponame, False, -1)
supergroup = legend.addGroup(u'Topology "%s"' % toponame, False)
# should not be needed: http://hub.qgis.org/issues/6938
legend.setGroupVisible(supergroup, False)

provider = db.dbplugin().providerName()
uri = db.uri();

# FACES
group = legend.addGroup(u'Faces', False, supergroup)
# should not be needed: http://hub.qgis.org/issues/6938
legend.setGroupVisible(group, False)

# face
layer = db.toSqlLayer(u'SELECT face_id, topology.ST_GetFaceGeometry(%s, face_id) as geom ' \
'FROM %s.face WHERE face_id > 0' % (quoteStr(toponame), quoteId(toponame)),
'geom', 'face_id', u'geom')
'FROM %s.face WHERE face_id > 0' % (quoteStr(toponame), quoteId(toponame)),
'geom', 'face_id', u'geom')
layer.loadNamedStyle(os.path.join(template_dir, 'face.qml'))
registry.addMapLayers([layer])
legend.setLayerVisible(layer, False)
@@ -114,8 +116,8 @@ def run(item, action, mainwindow):

# face_seed
layer = db.toSqlLayer(u'SELECT face_id, ST_PointOnSurface(topology.ST_GetFaceGeometry(%s, face_id)) as geom ' \
'FROM %s.face WHERE face_id > 0' % (quoteStr(toponame), quoteId(toponame)),
'geom', 'face_id', u'seed')
'FROM %s.face WHERE face_id > 0' % (quoteStr(toponame), quoteId(toponame)),
'geom', 'face_id', u'seed')
layer.loadNamedStyle(os.path.join(template_dir, 'face_seed.qml'))
registry.addMapLayers([layer])
legend.setLayerVisible(layer, False)
@@ -127,6 +129,8 @@ def run(item, action, mainwindow):

# NODES
group = legend.addGroup(u'Nodes', False, supergroup)
# should not be needed: http://hub.qgis.org/issues/6938
legend.setGroupVisible(group, False)

# node
uri.setDataSource(toponame, 'node', 'geom', '', 'node_id')
@@ -148,16 +152,27 @@ def run(item, action, mainwindow):

# EDGES
group = legend.addGroup(u'Edges', False, supergroup)
# should not be needed: http://hub.qgis.org/issues/6938
legend.setGroupVisible(group, False)

# edge
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
layer = QgsVectorLayer(uri.uri(), u'geom', provider)
registry.addMapLayers([layer])
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)

# directed edge
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
layer = QgsVectorLayer(uri.uri(), u'directed_geom', provider)
layer.loadNamedStyle(os.path.join(template_dir, 'edge.qml'))
registry.addMapLayers([layer])
legend.setLayerVisible(layer, False)
legend.setLayerExpanded(layer, False)
legend.moveLayer(layer, group)


# edge labels
uri.setDataSource(toponame, 'edge_data', 'geom', '', 'edge_id')
layer = QgsVectorLayer(uri.uri(), u'edge_id', provider)

0 comments on commit 1039423

Please sign in to comment.