VivoQuant 6.5.0
Loading...
Searching...
No Matches
Customizable VQS UI
var scriptPath = VQ.getScriptPath().replace(/[/\\‍][^/\\‍]+$/, "");
//---------------------------------------------------------
// Start - Only for internal testing (users can disregard or remove)
//---------------------------------------------------------
var isTestModule = scriptPath.indexOf("extern/t/TestModules") !== -1;
VQ.setTestMode(isTestModule);
//---------------------------------------------------------
// End - Only for internal testing (users can disregard or remove)
//---------------------------------------------------------
//---------------------------------------------------------
// Script Panel example
//
// The Script Panel is a dock that a script fills with fields. The script can update
// the fields while it works and read back what the user entered. Closing the dock
// only hides it; it can be reopened from the Script > VivoScript Panel menu.
// The Script Panel Tutorial in the Workflow Assistant goes further, step by step: tabs,
// repeatables, the status line, reacting to edits and waiting for the user.
//---------------------------------------------------------
var panel = VQ.scriptPanel();
panel.clear();
panel.setTitle("QC Review");
// Describe the fields. 'name' is the key used to set and read a field; 'label' is the
// text shown next to it (it defaults to the name).
panel.setFields([
{ name: 'status', label: 'Status', type: 'label', value: 'Starting...' },
// A section groups fields in a framed box, here in two columns.
{ type: 'section', label: 'Review', columns: 2, children: [
{ name: 'reader', label: 'Reader', type: 'text' },
{ name: 'quality', label: 'Image quality', type: 'item', items: ['Good', 'Acceptable', 'Poor'] },
{ name: 'lesions', label: 'Lesions', type: 'int', min: 0, max: 50 },
{ name: 'repeat', label: 'Repeat scan', type: 'bool' }
] },
{ name: 'notes', label: 'Notes', type: 'textarea',
tooltip: 'Anything the next reader should know' }
]);
panel.showPanel();
// Update fields while the script works. Values set by the script show immediately.
var steps = ['Loading', 'Checking orientation', 'Measuring'];
for (var i = 0; i < steps.length; i++) {
panel.setValue('status', steps[i] + '...');
// ... the real work for this step goes here ...
}
panel.setValue('status', 'Done');
// Fill in fields, for example from the loaded data.
panel.setValue('reader', 'Example reader');
panel.setValue('lesions', 3);
// Setting a name the panel doesn't have adds a text field for it, so the panel can
// also be used as a simple log.
panel.setValue('Steps completed', steps.length);
// To let the user review and edit the fields before the script goes on, wait for a
// button at the bottom of the panel:
//
// panel.wait('Submit');
//
// wait() returns true when the user presses the button, and false if the script is
// stopped. While the script waits, the user can edit the panel and use the rest of
// VivoQuant.
// Read back all values: an object from field name to value.
var values = panel.values();
VQ.debug("Panel values: " + JSON.stringify(values));
if (VQ.isTestMode()) {
VQ.quit();
}