Hi Sander,
Of course, when one just wants to solve a particular problem, not willing to create a tool to be used by others, creating a graphical interface is an unnecessary pain. This is why there is a Console object in PI's runtime
Try this one:
#include <pjsr/ImageOp.jsh>
function FixColumn( image, col )
{
for ( var y = 0; y < image.height; ++y )
image.setSample( (image.sample( col-2, y ) + image.sample( col+2, y ))/2, col, y );
}
function main()
{
// Get access to the currently active image window.
//var window = ImageWindow.activeWindow;
// Do we have at least one image window?
if ( ImageWindow.windows.length == 0 )
throw Error( "There are no image windows!" );
for ( var i = 0; i < ImageWindow.windows.length; ++i ) // for each image window
with ( ImageWindow.windows[i].mainView )
{
// Inform the core PixInsightapplication that we are about to modify the
// image in this view. Without this,we have read-only access to the image.
beginProcess();
FixColumn( image, 2359 );
// Done modifying the image.
endProcess();
}
}
main();
As you can see in this example,
for ( var x in ImageWindow.windows ) won't work. This is a limitation related to the way actual objects living in PI's graphical interface are being made visible to the JS runtime. Basically, for the "in" clause to work, the iterated objects (x in this example) should be native JS objects, which is not the case. ImageWindow.windows is an array of ImageWindow objects, which are just
managed aliases of actual image windows. In other words, to instantiate an ImageWindow variable in a meaningful way, the new operator must be used; for example:
var window = new ImageWindow;
This happens also with the rest of managed objects that work as virtual aliases of actual objects in the PI platform. As you can see, this is not actually a problem (other than the fact that "for ( var x in ..." is more elegant than "for ( var i = 0; ...") since an array can be iterated with the subscript operator.
don't you think it's time to stop coding and start writing documentation?
Of course, I agree completely. But the problem is that I am completely alone to carry out the following tasks:
- Development. Keep in mind that we have now 4 different versions (32/64 bits and Linux/Windows). Of course the whole code is 99.9% portable, but each platform has its own idiosyncrasies.
- Authoring documentation, which is not the nicest task I can think of, indeed. This is my worst nightmare and I am conscious that I am not being able to do even a minimally decent work.
- Giving support to the users, mainly by email.
- Taking care of the users on this forum, which is a pleasure.
- Maintenance of the web site. Needless to say that it is way outdated (look at the screenshots and you'll know what I mean).
- Maintenance of the e-commerce system and the licensing system (100% my own php code).
Add to this all of the bureaucratic tasks related to our company (a company is much harder to maintain here in Europe than in the U.S.), although I must say that my wife helps me a lot with this stuff.
I simply cannot do more things. I use to work 12 or more hours a day (the last week have been 14 to 16). It seems that I have bitten more than I can chew, as a user told to me.
All I can say is "I'll try to do that as soon as possible". The problem is that I've said that before, probably more than 100 times, so I'll better shut up :lol: