Skip to content

Commit

Permalink
Merge branch 'ome:master' into image-outline
Browse files Browse the repository at this point in the history
  • Loading branch information
Rdornier authored Oct 10, 2024
2 parents b59d9ee + 1c0e5f9 commit 3e0427f
Show file tree
Hide file tree
Showing 17 changed files with 637 additions and 36 deletions.
30 changes: 19 additions & 11 deletions licenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,21 @@ Library: backbone.mousetrap
Site: https://github.com/elasticsales/backbone.mousetrap
License: MIT

Library: bootstrap3
Library: bootstrap
Site: http://getbootstrap.com/
License: Apache Software License, Version 2
License: MIT

Library: bootstrap-colorpicker
Site: http://mjolnic.com/bootstrap-colorpicker/
License: Apache Software License, Version 2
Library: bootstrap icons
Site: https://github.com/twbs/icons
License: MIT

Library: dompurify
Site: https://www.npmjs.com/package/dompurify
License: Apache License Version 2.0, or Mozilla Public License Version 2.0

Library: json2js
Site: http://www.JSON.org/json2.js
License: Public Domain
Library: jquery
Site: https://jquery.com/
License: MIT

Library: markdown-browser-0.6.0-beta1
Site: https://github.com/evilstreak/markdown-js
Expand All @@ -34,14 +38,18 @@ Library: mousetrap-1.5.3
Site: craig.is/killing/mice
License: Apache Software License, Version 2

Library: shape-editor-3.0.0
Site: https://github.com/ome/shape-editor
License: BSD
Library: @popperjs/core
Site: https://www.npmjs.com/package/@popperjs/core
License: MIT

Library: raphael
Site: https://github.com/fanstatic/js.raphael
License: BSD

Library: sortablejs
Site: https://www.npmjs.com/package/sortablejs
License: MIT

Library: underscore
Site: https://github.com/jashkenas/underscore
License: MIT
Expand Down
37 changes: 30 additions & 7 deletions omero_figure/omeroutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

from omero.sys import ParametersI
from omero.gateway import PlaneInfoWrapper
from omero.model.enums import UnitsTime
from omero.model import TimeI


def get_timestamps(conn, image):
Expand All @@ -28,13 +30,34 @@ def get_timestamps(conn, image):
info_list = conn.getQueryService().findAllByQuery(
query, params, conn.SERVICE_OPTS)
timemap = {}
for info in info_list:
t_index = info.theT.getValue()
if info.deltaT is not None:
# Use wrapper to help unit conversion
plane_info = PlaneInfoWrapper(conn, info)
delta_t = plane_info.getDeltaT('SECOND')
timemap[t_index] = delta_t.getValue()
# check if any PlaneInfo was found
if len(info_list) > 0:
# get time info from the PlaneInfo
for info in info_list:
t_index = info.theT.getValue()
if info.deltaT is not None:
# Use wrapper to help unit conversion
plane_info = PlaneInfoWrapper(conn, info)
delta_t = plane_info.getDeltaT('SECOND')
timemap[t_index] = delta_t.getValue()
# double check to see if timemap actually got populated
if len(info_list) == 0 or len(timemap) == 0:
# get time info from the timeIncrement of the Pixels
time_increment = 0
converted_value = 0
try:
pixels = image.getPrimaryPixels()._obj
time_increment = pixels.getTimeIncrement()
secs_unit = getattr(UnitsTime, "SECOND")
seconds = TimeI(time_increment, secs_unit)
converted_value = seconds.getValue()

except Exception as error:
print(f"An exception occured: {error}\n"
"maybe the image has no 'timeIncrement' set")
if converted_value != 0:
for i in range(image.getSizeT()):
timemap[i] = i*converted_value
time_list = []
for t in range(image.getSizeT()):
if t in timemap:
Expand Down
8 changes: 5 additions & 3 deletions omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ def draw_ellipse(self, shape):
cy = self.page_height - c['y']
rx = shape['radiusX'] * self.scale
ry = shape['radiusY'] * self.scale
rotation = (shape['rotation'] + self.panel['rotation']) * -1
rotation = (shape.get('rotation', 0) + self.panel['rotation']) * -1
r, g, b, a = self.get_rgba(shape['strokeColor'])
self.canvas.setStrokeColorRGB(r, g, b, alpha=a)

Expand Down Expand Up @@ -809,7 +809,7 @@ def draw_ellipse(self, shape):
cy = ctr['y']
rx = self.scale * shape['radiusX']
ry = self.scale * shape['radiusY']
rotation = (shape['rotation'] + self.panel['rotation']) * -1
rotation = (shape.get('rotation', 0) + self.panel['rotation']) * -1

