Hierarchical list widget error?
LTKunneman
To make the listbox:
Function ErrorHierarchicalList()
String Swinname="WindowDataHierarchy"
String Slistboxname="HierarchicalListbox"
Dowindow/K $(Swinname)
NewPanel /N=$(Swinname) /W=(1000,100,1250,460) as "Data gestructureerd"
Make /O/T WhierarchyItems
Make/O WhierarchySel
ListBox $(Slistboxname),ListWave=WhierarchyItems,size={235,315},pos={5,30},widths={30,185}
ListBox $(Slistboxname),fsize=15,mode=4,SelWave=WhierarchySel
MakeListIntoHierarchicalList(Swinname,Slistboxname,"ContainerOpenFamOrFolder")
end
String Swinname="WindowDataHierarchy"
String Slistboxname="HierarchicalListbox"
Dowindow/K $(Swinname)
NewPanel /N=$(Swinname) /W=(1000,100,1250,460) as "Data gestructureerd"
Make /O/T WhierarchyItems
Make/O WhierarchySel
ListBox $(Slistboxname),ListWave=WhierarchyItems,size={235,315},pos={5,30},widths={30,185}
ListBox $(Slistboxname),fsize=15,mode=4,SelWave=WhierarchySel
MakeListIntoHierarchicalList(Swinname,Slistboxname,"ContainerOpenFamOrFolder")
end
To get the error, execute:
ErrorHierarchicalList()
WMHL_AddObject("WindowDataHierarchy","HierarchicalListbox","","item 1",1)
WMHL_DeleteRowAndChildren("WindowDataHierarchy","HierarchicalListbox",0)
WMHL_AddObject("WindowDataHierarchy","HierarchicalListbox","","item 1",1)
WMHL_AddObject("WindowDataHierarchy","HierarchicalListbox","","item 1",1)
WMHL_DeleteRowAndChildren("WindowDataHierarchy","HierarchicalListbox",0)
WMHL_AddObject("WindowDataHierarchy","HierarchicalListbox","","item 1",1)
Am I making a basic mistake?
(ps, edit: the error is: "While executing a wave write, the following error occured: Index out of range for wave "Selwave".)
I started digging in the procedure file of the hierarchical listwidget, and I think I have the root of the trouble: if the LB is initialized, but all rows are killed, then the number of columns and layers of SelWave and ListWave are also reduced to zero. Changing the function WMHL_AddObjectToList solved the error, but I don't know if I introduced other errors as well. (When extra columns are used e.g.) Some advice please!
Change to WMHL_AddObjectToList:
if ( (nRows == 1) && (CmpStr(ListWave[0][1][1], "<uninitialized>") == 0) )
nRows = 0
else
InsertPoints nRows, 1, SelWave, ListWave
redimension /N=(-1,2) Selwave // added as a "fix"
redimension /N=(-1,2,2) Listwave // added as a "fix"
endif
...
October 22, 2013 at 04:48 am - Permalink
Just as a side note- ErrorHierarchicalLis() makes a listwave and selwave for the listbox, but that's not needed. MakeListIntoHierarchicalList() creates waves private to HierarchicalListWidget, abandoning the waves you created. The only things you need to do with the listbox are to create it and give it a size and position.
I'll let you know what I figure out.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
October 22, 2013 at 09:30 am - Permalink
String windowname
String listcontrolname
Variable theRow
STRUCT HierarchicalListListInfo ListInfo
if (WMHL_GetListInfo(windowname, listcontrolname, ListInfo))
Wave SelWave = $("root:Packages:WM_HierarchicalList:"+ListInfo.FolderName+":"+ListInfo.SelWaveName)
Wave/T ListWave = $("root:Packages:WM_HierarchicalList:"+ListInfo.FolderName+":"+ListInfo.ListWaveName)
Variable lastRow = theRow
if ( WMHL_RowIsContainer(windowname, listcontrolname, theRow) && WMHL_RowIsOpen(windowname, listcontrolname, theRow) )
lastRow = WMHL_FindLastChild(ListInfo, theRow)
endif
Variable numRowsToDelete = lastRow-theRow+1
if (numRowsToDelete == DimSize(SelWave, 0))
// JW 131022 We are deleting all rows in the list. If we remove all the rows in the waves, they will forget that they are
// multicolumn waves. So here we just return the list to the same state as it was in when it was new, except that if WMHL_AddColumns()
// has been used, it will have more columns than a new list.
Redimension/N=(1, -1) SelWave
Redimension/N=(1, -1, -1) ListWave
ListWave = ""
ListWave[0][1][1] = "<uninitialized>"
SelWave = 0
else
DeletePoints/M=0 theRow, lastRow-theRow+1, SelWave, ListWave
endif
endif
end
This fix will be included in the next minor release of Igor, but I don't know when that might be. I don't want to post the revised procedure file here because then it will have an indefinite life. I would be happy to send you a copy if you send an e-mail to support@wavemetrics.com.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
October 22, 2013 at 10:46 am - Permalink
edit: as I typed this reply, you posted the fix. I replaced "WMHL_DeleteRowAndChildren" by your function, and it works! Thank you so much for the fantastic service.
October 22, 2013 at 10:56 am - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
October 22, 2013 at 11:06 am - Permalink
The current fix of reinitialization seems to kill color support as well, I have to add it after removing the last item.
November 4, 2013 at 11:06 am - Permalink
Perhaps if we need to continue, we should handle this via support@wavemetrics.com.
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
November 5, 2013 at 09:45 am - Permalink