LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Tree control snapshot / track changes

Hi all,

The user of my Software should work with a labview tree control on the front Panel. I want to track changes about what the user has done to enable i.e. undo the last 10 changes.

 

My idea is to create a snapshot every time the user modifies anything on the tree, and so Keep the last 10 snapshots in the Memory to be able to undo those changes. Well I don't have any good idea, how to create a snapshot (maybe create XML?).

 

My question is, what is the right way to enable users undoing changes on a tree control?

0 Kudos
Message 1 of 6
(3,078 Views)

A tree control by itself does not store a history. Therefore, it is up to you to decide what you are going to implement.

A couple of remarks as feed for thought:

1. When talking about a "history of a tree" you can look into two aspects: The number and names of nodes or their values (e.g. boolean as On/Off selection). Are both important or only one of them?

2. Is the history you want to provide volatile? If yes, do not bother to convert to external format

3. How much data do you store in a tree? You might run into memory issues by keeping a history for large data sets

 

Please note that the Tree Control in LV does not grant access to the data structure inside the tree. Hence, you have to rebuild a comparable structure and synchronize it unless you are looking purely into the list of tags. Access to the tree items have to be done by property nodes.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 6
(3,041 Views)

History of what exactly?

 

Values?

Open\close state of nodes?

Selected items?

Icons?

 

I'm going to talk from a OO perspective here. If you don't do OO, I have no idea how to implement this. It might be hard enough to pick up OO.

 

Each action ("redo" method of the specific child of action class) can have a reverse action ("undo" method). So on each change event, you can create an object, execute it's "redo" method, and store the object (with details in it's private data) in the history. So basically, on each tree event, you're building an array of (reverse) commands. On undo, execute the last object's undo method. To redo, keep a pointer in the action array. That will allow you to go back and forth. See Command Pattern.

 

This will in not make snapshots. To do that, you'll have to recourse though the tree, and for each node store it's information and do the same for it's children. You probably benefit from a smartly designed recursive VI. Problem with understanding recursion is you first have to understand recursion (couldn't resist)...

0 Kudos
Message 3 of 6
(3,023 Views)

I want to undo / redo:

- String changes on each cell

- Symbols (Checkbox symbols check/uncheck)

- Deleting tree items

- moving tree items inside the tree

 

I think it doesn't matter if I use OO or not. You write "...store object with Details in its private data". Well, this is the Point: what is the private data type?

 

As Norbert said, we have no direct Access to the data structure of a LV tree. But then how can I Keep track on the changes? How does LabVIEW do it if I edit the tree in edit-time?

 

 

0 Kudos
Message 4 of 6
(3,013 Views)

@Madottati wrote:

 

As Norbert said, we have no direct Access to the data structure of a LV tree. But then how can I Keep track on the changes? How does LabVIEW do it if I edit the tree in edit-time.


The data structure of the tree is accessible. The data is a string (the selected item). You already know this, but obviously not what you want...

 

What you want is access to the properties of the items.

 

You can set the Active tag (this is not the selected tag). Then get the properties of that tag (under Active Item). The string and symbol are included.

 

Traversing the tree (Navigate Tree method) will reveal moved or deleted items.

 

Also note there are events when cells are edited. You can make a delete possible with a menu item, and you can catch that menu's activation.

0 Kudos
Message 5 of 6
(3,008 Views)

Something like this (LV2013). Didn't say it was easy, the API is terrible.

 

Converting to XML isn't that difficult, as XML is highly recursive just like the tree and the VI.

0 Kudos
Message 6 of 6
(2,989 Views)