Skip to content
Snippets Groups Projects
Commit 8c95274c authored by Nicola Vigano's avatar Nicola Vigano
Browse files

IPFCmapKey: small fixes

parent 8d42d06e
No related branches found
No related tags found
No related merge requests found
...@@ -8,49 +8,52 @@ function h = gtIPFCmapKey(varargin) ...@@ -8,49 +8,52 @@ function h = gtIPFCmapKey(varargin)
% crystal_system = <string> % crystal_system = <string>
% N = <int> Number of angular steps (quality of the plot) {30} % N = <int> Number of angular steps (quality of the plot) {30}
% saturate = <logical> Saturate or not the color in the SST {true} % saturate = <logical> Saturate or not the color in the SST {true}
% label = <logical> Draw poles label {false} % ipf_label = <logical> Draw IPF label {false}
% fontsize = <int> Font size for labels {18} % poles_label = <logical> Draw poles label {false}
% fontcolor = <double> Font color {[0 0 0]} % font_size = <int> Font size for labels {18}
% font_color = <double> Font color {[0 0 0]}
% drawing = <logical> Draw the patch with RGB colors {true} % drawing = <logical> Draw the patch with RGB colors {true}
% hf = <handle> figure handle {[]} % hf = <handle> figure handle {[]}
% ha = <handle> axis handle {[]} % ha = <handle> axis handle {[]}
% figcolor = <dobule> figure color {[1 1 1]} % fig_color = <dobule> figure color {[1 1 1]}
% sampleDir = <string> sample direction for IPF map {''} % sample_dir = <string> sample direction for IPF map {''}
% %
% OUTPUT: % OUTPUT:
% h = <handle> Handles in figure % h = <handle> Handles in figure
app.crystal_system = ''; app = struct( ...
app.N = 30; 'crystal_system', '', ...
app.saturate = true; 'N', 30, ...
app.label = true; 'poles_label', true, ...
app.fontsize = 12; 'ipf_label', true, ...
app.fontcolor = [0 0 0]; 'font_size', 12, ...
app.drawing = true; 'font_color', [0 0 0], ...
app.hf = []; 'drawing', true, ...
app.ha = []; 'hf', [], ...
app.figcolor = [1 1 1]; 'ha', [], ...
app.sampleDir = ''; 'fig_color', [1 1 1], ...
'sample_dir', '' );
[app, rej_pars] = parse_pv_pairs(app, varargin); [app, rej_pars] = parse_pv_pairs(app, varargin);
if isempty(app.crystal_system) if (isempty(app.crystal_system))
parameters = []; parameters = gtLoadParameters();
load('parameters.mat');
app.crystal_system = parameters.cryst(1).crystal_system; app.crystal_system = parameters.cryst(1).crystal_system;
end end
if isempty(app.hf)
if (isempty(app.hf))
hf = figure(); hf = figure();
else else
hf = app.hf; hf = app.hf;
end end
if isempty(app.ha) if (isempty(app.ha))
ha = axes('Parent', hf); ha = axes('Parent', hf);
else else
ha = app.ha; ha = app.ha;
end end
hold(ha, 'on'); hold(ha, 'on');
if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}) if (ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}))
% For hexagonal colour map, we need two angles: % For hexagonal colour map, we need two angles:
% - phi (around z-axis) % - phi (around z-axis)
% - psi (from z-axis to vector) % - psi (from z-axis to vector)
...@@ -61,7 +64,7 @@ if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}) ...@@ -61,7 +64,7 @@ if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'})
psimin = 0; psimin = 0;
psimax = pi/2; psimax = pi/2;
elseif ismember(app.crystal_system, {'cubic', 'cube', 'c'}) elseif (ismember(app.crystal_system, {'cubic', 'cube', 'c'}))
% For cubic colour map, we need two angles: % For cubic colour map, we need two angles:
% - phi (around z-axis) % - phi (around z-axis)
% - chi (around y-axis) % - chi (around y-axis)
...@@ -79,9 +82,9 @@ h_p = []; ...@@ -79,9 +82,9 @@ h_p = [];
for phi = phimin:inc:(phimax-inc) % Rotation around z-axis for phi = phimin:inc:(phimax-inc) % Rotation around z-axis
for psi = psimin:inc:(psimax-inc) % Out from z-axis to vector for psi = psimin:inc:(psimax-inc) % Out from z-axis to vector
if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}) if (ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}))
ratioR = 1 - psi/psimax; ratioR = 1 - psi/psimax;
elseif ismember(app.crystal_system, {'cubic', 'cube', 'c'}) elseif (ismember(app.crystal_system, {'cubic', 'cube', 'c'}))
z = cos(psi); z = cos(psi);
x = sin(psi)*cos(phi); x = sin(psi)*cos(phi);
...@@ -130,11 +133,10 @@ end ...@@ -130,11 +133,10 @@ end
axis(ha, 'tight') axis(ha, 'tight')
axis(ha, 'equal'); axis(ha, 'equal');
if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}) if (ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}))
set(ha, 'xlim', [-0.05 1.05]); set(ha, 'xlim', [-0.05 1.05]);
set(ha, 'ylim', [-0.06 0.56]); set(ha, 'ylim', [-0.06 0.56]);
% Add a black border around triangle % Add a black border around triangle
% For hexagonal: % For hexagonal:
% - line from [0 0 0 1] to [2 -1 -1 0] (phi=0) % - line from [0 0 0 1] to [2 -1 -1 0] (phi=0)
...@@ -143,8 +145,7 @@ if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}) ...@@ -143,8 +145,7 @@ if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'})
line_phi = (phimin:inc:phimax)'; line_phi = (phimin:inc:phimax)';
line_r = tan(psimax/2 * ones(size(line_phi))); line_r = tan(psimax/2 * ones(size(line_phi)));
elseif ismember(app.crystal_system, {'cubic', 'cube', 'c'}) elseif (ismember(app.crystal_system, {'cubic', 'cube', 'c'}))
set(gca, 'xlim', [-0.01 0.45]); set(gca, 'xlim', [-0.01 0.45]);
set(gca, 'ylim', [-0.03 0.39]); set(gca, 'ylim', [-0.03 0.39]);
...@@ -169,17 +170,17 @@ end ...@@ -169,17 +170,17 @@ end
xp = [line_x; 0; line_x(1)]; xp = [line_x; 0; line_x(1)];
yp = [line_y; 0; line_y(1)]; yp = [line_y; 0; line_y(1)];
h_line_plot = plot(xp, yp, '-', ... h_line_plot = plot(xp, yp, '-', ...
'Tag', 'h_line_plot', 'Color', app.fontcolor, 'Parent', ha); 'Tag', 'h_line_plot', 'Color', app.font_color, 'Parent', ha);
if ismember(app.crystal_system, {'cubic', 'cube', 'c'}) if (ismember(app.crystal_system, {'cubic', 'cube', 'c'}))
% Add a white patch to mask the rough outer edge of the triangle % Add a white patch to mask the rough outer edge of the triangle
xp = [line_x ; line_x(end) ; 0.45 ; 0.45 ; line_x(1)]; xp = [line_x ; line_x(end) ; 0.45 ; 0.45 ; line_x(1)];
yp = [line_y ; 0.39 ; 0.39 ; 0 ; 0 ]; yp = [line_y ; 0.39 ; 0.39 ; 0 ; 0 ];
patch(xp, yp, app.figcolor, 'EdgeColor', 'none', 'Parent', ha); patch(xp, yp, app.fig_color, 'EdgeColor', 'none', 'Parent', ha);
end end
if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}) if (ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}))
% Add labels for the 3 corners poles % Add labels for the 3 corners poles
poles_psi = [psimin psimax psimax]; poles_psi = [psimin psimax psimax];
poles_phi = [phimin phimax phimin]; poles_phi = [phimin phimax phimin];
...@@ -188,8 +189,7 @@ if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'}) ...@@ -188,8 +189,7 @@ if ismember(app.crystal_system, {'hexagonal', 'hex', 'hcp', 'h'})
uvw_poles_l = {'[0 0 0 1]', '[1 0 -1 0]', '[2 -1 -1 0]'}; uvw_poles_l = {'[0 0 0 1]', '[1 0 -1 0]', '[2 -1 -1 0]'};
uvw_poles_x = poles_x; uvw_poles_x = poles_x;
uvw_poles_y = poles_y; uvw_poles_y = poles_y;
elseif (ismember(app.crystal_system, {'cubic', 'cube', 'c'}))
elseif ismember(app.crystal_system, {'cubic', 'cube', 'c'})
uvw_poles_x = [0 0.366 0.4142 0.236 0.2247 0.3 0.4]; uvw_poles_x = [0 0.366 0.4142 0.236 0.2247 0.3 0.4];
uvw_poles_y = [0 0.366 0 0 0.2247 0.153 0.2]; uvw_poles_y = [0 0.366 0 0 0.2247 0.153 0.2];
uvw_poles_l = {'[0 0 1]', '[1 1 1]', '[1 0 1]', '[1 0 2]', '[1 1 2]', '[2 1 3]', '[2 1 2]'}; uvw_poles_l = {'[0 0 1]', '[1 1 1]', '[1 0 1]', '[1 0 2]', '[1 1 2]', '[2 1 3]', '[2 1 2]'};
...@@ -199,13 +199,13 @@ elseif ismember(app.crystal_system, {'cubic', 'cube', 'c'}) ...@@ -199,13 +199,13 @@ elseif ismember(app.crystal_system, {'cubic', 'cube', 'c'})
end end
h_t = []; h_t = [];
if (app.label) if (app.poles_label)
for ii = 1:length(uvw_poles_x) for ii = 1:length(uvw_poles_x)
plot(uvw_poles_x(ii), uvw_poles_y(ii), '*', ... plot(uvw_poles_x(ii), uvw_poles_y(ii), '*', ...
'Tag', 'h_points_plot', 'Color', app.fontcolor, 'Parent', ha); 'Tag', 'h_points_plot', 'Color', app.font_color, 'Parent', ha);
h_t{ii} = text(uvw_poles_x(ii), uvw_poles_y(ii), uvw_poles_l{ii}, ... h_t{ii} = text(uvw_poles_x(ii), uvw_poles_y(ii), uvw_poles_l{ii}, ...
'FontSize', app.fontsize, 'Color', app.fontcolor, ... 'FontSize', app.font_size, 'Color', app.font_color, ...
'VerticalAlignment', 'top', 'HorizontalAlignment', 'center', ... 'VerticalAlignment', 'top', 'HorizontalAlignment', 'center', ...
'Tag', 'h_poles', 'Parent', ha); 'Tag', 'h_poles', 'Parent', ha);
...@@ -215,29 +215,33 @@ if (app.label) ...@@ -215,29 +215,33 @@ if (app.label)
end end
end end
if isempty(get(hf, 'Tag')) if (isempty(get(hf, 'Tag')))
set(hf, 'Tag', 'h_figure') set(hf, 'Tag', 'h_figure')
end end
set(hf, 'Color', app.figcolor) set(hf, 'Color', app.fig_color)
set(ha, 'Visible', 'off'); set(ha, 'Visible', 'off');
% label and sample direction to plot if (app.ipf_label)
h_ipf = text(0,0.6,0,'IPF',... label and sample direction to plot
'FontSize',app.fontsize,'Color',app.fontcolor,... h_ipf = text(0, 0.6, 0, 'IPF', ...
'VerticalAlignment','top','HorizontalAlignment','left',... 'FontSize', app.font_size, 'Color', app.font_color, ...
'Tag','h_ipf','Parent',ha); 'VerticalAlignment', 'top', 'HorizontalAlignment', 'left', ...
'Tag', 'h_ipf', 'Parent', ha);
end
h_ipf_dir = text(0,0.52,0,app.sampleDir,... h_ipf_dir = text(0, 0.52, 0, app.sample_dir, ...
'FontSize',app.fontsize,'Color',app.fontcolor,... 'FontSize', app.font_size, 'Color', app.font_color, ...
'VerticalAlignment','top','HorizontalAlignment','left',... 'VerticalAlignment', 'top', 'HorizontalAlignment', 'left', ...
'Tag','h_ipf_dir','Parent',ha); 'Tag', 'h_ipf_dir', 'Parent', ha);
if ismember(app.crystal_system,{'cubic','cube','c'}) if (ismember(app.crystal_system, {'cubic', 'cube', 'c'}))
set(h_ipf, 'Position', [0, 0.35, 0]) if (app.ipf_label)
set(h_ipf_dir,'Position',[0,0.32,0]) set(h_ipf, 'Position', [0, 0.35, 0])
end
set(h_ipf_dir, 'Position', [0, 0.32, 0])
end end
if nargout > 0 if (nargout > 0)
h = guihandles(hf); h = guihandles(hf);
end end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment