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

Z-offset attribute label #521

Merged
merged 18 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1265,9 +1265,13 @@ def draw_labels(self, panel, page):
else:
the_z = panel['theZ'] if panel['theZ'] else 0
if format == "pixel":
if offset is not None and 1 <= offset:
the_z -= offset
label_value = str(the_z + 1)
elif (format == "unit" and size_z
and the_z < size_z):
if offset is not None and 1 <= offset:
the_z -= offset
z_pos = "%.*f" % (precision,
(the_z * pixel_size_z))
label_value = (z_pos + " " + z_symbol)
Expand Down
10 changes: 10 additions & 0 deletions omero_figure/templates/figure/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,16 @@ <h4>Dynamic properties</h4>
<td>Time: [time.seconds; precision=2; offset=3]</td>
<td>Time: -0.06 s</td>
</tr>
<tr>
<th>Z index with units <br/> (first plane is Z: 0.00 &#181;m), <br/>offset by 3 times the Z pixel size</th>
<td>Z: [z.unit; offset=3]</td>
<td>Z: -3.00 &#181;m </td>
</tr>
<tr>
<th>Z index (first plane is Z: 1) <br/>offset by 3</th>
<td>Z: [z.pixel; offset=3]</td>
<td>Z: -2 </td>
</tr>
<tr>
<th>Image ID</th>
<td>Image ID: [image.id]</td>
Expand Down
20 changes: 15 additions & 5 deletions src/js/models/panel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@
text = "", h, m, s;

if (ref_idx) {
var shift = this.get('deltaT')[parseInt(ref_idx)-1];
deltaT = shift==null ? deltaT : deltaT-shift;
var shift = this.get('deltaT')[parseInt(ref_idx) - 1];
deltaT = shift==null ? deltaT : deltaT - shift;
}
var isNegative = (deltaT < 0);
deltaT = Math.abs(deltaT);
Expand Down Expand Up @@ -334,6 +334,7 @@
if (["0"+dec_str+" s", "0"+dec_str+" mins", "0:00"+dec_str, "0:00:00"+dec_str].indexOf(text) > -1) {
isNegative = false;
}

return (isNegative ? '-' : '') + text;
},

Expand Down Expand Up @@ -362,7 +363,7 @@
return text;
},

get_view_label_text: function(property, format, dec_prec) {
get_view_label_text: function(property, format, ref_idx, dec_prec) {
if (format === "px") format = "pixel";

if (property === "w") property = "width";
Expand Down Expand Up @@ -399,10 +400,19 @@
}
else {
var theZ = this.get('theZ');
var deltaZ = theZ;

var shift;
if (ref_idx) {
shift = parseInt(ref_idx)
}
if(!isNaN(shift)){
deltaZ = theZ - shift;
}
if (format === "pixel") {
text = "" + (theZ + 1);
text = "" + (deltaZ + 1);
} else if (format === "unit") {
text = ""+ (theZ * z_size).toFixed(dec_prec) +" "+ z_symbol
text = ""+ (deltaZ * z_size).toFixed(dec_prec) +" "+ z_symbol
}
}
return text
Expand Down
2 changes: 1 addition & 1 deletion src/js/views/panel_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@
} else if (['x', 'y', 'z', 'width', 'height', 'w', 'h', 'rotation', 'rot'].includes(prop_nf[0])){
format = prop_nf[1] ? prop_nf[1] : "pixel";
precision = param_dict["precision"] !== undefined ? param_dict["precision"] : 2; // decimal places default to 2
label_value = self.model.get_view_label_text(prop_nf[0], format, precision);
label_value = self.model.get_view_label_text(prop_nf[0], format, param_dict["offset"], precision);
} else if (['channels', 'c'].includes(prop_nf[0])) {
label_value = self.model.get_channels_label_text();
} else if (['zoom'].includes(prop_nf[0])) {
Expand Down