Creating an icon from a script

mcore

New member
Hi all -

I'm scripting my standard processing sequence.  I currently have scripts that calibrate and cosmetic correct new data, so that the first thing I need to do is subframe selection.  What I'd like to do is create subframe selection icons as the output of my script so that I can just click and go.  I've found the "writeIcon()" method of the ProcessInstance base class, but this only works to overwrite an existing process icon on the desktop.  What I'd like to do is create a new process icon and then write it.  Does anyone know how / whether this is possible?

Thanks.
 
What I'd like to do is create a new process icon and then write it.

This cannot be done yet. I plan on including a new Workspace core JavaScript object in version 1.8.9 of PixInsight, which will allow scripts to have full control over all workspaces, including workspace management, window and icon positions, dimensions and Z order, as well as creation of new process and image icons. So you'll have to have some patience to implement this; sorry for the inconvenience.
 
Hi all -

I'm scripting my standard processing sequence. I currently have scripts that calibrate and cosmetic correct new data, so that the first thing I need to do is subframe selection. What I'd like to do is create subframe selection icons as the output of my script so that I can just click and go. I've found the "writeIcon()" method of the ProcessInstance base class, but this only works to overwrite an existing process icon on the desktop. What I'd like to do is create a new process icon and then write it. Does anyone know how / whether this is possible?

Thanks.
Hi more,

Looks like you might be doing similar things to me...

I have a specific series of processes up to integrate which I want to control and fully-automate on a session-by-session basis (the batch-preprocessing is good, but not quite what I'm looking for.. ).

I have managed to reverse engineer some of the javascript code as I want to be able to modify process instances on the fly. I have worked out basic view manipulation and process access, but am stuck with the modification of instance parameters. Have you a code example of the writeIcon method and how did you come across it?

Looking at the xosm files in project files, it seems to give hints on what the parameters/id's might be, and am looking at this route at present: standard Object.getOwnPropertyNames() only has limited success. This might be blind alley, but like others at present, have time to explore and get lost :)

I am documenting as I go along what I have got, inc the javascript widget generation: hopefully this might be useful to others - when complete I'll drop on github.

Hope you can help

Colin

If Juan is reading, I'm used to grid computing ( i.e. Univa): having a series of machines around the house it would be interesting to have Pixinsight run from command line and fire scripts in parallel on multiple machines ...a long term thought :cool:
 
Hi,

Okay an update.. Looking at the PCL * .h files gives a clue on what process variables might be:

i.e. for HistogramTransformation.h we have:

void SetShadowsClipping( double c )
264 {
265 PCL_PRECONDITION( c >= 0 && c <= 1 )
266 m_clipLow = pcl::Range( c, 0.0, 1.0 );
267 if ( m_clipHigh < m_clipLow )
268 pcl::Swap( m_clipLow, m_clipHigh );
269 UpdateFlags();
270 }

So in Javascript , clipLow and clipHigh look like variables

I have a ProcessInstance called 'HistTrans', so in javascript, I can find it and make changes to these values.. I can also set the icon description.

i.e.
====================================
var CC = ProcessInstance.fromIcon( 'HistTrans' );

if ( CC == null )
throw new Error( "No such process icon: ");
if ( !(CC instanceof HistogramTransformation) )
throw new Error( "The specified icon is not an instance of HistogramTransformation: ");
//Set some values:
CC.expandLow = 0.123456;
CC.midTones = 0.9999;
CC.clipLow = 0.3;
CC.clipHigh = 0.9
//add a description
CC.setDescription("Hello World");
/Check if its set:
console.writeln("Description: " + CC.description() );
//Correctly get on console: "Description: Hello World" :)
//Launch it
CC.launch()
//But on this created instance nor description the variable have not be set :-(

//Write the icon back to the original instance
CC.writeIcon('HistTrans')
//This also does not have the changes.. :-(
====================================

So I think I might be on the right track to alter process instance variable, but I've missed something...

Any pointers welcomed

Many thanks

Colin

ps. I am after changing imageIntegration process instance variables, but could not find a pcl header file for this on the html site. Again any pointer welcomed.
 
Hi,

Okay some more hacking, and I think I've cracked it.

The best place for instance variables is the "Edit Instance Source Code" from the Instance.

For ImageInstance there is a combination variable. From Source Code default looks like:

P.combination = ImageIntegration.prototype.Average;

So I want to change it to Median

//
var II = ProcessInstance.fromIcon( 'Process04' );
if ( II == null )
throw new Error( "No such process icon: ");
if ( !(II instanceof ImageIntegration) )
throw new Error( "Not an instance of ImageIntegration: " );

II.setDescription("Hello World");
console.writeln("II Description:" + II.description());

//Change the Variable
II.combination = ImageIntegration.prototype.Median;

II.writeIcon('Process04');
II.launch();

//

The Process04 now has combination changed from Average -> Median

BUT, the description is still not changed... is this an issue, or have I missed something ?


Many thanks

Colin
 
This cannot be done yet. I plan on including a new Workspace core JavaScript object in version 1.8.9 of PixInsight, which will allow scripts to have full control over all workspaces, including workspace management, window and icon positions, dimensions and Z order, as well as creation of new process and image icons. So you'll have to have some patience to implement this; sorry for the inconvenience.

Hi Juan

The new Workspace JavaScript object does not seem to have been included in the latest 1.8.9 release. Has this been put on the back burner?

Thanks

Mike
 
Hi Mike,

We have had much more urgent tasks for this release, which have forced us to stop development of new features like this Workspace object, although only temporarily. As soon as things stabilize in other fronts, we have plans to improve the scripting capabilities of PixInsight significantly.
 
Back
Top