Skip to content

Commit

Permalink
Merge branch 'master' into update_readme
Browse files Browse the repository at this point in the history
  • Loading branch information
will-moore authored Dec 20, 2023
2 parents 55d7177 + e9b01f7 commit 700f29f
Show file tree
Hide file tree
Showing 19 changed files with 3,892 additions and 72 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/publish_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Build a binary wheel and a source tarball
run: |
python -mpip install wheel
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ RUN npm install -g grunt-cli && npm install grunt --save-dev
RUN $(npm bin)/grunt build
RUN /opt/omero/web/venv3/bin/pip install -e .


RUN echo "config set omero.web.application_server development" >> /opt/omero/web/config/01-default-webapps.omero
RUN echo "config set omero.web.debug true" >> /opt/omero/web/config/01-default-webapps.omero
USER omero-web
2 changes: 1 addition & 1 deletion docs/figure_file_format.rst
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Optional settings for each panel::
],

// labels on the panel
// positions are: top, left, right, leftvert, bottom, topleft, topright, bottomleft, bottomright
// positions are: top, left, right, leftvert, rightvert, bottom, topleft, topright, bottomleft, bottomright
"labels": [
{
"text": "GFP-INCENP",
Expand Down
45 changes: 37 additions & 8 deletions omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ def draw_shape_label(self, shape, bounds):
except Exception:
font = ImageFont.load(
'%s/pilfonts/B%0.2d.pil' % (self.GATEWAYPATH, size))
textsize = font.getsize(text)
textsize = font.getbbox(text)[2:]
xy = (center[0] - textsize[0] / 2.0, center[1] - textsize[1] / 2.0)
self.draw.text(xy, text, fill=rgba, font=font)

Expand Down Expand Up @@ -1153,7 +1153,7 @@ def draw_labels(self, panel, page):

# group by 'position':
positions = {'top': [], 'bottom': [], 'left': [],
'leftvert': [], 'right': [],
'leftvert': [], 'right': [], 'rightvert': [],
'topleft': [], 'topright': [],
'bottomleft': [], 'bottomright': []}

Expand Down Expand Up @@ -1247,6 +1247,7 @@ def draw_labels(self, panel, page):
z_symbol = panel.get('pixel_size_z_symbol')
if pixel_size_z is None:
pixel_size_z = 0
if z_symbol is None:
z_symbol = "\xB5m"

if ("z_projection" in panel.keys()
Expand All @@ -1265,9 +1266,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 Expand Up @@ -1299,6 +1304,8 @@ def draw_labels(self, panel, page):
label_value.append(channel["label"])
label_value = " ".join(label_value)

elif prop_nf[0] in ["zoom"]:
label_value = str(panel["zoom"]) + " %"
new_text.append(label_value if label_value else item.group())
last_idx = item.end()

Expand All @@ -1310,7 +1317,7 @@ def draw_labels(self, panel, page):
page_color = self.figure_json.get('page_color', 'ffffff').lower()
label_color = label['color'].lower()
label_on_page = pos in ('left', 'right', 'top',
'bottom', 'leftvert')
'bottom', 'leftvert', 'rightvert')
if label_on_page:
if label_color == '000000' and page_color == '000000':
label['color'] = 'ffffff'
Expand Down Expand Up @@ -1396,6 +1403,13 @@ def draw_lab(label, lx, ly, align='left'):
for label in labels:
lx = lx - label['size'] - spacer
draw_lab(label, lx, ly, align='vertical')
elif key == 'rightvert':
lx = x + width + spacer
ly = y + (height/2)
labels.reverse()
for label in labels:
lx = lx + label['size'] + spacer
draw_lab(label, lx, ly, align='right-vertical')

def draw_scalebar(self, panel, region_width, page):
"""
Expand Down Expand Up @@ -2024,7 +2038,7 @@ def draw_text(self, text, x, y, fontsize, rgb, align="center"):
x = x - para_width
elif (align == "left"):
pass
elif align == 'vertical':
elif align == 'left-vertical':
# Switch axes
c.rotate(90)
px = x
Expand All @@ -2033,6 +2047,15 @@ def draw_text(self, text, x, y, fontsize, rgb, align="center"):
# Align center
alignment = TA_CENTER
x = x - (para_width/2)
elif align == 'right-vertical':
# Switch axes
c.rotate(-90)
px = x
x = -y
y = px
# Align center
alignment = TA_CENTER
x = x - (para_width/2)

# set fully opaque background color to avoid transparent text
c.setFillColorRGB(0, 0, 0, 1)
Expand All @@ -2050,8 +2073,10 @@ def draw_text(self, text, x, y, fontsize, rgb, align="center"):
para.drawOn(c, x, y - h + int(fontsize * 0.25))

# Rotate back again
if align == 'vertical':
if align == 'left-vertical':
c.rotate(-90)
elif align == 'right-vertical':
c.rotate(90)

def draw_scalebar_line(self, x, y, x2, y2, width, rgb):
""" Adds line to PDF. Overwritten for TIFF below """
Expand Down Expand Up @@ -2230,7 +2255,7 @@ def draw_temp_label(self, text, fontsize, rgb):
heights = []
for t in tokens:
font = self.get_font(fontsize, t['bold'], t['italics'])
txt_w, txt_h = font.getsize(t['text'])
txt_w, txt_h = font.getbbox(t['text'])[2:]
widths.append(txt_w)
heights.append(txt_h)

Expand All @@ -2243,7 +2268,7 @@ def draw_temp_label(self, text, fontsize, rgb):
w = 0
for t in tokens:
font = self.get_font(fontsize, t['bold'], t['italics'])
txt_w, txt_h = font.getsize(t['text'])
txt_w, txt_h = font.getbbox(t['text'])[2:]
textdraw.text((w, 0), t['text'], font=font, fill=rgb)
w += txt_w
return temp_label
Expand Down Expand Up @@ -2308,9 +2333,13 @@ def draw_text(self, text, x, y, fontsize, rgb, align="center"):

temp_label = self.draw_temp_label(text, fontsize, rgb)

if align == "vertical":
if align == "left-vertical":
temp_label = temp_label.rotate(90, expand=True)
y = y - (temp_label.size[1]/2)
elif align == "right-vertical":
temp_label = temp_label.rotate(-90, expand=True)
y = y - (temp_label.size[1]/2)
x = x - temp_label.size[0]
elif align == "center":
x = x - (temp_label.size[0] / 2)
elif align == "right":
Expand Down
29 changes: 28 additions & 1 deletion omero_figure/static/figure/css/figure.css
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
line-height: 20px;
padding: 12px;
position: absolute;
right: 450px;
right: 520px;
text-align: center;
height: 100%;
}
Expand Down Expand Up @@ -233,6 +233,11 @@
height: 14px;
border-radius: 5px;
}
#vp_zoom_value {
float: right;
width: 50px;
margin-top: 5px;
}
.toggle_channel {
border-radius: 6px 6px 6px 6px;
margin: 2px;
Expand Down Expand Up @@ -344,6 +349,9 @@
.left_vlabels>div {
margin-bottom: 5px;
}
.right_vlabels>div {
margin-bottom: 5px;
}
.label_middle, .label_middle table, .label_middle td {
height:100%;
width:10000px;
Expand All @@ -362,11 +370,26 @@
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
}
.right_vlabels{
position: absolute;
left: 100%;
height: 300%;
top: -100%;
width: 300%;
text-align: center;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
}
.left_vlabels>div {
position: absolute;
bottom:0;
width:100%;
}
.right_vlabels>div {
position: absolute;
bottom:0;
width:100%;
}

.previewIdChange .glyphicon-ok {
color: #0f0;
Expand Down Expand Up @@ -705,6 +728,10 @@
.navbar>div.container {
max-width: 100%;
}
#alignment-toolbars {
padding-right: 0;
margin-right: -20px;
}
/** Add my class to boost size of font icons **/
.icon-buttons {
margin-right: 20px;
Expand Down
61 changes: 48 additions & 13 deletions omero_figure/templates/figure/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,14 @@ <h4 class="modal-title">Label Formatting</h4>
<h4>Markdown formatting</h4>
<p>
You can use "Markdown" syntax to add formatting to plain text. For example,
**this text will be bold** and this *word* will be italic. NB: Links are not
supported for panel labels.
**this text will be bold** and this *word* will be italic.
</p>
<p>
NB: Links are not supported for panel labels.
</p>
<p>
NB: You can escape a certain character to not be interpreted as Markdown by adding \ in front of the
character. Ex: "my_string_" is interpreted as "my<i>string</i>" but "my\_string\_" is now interpreted as "my_string_"
</p>

<table class="table">
Expand All @@ -531,21 +537,21 @@ <h4>Markdown formatting</h4>
<th>...this text</th></tr>
<tr>
<th>BOLD</th>
<td>Use 2 stars for **bold**.</td>
<td>Use 2 stars for <strong>bold</strong>.</td>
<td>**bold** or __bold__</td>
<td><strong>bold</strong> or <strong>bold</strong></td>
</tr>
<tr>
<th>ITALIC</th>
<td>Use 1 star for *italic*.</td>
<td>Use 1 star for <i>italic</i>.</td>
<td>*italic* or _italic_</td>
<td><i>italic</i> or <i>italic</i></td>
</tr>
<tr>
<th>LINKS</th>
<td>Add links with [Link text](http://link_url.com)</td>
<td>Add links with <a href="#">Link text</a></td>
<td>[Link text](http://link_url.com)</td>
<td><a href="#">Link text</a></td>
</tr>
<!-- <tr><td>You need to use 2 line breaks between paragraphs</td><td></td></tr> -->
</table>
</table>
<h4>Dynamic properties</h4>
<p>
The drop-down menu in the 'Add Labels' form allows you to create labels based on Image metadata.
Expand Down Expand Up @@ -595,6 +601,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 All @@ -605,6 +621,11 @@ <h4>Dynamic properties</h4>
<td>Dataset ID: [dataset.id]</td>
<td>Dataset ID: 1654</td>
</tr>
<tr>
<th>Zoom</th>
<td>[zoom]</td>
<td>100 %</td>
</tr>
</table>
<h4>Legend</h4>
<p>The figure legend will be included in the PDF info page when the figure is
Expand Down Expand Up @@ -698,8 +719,14 @@ <h4 class="modal-title" id="addImagesLabel">Labels from Key-Value Pairs</h4>
</div>
<form class="labelsFromMapAnnsForm" role="form">
<div class="modal-body">
<p>Choose Key
<small class="text-muted">(shows numbers of images)</small>:</p>
<div>
<input type="radio" id="all-keys" name="kvpChoice" value="all-keys" />
<label for="all-keys">All Keys </label>

<input type="radio" id="single-key" name="kvpChoice" value="single-key" checked />
<label for="single-key">Choose Key <small class="text-muted">(shows numbers of images)</small>:</label>
</div>

<select>
</select>
<div class="checkbox">
Expand Down Expand Up @@ -865,6 +892,9 @@ <h5>Example Label</h5>
<button type="button" class="aleft btn btn-default btn-sm" title="Align Left" disabled="disabled">
<span class="glyphicon glyphicon-align-left"></span>
</button>
<button type="button" class="aright btn btn-default btn-sm" title="Align Right" disabled="disabled">
<span class="glyphicon glyphicon-align-right"></span>
</button>
<button type="button" class="agrid btn btn-default btn-sm" title="Align To Grid" disabled="disabled">
<span class="glyphicon glyphicon-th"></span>
</button>
Expand All @@ -890,6 +920,9 @@ <h5>Example Label</h5>
<button type="button" class="atop btn btn-default btn-sm rotate-font" title="Align Top" disabled="disabled">
<span class="glyphicon glyphicon-align-right"></span>
</button>
<button type="button" class="abottom btn btn-default btn-sm rotate-font" title="Align Bottom" disabled="disabled">
<span class="glyphicon glyphicon-align-left"></span>
</button>
<button type="button" class="btn btn-default btn-sm dropdown-toggle" title="Align Sizes"
disabled="disabled" data-toggle="dropdown">
<span class="glyphicon glyphicon-fullscreen"></span>
Expand Down Expand Up @@ -1070,12 +1103,14 @@ <h5>Example Label</h5>
<div class='clearfix'></div>
<div class='tab-footer'>
<div class="col-sm-2 no-padding">
<h5>Zoom</h5>
<h5>Zoom %</h5>
</div>
<div class="col-sm-8 no-padding">
<div id="vp_zoom_slider"></div>
</div>
<div id="vp_zoom_value" class="col-sm-2" style="padding: 8px 0 0; text-align:right"></div>

<input id="vp_zoom_value" type="number" size="4"/>

<div class='clearfix'></div>
<div id="reset-zoom-view">
<!-- button added by ZoomView render() -->
Expand Down
16 changes: 10 additions & 6 deletions omero_figure/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,19 @@ def img_data_json(request, image_id, conn=None, **kwargs):

if units_support:
# Add extra parameters with units data
if 'pixel_size' not in rv:
rv['pixel_size'] = {}
# NB ['pixel_size']['x'] will have size in MICROMETER
px = image.getPrimaryPixels().getPhysicalSizeX()
rv['pixel_size']['valueX'] = px.getValue()
rv['pixel_size']['symbolX'] = px.getSymbol()
rv['pixel_size']['unitX'] = str(px.getUnit())
if px is not None:
rv['pixel_size']['valueX'] = px.getValue()
rv['pixel_size']['symbolX'] = px.getSymbol()
rv['pixel_size']['unitX'] = str(px.getUnit())
py = image.getPrimaryPixels().getPhysicalSizeY()
rv['pixel_size']['valueY'] = py.getValue()
rv['pixel_size']['symbolY'] = py.getSymbol()
rv['pixel_size']['unitY'] = str(py.getUnit())
if py is not None:
rv['pixel_size']['valueY'] = py.getValue()
rv['pixel_size']['symbolY'] = py.getSymbol()
rv['pixel_size']['unitY'] = str(py.getUnit())
pz = image.getPrimaryPixels().getPhysicalSizeZ()
if pz is not None:
rv['pixel_size']['valueZ'] = pz.getValue()
Expand Down
Loading

0 comments on commit 700f29f

Please sign in to comment.