% data must be loaded via SRread_script

close all

% shapes = {'generic_paracetamol_0'};
shapes = {'generic_paracetamol_1'};
          
% names = {'paracetamol_0'};
% labels = {'I', 'II', 'III'};
names = {'paracetamol_1'};
labels = {'I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII', 'XIII'};

rand('seed', 0);
lim = [-6 6];

for i = 1:length(shapes)
    %% Sample specific setup
    cmap = bone(4+size(data.(shapes{i}).cdef.G, 2));
    cmap = cmap(2+(1:size(data.(shapes{i}).cdef.G, 2)), :);
    SR = data.(shapes{i}).SR_part;
    cdef = data.(shapes{i}).cdef;
    disp(names{i})
    for j = 1:size(SR.unified.se_partitions, 1)
        disp(find(SR.unified.se_partitions(j,:)))
    end
    %% Draw SE's
    for j = 1:size(SR.se, 1)
        hC = SR.se(j,:)';
        viewCrystal(cdef, ...
            cdef.G*hC,...
            'colormap', cmap, ...
            'colorbar', 0, ...
            'annotation', 'none', ...
            'flatness', 1e-3);
        box off,axis off
        set(gcf, 'PaperUnits', 'centimeters', ...
            'PaperSize', [7, 7], ...
            'PaperPosition', [0 0 7 7]);
        set(gca, 'xlim', lim, 'ylim', lim, 'zlim', lim);
        set(get(gca,'children'), 'linewidth', 0.5);
        print('-depsc', [names{i} '_se_' num2str(j) '.eps'])
    end
    %% Draw different combinatorics
    for j = 1:size(SR.unified.se_partitions, 1)
        hC = SR.se(SR.unified.se_partitions(j,:), :)';
        hC = hC * ones([size(hC, 2) 1]);
        viewCrystal(cdef, ...
            cdef.G*hC,...
            'colormap', cmap, ...
            'colorbar', 0, ...
            'annotation', 'none');
        box off,axis off
        set(gcf, 'PaperUnits', 'centimeters', ...
            'PaperSize', [7, 7], ...
            'PaperPosition', [0 0 7 7]);
        set(gca, 'xlim', lim, 'ylim', lim, 'zlim', lim);
        print('-depsc', [names{i} '_com_' num2str(j) '.eps'])
    end
    
    
%     
%     ah = get(gcf, 'children');
%     % crystal
%     set(ah(2), 'position', [-0.15 -0.1    1  1.2]);
%     % legend
%     set(ah(1), 'position', [0.75  0.2    0.05  0.6], ...
%                'FontSize', 6);
         

end 