AutoScaler Panel for Table Column


// Creates a panel with a checkbox and value display
// Checking the box will auto-scale a wave in the first
// column of a table by factors in orders of magnitude
// Put in procedure window and type AutoScaler() to show panel
// Must have an active table with the first column as a numeric wave

Function AutoScaler()
	NewPanel /W=(292,129,494,204) as "AutoScaler"
	CheckBox scaleit,pos={12,16},size={173,19},proc=CheckProc,title="Auto-Scale 1st Column"
	CheckBox scaleit,fSize=14,value= 0
	ValDisplay scalefactor,pos={18,41},size={150,20},title="Scale x10^",fSize=14
	ValDisplay scalefactor,limits={0,0,0},barmisc={0,1000},value= #"1"
	return 0
end

Function CheckProc(cba) : CheckBoxControl
	STRUCT WMCheckboxAction &cba
	
	string theOne
	variable itsScale

	switch( cba.eventCode )
		case 2: // mouse up
			theOne=StringFromList(0,WinList("*",";","WIN:2"))
                        // no table windows active
			if (strlen(theOne)==0)
				Checkbox scaleit, value=0
				ValDisplay scalefactor, value=_NUM:1
				break
			endif
			wave theWave = WaveRefIndexed(theOne,0,3)
                        // no waves in table
			if (!WaveExists(theWave))
				Checkbox scaleit, value=0
				ValDisplay scalefactor, value=_NUM:1
				break
			endif
                        // first wave is not numeric		
			if (WaveType(theWave,1)!=1)
				Checkbox scaleit, value=0
				ValDisplay scalefactor, value=_NUM:1
				break
			endif
                        // checked or unchecked action
			if (cba.checked)
				itsScale = round( log(WaveMax(theWave)))
				ValDisplay scalefactor, value=_NUM:itsScale
			else
				ControlInfo scalefactor
				itsScale = -V_value
				ValDisplay scalefactor, value=_NUM:1				
			endif
			theWave /= 10^itsScale
			break
	endswitch

	return 0
end

Forum

Support

Gallery

Igor Pro 10

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More