Here is a workaround using parsing of the xml representation of the processes.
This small script list the images referencing a mask, may be useful if you do not remember where a mask is used (if at all).
"use strict";
// ShowMaskUsage.js
// List the views referencing a mask.
// Select the mask, execute the script, the referencing views will be logged on the console
// This is somewhat hacky and may not be 100% right, but proved useful.
#define DEBUG false
// Search masks refered to in a process container
var searchMask = /mask id="([^"]+)"/;
function isMaskReferencedInProcessContainer(maskId, pc) {
if (pc == null) return false;
for (var i=0; i<pc.length; i++) {
var p = pc.at(i);
var source = p.toSource("XPSM 1.0");
var lines = source.split("\n");
// if(DEBUG) Console.writeln("DEBUG - process " + source.replace("<", "<","g").replace(">",">","g"));
for (var j=0; j<lines.length;j++) {
var line = lines[j];
var searchResult = searchMask.exec(line);
if(searchResult) {
var maskIdInHistory = searchResult[1];
if (DEBUG) Console.writeln("DEBUG -entry " + i + ", line " + j + ", mask: " + maskIdInHistory);
if (maskIdInHistory === maskId) return true;
};
}
}
// None found
return false;
}
// { maskId -> {viewId - > count,...}, ... }
var maskUsage = {};
function addMaskReferences(name, maskIds) {
for (var i=0; i<maskIds.length;i++) {
var maskId = maskIds[i];
if (maskUsage.hasOwnProperty(maskId)) {
var ref = maskUsage[maskId];
if (ref.hasOwnProperty(name)) {
ref[name] = ref[name] + 1;
} else {
ref[name] = 1;
}
} else {
maskUsage[maskId] = new Object;
maskUsage[maskId][name]=1;
}
}
}
function main()
{
Console.show();
Console.writeln("ShowMaskUsage - list which views references the current view as a mask");
var aw = ImageWindow.activeWindow;
var cv = aw.mainView;
if (! aw.isValidView(cv)) { Console.writeln("ERROR - No active view"); return 0; }
var maskId = cv.id;
if (aw.hasMaskReferences) {
Console.writeln("View '" + maskId + "' is used as a mask");
} else {
Console.writeln("View '" + maskId + "' is not used as a mask");
return 0;
}
// Look up in all windows except current one
var windows = ImageWindow.windows;
var nReferences = 0;
if (DEBUG) Console.writeln("DEBUG - windows.length '" + windows.length);
for (var i=0; i<windows.length; i++) {
var w = windows[i];
var v = w.mainView;
if (DEBUG) Console.writeln("DEBUG - # '" + i + " view '" + v.id + "' cv.id '"+ cv.id + "'");
if (v.id == cv.id) continue;
var isReferencingMask = false;
isReferencingMask |= isMaskReferencedInProcessContainer(maskId, v.initialProcessing);
isReferencingMask |= isMaskReferencedInProcessContainer(maskId, v.processing);
// Also check the current mask
if (DEBUG) Console.writeln("DEBUG - view '" + v.id + "' " + w.mask);
if (typeof w.mask !== "undefined") {
if (DEBUG) Console.writeln("DEBUG - view '" + v.id + "' has mask '" + w.mask.mainView.id + "'");
if (w.mask.mainView.id === maskId) isReferencingMask = true;
}
if (isReferencingMask) {
Console.writeln(" referenced by view '" + v.id + "'");
nReferences ++;
}
}
if (nReferences>0) {
Console.writeln("ShowMaskUsage found " + nReferences + " references to the view '" + cv.id + "'");
} else {
Console.writeln("ShowMaskUsage found no reference to the view '" + cv.id + "'");
}
return nReferences;
}
main();
-- bitli