Warning: session_start(): open(/var/lib/php/sessions/sess_159t35mc0obsoh3kp7t0et90jb, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
!7
module MarkImage > DynImageSurface {
File file;
transient JTable table;
start {
ownResource(onClipboardFile(vf loadFile));
}
void loadFile(final File f) enter {
if (!isImageFile(f)) ret;
setModuleName("Mark Image - " + f2s(f));
setField(file := f);
setImage(loadImage2(file));
loadMarkings();
}
visualize {
table = sexyTable();
JComponent i = super.visualize();
loadFile(file);
ret withCenteredButtons(jvsplit(i,
jSection("Marked things", table)),
imageSelectionDepend(imageSurface, jbutton("Mark selection...", rThread markSelection)),
jHelpIcon("Copy an image to the clipboard to mark it here"));
}
void markSelection enter {
Rect r = getSelection();
if (r == null) ret;
inputText("Enter description for selected area", voidfunc(S name) {
LPair markings = unnull(loadImageFileMarkings(file));
setAdd(markings, pair(r, name));
print("New markings:");
pnlIndent(markings);
saveImageFileMarkings(file, markings);
});
}
void loadMarkings {
LPair markings = unnull(loadImageFileMarkings(file));
dataToTable(table, map(markings, p -> litorderedmap("Rect" := str(p.a), "Description" := p.b)));
}
}