Loading Data.m 0 → 100644 +113 −0 Original line number Diff line number Diff line classdef Data < handle % This class will store the data for each table, ideally to seperate % out the data from the gui and logic. properties Grid0 = []; Grid1 = []; Grid2 = []; function_name = []; function_inputs = []; settings = []; open = []; fig = []; end methods function obj = Data() end function [] = setData(object, grid0, grid1, grid2, name, inputs) object.Grid0 = grid0; object.Grid1 = grid1; object.Grid2 = grid2; object.function_name = name; object.function_inputs = inputs; end function [] = init(object) object.Grid2 = Grid(2,[]); object.Grid1 = Grid(1,[]); object.Grid0 = RGrid(object.Grid1,object.Grid2); object.Grid1.set_rGrid(object.Grid0); object.Grid2.set_rGrid(object.Grid0); object.Grid2.new_Cell; object.Grid1.new_Cell; end function [grid0, grid1, grid2, name, inputs] = getData(object) grid0 = object.Grid0; grid1 = object.Grid1; grid2 = object.Grid2; name = object.function_name; inputs = object.function_inputs; end function valid = valid(object) if isempty(object.Grid0) valid = 0; return end if isempty(object.Grid1) valid = 0; return end if isempty(object.Grid2) valid = 0; return end valid = 1; end %% clone % creates copy of object function copy = clone(obj,handle) % assume that dialog is closed copy = Data(); copy.function_name = get(handle,'Name') copy.function_inputs = obj.function_inputs copy.Grid2 = Grid(2,[]); copy.Grid1 = Grid(1,[]); copy.Grid0 = RGrid(copy.Grid1,copy.Grid2); copy.Grid1.set_rGrid(copy.Grid0); copy.Grid2.set_rGrid(copy.Grid0); obj.Grid2.clone(copy.Grid2,obj.Grid2.grid_index,[]) obj.Grid1.clone(copy.Grid1,obj.Grid1.grid_index,[]) obj.copy_results(copy) end function [] = setvalues(obj,settings) obj.settings = settings; end function [] = copy_results(obj,dest) for i=1:size(dest.Grid0.Cells,2) for j=1:size(obj.Grid0.Cells,2) if (strcmp(obj.Grid0.Cells(j).Cell1.cond_text,dest.Grid0.Cells(i).Cell1.cond_text) && strcmp(obj.Grid0.Cells(j).Cell2.cond_text,dest.Grid0.Cells(i).Cell2.cond_text)) dest.Grid0.Cells(i).result_text = obj.Grid0.Cells(j).result_text; end end end end function [] = save(obj) filename = [ obj.function_name '.data']; save(filename,'object'); end end end GUI.m +3 −1 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ classdef GUI < handle obj.Grid2 = Data.Grid2; obj.function_name_text = Data.function_name; obj.function_inputs_text = Data.function_inputs; obj.settings = Data.settings; end %% init Loading Loading @@ -290,7 +291,8 @@ classdef GUI < handle % save an extra file called expression_name.data which % contains a binary representation of the current gui object. filename = [get(object.function_name_control,'String') '.data']; save(filename,'object'); %save(filename,'object'); object.Data.save; fclose(fileid); end Loading Loading
Data.m 0 → 100644 +113 −0 Original line number Diff line number Diff line classdef Data < handle % This class will store the data for each table, ideally to seperate % out the data from the gui and logic. properties Grid0 = []; Grid1 = []; Grid2 = []; function_name = []; function_inputs = []; settings = []; open = []; fig = []; end methods function obj = Data() end function [] = setData(object, grid0, grid1, grid2, name, inputs) object.Grid0 = grid0; object.Grid1 = grid1; object.Grid2 = grid2; object.function_name = name; object.function_inputs = inputs; end function [] = init(object) object.Grid2 = Grid(2,[]); object.Grid1 = Grid(1,[]); object.Grid0 = RGrid(object.Grid1,object.Grid2); object.Grid1.set_rGrid(object.Grid0); object.Grid2.set_rGrid(object.Grid0); object.Grid2.new_Cell; object.Grid1.new_Cell; end function [grid0, grid1, grid2, name, inputs] = getData(object) grid0 = object.Grid0; grid1 = object.Grid1; grid2 = object.Grid2; name = object.function_name; inputs = object.function_inputs; end function valid = valid(object) if isempty(object.Grid0) valid = 0; return end if isempty(object.Grid1) valid = 0; return end if isempty(object.Grid2) valid = 0; return end valid = 1; end %% clone % creates copy of object function copy = clone(obj,handle) % assume that dialog is closed copy = Data(); copy.function_name = get(handle,'Name') copy.function_inputs = obj.function_inputs copy.Grid2 = Grid(2,[]); copy.Grid1 = Grid(1,[]); copy.Grid0 = RGrid(copy.Grid1,copy.Grid2); copy.Grid1.set_rGrid(copy.Grid0); copy.Grid2.set_rGrid(copy.Grid0); obj.Grid2.clone(copy.Grid2,obj.Grid2.grid_index,[]) obj.Grid1.clone(copy.Grid1,obj.Grid1.grid_index,[]) obj.copy_results(copy) end function [] = setvalues(obj,settings) obj.settings = settings; end function [] = copy_results(obj,dest) for i=1:size(dest.Grid0.Cells,2) for j=1:size(obj.Grid0.Cells,2) if (strcmp(obj.Grid0.Cells(j).Cell1.cond_text,dest.Grid0.Cells(i).Cell1.cond_text) && strcmp(obj.Grid0.Cells(j).Cell2.cond_text,dest.Grid0.Cells(i).Cell2.cond_text)) dest.Grid0.Cells(i).result_text = obj.Grid0.Cells(j).result_text; end end end end function [] = save(obj) filename = [ obj.function_name '.data']; save(filename,'object'); end end end
GUI.m +3 −1 Original line number Diff line number Diff line Loading @@ -67,6 +67,7 @@ classdef GUI < handle obj.Grid2 = Data.Grid2; obj.function_name_text = Data.function_name; obj.function_inputs_text = Data.function_inputs; obj.settings = Data.settings; end %% init Loading Loading @@ -290,7 +291,8 @@ classdef GUI < handle % save an extra file called expression_name.data which % contains a binary representation of the current gui object. filename = [get(object.function_name_control,'String') '.data']; save(filename,'object'); %save(filename,'object'); object.Data.save; fclose(fileid); end Loading