#pragma TextEncoding = "UTF-8" #pragma rtGlobals=3 // Use modern global access method and strict wave access #pragma DefaultTab={3,20,4} // Set default tab width in Igor Pro 9 and later #pragma version=9.06 // shipped with Igor 9.06 #pragma IndependentModule=WMTexOverrides StrConstant ksPanel = "WMTeXSettings" Menu "Graph", hideable Submenu "Packages" "Show Igor TeX Settings",/Q, WMTexOverrides#ShowWMTeXSettings() End End Menu "Layout", hideable Submenu "Packages" "Show Igor TeX Settings",/Q, WMTexOverrides#ShowWMTeXSettings() End End Function ShowWMTeXSettings() DoWindow/F $ksPanel if( V_Flag ) return 0 endif EnsureOveridesWave() NewPanel /K=1 /W=(100,83,340,297)/N=$ksPanel as "WMTeX Settings" String target = WinName(0,1+4,1) // top-most visible graph or layout if( strlen(target) ) AutoPositionWindow/R=$target $ksPanel endif GroupBox GlobalOverrides,pos={18.00,11.00},size={208.00,149.00} GroupBox GlobalOverrides,title="Global WMTeX Overrides" TitleBox zeroIsDefault,pos={47.00,35.00},size={140.00,16.00} TitleBox zeroIsDefault,title="Enter 0 for default settings",fSize=12,frame=0 TitleBox zeroIsDefault,fColor=(0,0,65535) SetVariable superscriptOffset,pos={39.00,64.00},size={159.00,19.00},bodyWidth=60,proc=WMTexOverrides#SuperscriptSetVarProc SetVariable superscriptOffset,title="Superscript Offset" SetVariable superscriptOffset,help={"sup2, sup3, sup_drop"} SetVariable superscriptOffset,limits={0,1.5,0.05},value=_NUM:0 SetVariable subscriptOffset,pos={50.00,95.00},size={148.00,19.00},bodyWidth=60,proc=WMTexOverrides#SubscriptSetVarProc SetVariable subscriptOffset,title="Subscript Offset" SetVariable subscriptOffset,help={"sub1, sub2, sub_drop"} SetVariable subscriptOffset,limits={0,1.5,0.05},value=_NUM:0 SetVariable RuleThickness,pos={57.00,126.00},size={141.00,19.00},bodyWidth=60,proc=WMTexOverrides#RuleThickSetVarProc SetVariable RuleThickness,title="Rule Thickness",help={"rule_thickness"} SetVariable RuleThickness,limits={0,10,0.5},value=_NUM:0 Button help,pos={69.00,180.00},size={100.00,20.00},proc=WMTexOverrides#AboutWMTeXButtonProc Button help,title="About WMTeX" End Function DrawOutlinesCheckProc(ctrlName,checked) : CheckBoxControl String ctrlName Variable checked WAVE/Z params = EnsureOveridesWave() params[%drawOutlines] = checked UpdateTargetWindow() End Function SubscriptSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName WAVE/Z params = EnsureOveridesWave() params[%sub1] = varNum params[%sub2] = varNum params[%sub_drop] = varNum UpdateTargetWindow() End Function SuperscriptSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName WAVE/Z params = EnsureOveridesWave() params[%sup1] = varNum params[%sup2] = varNum params[%sup3] = varNum params[%sup_drop] = varNum UpdateTargetWindow() End Function RuleThickSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName WAVE/Z params = EnsureOveridesWave() params[%rule_thickness] = varNum UpdateTargetWindow() End Function AboutWMTeXButtonProc(ctrlName) : ButtonControl String ctrlName DisplayHelpTopic "Igor TeX" End Function/S UpdateTargetWindow() String win = WinName(0,1+4,1) // top-most visible graph or layout if( strlen(win) ) if( !TrivialAnnotationChange(win) ) DoUpdate/W=$win endif endif return win End // toggle the annotation's freeze stats Function TrivialAnnotationChange(win) String win String anno = StringFromList(0,AnnotationList(win)) if( strlen(anno) ) String info = AnnotationInfo(win,anno,1) String cmd = StringByKey("TYPE",info) String flags = StringByKey("FLAGS",info) String slashZ = StringByKey("Z", flags, "=", "/") // "0" or "1" String toggledZ = SelectString(CmpStr(slashZ,"0") == 0, "0", "1") String s = cmd + "/C/N=" + anno + "/Z=" Execute/Q/Z s+toggledZ Execute/Q/Z s+slashZ return 1 endif return 0 End Function/WAVE EnsureOveridesWave() WAVE/Z params = root:M_TeXParams if( !WaveExists(params) ) Make/O/N=20 root:M_TeXParams= 0 // defaults WAVE w= root:M_TeXParams // set dimension labels // The order doesn't matter to IgorTeX, but these are the items in the Igor TeX demo experiment. SetDimLabel 0, 0, axis_height, w // height of fraction lines above the baseline (not useful) // numerators - not implemented SetDimLabel 0, 1, num1, w // numerator shift-up in display styles (not implemented) SetDimLabel 0, 2, num2, w // numerator shift-up in non-display, non-\atop (not implemented) SetDimLabel 0, 3, num3, w // numerator shift-up in non-display \atop (not implemented) // denominators - not implemented SetDimLabel 0, 4, denom1, w // denominator shift-down in display styles (not implemented) SetDimLabel 0, 5, denom2, w // denominator shift-down in non-display styles (not implemented) // superscript offsets SetDimLabel 0, 6, sup1, w // superscript shift-up in uncramped display style SetDimLabel 0, 7, sup2, w // superscript shift-up in uncramped non-display SetDimLabel 0, 8, sup3, w // superscript shift-up in cramped styles SetDimLabel 0, 9, sup_drop, w // superscript baseline below top of large box // subscript offsets SetDimLabel 0, 10, sub1, w // subscript shift-down if superscript is absent SetDimLabel 0, 11, sub2, w // subscript shift-down if superscript is present SetDimLabel 0, 12, sub_drop, w // subscript baseline below bottom of large box // delimiters SetDimLabel 0, 13, delim1, w // size of \.{\\atopwithdelims} delimiters in display styles (not implemented) SetDimLabel 0, 14, delim2, w // size of \.{\\atopwithdelims} delimiters in non-displays (not implemented) // misc SetDimLabel 0, 15, rule_thickness, w // thickness of \.{\\over} bars SetDimLabel 0, 16, char_italic, w // used only when both sub and super-script are present SetDimLabel 0, 17, script_space, w // not useful // debugging only SetDimLabel 0, 19, drawOutlines, w endif return params End #if 0 // These other settings don't really do anything (yet?) PopupMenu otherSettings,pos={50.00,181.00},size={160.00,20.00},proc=WMTexOverrides#OtherSettingPopMenuProc PopupMenu otherSettings,title="Other Setting" PopupMenu otherSettings,mode=9,popvalue="script_space",value=#"\"num1;num2;num3;denom1;denom2;delim1;delim2;axis_height;script_space\"" SetVariable OtherSetting,pos={56.00,216.00},size={128.00,19.00},bodyWidth=60,proc=WMTexOverrides#OtherSettingSetVarProc SetVariable OtherSetting,title="script_space",help={"rule_thickness"} SetVariable OtherSetting,limits={0,20,0.1},value=_NUM:0 Function OtherSettingPopMenuProc(ctrlName,popNum,popStr) : PopupMenuControl String ctrlName Variable popNum String popStr WAVE/Z params = EnsureOveridesWave() Variable row = FindDimLabel(params, 0, popStr) Variable value = params[row] SetVariable OtherSetting win=$ksPanel, title=popStr SetVariable OtherSetting, value=_NUM:value End Function OtherSettingSetVarProc(ctrlName,varNum,varStr,varName) : SetVariableControl String ctrlName Variable varNum String varStr String varName WAVE/Z params = EnsureOveridesWave() ControlInfo/W=$ksPanel OtherSettings String dimLabel = S_Value Variable row = FindDimLabel(params, 0, dimLabel) params[row] = varNum UpdateTargetWindow() End #endif