Skip to content

Commit fc06f2d

Browse files
committed
GUI util: Add utility function to remove all columns from a table
This is the equivalent for RemoveTracesFromGraph for plots with the base functionality. Function: RemoveAllColumnsFromTable
1 parent 514ef99 commit fc06f2d

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

Packages/MIES/MIES_Utilities_GUI.ipf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,24 @@ Function RemoveTracesFromGraph(string graph, [string trace, WAVE/Z wv, DFREF dfr
661661
return NaN
662662
End
663663

664+
/// @brief Removes all wave columns from a table
665+
///
666+
/// @param win name of a window containing a table
667+
Function RemoveAllColumnsFromTable(string win)
668+
669+
ASSERT(WinType(win) == WINTYPE_TABLE, "Target window must be a table")
670+
671+
for(;;)
672+
WAVE/Z wv = WaveRefIndexed(win, 0, 3)
673+
if(!WaveExists(wv))
674+
break
675+
endif
676+
// the order of the columnSpec subTypes is very important here
677+
// see WM issue #7689
678+
RemoveFromTable/W=$win wv.id, wv.ld, wv.i, wv.l, wv.d
679+
endfor
680+
End
681+
664682
/// @brief Add user data "panelVersion" to the panel
665683
Function AddVersionToPanel(string win, variable version)
666684

Packages/tests/Basic/UTF_Utils_GUI.ipf

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,60 @@ Function TestIsExteriorSubWindow()
158158
CHECK(IsExteriorSubWindow(main + "#" + sub0))
159159
CHECK(!IsExteriorSubWindow(main + "#" + sub0 + "#" + sub1))
160160
End
161+
162+
Function TestRemoveAllColumnsFromTable()
163+
164+
string win
165+
string wName1 = "racft1"
166+
string wName2 = "racft2"
167+
string wName3 = "racft3"
168+
169+
try
170+
RemoveAllColumnsFromTable("IdoNotExist")
171+
FAIL()
172+
catch
173+
PASS()
174+
endtry
175+
176+
Display/N=myPlot
177+
win = S_name
178+
try
179+
RemoveAllColumnsFromTable(win)
180+
FAIL()
181+
catch
182+
PASS()
183+
endtry
184+
KillWindow/Z $win
185+
186+
KillWaves/Z $wName1, $wName2, $wName3
187+
Make $wName1/WAVE=wv1
188+
Make $wName2/WAVE=wv2
189+
Make/N=(1, 1) $wName3/WAVE=wv3
190+
191+
Edit/N=myTable wv1
192+
win = S_name
193+
194+
RemoveAllColumnsFromTable(win)
195+
WAVE/Z wvremain = WaveRefIndexed(win, 0, 3)
196+
CHECK_WAVE(wvremain, NULL_WAVE)
197+
KillWindow/Z $win
198+
199+
Edit/N=myTable wv1
200+
win = S_name
201+
AppendToTable/W=$win wv2
202+
203+
RemoveAllColumnsFromTable(win)
204+
WAVE/Z wvremain = WaveRefIndexed(win, 0, 3)
205+
CHECK_WAVE(wvremain, NULL_WAVE)
206+
KillWindow/Z $win
207+
208+
Edit/N=myTable wv3
209+
win = S_name
210+
211+
RemoveAllColumnsFromTable(win)
212+
WAVE/Z wvremain = WaveRefIndexed(win, 0, 3)
213+
CHECK_WAVE(wvremain, NULL_WAVE)
214+
KillWindow/Z $win
215+
216+
KillWaves/Z $wName1, $wName2, $wName3
217+
End

0 commit comments

Comments
 (0)