From 3998c016097ef9154d2df3e0d6c907178a1a8685 Mon Sep 17 00:00:00 2001 From: William Moore Date: Wed, 26 Apr 2017 12:34:20 +0100 Subject: [PATCH 01/12] Initial support for export-to-OMERO in script and UI --- .../omero/figure_scripts/Figure_To_Pdf.py | 52 ++++++++++++++++--- omero_figure/templates/figure/index.html | 5 ++ 2 files changed, 51 insertions(+), 6 deletions(-) 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 95439356c..3b6c1d92f 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -678,6 +678,11 @@ def build_figure(self): id1 = panels_json[0]['imageId'] group_id = self.conn.getObject("Image", id1).getDetails().group.id.val + # PDF will get created in this group + if group_id is None: + group_id = self.conn.getEventContext().groupId + self.conn.SERVICE_OPTS.setOmeroGroup(group_id) + # For each page, add panels... col = 0 row = 0 @@ -703,11 +708,11 @@ def build_figure(self): # Saves the completed figure file self.save_figure() - # PDF will get created in this group - if group_id is None: - group_id = self.conn.getEventContext().groupId - self.conn.SERVICE_OPTS.setOmeroGroup(group_id) + file_ann = self.create_file_annotation(image_ids) + return file_ann + + def create_file_annotation(self, image_ids): output_file = self.figure_file_name ns = self.ns mimetype = self.mimetype @@ -1590,6 +1595,39 @@ def save_figure(self): self.figure_canvas.save() +class OmeroExport(TiffExport): + + def __init__(self, conn, script_params): + + super(OmeroExport, self).__init__(conn, script_params, export_images) + + def save_page(self): + """ + Save the current PIL image page as a TIFF and start a new + PIL image for the next page + """ + self.figure_file_name = self.get_figure_file_name() + + # self.tiff_figure.save(self.figure_file_name) + + import numpy + if (self.export_omero): + np_array = numpy.asarray(self.tiff_figure) + red = np_array[::,::,0] + green = np_array[::,::,1] + blue = np_array[::,::,2] + plane_gen = iter([red, green, blue]) + image_id = self.conn.createImageFromNumpySeq(plane_gen, + self.figure_file_name, + sizeC=3, + description=None, dataset=None) + # Create a new blank tiffFigure for subsequent pages + self.create_figure() + + def create_file_annotation(self, image_ids): + pass + + def export_figure(conn, script_params): # make sure we can find all images @@ -1605,7 +1643,8 @@ def export_figure(conn, script_params): fig_export = TiffExport(conn, script_params) elif export_option == 'TIFF_IMAGES': fig_export = TiffExport(conn, script_params, export_images=True) - + elif export_option == 'OMERO_IMAGES': + fig_export = OmeroExport(conn, script_params, export_omero=True) return fig_export.build_figure() @@ -1616,7 +1655,8 @@ def run_script(): """ export_options = [rstring('PDF'), rstring('PDF_IMAGES'), - rstring('TIFF'), rstring('TIFF_IMAGES')] + rstring('TIFF'), rstring('TIFF_IMAGES'), + rstring('OMERO_IMAGES')] client = scripts.client( 'Figure_To_Pdf.py', diff --git a/omero_figure/templates/figure/index.html b/omero_figure/templates/figure/index.html index a256d4c86..adb67512a 100644 --- a/omero_figure/templates/figure/index.html +++ b/omero_figure/templates/figure/index.html @@ -758,6 +758,11 @@ TIFF with images +
  • + + New OMERO Image +
  • From 6d07fc883b7f9c39deb573bc3841b1b46b07d710 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 27 Apr 2017 14:51:46 +0100 Subject: [PATCH 02/12] Export script returns new OMERO image --- .../omero/figure_scripts/Figure_To_Pdf.py | 60 +++++++++++-------- 1 file changed, 36 insertions(+), 24 deletions(-) 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 3b6c1d92f..7f358e042 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -19,6 +19,7 @@ import logging import json import unicodedata +import numpy from datetime import datetime import os @@ -213,7 +214,8 @@ def draw_rectangle(self, shape): g = float(rgb[1])/255 b = float(rgb[2])/255 self.canvas.setStrokeColorRGB(r, g, b) - stroke_width = shape['strokeWidth'] * self.scale + stroke_width = shape['strokeWidth'] if 'strokeWidth' in shape else 2 + stroke_width = stroke_width * self.scale self.canvas.setLineWidth(stroke_width) rotation = self.panel['rotation'] * -1 @@ -481,7 +483,7 @@ def draw_line(self, shape): def draw_rectangle(self, shape): # clockwise list of corner points on the OUTSIDE of thick line - w = shape['strokeWidth'] + w = shape['strokeWidth'] if 'strokeWidth' in shape else 2 cx = shape['x'] + (shape['width']/2) cy = shape['y'] + (shape['height']/2) rotation = self.panel['rotation'] * -1 @@ -705,7 +707,7 @@ def build_figure(self): # Add thumbnails and links page self.add_info_page(panels_json) - # Saves the completed figure file + # Saves the completed figure file self.save_figure() file_ann = self.create_file_annotation(image_ids) @@ -1599,33 +1601,43 @@ class OmeroExport(TiffExport): def __init__(self, conn, script_params): - super(OmeroExport, self).__init__(conn, script_params, export_images) + super(OmeroExport, self).__init__(conn, script_params) + + self.new_image = None def save_page(self): """ - Save the current PIL image page as a TIFF and start a new + Save the current PIL image page as a new OMERO images and start a new PIL image for the next page """ self.figure_file_name = self.get_figure_file_name() - # self.tiff_figure.save(self.figure_file_name) - - import numpy - if (self.export_omero): - np_array = numpy.asarray(self.tiff_figure) - red = np_array[::,::,0] - green = np_array[::,::,1] - blue = np_array[::,::,2] - plane_gen = iter([red, green, blue]) - image_id = self.conn.createImageFromNumpySeq(plane_gen, - self.figure_file_name, - sizeC=3, - description=None, dataset=None) + # Try to get a Dataset + dataset = None + for p in self.figure_json['panels']: + dataset = conn.getObject('Image', p['imageId'] + + description = self.figure_json.get('legend') + + np_array = numpy.asarray(self.tiff_figure) + red = np_array[::,::,0] + green = np_array[::,::,1] + blue = np_array[::,::,2] + plane_gen = iter([red, green, blue]) + self.new_image = self.conn.createImageFromNumpySeq( + plane_gen, + self.figure_file_name, + sizeC=3, + description=description, dataset=None) # Create a new blank tiffFigure for subsequent pages self.create_figure() def create_file_annotation(self, image_ids): - pass + """Return result of script.""" + + # We don't need to create file annotation, but we can return + # the new image, which will be returned from the script + return self.new_image def export_figure(conn, script_params): @@ -1643,8 +1655,8 @@ def export_figure(conn, script_params): fig_export = TiffExport(conn, script_params) elif export_option == 'TIFF_IMAGES': fig_export = TiffExport(conn, script_params, export_images=True) - elif export_option == 'OMERO_IMAGES': - fig_export = OmeroExport(conn, script_params, export_omero=True) + elif export_option == 'OMERO': + fig_export = OmeroExport(conn, script_params) return fig_export.build_figure() @@ -1656,7 +1668,7 @@ def run_script(): export_options = [rstring('PDF'), rstring('PDF_IMAGES'), rstring('TIFF'), rstring('TIFF_IMAGES'), - rstring('OMERO_IMAGES')] + rstring('OMERO')] client = scripts.client( 'Figure_To_Pdf.py', @@ -1691,10 +1703,10 @@ def run_script(): file_annotation = export_figure(conn, script_params) # return this file_annotation to the client. - client.setOutput("Message", rstring("Pdf Figure created")) + client.setOutput("Message", rstring("Figure created")) if file_annotation is not None: client.setOutput( - "File_Annotation", + "New_Figure", robject(file_annotation._obj)) finally: From 197fe4bea9ab8417a0c0e2dfc0012e8c2eec0fac Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 27 Apr 2017 14:52:13 +0100 Subject: [PATCH 03/12] New OMERO Image link displayed on script finished in UI --- omero_figure/templates/figure/index.html | 3 ++- src/js/views/figure_view.js | 23 ++++++++++++++++++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/omero_figure/templates/figure/index.html b/omero_figure/templates/figure/index.html index adb67512a..121e3b192 100644 --- a/omero_figure/templates/figure/index.html +++ b/omero_figure/templates/figure/index.html @@ -713,9 +713,10 @@ Exporting Figure... - diff --git a/src/js/views/figure_view.js b/src/js/views/figure_view.js index 3d0f7acb2..852b54d47 100644 --- a/src/js/views/figure_view.js +++ b/src/js/views/figure_view.js @@ -168,7 +168,8 @@ opts = {"PDF": "PDF", "PDF & images": "PDF_IMAGES", "TIFF": "TIFF", - "TIFF & images": "TIFF_IMAGES"}; + "TIFF & images": "TIFF_IMAGES", + "to OMERO": "OMERO"}; exportOption = opts[export_opt]; // Get figure as json @@ -214,10 +215,22 @@ $pdf_inprogress.hide(); // Show result - if (pdf_job.results.File_Annotation) { - var fa_id = pdf_job.results.File_Annotation.id, - fa_download = WEBINDEX_URL + "annotation/" + fa_id + "/"; - $pdf_download.attr('href', fa_download).show(); + if (pdf_job.results.New_Figure) { + var fa_id = pdf_job.results.New_Figure.id; + if (pdf_job.results.New_Figure.type === "FileAnnotation") { + var fa_download = WEBINDEX_URL + "annotation/" + fa_id + "/"; + $pdf_download + .attr({'href': fa_download, 'data-original-title': 'Download Figure'}) + .show() + .children('span').prop('class', 'glyphicon glyphicon-download-alt'); + } else if (pdf_job.results.New_Figure.type === "Image") { + var fa_download = pdf_job.results.New_Figure.browse_url; + $pdf_download + .attr({'href': fa_download, 'data-original-title': 'Go to Figure Image'}) + .show() + .tooltip() + .children('span').prop('class', 'glyphicon glyphicon-share'); + } } else if (pdf_job.stderr) { // Only show any errors if NO result var stderr_url = WEBINDEX_URL + "get_original_file/" + pdf_job.stderr + "/"; From fcf28a07fcb7aa5b53863db042a8bf68a892d189 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 27 Apr 2017 15:33:17 +0100 Subject: [PATCH 04/12] Export image into Dataset in correct group Also handle multiple page figures --- .../omero/figure_scripts/Figure_To_Pdf.py | 45 ++++++++++++------- 1 file changed, 30 insertions(+), 15 deletions(-) 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 7f358e042..7b16fe473 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -584,13 +584,15 @@ def get_zip_name(self): name = name.replace(",", ".") return "%s.zip" % name - def get_figure_file_name(self): + def get_figure_file_name(self, page=None): """ For PDF export we will only create a single figure file, but for TIFF export we may have several pages, so we need unique names for each to avoid overwriting. This method supports both, simply using different extension (pdf/tiff) for each. + + @param page: If we know a page number we want to use. """ # Extension is pdf or tiff @@ -611,7 +613,7 @@ def get_figure_file_name(self): # Remove commas: causes problems 'duplicate headers' in file download full_name = full_name.replace(",", ".") - index = 1 + index = page if page is not None else 1 if fext == "tiff" and self.page_count > 1: full_name = "%s_page_%02d.%s" % (name, index, fext) if self.zip_folder_name is not None: @@ -680,11 +682,6 @@ def build_figure(self): id1 = panels_json[0]['imageId'] group_id = self.conn.getObject("Image", id1).getDetails().group.id.val - # PDF will get created in this group - if group_id is None: - group_id = self.conn.getEventContext().groupId - self.conn.SERVICE_OPTS.setOmeroGroup(group_id) - # For each page, add panels... col = 0 row = 0 @@ -697,7 +694,7 @@ def build_figure(self): self.add_panels_to_page(panels_json, image_ids, page) # complete page and save - self.save_page() + self.save_page(p) col = col + 1 if col >= page_col_count: @@ -710,6 +707,11 @@ def build_figure(self): # Saves the completed figure file self.save_figure() + # PDF will get created in this group + if group_id is None: + group_id = self.conn.getEventContext().groupId + self.conn.SERVICE_OPTS.setOmeroGroup(group_id) + file_ann = self.create_file_annotation(image_ids) return file_ann @@ -1335,7 +1337,7 @@ def create_figure(self): self.figure_canvas = canvas.Canvas( name, pagesize=(self.page_width, self.page_height)) - def save_page(self): + def save_page(self, page=None): """ Called on completion of each page. Saves page of PDF """ self.figure_canvas.showPage() @@ -1558,7 +1560,7 @@ def draw_text(self, text, x, y, fontsize, rgb, align="center"): x = x - txt_w textdraw.text((x, y), text, font=font, fill=rgb) - def save_page(self): + def save_page(self, page=None): """ Save the current PIL image page as a TIFF and start a new PIL image for the next page @@ -1605,17 +1607,28 @@ def __init__(self, conn, script_params): self.new_image = None - def save_page(self): + def save_page(self, page=None): """ Save the current PIL image page as a new OMERO images and start a new PIL image for the next page """ - self.figure_file_name = self.get_figure_file_name() + self.figure_file_name = self.get_figure_file_name(page + 1) # Try to get a Dataset dataset = None - for p in self.figure_json['panels']: - dataset = conn.getObject('Image', p['imageId'] + for panel in self.figure_json['panels']: + parent = self.conn.getObject('Image', panel['imageId']).getParent() + if parent is not None and parent.OMERO_CLASS == 'Dataset': + if parent.canLink(): + dataset = parent + break + + # Need to specify group for new image + group_id = self.conn.getEventContext().groupId + if dataset is not None: + group_id = dataset.getDetails().group.id.val + dataset = dataset._obj # get the omero.model.DatasetI + self.conn.SERVICE_OPTS.setOmeroGroup(group_id) description = self.figure_json.get('legend') @@ -1628,7 +1641,9 @@ def save_page(self): plane_gen, self.figure_file_name, sizeC=3, - description=description, dataset=None) + description=description, dataset=dataset) + # Reset group context + self.conn.SERVICE_OPTS.setOmeroGroup(-1) # Create a new blank tiffFigure for subsequent pages self.create_figure() From 7cce2d4423f7428da7f94fb89b2980ba1c86aee5 Mon Sep 17 00:00:00 2001 From: William Moore Date: Thu, 27 Apr 2017 15:38:12 +0100 Subject: [PATCH 05/12] flake8 fixes --- .../scripts/omero/figure_scripts/Figure_To_Pdf.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) 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 7b16fe473..ac1ce0d12 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -715,7 +715,6 @@ def build_figure(self): file_ann = self.create_file_annotation(image_ids) return file_ann - def create_file_annotation(self, image_ids): output_file = self.figure_file_name ns = self.ns @@ -1633,15 +1632,15 @@ def save_page(self, page=None): description = self.figure_json.get('legend') np_array = numpy.asarray(self.tiff_figure) - red = np_array[::,::,0] - green = np_array[::,::,1] - blue = np_array[::,::,2] + red = np_array[::, ::, 0] + green = np_array[::, ::, 1] + blue = np_array[::, ::, 2] plane_gen = iter([red, green, blue]) self.new_image = self.conn.createImageFromNumpySeq( - plane_gen, - self.figure_file_name, - sizeC=3, - description=description, dataset=dataset) + plane_gen, + self.figure_file_name, + sizeC=3, + description=description, dataset=dataset) # Reset group context self.conn.SERVICE_OPTS.setOmeroGroup(-1) # Create a new blank tiffFigure for subsequent pages From 2309f90f4b3a9e22bdc6b0a06d3788d1b91f740d Mon Sep 17 00:00:00 2001 From: William Moore Date: Tue, 2 May 2017 16:00:42 +0100 Subject: [PATCH 06/12] Use try/except to import numpy Since we only use numpy for OMERO export, this means the script can still be used for other export if we happen to be missing numpy --- omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 ac1ce0d12..f661c5599 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -19,7 +19,6 @@ import logging import json import unicodedata -import numpy from datetime import datetime import os @@ -61,6 +60,11 @@ logger.error("Reportlab not installed. See" " https://pypi.python.org/pypi/reportlab/") +try: + import numpy +except ImportError: + pass + ORIGINAL_DIR = "1_originals" RESAMPLED_DIR = "2_pre_resampled" From bf9b3be8400c12024d2233794c750ea8464cd703 Mon Sep 17 00:00:00 2001 From: William Moore Date: Tue, 2 May 2017 16:01:36 +0100 Subject: [PATCH 07/12] Export script handles missing images (image is None) --- omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py | 6 ++++++ 1 file changed, 6 insertions(+) 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 f661c5599..0c89a1319 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -1131,6 +1131,8 @@ def draw_panel(self, panel, page, idx): y = y - page['y'] image = self.conn.getObject("Image", image_id) + if image is None: + return None, None self.apply_rdefs(image, channels) # create name to save image @@ -1158,6 +1160,8 @@ def get_thumbnail(self, image_id): conn = self.conn image = conn.getObject("Image", image_id) + if image is None: + return thumb_data = image.getThumbnail(size=(96, 96)) i = StringIO(thumb_data) pil_img = Image.open(i) @@ -1317,6 +1321,8 @@ def add_panels_to_page(self, panels_json, image_ids, page): # For TIFF export, draw_panel() also adds shapes to the # PIL image before pasting onto the page... image, pil_img = self.draw_panel(panel, page, i) + if image is None: + continue if image.canAnnotate(): image_ids.add(image_id) # ... but for PDF we have to add shapes to the whole PDF page From 3660fba5a7e9a7cb9f2b6212fac14d30e997b872 Mon Sep 17 00:00:00 2001 From: William Moore Date: Tue, 2 May 2017 16:37:55 +0100 Subject: [PATCH 08/12] Provide more info and url in new image description --- .../scripts/omero/figure_scripts/Figure_To_Pdf.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 0c89a1319..65c346fee 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -1639,7 +1639,13 @@ def save_page(self, page=None): dataset = dataset._obj # get the omero.model.DatasetI self.conn.SERVICE_OPTS.setOmeroGroup(group_id) - description = self.figure_json.get('legend') + description = "Created from OMERO.figure: " + url = self.script_params.get("Figure_URI") + legend = self.figure_json.get('legend') + if url is not None: + description += url + if legend is not None: + description = "%s\n\n%s" % (description ,legend) np_array = numpy.asarray(self.tiff_figure) red = np_array[::, ::, 0] From 33ec09b7993deada852de12f202d05e5cf08103c Mon Sep 17 00:00:00 2001 From: William Moore Date: Tue, 2 May 2017 16:42:05 +0100 Subject: [PATCH 09/12] flake8 fix --- omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 65c346fee..d182471ec 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -1645,7 +1645,7 @@ def save_page(self, page=None): if url is not None: description += url if legend is not None: - description = "%s\n\n%s" % (description ,legend) + description = "%s\n\n%s" % (description, legend) np_array = numpy.asarray(self.tiff_figure) red = np_array[::, ::, 0] From 8835b05447cddf9787ea29353df5755ae3d71d43 Mon Sep 17 00:00:00 2001 From: William Moore Date: Wed, 3 May 2017 12:05:52 +0100 Subject: [PATCH 10/12] Revert "Use try/except to import numpy" This reverts commit 2309f90f4b3a9e22bdc6b0a06d3788d1b91f740d. --- omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) 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 d182471ec..8884966b4 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -19,6 +19,7 @@ import logging import json import unicodedata +import numpy from datetime import datetime import os @@ -60,11 +61,6 @@ logger.error("Reportlab not installed. See" " https://pypi.python.org/pypi/reportlab/") -try: - import numpy -except ImportError: - pass - ORIGINAL_DIR = "1_originals" RESAMPLED_DIR = "2_pre_resampled" From a47f0dbac1a9cca2fc8056c547c63d831a18d48e Mon Sep 17 00:00:00 2001 From: William Moore Date: Wed, 3 May 2017 12:12:58 +0100 Subject: [PATCH 11/12] Fixed suggestions from PR 210 --- .../scripts/omero/figure_scripts/Figure_To_Pdf.py | 8 +++----- omero_figure/templates/figure/index.html | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) 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 8884966b4..9fbefd1ac 100644 --- a/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py +++ b/omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py @@ -58,8 +58,7 @@ reportlab_installed = True except ImportError: reportlab_installed = False - logger.error("Reportlab not installed. See" - " https://pypi.python.org/pypi/reportlab/") + logger.error("Reportlab not installed.") ORIGINAL_DIR = "1_originals" @@ -712,8 +711,7 @@ def build_figure(self): group_id = self.conn.getEventContext().groupId self.conn.SERVICE_OPTS.setOmeroGroup(group_id) - file_ann = self.create_file_annotation(image_ids) - return file_ann + return self.create_file_annotation(image_ids) def create_file_annotation(self, image_ids): output_file = self.figure_file_name @@ -1614,7 +1612,7 @@ def __init__(self, conn, script_params): def save_page(self, page=None): """ - Save the current PIL image page as a new OMERO images and start a new + Save the current PIL image page as a new OMERO image and start a new PIL image for the next page """ self.figure_file_name = self.get_figure_file_name(page + 1) diff --git a/omero_figure/templates/figure/index.html b/omero_figure/templates/figure/index.html index 121e3b192..fb787fb9d 100644 --- a/omero_figure/templates/figure/index.html +++ b/omero_figure/templates/figure/index.html @@ -760,7 +760,7 @@ TIFF with images
  • + title="Export each page as an Image in OMERO"> New OMERO Image
  • From e32835b8f552393ca9a0f1ef34b55996ec03d855 Mon Sep 17 00:00:00 2001 From: William Moore Date: Wed, 3 May 2017 12:37:46 +0100 Subject: [PATCH 12/12] Show spinner for 'Exporting Figure' --- omero_figure/static/figure/css/figure.css | 8 ++++++++ omero_figure/templates/figure/index.html | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/omero_figure/static/figure/css/figure.css b/omero_figure/static/figure/css/figure.css index b2f8e7e16..a474a3726 100644 --- a/omero_figure/static/figure/css/figure.css +++ b/omero_figure/static/figure/css/figure.css @@ -704,6 +704,14 @@ transform: rotate(90deg); } + @keyframes spin { + 100% { -webkit-transform: rotate(360deg); transform:rotate(360deg); } + } + + .navbar-right .glyphicon-refresh { + animation: spin 2s linear infinite; + padding: 2px 2px 5px 2px; + } .colorpicker span, .label-color span:first-child, diff --git a/omero_figure/templates/figure/index.html b/omero_figure/templates/figure/index.html index fb787fb9d..afe9d799b 100644 --- a/omero_figure/templates/figure/index.html +++ b/omero_figure/templates/figure/index.html @@ -710,7 +710,8 @@