Commit 1b58ab1b authored by Colin Eles's avatar Colin Eles
Browse files

copy and paste of table block working better now

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/trunk/TableTool@5767 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent e9c65373
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -192,6 +192,10 @@ classdef Cell < handle
            end
        
        end
        
        function new_cell = clone()
            
        end
    end
    
end
+39 −9
Original line number Diff line number Diff line
@@ -304,11 +304,14 @@ classdef GUI < handle
            set_param(object.block_handle,'LinkStatus','none')
            
            % determine if the name already exists in the model
            
            if (~strcmp(get(object.block_handle,'Name'),get(object.function_name_text,'String')))
                try
                set_param(object.block_handle,'Name',get(object.function_name_control,'String'));
                catch exception
                    msgbox(exception.message);
                end
            end
            
            % embedded matlab code block store code in stateflow states so
            % we need to get the root hande
@@ -1032,10 +1035,6 @@ classdef GUI < handle
        end

        
        function [] = look_for_blanks(obj,grid)
            
        end
        
        %% save_conditions
        % this function is used to save the strings that are in each of the
        % condition edit boxes string field. We do this because when we
@@ -1532,8 +1531,39 @@ classdef GUI < handle
                'BackgroundColor',[1 1 1],...
                'horizontalalign','center',...
                'fontsize',11);
        end
       
        %% clone
        % creates copy of object
        function copy = clone(obj,handle)
            % assume that dialog is closed
            copy = GUI(handle);
            copy.function_name_text =   get(handle,'Name')
            copy.function_inputs_text = obj.function_inputs_text;
            
            
            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 [] = 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
        
        
+16 −0
Original line number Diff line number Diff line
@@ -262,6 +262,22 @@ classdef Grid < handle
             obj.delete_cell_pb = [];
             
         end
         
         
         function [] = clone(obj,dest_grid,index,p_cell)
            for i=1:size(obj.cells,2)
                dest_grid.new_Cell();
                dest_grid.cells(i).cond_text = obj.cells(i).cond_text
                if (~isempty(obj.cells(i).subgrid))
                    dest_grid.cells(i).subgrid = Grid(dest_grid.cells(i).cell_index,dest_grid.cells(i))
                    dest_grid.cells(i).subgrid.set_rGrid(dest_grid.cells(i).parent_grid.rGrid);
                   obj.cells(i).subgrid.clone(dest_grid.cells(i).subgrid,obj.cells(i).subgrid.grid_index,dest_grid.cells(i))
                else
                    
                end
                
            end
         end
    end
    
    
+2 −1
Original line number Diff line number Diff line
@@ -33,12 +33,13 @@ end
function LocalCopyBlockFcn(blockHandleTTTopMask)
    gui = get(blockHandleTTTopMask,'UserData')
    if(~isempty(gui))
        gui_new = gui.clone(blockHandleTTTopMask);  
    %    gui_new = copy(gui,blockHandleTTTopMask)
    %    gui_new.function_name_text = get_param(blockHandleTTTopMask,'Name');
    %    gui_new.fig = [];
    %    gui_new.block_handle = blockHandleTTTopMask;
    % TEMPORARY SOLUTION
    set_param(blockHandleTTTopMask,'UserData',[])
    set_param(blockHandleTTTopMask,'UserData',gui_new)
    end
end