width = int((rx * 2) + w)
height = int((ry * 2) + w)
Expand All @@ -820,7 +820,9 @@ def draw_ellipse(self, shape):
rgba = ShapeToPdfExport.get_rgba_int(shape['strokeColor'])
ellipse_draw.ellipse((0, 0, width, height), fill=rgba)
rgba = self.get_rgba_int(shape.get('fillColor', '#00000000'))
ellipse_draw.ellipse((w, w, width - w, height - w), fill=rgba)
# when rx is ~zero (for a Point, scaled down) don't need inner ellipse
if (width - w) >= w:
ellipse_draw.ellipse((w, w, width - w, height - w), fill=rgba)
temp_ellipse = temp_ellipse.rotate(rotation, resample=Image.BICUBIC,
expand=True)
# Use ellipse as mask, so transparent part is not pasted
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,5 @@ def run(self):
'sdist': require_npm(sdist, True),
'develop': require_npm(develop),
},
tests_require=['pytest', 'numpy'],
tests_require=['pytest'],
)
4 changes: 4 additions & 0 deletions src/css/figure.css
Original file line number Diff line number Diff line change
Expand Up @@ -1267,6 +1267,10 @@
.ellipse-icon{
background-image: url("../images/ellipse-icon-16.png");
}
.point-icon{
background-image: url("../images/point-icon-24.png");
background-position: center;
}
.polygon-icon{
background-image: url("../images/polygon-icon-16.png");
}
Expand Down
Binary file added src/images/point-icon-24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 22 additions & 5 deletions src/js/models/panel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@
return true;
}
var points;
if (shape.type === "Ellipse") {
if (shape.type === "Ellipse" || shape.type === "Point") {
points = [[shape.cx, shape.cy]];
} else if (shape.type === "Rectangle") {
points = [[shape.x, shape.y],
Expand Down Expand Up @@ -569,7 +569,7 @@
// labels_map is {labelKey: {size:s, text:t, position:p, color:c}} or {labelKey: false} to delete
// where labelKey specifies the label to edit. "l.text + '_' + l.size + '_' + l.color + '_' + l.position"
edit_labels: function(labels_map) {

var oldLabs = this.get('labels');
// Need to clone the list of labels...
var labs = [],
Expand All @@ -595,7 +595,7 @@
// Extract all the keys (even duplicates)
var keys = labs.map(lbl => this.get_label_key(lbl));

// get all unique labels based on filtering keys
// get all unique labels based on filtering keys
//(i.e removing duplicate keys based on the index of the first occurrence of the value)
var filtered_lbls = labs.filter((lbl, index) => index == keys.indexOf(this.get_label_key(lbl)));

Expand All @@ -617,12 +617,29 @@
this.save('channels', chs);
},

toggle_channel: function(cIndex, active ) {
save_channels: function(channels) {
// channels should be a list of objects [{key:value}, {}..]
var oldChs = this.get('channels');
// Clone channels, applying changes
var chs = this.get('channels').map((oldCh, idx) => {
return $.extend(true, {}, oldCh, channels[idx]);
});
this.save('channels', chs);
},

toggle_channel: function(cIndex, active) {
if (typeof active == "undefined") {
active = !this.get('channels')[cIndex].active;
}
this.save_channel(cIndex, 'active', active);

if (this.get("hilo_enabled") && active) {
let newChs = this.get('channels').map(function(channel, idx) {
return {'active': idx == cIndex};
});
this.save_channels(newChs);
} else {
this.save_channel(cIndex, 'active', active);
}
},

save_channel_window: function(cIndex, new_w) {
Expand Down
3 changes: 2 additions & 1 deletion src/js/models/undo.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ export const UndoManager = Backbone.Model.extend({
// into undo / redo operations to go into our Edit below
var createUndo = function(callList) {
var undos = [];
for (var u=0; u<callList.length; u++) {
// add in reverse order
for (var u=(callList.length - 1); u>=0; u--) {
undos.push(callList[u]);
}
// get the currently selected panels
Expand Down
5 changes: 5 additions & 0 deletions src/js/shapeEditorTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,11 @@ $(function() {
"y": 260.5,
"x": 419});

shapeManager.addShapeJson({"type": "Point",
"strokeWidth": 2,
"y": 30,
"x": 30});

var s = shapeManager.addShapeJson({"type": "Line",
"strokeColor": "#00ff00",
"strokeWidth": 2,
Expand Down
4 changes: 2 additions & 2 deletions src/js/shape_editor/ellipse.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ Ellipse.prototype.createHandles = function createHandles() {
handle = this.paper.rect(hx - hsize / 2, hy - hsize / 2, hsize, hsize);
handle.attr({ cursor: "move" });
handle.h_id = key;
handle.line = self;
// handle.line = self;

if (this.manager.canEdit) {
handle.drag(_handle_drag(), _handle_drag_start(), _handle_drag_end());
Expand Down Expand Up @@ -511,7 +511,7 @@ Ellipse.prototype.getHandleCoords = function getHandleCoords() {
};
};

// Class for creating Lines.
// Class for creating Ellipse.
var CreateEllipse = function CreateEllipse(options) {
this.paper = options.paper;
this.manager = options.manager;
Expand Down
Loading

0 comments on commit 3e0427f

Please sign in to comment.