01-31-2023 08:15 AM - edited 01-31-2023 08:26 AM
Hello there,
I struggle with a pixel accurate alignment of subpanels. I have SubVI_A with a front panel of 200x200 pixels. I also have SubVI_B which should display SubVI_A in a subpanel right at the coordinates 0,0
What I have found is (and this is weird on its own) that I need to size my subpanel to 206x206 to display everything. Then I thought its the frame of the subpanel. If I needed to increase both X and Y size by 6px then probably the frame is 3px. So then I thought I need to position my subpanel to -3,-3. But this also doesnt seem to be true. It seems that I really need a 206x206 panel but positioned to 0,0. If I put it even to -1,-1 the first row and column of pixels seems really be at -1,-1.
There must be a golden rule of how to position subpanel, please let me know what it is as it seems that I really dont understand this topic.
I have attached the VIs. Note that the grid size is 10px instead of the default 12px, so 200px can be measured easier.
Thx!
01-31-2023 08:41 AM - edited 01-31-2023 08:44 AM
Hello 1984,
Subpanels have a frame thickness of 3 pixels, which offsets by the same amount the display of the contained panel.
So in order to fit a W*H panel, the Subpanel must have a size of (W+6)*(H+6). In your case 206*206.
If you want to display the contained panel at position (X, Y), the Subpanel must be positioned at (X-3, Y-3). In your case (-3, -3).
Check the VIs attached.
Regards,
raphschru.
01-31-2023 08:58 AM - edited 01-31-2023 09:02 AM
If you want to display the contained panel at position (X, Y), the Subpanel must be positioned at (X-3, Y-3). In your case (-3, -3).
This is what I have thought, and it could be right, but what I see is still very confusing. If in my SubVI_B you move the subpanel to -1,-1 then you'll see that the white background of SubVI_A goes above and to the left of the reference lines which intersect at 0,0. And suggests the stupid idea that the subpanel has a 0px wide frames on the top and the left and a 6px wide frame on the bottom and the right.
Again, I believe you are right with 3px uniform frame width, but I can't explain what I see by assuming a 3px wide frame. See a screenshot about my original VI if the subpanel is at -1,-1
01-31-2023 09:21 AM - edited 01-31-2023 09:45 AM
Well, it seems you have found a new bug.
The Position property seems to be broken when the frame is not visible, which puts the Subpanel in a kind of "inconsistent" state.
As a workaround:
1. Set the Subpanels's frame visible.
2. Adjust its position via the property dialog and validate (you may have to do it twice to clear the "inconsistent" state of the Subpanel).
3. Set it back to invisible.
01-31-2023 09:39 AM
To make it further confusing:
Looks great! Now go to subvi-A and delete the frame, save the VI, run subVI-b and you'll see that the white background is still perfectly aligned! Awesome!
Now whats not gonna be that awesome is this:
I'm really wondering if this behaviour is reproducible on other PCs, because looks very odd.