Skip to content

Commit

Permalink
Merge pull request #555 from will-moore/points_in_shapeEditor
Browse files Browse the repository at this point in the history
Points in shape editor
  • Loading branch information
jburel authored Oct 4, 2024
2 parents 896a35b + 41b3686 commit 1c0e5f9
Show file tree
Hide file tree
Showing 11 changed files with 510 additions and 9 deletions.
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 @@ -465,7 +465,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 @@ -761,7 +761,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 @@ -772,7 +772,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
4 changes: 4 additions & 0 deletions src/css/figure.css
Original file line number Diff line number Diff line change
Expand Up @@ -1266,6 +1266,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.
2 changes: 1 addition & 1 deletion src/js/models/panel_model.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,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
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 1c0e5f9

Please sign in to comment.