Hi Andres, David,
Excellent questions and discussion topics. David has already described the required procedure to obtain the JavaScript equivalent to an existing instance (import from ProcessContainer and copy the right-panel's script contents), so let's restart from the end (reverse iterator
):
Should the desktop background be an object?
Definitely yes. I'm working on this (among many other new features) for version 1.5. It is the Workspace JavaScript object, which will give access to most elements of PixInsight's workspace. Another new object is Icon, with two derived objects: ProcessIcon and ImageIcon.
ProcessIcon and ImageIcon allow you to control most properties and methods of icons in PixInsight. For example, you can create process icons with instances generated programatically from JavaScript code, rename them, define their textual information, get copies of their transported instances, save/load .psm files, and delete icons. You can also iconize an image and send the icon to the third workspace, for example. This is Just to enumerate a set of key features.
Workspace allows you to move and organize windows and Icon instances, and to manage multiple workspaces. In fact you can write a fancy workspace organizer with JavaScript very easily
Note that these objects and functions are going to be exclusive of PixInsight's scripting engine. The PCL won't define equivalent C++ classes (although a module can define and execute JavaScript code programatically, using the Console C++ class, if the user has given it enough permissions).
That said, I don't know how to manage dynamic processes (a category DBE belongs) from JS. A quick look reveals that you can create the object and specify the location of all samples, but it seems that it's not possible to generate samples automatically (although there are settable properties for samplesPerRow, tolerance and such things).
No, you can't define samples automatically by telling DBE's interface to generate them. This is because there's no way to interact with a processing interface from JS, and the automatic sample generation feature belongs to DBE's interface, not to the DBE process.
Although you can define DBE samples very easily from JS code, by doing so you can't force a DBE instance to acquire actual sample values from a particular image. So even if you define an instance with a set of DBE samples regularly located over an image, you still depend on a user loading the instance from DBE's interface.
Now this leads us to a third category of improvements to PixInsight's scripting engine: interaction with processing interfaces. To accomplish this task a new ProcessingInterface object should be defined. ProcessingInterface (from which a corresponding derived object should be created automatically for each installed interface) should expose a large number of dynamic and static methods and data items available on PI's processing interfaces. For example, DBE's automatic generation feature would be available as a method of the DBE interface object. These mechanisms are extremely complex and still unclear. Basically, with this implemented you could automatize an entire workflow, turning the entire PixInsight environment into a robot. This has endless possibilities, but the amount of work required is immense.