#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access. //****************************************************** static strconstant MPF2_VERSIONSTRING="2.22" static constant MPF2_UPDATEPANELVERSION=2.22 static constant MPF2_NarrowWidth=265 static constant MPF2_PanelWidth=375 static constant MPF2_PanelLength = 450 static Function/S MPF2_FolderPathFromSetNumber(setnumber) Variable setnumber return "root:Packages:MultiPeakFit2:"+MPF2_FolderNameFromSetNumber(setnumber) end static Function/S MPF2_FolderNameFromSetNumber(setnumber) Variable setnumber return "MPF_SetFolder_"+num2str(setnumber) end Static Function GetSetNumberFromWinName(windowName) String windowName String windowWithData Variable poundPos = strsearch(windowName, "#", 0) if (poundPos < 0) windowWithData = windowName else poundPos = strsearch(windowName, "#", poundPos+1) if (poundPos < 0) windowWithData = windowName else windowWithData = windowName[0,poundPos-1] endif endif return str2num(GetUserData(windowWithData, "", "MPF2_DataSetNumber")) end //****************************************************** Function BuildMultiPeak2Panel_mod(hostgraph, setNumber, position) String hostgraph Variable setNumber Variable position DoWindow/F $hostgraph String DFpath = MPF2_FolderPathFromSetNumber(setNumber) // constraints visible NVAR/Z MPF2ConstraintsShowing = $(DFPath+":MPF2ConstraintsShowing") if (!NVAR_Exists(MPF2ConstraintsShowing)) Variable/G $(DFPath+":MPF2ConstraintsShowing") NVAR MPF2ConstraintsShowing = $(DFPath+":MPF2ConstraintsShowing") MPF2ConstraintsShowing = 0 endif Variable width = MPF2ConstraintsShowing ? MPF2_PanelWidth : MPF2_NarrowWidth Variable left, top, right, bottom switch(position) case 0: // right left=0; top=MPF2_PanelLength; right=width; bottom=MPF2_PanelLength; break; case 1: // left left=width; top=MPF2_PanelLength; right=0; bottom=MPF2_PanelLength; break; case 2: // below left=width; top=0; right=width; bottom=MPF2_PanelLength; break; case 3: // above left=width; top=MPF2_PanelLength; right=width; bottom=0; break; endswitch NewPanel /W=(left,top,right,bottom)/K=1/HOST=$hostgraph/EXT=(position) as "Multi-peak Fit Set "+num2str(setNumber) String panelName = hostgraph+"#"+S_name RenameWindow $panelName, MultiPeak2Panel panelName = hostgraph+"#MultiPeak2Panel" ModifyPanel/W=$panelName fixedSize=0 DefineGuide UGH0={FT,5} DefineGuide UGH1={UGH0,70} DefineGuide UGH3={FB,-23} DefineGuide UGH2={UGH3,-99} ///// Panel has had significant changes for version 2.15. Need a way to check for the old version and update the panel ///// It will be done by checking existence of new variables. If they don't exist then check for a userdata version number ///// If the userdata version doesn't exist or < MPF2_UPDATEPANELVERSION then update the panel and additional coefficients SetWindow $panelName userdata(MPF2_UPDATEPANELVERSION)=num2str(MPF2_UPDATEPANELVERSION) Variable/G $(DFPath+":negativePeaks") = NumVarOrDefault(DFPath+":negativePeaks", 0) NVAR negativePeaks = $(DFPath+":negativePeaks") Variable/G $(DFPath+":displayPeaksFullWidth") = NumVarOrDefault(DFPath+":displayPeaksFullWidth", 0) NVAR displayPeaksFullWidth = $(DFPath+":displayPeaksFullWidth") Variable/G $(DFPath+":panelPosition") = position //// Panel 0 - Peak location NewPanel/N=P0/W=(0,86,width,149)/FG=(,UGH0,,UGH1)/HOST=$panelName ModifyPanel frameStyle=0, frameInset=0 GroupBox MPF2_LocatePeaksGroupBox,pos={8,2},size={width-16,64},title="Locate Peaks" GroupBox MPF2_LocatePeaksGroupBox,fStyle=1 Button MPF2_AutoLocatePeaksButton,pos={(MPF2_NarrowWidth-158)/2,21},size={158,20},proc=MPF2_AutoLocatePeaksButtonProc,title="Auto-locate Peaks Now" //Button MPF2_AutoLocatePeaksButton,fSize=10 CheckBox MPF2_NegativePeaksCheck,pos={(MPF2_NarrowWidth+16)/2,45},size={85,14},title="Negative Peaks" CheckBox MPF2_NegativePeaksCheck,variable=negativePeaks CheckBox MPF2_DiscloseAutoPickParams,pos={14,44},size={16,14},proc=MPF2_DiscloseAutoPickCheckProc,title="More options" CheckBox MPF2_DiscloseAutoPickParams,value=0,mode=2 #if IgorVersion() >= 7 CheckBox MPF2_DiscloseAutoPickParams focusRing=0 #endif SetActiveSubwindow ## //// Panel 1 - fit controls NewPanel/N=P1/FG=(FL,UGH1,FR,UGH2)/HOST=$panelName ModifyPanel frameStyle=0, frameInset=0 String listPanel = panelName+"#P1" Variable/G $(DFPath+":MPF2_UserCursors") = NumVarOrDefault(DFPath+":MPF2_UserCursors", 0) NVAR useCursors = $(DFPath+":MPF2_UserCursors") CheckBox MPF2_UserCursorsCheckbox,win=$listPanel,pos={10,1},size={105,15},title="Use Graph Cursors" CheckBox MPF2_UserCursorsCheckbox,win=$listPanel,value=useCursors,proc=MPF2_CursorsCheckProc CheckBox MPF2_DiscloseConstraints,win=$listPanel,pos={140,1},size={85,15},title="Apply Constraints",value=MPF2ConstraintsShowing,proc=MPF2_DiscloseConstraints_mod//,fsize=10 ListBox MPF2_PeakList,win=$listPanel,pos={6,20},size={width-16,MPF2_PanelLength-220},clickEventModifiers=2+4 // don't allow checkbox toggle or selection with option or context click ListBox MPF2_PeakList win=$listPanel,userdata(MPF2_DataSetNumber)=num2str(setnumber) MakeListIntoHierarchicalList(listPanel, "MPF2_PeakList", "PeakListOpenNotify", selectionMode=WMHL_SelectionNonContinguous, userListProc="MPF2_PeakListProc") WMHL_AddColumns(listPanel, "MPF2_PeakList", 6) WMHL_SetNotificationProc(listPanel, "MPF2_PeakList", "PeakListClosingNotify", WMHL_SetClosingNotificationProc) WMHL_AddObject(listPanel, "MPF2_PeakList", "", "Baseline", 1) WMHL_ExtraColumnData(listPanel, "MPF2_PeakList", 0, 0, "Constant"+MENU_ARROW_STRING, 0) if (MPF2ConstraintsShowing) ListBox MPF2_PeakList win=$listPanel,widths={4,12,15,11,5,10,6,10} else ListBox MPF2_PeakList win=$listPanel,widths={4,12,15,11,0,0,0,0} endif SetActiveSubwindow ## NewPanel/N=P2/W=(65,86,width,260)/FG=(FL,UGH2,FR,UGH3)/HOST=$panelName ModifyPanel frameStyle=0, frameInset=0 String buttonPanel = panelName+"#P2" PopupMenu MPF2_SetAllPeakTypesMenu,win=$buttonPanel,pos={MPF2_NarrowWidth-135,4},size={130,20},proc=MPF2_SetAllPeakTypesMenuProc,title="Set Peak Type for All" PopupMenu MPF2_SetAllPeakTypesMenu,win=$buttonPanel,bodyWidth=130,mode=0,value= #"MPF2_ListPeakTypeNames()" PopupMenu MPF2_CheckPointMenu,win=$buttonPanel,pos={MPF2_NarrowWidth-135,28},size={130,20},title="Fit Checkpoint", proc=MPF2_CheckpointMenuProc PopupMenu MPF2_CheckPointMenu,win=$buttonPanel,bodyWidth=130,mode=0,value= #"\"Save Checkpoint;Restore Checkpoint;\"" Variable leftSideControlOffset = floor(width/15) Button MPF2_DoFitButton,win=$buttonPanel,pos={8,3},size={55,20},proc=MPF2_DoFitButtonProc,title="Do Fit"//,fSize=10 Button MPF2_DoFitButton,win=$buttonPanel,fStyle=1,fColor=(32768,32770,65535), disable=2 Button MPF2_HelpButton,win=$buttonPanel,pos={68,3},size={55,20},title="Help", proc=MPF2_DoHelpButtonProc Button MPF2_RevertToGuessesButton,win=$buttonPanel,pos={8,28},size={115,20},proc=MPF2_RevertToPreviousButtonProc,title="Revert to Last Values",fSize=11 GroupBox MPF2_FitResultsGroupBox,pos={8,53},size={width-16,44},title="Fit Results",fStyle=1 Button MPF2_PeakResultsButton,win=$buttonPanel,pos={18,70},size={115,20},proc=MPF2_PeakResultsButtonProc,title="Peak Results..."//,fSize=10 Button MPF2_GraphResultsButton,win=$buttonPanel,pos={MPF2_NarrowWidth-125,70},size={109,20},proc=MPF2Results_GraphButtonProc,title="Results Graph..."//,fSize=10 SetActiveSubwindow ## NVAR MPF2_DontShowHelpMessage = root:Packages:MultiPeakFit2:MPF2_DontShowHelpMessage NewPanel/FG=(FL,UGH2,FR,FB)/HOST=# TitleBox MPF2_DoFitHelpBox,pos={14,35},size={193,60},frame=0, fsize=10 TitleBox MPF2_DoFitHelpBox,variable= root:Packages:MultiPeakFit2:MPF2_DoFitHelpBoxText Button MPF2_HelpPanelCloseButton,pos={(MPF2_NarrowWidth-30)/2,12},size={30,20},title="OK",proc=MPF2_DoFitHelpBoxButtonProc CheckBox MPF2_HelpPanelDontShow,pos={16,88},size={169,14},title="Don't show me this message again" CheckBox MPF2_HelpPanelDontShow,variable=MPF2_DontShowHelpMessage RenameWindow #,HelpPanel SetActiveSubwindow ## NewPanel/N=P3/W=(65,86,196,386)/FG=(FL,UGH3,FR,FB)/HOST=# ModifyPanel frameStyle=0, frameInset=0 NVAR/Z MPF2OptionsShowing = $(DFPath+":MPF2OptionsShowing") if (!NVAR_Exists(MPF2OptionsShowing)) Variable/G $(DFPath+":MPF2OptionsShowing") NVAR MPF2OptionsShowing = $(DFPath+":MPF2OptionsShowing") MPF2OptionsShowing = 0 String/G $(DFPath+":MPF2WeightWaveName") SVAR MPF2WeightWaveName = $(DFPath+":MPF2WeightWaveName") MPF2WeightWaveName = "" String weightPath = "_none_" String/G $(DFPath+":MPF2MaskWaveName") SVAR MPF2MaskWaveName = $(DFPath+":MPF2MaskWaveName") MPF2MaskWaveName = "" String maskPath = "_none_" else SVAR MPF2WeightWaveName = $(DFPath+":MPF2WeightWaveName") SVAR MPF2MaskWaveName = $(DFPath+":MPF2MaskWaveName") Wave/Z w = $MPF2WeightWaveName if (WaveExists(w)) weightPath = GetWavesDataFolder(w, 2) else weightPath = "_none_" endif Wave/Z w = $MPF2MaskWaveName if (WaveExists(w)) maskPath = GetWavesDataFolder(w, 2) else maskPath = "_none_" endif endif CheckBox MPF2_DiscloseOptions,pos={10,5},size={51,14},title="Options",value= 0,mode=2,proc=MPF2_DiscloseOptions,fsize=10 #if IgorVersion() >= 7 CheckBox MPF2_DiscloseOptions focusRing=0 #endif SVAR /Z interPeakString = $(DFPath+":interPeakConstraints") if (!SVAR_exists(interPeakString)) String /G $(DFPath+":interPeakConstraints") SVAR interPeakString = $(DFPath+":interPeakConstraints") endif TitleBox MPF2_InterPeakConstrTitle,pos={10,25},size={width-100,20},title="Inter-Peak Constraints:",fSize=10, frame=0 NewNotebook /HOST=$panelName#P3 /N=MPF2_InterPeakConstraints /W=(10,42,width-10,62) /F=0 /OPTS=3 Notebook $(panelName+"#P3#MPF2_InterPeakConstraints") visible=0, text=interPeakString SetActiveSubwindow $panelName#P3 TitleBox MPF2_ConstraintsExample,pos={10,65},size={width-100,20},title="Example: P1K0>P0K0;P2K1= 7 SetWindow $panelName sizeLimit={0,0,Inf,Inf} #endif MoveSubwindow/W=$panelName fnum=(left, top, right, bottom) //MPF2_EnforcePanelMinSize(panelName) //MPF2_PanelMoveControls(panelName) end