Commit df9c6f86 authored by Matthew Dawson's avatar Matthew Dawson
Browse files

Get the vertical hierarchical grid working.

The left condition grid works properly now.  Needs some testing.


git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/branches/TableTool_refactor@8740 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent e91cb697
Loading
Loading
Loading
Loading
+33 −1
Original line number Diff line number Diff line
@@ -32,7 +32,39 @@ classdef HierarchicalGrid < handle
        end
        
        function cell = get_cell(object, cell_index)
            cell = object.grid{cell_index};
            cell = object.get_child_cell([], cell_index);
        end
        
        function cell = get_child_cell(object, parent, cell_index)
            if isempty(parent)
                grid = object.grid
            else
                grid = parent.grid
            end
            
            cell = grid{cell_index}
        end
        
        function cell = recurse_top_cell(object, the_cell)
            cell = the_cell
            while size(cell.grid, 2) ~= 0
                cell = cell.grid{1};
            end
        end
        
        function count = children_count(object, parent)
            if isempty(parent)
                parent = object
            end
            
            count = size(parent.grid, 2);
        end
        
        function cell = recurse_bottom_cell(object, the_cell)
            cell = the_cell
            while size(cell.grid, 2) ~= 0
                cell = cell.grid{size(cell.grid, 2)};
            end
        end
        
    end
+5 −1
Original line number Diff line number Diff line
@@ -36,7 +36,11 @@ function [] = add_cell( object, beneath_cell, after_cell )
                notify(object, 'AddedOuterCell', GridSingleCellEventDetails(rmgi))
            end
        else
            rmgi = object.find_cell_in_list(object.right_most_grid_cells, subgrid.grid{ size(subgrid.grid, 2) });
            cell_in_rmg = subgrid.grid{ size(subgrid.grid, 2) };
            while size(cell_in_rmg.grid, 2) ~= 0
                cell_in_rmg = cell_in_rmg.grid{ size(cell_in_rmg.grid, 2) };
            end
            rmgi = object.find_cell_in_list(object.right_most_grid_cells, cell_in_rmg);
            
            %Since this is now an addition to the right most list, append.
            object.right_most_grid_cells = {object.right_most_grid_cells{1:rmgi} NewCell object.right_most_grid_cells{(rmgi+1):size(object.right_most_grid_cells, 2)}};
+17 −4
Original line number Diff line number Diff line
@@ -13,16 +13,29 @@ function delete_cell( object, beneath_cell, the_cell )
        subgrid = beneath_cell;
    end
    
    if isempty(beneath_cell) && isempty(the_cell.grid)
    if true || isempty(beneath_cell) && isempty(the_cell.grid)
        cur_index = object.find_cell_in_list(subgrid.grid, the_cell);
        rmgi = object.find_cell_in_list(object.right_most_grid_cells, the_cell);
        
        top_rmg = object.recurse_top_cell(the_cell);
        top_rmgi = object.find_cell_in_list(object.right_most_grid_cells, top_rmg);
        
        bottom_rmg = object.recurse_bottom_cell(the_cell);
        bottom_rmgi = object.find_cell_in_list(object.right_most_grid_cells, bottom_rmg);
        
        subgrid.grid = [subgrid.grid(1:cur_index-1) subgrid.grid(cur_index+1:size(subgrid.grid, 2))];
        
        %For readability, use rmgc.
        rmgc = object.right_most_grid_cells;
        object.right_most_grid_cells = [rmgc(1:rmgi-1) rmgc(rmgi+1:size(rmgc, 2))];
        notify(object, 'RemovedOuterCell', GridSingleCellEventDetails(rmgi))
        object.right_most_grid_cells = [rmgc(1:top_rmgi-1) rmgc(bottom_rmgi+1:size(rmgc, 2))];
        
        if ~isempty(beneath_cell)
            rmgc = object.right_most_grid_cells
            object.right_most_grid_cells = [rmgc(1:top_rmgi-1) {beneath_cell} rmgc(top_rmgi:size(rmgc, 2))];
            top_rmgi = top_rmgi + 1;
        end
        for i = 0:bottom_rmgi-top_rmgi
            notify(object, 'RemovedOuterCell', GridSingleCellEventDetails(top_rmgi))
        end
    else
        assert(false, 'Deal with sub-sub* grids');
    end
+1 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ function [ gi ] = find_cell_in_list( object, grid, find_cell )

    gi = -1;
    
    for i = 1:size(object.right_most_grid_cells, 2)
    for i = 1:size(grid, 2)
        if grid{i} == find_cell
            gi = i;
            break;
+13 −1
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ classdef VerticalHierarchicalGridDraw < GUIBase
    properties
        my_grid = []
        controls = {}
        root_controls = [];
        
        gui_params = []
        
@@ -21,6 +22,10 @@ classdef VerticalHierarchicalGridDraw < GUIBase
           object.my_grid = my_grid;
           object.gui_params = gui_params;
           
           object.root_controls = struct();
           object.root_controls.pb_new = -1;
           object.root_controls.pb_delete = -1;
           
           my_grid.addlistener('StructureChanged', @(src, event)redraw_and_update_bb(object, src, event));
        end
    end
@@ -28,8 +33,15 @@ classdef VerticalHierarchicalGridDraw < GUIBase
    methods
        function recurse_delete(object, controls)
            delete(controls.control);
            if ishandle(controls.pb_extend)
                delete(controls.pb_extend);
            end
            if ishandle(controls.cell_controls.pb_new)
                delete(controls.cell_controls.pb_new);
                delete(controls.cell_controls.pb_delete);
            end
            for i = 1:size(controls.subgrid, 2)
                recurse_delete(controls.subgrid{i});
                object.recurse_delete(controls.subgrid{i});
            end
        end
    end
Loading