I've cleaned up the patch slightly - whitespace, one spelling error, and fixed some keyboard shortcuts that weren't working properly. It's working nicely, I'll get an upload taken care of soon.
- Nicholas
Index: grace-5.1.22/src/nonlwin.c =================================================================== --- grace-5.1.22.orig/src/nonlwin.c 2010-05-21 14:09:48.000000000 -0700 +++ grace-5.1.22/src/nonlwin.c 2010-05-21 14:14:12.000000000 -0700 @@ -101,6 +101,11 @@ static void update_nonl_frame_cb(void *data); static void reset_nonl_frame_cb(void *data); +static void nonl_Lorentzian_cb(void *data); +static void nonl_doubleLorentzian_cb(void *data); +static void nonl_Gaussian_cb(void *data); +static void nonl_doubleGaussian_cb(void *data); + static void do_nparm_toggle(int value, void *data); static void create_openfit_popup(void *data); static void create_savefit_popup(void *data); @@ -145,6 +150,16 @@ CreateMenuSeparator(menupane); CreateMenuButton(menupane, "Update", 'U', update_nonl_frame_cb, NULL); + menupane = CreateMenu(menubar, "Formula", 'a', FALSE); + + CreateMenuButton(menupane, "Gaussian fit", 'G', nonl_Gaussian_cb, NULL); + CreateMenuButton(menupane, "Double Gaussian fit", 'D', nonl_doubleGaussian_cb, NULL); + CreateMenuSeparator(menupane); + CreateMenuButton(menupane, "Lorentzian fit", 'L', nonl_Lorentzian_cb, NULL); + CreateMenuButton(menupane, "Double Lorentzian fit", 'z', nonl_doubleLorentzian_cb, NULL); + CreateMenuSeparator(menupane); + CreateMenuButton(menupane, "Reset fit parameters", 'R', reset_nonl_frame_cb, NULL); + menupane = CreateMenu(menubar, "Help", 'H', TRUE); CreateMenuHelpButton(menupane, "On fit", 'f', @@ -712,3 +727,35 @@ } return TRUE; } + +static void nonl_Lorentzian_cb(void *data) +{ + nonl_opts.title = copy_string(nonl_opts.title, "Lorentzian fit"); + nonl_opts.formula = copy_string(nonl_opts.formula, "y = (2*A1*A2/pi)/(4*(x-A0)^2 + A1^2)"); + nonl_opts.parnum = 3; + update_nonl_frame(); +} + +static void nonl_doubleLorentzian_cb(void *data) +{ + nonl_opts.title = copy_string(nonl_opts.title, "Double Lorentzian fit"); + nonl_opts.formula = copy_string(nonl_opts.formula, "y = (2*A1*A2/pi)/(4*(x-A0)^2 + A1^2) + (2*A4*A5/pi)/(4*(x-A3)^2 + A4^2)"); + nonl_opts.parnum = 6; + update_nonl_frame(); +} + +static void nonl_Gaussian_cb(void *data) +{ + nonl_opts.title = copy_string(nonl_opts.title, "Gaussian fit"); + nonl_opts.formula = copy_string(nonl_opts.formula, "y = ((A2*(sqrt(2*ln(2))))/(A1*(sqrt(2*pi))))*exp((-(x-A0)^2)*(2*ln(2))/(2*A1^2))"); + nonl_opts.parnum = 3; + update_nonl_frame(); +} + +static void nonl_doubleGaussian_cb(void *data) +{ + nonl_opts.title = copy_string(nonl_opts.title, "Double Gaussian fit"); + nonl_opts.formula = copy_string(nonl_opts.formula, "y = ((A2*(sqrt(2*ln(2))))/(A1*(sqrt(2*pi))))*exp((-(x-A0)^2)*(2*ln(2))/(2*A1^2)) + ((A5*(sqrt(2*ln(2))))/(A4*(sqrt(2*pi))))*exp((-(x-A3)^2)*(2*ln(2))/(2*A4^2))"); + nonl_opts.parnum = 6; + update_nonl_frame(); +}