diff --git a/.github/workflows/publish_pypi.yml b/.github/workflows/publish_pypi.yml index 3be31642b..0efc15e88 100644 --- a/.github/workflows/publish_pypi.yml +++ b/.github/workflows/publish_pypi.yml @@ -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 diff --git a/Dockerfile b/Dockerfile index 8926eb004..3d0d58012 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/docs/figure_file_format.rst b/docs/figure_file_format.rst index 3218d2483..e56e5ee9f 100644 --- a/docs/figure_file_format.rst +++ b/docs/figure_file_format.rst @@ -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", diff --git a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py index bb962dfe1..ce75fd7bc 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -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) @@ -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': []} @@ -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() @@ -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) @@ -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() @@ -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' @@ -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): """ @@ -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 @@ -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) @@ -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 """ @@ -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) @@ -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 @@ -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": diff --git a/omero_figure/static/figure/css/figure.css b/omero_figure/static/figure/css/figure.css index 332b65788..634d636d0 100644 --- a/omero_figure/static/figure/css/figure.css +++ b/omero_figure/static/figure/css/figure.css @@ -123,7 +123,7 @@ line-height: 20px; padding: 12px; position: absolute; - right: 450px; + right: 520px; text-align: center; height: 100%; } @@ -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; @@ -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; @@ -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; @@ -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; diff --git a/omero_figure/templates/figure/index.html b/omero_figure/templates/figure/index.html index 6eae81088..176a77412 100644 --- a/omero_figure/templates/figure/index.html +++ b/omero_figure/templates/figure/index.html @@ -520,8 +520,14 @@

Markdown formatting

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. +

+

+ NB: Links are not supported for panel labels. +

+

+ 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 "mystring" but "my\_string\_" is now interpreted as "my_string_"

@@ -531,21 +537,21 @@

Markdown formatting

- - + + - - + + - - + + -
...this text
BOLDUse 2 stars for **bold**.Use 2 stars for bold.**bold** or __bold__bold or bold
ITALICUse 1 star for *italic*.Use 1 star for italic.*italic* or _italic_italic or italic
LINKSAdd links with [Link text](http://link_url.com)Add links with Link text[Link text](http://link_url.com)Link text
+

Dynamic properties

The drop-down menu in the 'Add Labels' form allows you to create labels based on Image metadata. @@ -595,6 +601,16 @@

Dynamic properties

Time: [time.seconds; precision=2; offset=3] Time: -0.06 s + + Z index with units
(first plane is Z: 0.00 µm),
offset by 3 times the Z pixel size + Z: [z.unit; offset=3] + Z: -3.00 µm + + + Z index (first plane is Z: 1)
offset by 3 + Z: [z.pixel; offset=3] + Z: -2 + Image ID Image ID: [image.id] @@ -605,6 +621,11 @@

Dynamic properties

Dataset ID: [dataset.id] Dataset ID: 1654 + + Zoom + [zoom] + 100 % +

Legend

The figure legend will be included in the PDF info page when the figure is @@ -698,8 +719,14 @@