Hi Ioannis,
Sorry for taking so long in getting back to you.
1) which method of Dialog I should use to perform a global cleanup ? (a destructor ? ) Maybe I have to overwrite "done" ?
What do you mean by "global cleanup"? If you mean destroying the Dialog object synchronously ala C++ for example, then never mind: object destruction is automatic in JavaScript. For example, this code:
var A = new Matrix( 1000, 1000 );creates a new Matrix object with 1,000,000 elements. After this code, suppose we have this at some point where A is still in scope:
A = null;After this statement, if there are no other references to the original Matrix object, then it will eventually be destroyed. When? We actually have no control on this. The 'orphan' object will be destroyed when the JavaScript runtime's
garbage collector decides to do so. JavaScript's garbage collector is a rather complex and sophisticated device. It frees memory asynchronously when it decides that the amount of released memory is worth the time required to run object destructors and restructure the internal memory arena. We have the
gc() global function, which we can call to tell the engine that now is a good time to run the garbage collector, but it has the right to ignore our suggestion completely or partially.
Maybe I have to overwrite "done" ?
This has nothing to do with memory management. The
done method of the Dialog object, namely:
void Dialog.done( int retCode )can be called to terminate the current modal session. The
retCode argument is the dialog's exit code. In general an exit code can be any integer value, but the standard dialog exit codes:
StdDialogCode_Cancel
StdDialogCode_Okshould always be used.
2) how do I change the position on the screen of an ImageWindow ?
By assigning a Point object to the
position property of the ImageWindow object:
Point ImageWindow.positionFor example:
ImageWindow w;
w.pos = new Point( 100, 200 ); // move w to x=100 y=200 in its parent workspaceBeware of setting
ImageWindow.position properties directly such as the following code:
w.pos.x = 100;
w.pos.y = 200;because it won't work. As soon as the compiler sees
w.pos.x it generates a temporary Point object which is
not the same as
w.pos. This happens because ImageWindow is not a JavaScript object, but a reflection (an alias) of a native PixInsight/PCL object, so the JS engine does not know how to reference properties of properties of ImageWindow (JavaScript's prototype-based inheritance chain is broken for native aliased objects beyond the first layer of properties exposed by the engine).
Unfortunately, the JS engine in version 1.7 still doesn't implement many objects that are necessary to manage the entire PixInsight workspace. This functionality will be complete in version 1.8 with runtime objects such as Workspace, Icon, etc.
3) Is there a way to create a modless Dialog?
Nope. Dialogs are always modal in PJSR, and there is no way to integrate a JavaScript message loop with the core application's message loop. This is a limitation of the PJSR due to reentrancy problems, which I hope to overcome in version 2.0 of PixInsight.
4 ) How do I exclude specific views from a ViewList ? The name (or a pattern of the name) of the views is my filter to exclude them.
You can exclude a single view by assigning the corresponding View object to
ViewList.excludedView. However you cannot exclude multiple views with a similar mechanism, beyond calling
ViewList.getMainViews() and
ViewList.getPreviews() to restrict the list to a particular type of views.
After loading all views (or previews / main views), you can implement a filter adapted to your needs with the
ViewList.remove( View ) method.
Let me know if you need further help.