Jump to content

Need Help: Getting Screen Coordinates of GObject on Block Diagram


Recommended Posts

I think the solution depends on exactly when you want to do this.

 

The obvious answer is to get the BD window properties and work from there, but this has the equally obvious problem of figuring out the size of the top section of the window. This might be workable if you can add a step somewhere in the process where you do this once (and would need to redo it if something changed).

 

A less obvious answer is that the panel has a method for this conversion. The BD doesn't have a parallel method, but since the top section appears to be the same size on both, it should be possible to place the FP window in the same position as the BD window and then use that method and return the FP window to its original spot. Probably as ugly as it sounds, but I expect it should work. Again, it probably depends on when you want to do this. Maybe this will be not as ugly if you create a temporary VI to do this and move it to the bottom of the window stack.

  • Like 1
Link to comment

One thing that might help is you can hide the Menu and Button bar using a property node on the block diagram.  I couldn't find one for removing the title bar, but I think that can be calculated.  I think this is possible if there is a property to read the scrollbar position on the block diagram but I can't seem to find it.

 

EDIT: Block Diagram Origin can give scrollbar position.  I think this can be possible.

  • Like 1
Link to comment

Okay attached is an example VI that I think does what you need.  It will look for the screen coordinates to the Tick Count object on the block diagram.  The only part I couldn't calculate is the width of the left edge of the window, and the height of the title bar of the window.  Mine was 10px and 32px so I have them as controls but there is probably a way to figure out what this size is.  Also I think we can assume the menu bar and debug buttons are always the same size so once this is determined once you won't need to recalculate it over and over.  My code currently does this by removing these buttons then subtracting the difference in window size from when they were there.

Get Object Position On Screen.vi

  • Like 1
Link to comment

I just realized that the panel's conversion method that I mentioned is actually more useful than I thought. You can use it once on first call to calc the window border (convert the top left point to the screen coords and subtract the window origin from it) and then cache that (LV has global data methods for caching) and use it for the BD window, because it should be the same numbers.

That should be pure LV and should ideally work every time.

P.S. You can probably do this calc on a temporary VI off screen or on any open VI, as long as it shows the window parts.

Link to comment

I've bookmarked this one a while back.

https://decibel.ni.com/content/servlet/JiveServlet/previewBody/22385-102-3-42676/LabVIEW%20VI%20Dimensional%20Model.pdf

 

Not sure if the same properties also apply to BD

That is a really neat document and I'm going to need to keep that in mind.  These same properties don't apply to the block diagram, but as Yair mentioned many of them can help you calculate the size of objects that are shared on the FP and BD.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.