#pragma rtGlobals=1 // Use modern global access method. Function AddWavesMenu(wave1,wave2) Wave wave1 ,wave2 String/G Fullname = NameOfWave(wave1)+"_combined", tempWaveName1=NameOfWave(wave1), tempWaveName2=NameOfWave(wave2) //Name der kombinierten Wave Duplicate/O wave1 $fullname ,tmpUpperWave Redimension/N=(-1,0) tmpUpperWave //Wave fuer den Schnitt am Ende des oberen Spektrums Duplicate/O tmpUpperWave tmpLowerWave //Wave fuer den Schnitt am Anfang des unteren Spektrums Display/K=1/W=(20,20,600,440)/N=TempDisplayResult as "Complete spectrum" //Darstellen der zusammengefuegten Wave zur Anschauung Appendimage $fullname Display/K=2/N=TempSetPanel/W=(500,20,800,440) tmpUpperWave as "Adjust Contrast" //Panel fuer die Kontrolle des Ergebnisses + Kontrollwaves AutoPositionWindow/E/M=0/R=TempDisplayResult //An Graph andocken AppendToGraph/C=(0,0,65280) tmpLowerWave; ModifyGraph mode=2 Legend/C/N=GraphInfoBox/J/A=LT "\Z10Slice at intersection:\r\\s(tmpUpperWave) " + NameOfWave(wave1) + "\r\\s(tmpLowerWave) " + NameOfWave(wave2) ControlBar 30 //Bereich fuer die Kontrollen SetVariable KConstant ,pos={10,7} ,title="Intensity ratio: " ,help={"Adjust the multiplication factor"} SetVariable KDegree ,pos={140,7} ,title="Shift ["+WaveUnits(wave1,1)+"]" ,help={"Adjust the tilt to move the wave"} Button AcceptButton ,pos={275,5} ,title="Accept & Quit" ,help={"Accept the result and finish adding"} SetVariable KConstant ,size={120,20} ,value =_NUM:1 ,proc=WavesContrastControl,limits={0,inf,0.05} SetVariable KDegree ,size={120,20} ,value =_NUM:10 ,proc=WavesContrastControl,limits={0,inf,DimDelta(wave1,1)} Button AcceptButton ,size={110,20} ,proc=TiltKillWhenReady WavesContrastControl("Contrast",1,"","") //Erste Berechnung End //############################################################################## Function TiltKillWhenReady(ctrlName) : ButtonControl //Killt Fenster auf Buttondruck String ctrlName DoWindow/K TempSetPanel //Fenster killen KillWaves tmpUpperWave, tmpLowerWave //Waves vor dem Fenster killen, damit diese bei Updates nicht erscheinen KillStrings Fullname, tempWaveName1, tempWaveName2 DoWindow/K TempDisplayResult //Alles loeschen End //############################################################################## Function WavesContrastControl(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName,varStr,varName Variable varNum SVAR tempWaveName1, tempWaveName2, fullname Wave inwave = $tempWaveName1, appendwave = $tempWaveName2, bigone = $fullname, tmpUpperWave,tmpLowerWave Variable rows,columns,ydelta,yoffset rows = DimSize(inwave,0) //Einlesen der Wave-Parameter columns = DimSize(inwave,1) yoffset = DimOffset(inwave,1) ydelta = DimDelta(inwave,1) Variable approws,appcolumns,appydelta,appyoffset approws = DimSize(appendwave,0) //Einlesen der Wave-Parameter fuer die 2. Wave appcolumns = DimSize(appendwave,1) appyoffset = DimOffset(appendwave,1) appydelta = DimDelta(appendwave,1) //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ControlInfo/W=TempSetPanel KDegree Variable tiltdegree = V_Value ControlInfo/W=TempSetPanel KConstant Variable tiltContrast = V_Value Variable ExtraColumns, FullColumns, Overlap ExtraColumns = round((yoffset - (appyoffset-tiltDegree))/appydelta) //Ueberhaengende Breite der 2. Wave in Columns FullColumns = columns + ExtraColumns //gesamte Wavebreite Overlap = appcolumns - ExtraColumns //Zahl der uebereinanderliegenden Columns // Print "Added:",ExtraColumns,"Full size:",FullColumns, "Overlap",Overlap //Debug Redimension/D/N=(-1,FullColumns) bigone //Auf volle Breite bringen SetScale/P y yoffset-ExtraColumns*ydelta,ydelta,WaveUnits(inwave,1), bigone //Rescalierung auf die neue Laenge bigone = 0 //Gesamtwave immer wieder zurücksetzen //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Variable addratio, smoothpercentage, i //Berechnung der Winkel-Verschiebung addratio = WaveMax(appendwave) / WaveMax(inwave) //Gleicht die Waveintensitaeten etwas an bigone[][ExtraColumns,FullColumns-1] = addratio* inwave[p][q-ExtraColumns] //1.Wave ans obere Ende der Gesamtwave bigone[][0,ExtraColumns-1] += tiltContrast*appendwave[p][q] //2. Wave fuellt den Rest if (Overlap > 1) for (i = ExtraColumns; i < ExtraColumns+Overlap; i += 1) //Ueberlappung einfuegen smoothpercentage = (i - ExtraColumns)/(Overlap-1) //Sorgt fuer einen Kantenlosen Uebergang von einer zur anderen Wave (0% -> 100%) bigone[][i] *= smoothpercentage //Intensitaet der 1. Wave skalieren bigone[][i] += tiltContrast * appendwave[p][i] * (1-smoothpercentage) //2. Wave skaliert anfuegen endfor endif tmpUpperWave = addratio*inwave[p][Overlap/2] //Unteren Rand der oberen Wave schreiben tmpLowerWave = tiltContrast*appendwave[p][ExtraColumns-1+Overlap/2] //Oberer Rand der unteren Wave schreiben End