Prepending a prefix to window names

Hi Rob,

Sorry to hear about that. I hope all goes well!

Jarmo

I still had some weird problems with column positions. Also AutoContinue icons go to wrongs rows. So I created an experimental window prefix name array version. I think you also hinted something like that in some comment. Script keeps track of known prefixes and their column positions. Also icon count is stored into array.

I have a branch prefix-array for this change. A link to change is below. Feel free to comment if you think is a good/bad change and if you want something changed. You can of course do changes directly if you like.

yes i did think about something like that. anyway i am still tied up with this problem for at least a week so i don’t think i can take a look for a while.

i have returned home and managed to figure out how to load your branch onto my fork. over the next couple of days i should be able to find some time to take a look at it.

Great to hear that! I have some commits on prefix array and then some others in that branch. I wanted to keep these changes on a separate branch so you can check them and maybe improve before moving to a master branch. Feel free to change the code if you think it should be done in some other way.

Jarmo

loaded H and O images; forgot to change to HOO from the default SHO. ran and script rightfully quit when it could not find an S image. tried to restart and script failed with:

then tried to click Close All Prefixes button and nothing happened. i guess the arrays were not populated yet? i need to trace thru the code to understand how it works now.

I repeated this problem. The reason as you suspected that array is not set yet. Array is only set when we iconize something. But it does not work if we hit an error and have created some Windows.

There are at least two options, add prefix to the array earlier, or make close to work with prefix even if it is not in the array.

I must say I am not totally happy with the prefix code. It looked simple at first but now it is getting more complex. I hope there are only minor tweaks left.

I guess main changes in the code are with Run, AutoContinue and Close* buttons.

Jarmo

yes like most new features it seems simple but integrating it into an existing codebase is a lot of work. hopefully there aren’t too many corner cases left.

related to all this, what is the difference between the “close all” button and “close all prefixes” button? it seems like they might do the same thing? or does “close all” take care of closing all the windows when the user has not ever specified a prefix?

i guess you might be able to add windows to the array on creation (and then fill in icon colums later at iconization time) but there are probably a lot of places in the code where windows are created.

i don’t know how many error cases there might be, but this particular one might be detectable before doing anything - if there are no subs for a filter that’s going to be needed based on the color mapping then that could stop execution before any windows are created.

Right now all new code at least from me is in prefix-array branch. So if we decide to keep prefix array then the integration back to master is easy. Otherwise need to cherry-pick those non-prefix-array changes.

Right now “Close All” closes all “current” set of files. So it closes using the prefix. Then “Close all prefix” closes all prefixes it can find from the array. Now while writing this it does not sound very clear from those names. Good ideas are welcome :slight_smile:

Yes, lots of Windows and they are created quite randomly. Maybe add a prefix always, or when we have passed some point and started actually processing something.

I fully agree on checking files for channel files at the start. I was thinking the same (again) when tested the problem you mentioned. Especially those Color palette files that would be passed to the PixelMath are easy to forget and then after some maybe lengthy processing notice that some files are missing.

i was thinking that if trying to manage the icon column automagically is too hard, maybe we just let the user manage that. meaning, after a run with a given prefix, the user just needs to move the icons away from the left side of the screen him/herself if they want to run again.

although i see with this prefix array code you’ve kept track of the current row which is of course really useful for autocontinue. but if we just kept the prefix code only it seems like the various failure modes (like trying to start the script from scratch again with the same prefix) would fail just like they used to before there were no prefixes.

anyway as far as i can tell from my limited use cases, your new array prefix code works right. but i will keep testing it. i guess the problem with the missing filters isn’t really new and the script behavior in that case is the same now as it was before all of these changes. the user would have to remove all the windows created before the error was thrown and start over.

I have pushed some fixes for autocontinue and an early check for missing color palette files. Check for missing files is done before processing starts. Changes are still in prefix-array branch but I guess it should be moved to master soon.

Jarmo

thanks - i updated yesterday but didn’t get time to test - today i will update and try it out.

i’ve been playing around with this and everything seems to work as expected. one thing though is that you can’t reset the prefix array without closing all images being tracked in the array. also of course the close all prefixes buton is pretty dangerous because it will just go force close all images even if they are edited and unsaved.

