-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMacros
66 lines (63 loc) · 2.28 KB
/
Macros
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//------------------- C l i c k C o o r d i n a t e s T o o l
-------------------
//
// On each click into an image, the x, y coordinates of the point are
// written into the "Results" window. The point can be also marked
// in the image (destructively). This tool can handle scaled images
// (also with nontrivial pixel aspect ratio). Double click on the tool
// icon to display the options dialog box. The "Invert Y" option in
// Analyze>Set Measurements is supported.
var outputScaled = 1; // report raw coordinates (pixels) if false
var drawPoints = 0; // draw cross at position of click
var drawNumbers = 0; // draw line number for each click
macro 'Click Coordinates Tool -
{
requires("1.37e");
getCursorLoc(x, y, z, flags);
if (drawPoints || drawNumbers) setupUndo();
if (drawPoints) {
setLineWidth(1);
tickLength = 3; // the "radius" of the crosses marking the points
drawLine(maxOf(x-tickLength,0),y,
minOf(x+tickLength,getWidth()-1), y);
drawLine(x,maxOf(y-tickLength,0), x,
minOf(y+tickLength,getHeight()-1));
}
if (drawNumbers) {
setFont("SansSerif",9);
if (drawPoints) {
setJustification("left");
xText = x + tickLength + 1;
} else {
setJustification("center");
xText = x + 1;
}
drawString(nResults+1, xText, y+6);
}
invertY =
parseInt(call("ij.plugin.filter.Analyzer.getMeasurements"))&4096!=0;
if (invertY) y = getHeight() - y - 1;
xScale = 1;
yScale = 1;
if (outputScaled) {
getPixelSize(unit, pixelWidth, pixelHeight);
} else {
pixelWidth = 1;
pixelHeight = 1;
}
setResult("X", nResults, x*pixelWidth);
setResult("Y", nResults-1, y*pixelHeight);
updateResults();
}
macro 'Click Coordinates Tool Options...' {
requires("1.37e");
Dialog.create("Click Coordinates Tool Options");
Dialog.addCheckbox("Scaled Coordinates", outputScaled);
Dialog.addCheckbox("Draw Cross at Each Clicked Point", drawPoints);
Dialog.addCheckbox("Write Point Number at Each Clicked Point",
drawNumbers);
Dialog.show();
outputScaled = Dialog.getCheckbox();
drawPoints = Dialog.getCheckbox();
drawNumbers = Dialog.getCheckbox();
}