Find graphs where a wave is plotted


//Brings to the front the graphs containing a given wave
//Given a wavename (requires full path), returns a string containing a list of window names indicating the
//graphs that contain this wave as a trace, and brings those graphs to the front.
//Written to find graphs that are blocking deletion of a wave, i.e., to
//cope with the error message "1 object(s) could not be deleted because they are in use".
//One way to use this function: select, in the data browser, the wave you are having trouble deleting;
//copy; type the function's name, FindWaveWindow(), in the command window; paste the wave name
//between the parentheses.
//Or use the function below this one, ShowWaveGraphs, which prompt the user for the name of a wave in the
//current data folder and then calls FindWaveGraphs to find graphs with that wave.
//Written by Pietro Mazzoni as an extension of a function written by  Rick Gerkin
Function /S FindWaveGraphs(waveSoughtFullName)
	String waveSoughtFullName

	Variable i, j
	String wins = WinList("*",";","WIN:1")
	String win, traces, trace, windowsList, yWaveRef, xWaveRef, prevWin

	windowsList = ""
	prevWin = ""
	for(i = 0; i < ItemsInList(wins); i += 1)	//Loop over all existing windows
		win=StringFromList(i, wins)
		traces=TraceNameList(win, ";", 3)
		for(j = 0; j < ItemsInList(wins); j += 1)	//Loop over all traces in current window
			trace=StringFromList(j, traces)
			wave yTraceWave = TraceNameToWaveRef(win, trace)
			yWaveRef = getWavesDataFolder(yTraceWave, 2)
			wave xTraceWave = xWaveRefFromTrace(win, trace)
			if (waveExists(xTraceWave) == 1)	//Checking for this avoids errors if the window is not a graph
				xWaveRef = getWavesDataFolder(xTraceWave, 2)
			else
				xWaveRef = ""
			endIf

			//Does name of wave of current trace match the wave we are looking for?
			if (StringMatch(yWaveRef, waveSoughtFullName) == 1 || StringMatch(xWaveRef, waveSoughtFullName) == 1)
				if (stringMatch(win, prevWin) == 0)
					doWindow /F $win
					windowsList +=  win + ";"
					prevWin = win
				endIf
			endif	//if (StringMatch(fullWaveRef, wName))

		endfor	//Loop over all traces in current window
	endfor	//Loop over all existing windows
	return windowslist
	
End	//FindWaveGraphs

//Prompts user to select a wave in current data folder. Then calls the function 
//FindWaveWindows to bring to the front all graphs that contain that wave
//either as a y trace or as an x trace
//Pietro Mazzoni
Function ShowWaveGraphs()

	string wName, fullName

	Prompt wName, "Name of wave to find in windows", popup sortList(waveList("*", ";", ""))
	doPrompt "Choose wave:", wName
	if (V_flag == 1)
		print "Routine stopped"
		Abort
	endIf
	fullName = getDataFolder(1) + wName
	print "Bringing to the front all graphs containing traces for the wave:", fullName
	print FindWaveGraphs(fullName)
	print "\rNOTE: only graphs are found. Your wave may also be displayed in tables, not found by this routine"
	doWindow /H
End	//ShowWaveGraphs

Forum

Support

Gallery

Igor Pro 10

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More