LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding Multiple Data Sets to a Tree

I have a good sized project, in which one of the VIs displays a somewhat complicated data set as a tree.  Now I'm working on an upgrade that will deal with multiple data sets (usually 2, but could be any number).  The most obvious solution is to add a hierarchal level at the top that would be used to select the data set.
However that would require a bunch of rework of existing code.

I think that the best solution is to replace the tree control with an XControl that's like a tree, but handles multiple data sets  On the GUI side, the XControl would have selector for choosing data sets; on the programming side, it would just have an extra property (an index) that specifies the active data set.

Can anyone think of a better route?

0 Kudos
Message 1 of 9
(699 Views)

2 Tree ctrls.  Use  a Tab ctrl to select which Tree.

 

George Zou
0 Kudos
Message 2 of 9
(679 Views)

@paul_a_cardinale wrote:

I have a good sized project, in which one of the VIs displays a somewhat complicated data set as a tree.  Now I'm working on an upgrade that will deal with multiple data sets (usually 2, but could be any number).  The most obvious solution is to add a hierarchal level at the top that would be used to select the data set.
However that would require a bunch of rework of existing code.

I think that the best solution is to replace the tree control with an XControl that's like a tree, but handles multiple data sets  On the GUI side, the XControl would have selector for choosing data sets; on the programming side, it would just have an extra property (an index) that specifies the active data set.

Can anyone think of a better route?


Considering trees are designed to handle this very situation, xcontrol seems not ideal especially given all the advice floating around to not use them at all and the specialized skill set that would be required to maintain it. Is the idea with the property node is you set it before all the existing code to silently move it into a subtree without changing the existing properties?

0 Kudos
Message 3 of 9
(673 Views)

@zou wrote:

2 Tree ctrls.  Use  a Tab ctrl to select which Tree.

 


That would only work most of the time: The number of data sets is usually 2, but can be anything.

Also, that might be more complicated than reworking the hierarchy.

0 Kudos
Message 4 of 9
(659 Views)

@avogadro5 wrote:

@paul_a_cardinale wrote:

I have a good sized project, in which one of the VIs displays a somewhat complicated data set as a tree.  Now I'm working on an upgrade that will deal with multiple data sets (usually 2, but could be any number).  The most obvious solution is to add a hierarchal level at the top that would be used to select the data set.
However that would require a bunch of rework of existing code.

I think that the best solution is to replace the tree control with an XControl that's like a tree, but handles multiple data sets  On the GUI side, the XControl would have selector for choosing data sets; on the programming side, it would just have an extra property (an index) that specifies the active data set.

Can anyone think of a better route?


Considering trees are designed to handle this very situation, xcontrol seems not ideal especially given all the advice floating around to not use them at all and the specialized skill set that would be required to maintain it.

I think that the objections to XControls are overblown.  As for maintenance, that won't be an issue because I am the only person dealing with the code.

 

Is the idea with the property node is you set it before all the existing code to silently move it into a subtree without changing the existing properties?

Yup.

0 Kudos
Message 5 of 9
(656 Views)

That type of functionality is something I would just code into the VI instead of making an XControl. Convert the data sets to arrays of items, as in, the same array of items that feeds into the Edit Tree Items.Add Multiple Items to End method, and hold them in state data in some form. Then have an enum/ring/whatever that lets the user choose which data set to show. When changed, delete all items and then add multiple items to end using the appropriate items array:

Spoiler
FireFistRedhawk_0-1793653981335.png

 

Redhawk

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

Message 6 of 9
(649 Views)

I think if I were designing this from scratch, I'd wrap all of the "interact with the tree" stuff in a library/class so that future additions could reuse the same (code) interface, and if you ever needed to do another "heavy" update like this one, then most of the interface VI's wouldn't need to change. You could then re-render the Tree control itself to add your new top-level heirarchy.

 

Your XControl idea would work fine, though you'd lose the ability to have multiple data sets in the tree at the same time. I'd personally use a QControl to do this but obviously you're like, the king of XControls 😉 The nice thing about QControls is that you'd be able to override all of the "Add to Tree" functionality to implement your Indexing stuff.

 

Do you ever need to do things like, say, drag and drop Tree fields from one dataset to another? If so, you'll need them all in the same Tree. Then again, you might need to explicitly not allow that, in which case it's probably easier to separate them out.

 

Whether you wrap it in an XControl "library" or a regular library, I think I'd try to switch to something that doesn't use any native Tree Control functionality, that way no matter what you do to the back end you don't break your (code) "interface contract"*. Instead, you'll be explicitly re-rendering the Control the way you want it. This would let you do things later on like, say, pick a subset of multiple datasets to render at once, instead of either only "single dataset" or "all datasets" like the options you mentioned earlier.

 

*Note: I don't know if XControls let you intercept invoke or property nodes to change their behavior. QControls let you do that in a somewhat roundabout way, meaning you can fully decouple how the data is stored in memory with how it's presented to the user.

0 Kudos
Message 7 of 9
(488 Views)

@BertMcMahan wrote:

I think if I were designing this from scratch, I'd wrap all of the "interact with the tree" stuff in a library/class so that future additions could reuse the same (code) interface, and if you ever needed to do another "heavy" update like this one, then most of the interface VI's wouldn't need to change. You could then re-render the Tree control itself to add your new top-level heirarchy.

 

Your XControl idea would work fine, though you'd lose the ability to have multiple data sets in the tree at the same time. I'd personally use a QControl to do this but obviously you're like, the king of XControls 😉 The nice thing about QControls is that you'd be able to override all of the "Add to Tree" functionality to implement your Indexing stuff.

 

Do you ever need to do things like, say, drag and drop Tree fields from one dataset to another? If so, you'll need them all in the same Tree. Then again, you might need to explicitly not allow that, in which case it's probably easier to separate them out.

 

Whether you wrap it in an XControl "library" or a regular library, I think I'd try to switch to something that doesn't use any native Tree Control functionality, that way no matter what you do to the back end you don't break your (code) "interface contract"*. Instead, you'll be explicitly re-rendering the Control the way you want it. This would let you do things later on like, say, pick a subset of multiple datasets to render at once, instead of either only "single dataset" or "all datasets" like the options you mentioned earlier.

 

*Note: I don't know if XControls let you intercept invoke or property nodes to change their behavior. QControls let you do that in a somewhat roundabout way, meaning you can fully decouple how the data is stored in memory with how it's presented to the user.


I've been going the 'restructure' route (and it's getting ugly).

My tree control is an indicator only, the only interaction is when the user clicks on an item, detailed info is displayed.

By default, XControls only have the base the properties and methods of controls.  Anything additional, you have to code; but if you're just mirroring properties/methods of a component, it's fairly simple (although you need a VI for each property and method).

0 Kudos
Message 8 of 9
(450 Views)

I haven't used this toolkit much, but perhaps it could be of help:

 

https://www.vipm.io/package/ni_tree_map/

 

I believe all of your data is stored as a string, which isn't ideal, but IIRC you can pull data to and from Tree controls quite easily. It would make it very easy to manipulate the data and rerender it into a new control.

0 Kudos
Message 9 of 9
(422 Views)