Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Pythagorean Tree: children order #3393

Merged
merged 5 commits into from
Nov 23, 2018
Merged

Conversation

thocevar
Copy link
Contributor

Issue

Fixes #3330.

Description of changes

Implemented two new features that should enable visualizations of Pythagorean trees with less overlap:

  • Add a button to completely redraw the tree with a random left/right ordering of children (this should give a user a good starting point).
  • Double click on a node reverses the order of its children (for manual fine-tuning).
Includes
  • Code changes
  • Tests
  • Documentation

@thocevar
Copy link
Contributor Author

Further work:

  • Make randomized/hand-crafted visualizations consistent between sessions.
  • Generate a good visualization automatically.

@codecov
Copy link

codecov bot commented Nov 13, 2018

Codecov Report

Merging #3393 into master will decrease coverage by 0.02%.
The diff coverage is 45.45%.

@@            Coverage Diff             @@
##           master    #3393      +/-   ##
==========================================
- Coverage   82.29%   82.27%   -0.03%     
==========================================
  Files         360      360              
  Lines       64080    64111      +31     
==========================================
+ Hits        52735    52745      +10     
- Misses      11345    11366      +21

Copy link
Collaborator

@pavlin-policar pavlin-policar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well. One thing that is still an issue, which we discussed yesterday - the scene doesn't resize properly. We agreed that resizing and re-centering the view on every change was a bad idea the tree would jump around, and I still think this is important. However, one issue that does arise from not resizing the viewport is that the report image can be cut off.

For example on the housing data set, the default report looks nice (I don't show reports here because the images are huge, but it's just whatever's visible in the viewport).
image

while if we flip the second largest bottom node, we get this
image

which unfortunately cuts off the top of the tree in the report.

I suppose we'd want to make sure to properly set the sceneRect (or something related) before rendering the report.
Ideally, this would work properly when right clicking - which resets the zoom. So in that case we'd expect the entire tree to be shown, but as it is now, the top of the tree is cut off (as seen in the pictures).

Looking at the code in _update_main_area, we'd only want to call self.scene.setSceneRect(self.view.central_widget_rect()), and not any of the others on every change.

@thocevar
Copy link
Contributor Author

Updating the scene rectangle repositions the tree in the current view. If we have a horizontal layout of the tree and flip something that results in a vertical layout, we would have to add some horizontal margin to keep the tree in place besides computing the right view parameters (such that the scene/view transformation keeps the items in place).

I resorted to updating the entire view with _update_main_area. It's not ideal as it moves the item that the user just clicked but I'll leave that as another issue.

@janezd janezd merged commit 49edd19 into biolab:master Nov 23, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants