Skip to content

Commit aab40d2

Browse files
author
niki_main
committed
add alter_internal_nodes function to make sure that internal nodes won't alter the y axis scale.
1 parent 5a0230c commit aab40d2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

ete3/treeview/qt4_render.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
from . import qt4_circular_render as crender
4646
from . import qt4_rect_render as rrender
4747
from .main import _leaf, NodeStyle, _FaceAreas, tracktime, TreeStyle
48-
from ..treeview.faces import CircleFace
48+
from ..treeview.faces import CircleFace, RectFace
4949
from .node_gui_actions import _NodeActions as _ActionDelegator
5050
from .qt4_face_render import update_node_faces, _FaceGroupItem, _TextFaceItem
5151
from .templates import _DEFAULT_STYLE, apply_template
@@ -609,6 +609,25 @@ def add_y_scale(img, mainRect, parent, root):
609609
alter_internal_nodes(root)
610610

611611

612+
def alter_internal_nodes(t):
613+
"""
614+
The function changes the internal nodes of the tree to zero size, to make sure that the y scale is correct.
615+
Making sure not to lose information the internal nodes are added as half opaque faces on top of the tree.
616+
:param t: root node
617+
:return:
618+
"""
619+
for node in t.traverse():
620+
if not node.is_leaf():
621+
if node.img_style['shape'] == 'square':
622+
C = RectFace(width=node.img_style['size'], height=node.img_style['size'],
623+
fgcolor=node.img_style['fgcolor'], bgcolor=node.img_style['fgcolor'])
624+
else:
625+
C = CircleFace(radius=node.img_style['size'], color=node.img_style['fgcolor'], style="sphere")
626+
C.opacity = 0.6
627+
node.add_face(C, 0, position="float-behind")
628+
node.img_style['size'] = 0
629+
630+
612631
def rotate_inverted_faces(n2i, n2f, img):
613632
for node, faceblock in six.iteritems(n2f):
614633
item = n2i[node]

0 commit comments

Comments
 (0)