if you were to switch to a new workspace in PI i think you’d want to reset the array independently of closing all the windows.

maybe that button should just reset the array and leave the windows? it’s pretty easy to select all the icons and tell PI to close the images if you want to do that.

Good to hear that you did not find any new problems.

I agree that the array management is difficult, there is really no other control than closing all windows. I guess we’ll need to see if that is a problem, maybe add a new button to remove items from the array, or something totally different.

Close button intentionally closes everything because I did not want to click all those Are you sure messages. But it has dangers if you have not saved your edits. Maybe there is a PI way to do the same, so Close all would close only all unsaved windows. Anyway after the script windows are saved by default and only unsaved ones are those with user edits.

Workspaces seem to share the same windows. It would be good to separate workspaces in the script. I have done only quick trials and you cannot run the script in two workspaces unless you use window name prefix.

yes that is correct, the window namespace spans the workspaces. but what i meant is that if you switch to a new workspace, you probably want to just reset the window prefix array so that your icons will start from the left again, and the assumption would be that the user chooses a new and unique prefix. personally i leave PI open for hundreds of days and do all kinds of different projects while it is open, and that was my motivation for the window prefix in the first place - it was pretty time consuming to rename all the AI windows so that i could run the script again on another project.

it’s exactly the user edits that i’m worried about. i did a bunch of work on an AutoRGB image made from autocontinue and then clicked the close all prefixes button to see what would happen. most everything was closed (there were a couple orphans) but the modified AutoRGB image was closed without a warning. that’s OK because i was testing and expected something like that. but that’s going to burn someone for sure.

maybe the close all prefixes button can have a dialog that asks “are you sure?” and displaying a warning that everything will be closed unconditionally before executing. i can certainly see someone changing workspaces, forgetting about the icons on another WS and then accidentally closing everything, or perhaps thinking the button would do nothing because there are no icons on the new WS.

edit: i think i mentioned that juan promised a new PJSR workspace object in the upcoming release which might make this stuff easier, however, it will break backward compatibility with 1.8.8-9 and below, which is bad.

I agree that there is a good reason to ask if you also want to close unsaved windows. Maybe that should be changed. I guess asking only once would be enough.

It was a good point that you mentioned about using prefixes and icons positions. I have never really used workspaces so I was not considering it that way. Also for me PixInsight does not survive that many AutoIntegrate script runs before the windowing system goes broken.

Before your message I was also thinking that maybe we could have a special section of saved Settings parameters. It could include a text field of an editable prefix array. Prefix array is a JSON array so it is not too hard to understand. Then there would be a way to modify or clear it manually if needed.

It could also include an option for force delete. Default is off which is safer. But someone like me could enable delete also for edited files.

These would be Session settings and they would be saved automatically as we do for window prefix and array now without the need to save them to an icon.

Not so sure any more if this section of saved Settings would be useful.

I have tried to look for info about workspaces but I guess it is not visible to scripts. Just the current workspace name/number would be enough.

Changed the window close code with Close all* buttons so that final windows are not force closed. PixInsight will ask to close it if it is modified but not saved. Some of the iconized windows are still force closed but they are not saved to disk. Not sure if this would be ok or not.

thanks, i’ll update and try it out.

btw i had mentioned about some orphan windows - i had assumed that the script just wasn’t tracking those windows, but it turns out that it probably is. after clicking “close all prefixes” there is at least one orphan icon left around (_Integration_RGB) for which the window has been deleted. i think this might be a bug in pixinsight - even mousing over the icon results in a segfault shown in the PI console and at least once all of PI just crashed when manipulating the icon. just now i was able to open another image, then select both icons and using the context menu ask to delete all icons, and the bad icon finally disappeared.

I have not seen that myself. I agree that it could be something in PixInsight as windows are always closed the same way. If the icon name is “_Integration_RGB” then that is a bit odd because as far as I know such a name is never generated by the script.

For PixInsight GUI problems, I have noticed that when running the script multiple times the GUI system randomly goes somewhat broken. There are a lot of QT* errors on console and the script window turns a bit different. To me it looks like “old” window style with no shading etc. I have been wondering if there is a way to avoid that in a script, like forcing a garbage collection. So far I have always just restarted PixInsight but it is not that nice if you have multiple things open at the same time.