Skip to content

Commit a39c63d

Browse files
committed
Change the meaning of view.aligned.zoom and of postwidth. Fix zoom in sequences/heatmaps.
This commit changes the meaning of view.aligned.zoom. Now it is not an extra zoom to add to view.zoom.x, but instead it is directly the zoom level in the aligned panel. It also changes the meaning of "postwidth" in SeqFace, HeatmapFace, and TextArrayFace. Now it is the width of each of the little squares/positions for zoom=1. And if we change the zoom, everything will contract or expand on the x axis.
1 parent 1b782f7 commit a39c63d

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

ete4/smartview/draw.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -626,9 +626,9 @@ def get_col_data(rows, x_col, dx_col, nodes, pos_box, pos, bdy_dy, zoom,
626626

627627
blocks = [] # will contain the column data to send afterwards
628628

629-
aligned_panel = not circular and pos in ['aligned', 'header']
629+
in_aligned_panel = not circular and pos in ['aligned', 'header']
630630
zx, zy, za = zoom
631-
zoom_xy = (zx * (za if aligned_panel else 1), zy)
631+
zoom_xy = (zx if not in_aligned_panel else za, zy)
632632

633633
# Iterate over the faces and get their graphics (none if
634634
# there's not enough space). We iterate reversed ([::-1]) so the

ete4/smartview/faces.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ def draw(self, nodes, size, collapsed, zoom=(1, 1), ax_ay=(0, 0), r=1):
414414
zx, zy = zoom
415415

416416
if dx <= 0: # no limit on dx? make it as big as possible
417-
dx = self.poswidth * len(self.seq) / zx
417+
dx = self.poswidth * len(self.seq)
418418

419419
assert dy > 0 or self.hmax is not None, 'hmax needed'
420420
if dy <= 0: # no limit on y? there better be hmax then
@@ -449,7 +449,7 @@ def draw(self, nodes, size, collapsed, zoom=(1, 1), ax_ay=(0, 0), r=1):
449449
zx, zy = zoom
450450

451451
if dx <= 0: # no limit on dx? make it as big as possible
452-
dx = self.poswidth * len(self.values) / zx
452+
dx = self.poswidth * len(self.values)
453453

454454
assert dy > 0 or self.hmax is not None, 'hmax needed'
455455
if dy <= 0: # no limit on y? there better be hmax then
@@ -485,7 +485,7 @@ def draw(self, nodes, size, collapsed, zoom=(1, 1), ax_ay=(0, 0), r=1):
485485
zx, zy = zoom
486486

487487
if dx <= 0: # no limit on dx? make it as big as possible
488-
dx = self.poswidth * len(self.texts) / zx
488+
dx = self.poswidth * len(self.texts)
489489

490490
assert dy > 0 or self.hmax is not None, 'hmax needed'
491491
if dy <= 0: # no limit on y? there better be hmax then

ete4/smartview/static/js/drag.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ function get_drag_scale() {
116116
if (dragging.element === div_tree)
117117
return [-1 / view.zoom.x, -1 / view.zoom.y];
118118
else if (dragging.element === div_aligned)
119-
return [-1 / view.aligned.zoom / view.zoom.x, 0];
119+
return [-1 / view.aligned.zoom, 0];
120120
else // dragging.element === div_visible_rect
121121
return [1 / view.minimap.zoom.x, 1 / view.minimap.zoom.y];
122122
}

ete4/smartview/static/js/draw.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ function get_items_per_panel(commands) {
205205
// Draw items in the aligned position.
206206
function draw_aligned(items, padding_x=15) {
207207
if (view.shape === "rectangular") {
208-
const zoom = {x: view.zoom.x * view.aligned.zoom,
208+
const zoom = {x: view.aligned.zoom,
209209
y: view.zoom.y};
210210
const tl = {x: view.aligned.origin - padding_x / zoom.x,
211211
y: view.tl.y}; // relative "top-left" point
@@ -221,7 +221,7 @@ function draw_aligned(items, padding_x=15) {
221221

222222
// Draw a white box and a line to clean the space where the headers will go.
223223
function draw_header_background(xmax, padding_x=15) {
224-
const zoom = {x: view.zoom.x * view.aligned.zoom,
224+
const zoom = {x: view.aligned.zoom,
225225
y: view.zoom.y};
226226
// Position where to put the header (in screen coordinates).
227227
const px = zoom.x * (xmax - view.aligned.origin) + padding_x,
@@ -260,7 +260,7 @@ function draw_header_background(xmax, padding_x=15) {
260260
// Draw items in the header position.
261261
function draw_header(items, padding_x=15) {
262262
if (view.shape === "rectangular") {
263-
const zoom = {x: view.zoom.x * view.aligned.zoom,
263+
const zoom = {x: view.aligned.zoom,
264264
y: view.zoom.y};
265265
const tl = {x: view.aligned.origin - padding_x / zoom.x,
266266
y: Math.min(-50 / zoom.y, view.tl.y + 10 / zoom.y)};

ete4/smartview/static/js/zoom.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function zoom_aligned(x, zoom_in, deltaY) {
9494
const { origin, zoom } = view.aligned; // shortcut
9595

9696
const zoom_new = qz * zoom;
97-
const origin_new = origin + (1 / zoom - 1 / zoom_new) / view.zoom.x * x;
97+
const origin_new = origin + (1 / zoom - 1 / zoom_new) * x;
9898

9999
view.aligned.origin = Math.max(0, origin_new);
100100
view.aligned.zoom = zoom_new;

0 commit comments

Comments
 (0)