From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI Scripting: Speeding up "ObjHighlight" or finding an alternative

Solved!
Go to solution

Hi,

 

I'm working on a fairly obscure topic: I am writing an express-vi that automatically builds an interface based on the parent-vi.

 

 A user can select on a GUI which front panel element of his parent-vi he wants to expose, and communication code is automatically generated to implement that.

For the visualization, I use ObjHighlight and then FP.GetImage.

ObjHighlight is needed, because when I call it, the frontpanel of my parent-vi is opened in the right tab, I get visibility of hidden elements, etc. After that I take a screenshot using GetImage.

 

 

This combination works really well and reliably.
However, it is comparatively slow. ObjHighlight needs a couple of 100ms, to draw user attention to itself.. - and when you analyse a VI with tens and hundreds of FP-Elements, you wait.
Of course, there is pre-fetching and parallelism.. but there has to be a better way to do this?

Right?

Thanks a lot,
B

0 Kudos
Message 1 of 4
(3,043 Views)

Hide-show a couple times?

Move rectangular frame and adjust its size?

0 Kudos
Message 2 of 4
(3,023 Views)

Hi,

the problem is: I don't want to modify my parent vi.
I analyse it for the user, but it's completely arbitrary.

 

For example, this would be the parent vi frontpanel:

3.PNG

 

What I produce is the following.. for example, if a user wanted to look at the Tank.

 

1.PNG

 

When my control is on another tab or hidden, I need to change tabs, visibility etc. ObjHighlight does that for me:

2.PNG

 

I do have the functionality I want for producing thses previews, and I get them with the following code:

GetPic.png

 

It's just terribly slow once you have a tens or hundres of FP elements.

0 Kudos
Message 3 of 4
(2,976 Views)
Solution
Accepted by topic author b.ploetzeneder

Just in case anyone else is looking for a solution on this, I finally wrote vi that does that job .. and doesn't need the 250ms of Highlight.

 

The idea is to first loop through all the owners, and collect their references, until you reach the top.
Then take that array of owning references, and tackle it bottom up.

I distinguish by ClassName.
If it is a normal control, I just save position and size (masterrect). I also store the owning Pane (not to be confused with Panel!)

If it is a Page (which is a sub-page of a TabControl), I note how it is called. Page-Names are enums, and therefore unique, so I can use that.
If it is a TabControl, (which has to follow after a Page), I look through all its Pages and switch to the one that I saved before.
Finally, I reach Panel, which is either a sub-panel (created by splitters) or the full panel, and modify the origin of the Pane (which should be better called ScrollPosition). Where to place this origin depends on the size of the object and the panel.. and you need to eventually figure out a solution depending on your needs. If you do that, stay aware of the difference between Panel and PaneCoordinates..

 

Not depictured is the eventual setting / resetting of the control visibility, which I handle and restore in another place.

 

(On a related note: Really?? Pane and Panels? Owners and Owning Panes? And I'm not even starting about the " curious" behaviour of FP.GetImage when the FP uses splitters...)

 

snippet.png

Message 4 of 4
(2,918 Views)