Skip to content

Commit

Permalink
add alter_internal_nodes function to make sure that internal nodes wo…
Browse files Browse the repository at this point in the history
…n't alter the y axis scale.
  • Loading branch information
niki_main committed Jan 24, 2018
1 parent 5a0230c commit aab40d2
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion ete3/treeview/qt4_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
from . import qt4_circular_render as crender
from . import qt4_rect_render as rrender
from .main import _leaf, NodeStyle, _FaceAreas, tracktime, TreeStyle
from ..treeview.faces import CircleFace
from ..treeview.faces import CircleFace, RectFace
from .node_gui_actions import _NodeActions as _ActionDelegator
from .qt4_face_render import update_node_faces, _FaceGroupItem, _TextFaceItem
from .templates import _DEFAULT_STYLE, apply_template
Expand Down Expand Up @@ -609,6 +609,25 @@ def add_y_scale(img, mainRect, parent, root):
alter_internal_nodes(root)


def alter_internal_nodes(t):
"""
The function changes the internal nodes of the tree to zero size, to make sure that the y scale is correct.
Making sure not to lose information the internal nodes are added as half opaque faces on top of the tree.
:param t: root node
:return:
"""
for node in t.traverse():
if not node.is_leaf():
if node.img_style['shape'] == 'square':
C = RectFace(width=node.img_style['size'], height=node.img_style['size'],
fgcolor=node.img_style['fgcolor'], bgcolor=node.img_style['fgcolor'])
else:
C = CircleFace(radius=node.img_style['size'], color=node.img_style['fgcolor'], style="sphere")
C.opacity = 0.6
node.add_face(C, 0, position="float-behind")
node.img_style['size'] = 0


def rotate_inverted_faces(n2i, n2f, img):
for node, faceblock in six.iteritems(n2f):
item = n2i[node]
Expand Down

0 comments on commit aab40d2

Please sign in to comment.