From 0ad5915830bf03aac6c4cc70becc886e2d02f5b9 Mon Sep 17 00:00:00 2001 From: Johannes Ranke Date: Sun, 23 Nov 2014 15:12:05 +0100 Subject: Create separate handler function for deleting fits This was done to make it possible to debug this function --- inst/GUI/gmkin.R | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'inst/GUI') diff --git a/inst/GUI/gmkin.R b/inst/GUI/gmkin.R index 693a038..0bd3c9b 100644 --- a/inst/GUI/gmkin.R +++ b/inst/GUI/gmkin.R @@ -894,26 +894,29 @@ keep.fit.gb <- gbutton("Keep fit", }, cont = f.gg.buttons) tooltip(keep.fit.gb) <- "Store the optimised model with all settings and the current dataset in the fit list" -delete.fit.gb <- gbutton("Delete fit", handler = function(h, ...) { - if (length(f) > 0) { - f[[f.cur]] <<- NULL - s[[f.cur]] <<- NULL - } - if (length(f) > 0) { - names(f) <<- as.character(1:length(f)) - names(s) <<- as.character(1:length(f)) - update_f.df() - f.cur <<- "1" - ftmp <<- f[[f.cur]] - stmp <<- s[[f.cur]] - ds.i <<- ftmp$ds.index - update_plotting_and_fitting() - } else { - f.df <<- f.df.empty - f.cur <<- "0" - } - f.gtable[,] <<- f.df - }, cont = f.gg.buttons) +delete_fit_handler <- function(h, ...) { + if (length(f) > 0) { + f[[f.cur]] <<- NULL + s[[f.cur]] <<- NULL + } + if (length(f) > 0) { + names(f) <<- as.character(1:length(f)) + names(s) <<- as.character(1:length(f)) + update_f.df() + f.cur <<- "1" + ftmp <<- f[[f.cur]] + stmp <<- s[[f.cur]] + ds.i <<- ftmp$ds.index + update_plotting_and_fitting() + } else { + f.df <<- f.df.empty + f.cur <<- "0" + } + f.gtable[,] <<- f.df +} + +delete.fit.gb <- gbutton("Delete fit", handler = delete_fit_handler, + cont = f.gg.buttons) tooltip(delete.fit.gb) <- "Delete the currently loaded fit from the fit list" show.initial.gb <- gbutton("Show initial", -- cgit v1.2.1