Commit 88e657a0 authored by Jay Dubb's avatar Jay Dubb
Browse files

v1.32.0

-- Second step in changes to make Homer3 coexist with AtlasViewer in same matlab session
parent b53ce61a
Loading
Loading
Loading
Loading
+54 −1
Original line number Diff line number Diff line
function dirname = getAppDir(isdeployed_override)
function [out1] = getAppDir(inp1)
out1 = [];
ns = getNamespace();
if isempty(ns)
    return;
end
if strcmp(ns, 'AtlasViewerGUI')
    if nargin == 0
        [out1] = getAppDir_AtlasViewerGUI();
    elseif nargin == 1
        [out1] = getAppDir_AtlasViewerGUI(inp1);
    end
elseif strcmp(ns, 'Homer3')
    if nargin == 0
        [out1] = getAppDir_Homer3();
    elseif nargin == 1
        [out1] = getAppDir_Homer3(inp1);
    end
end


% ---------------------------------------------------------
function [dirname] = getAppDir_AtlasViewerGUI(isdeployed_override)

if ~exist('isdeployed_override','var')
    isdeployed_override = 'notdeployed';
end

if isdeployed() || strcmp(isdeployed_override, 'isdeployed')
    if ispc()
        dirname = 'c:/users/public/atlasviewer/';
    else
        currdir = pwd;
        cd ~/;
        dirnameHome = pwd;
        dirname = [dirnameHome, '/atlasviewer/'];
        cd(currdir);
    end
else
    dirname = fileparts(which('AtlasViewerGUI.m'));
end

dirname(dirname=='\') = '/';
if dirname(end) ~= '/'
    dirname(end+1) = '/';
end





% ---------------------------------------------------------
function [dirname] = getAppDir_Homer3(isdeployed_override)

if ~exist('isdeployed_override','var')
    isdeployed_override = 'notdeployed';
@@ -24,3 +76,4 @@ if dirname(end) ~= '/'
end


+32 −3
Original line number Diff line number Diff line
function vrnnum = getVernum()
function [out1] = getVernum()
out1 = [];
ns = getNamespace();
if isempty(ns)
    return;
end
if strcmp(ns, 'AtlasViewerGUI')
    if nargin == 0
        [out1] = getVernum_AtlasViewerGUI();
    end
elseif strcmp(ns, 'Homer3')
    if nargin == 0
        [out1] = getVernum_Homer3();
    end
end


% ---------------------------------------------------------
function [vrnnum] = getVernum_AtlasViewerGUI()

vrnnum{1} = '2';   % Major version #
vrnnum{2} = '15';  % Major sub-version #
vrnnum{3} = '0';   % Minor version #
vrnnum{4} = '0';   % Minor sub-version # or patch #: 'p1', 'p2', etc



% ---------------------------------------------------------
function [vrnnum] = getVernum_Homer3()

vrnnum{1} = '1';   % Major version #
vrnnum{2} = '31';  % Major sub-version #
vrnnum{3} = '17';   % Minor version #
vrnnum{2} = '32';  % Major sub-version #
vrnnum{3} = '0';   % Minor version #
vrnnum{4} = '0';   % Minor sub-version # or patch #: 'p1', 'p2', etc
+2 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ function setNamespace(nm)
global namespace
N = 2;

fprintf('In setNamespace:\n');
% fprintf('In setNamespace:\n');

if nargin==0
    pname = filesepStandard(pwd);
@@ -31,5 +31,5 @@ idx = mod(length(namespace), N+1)+1;
namespace(idx).name = nm;
namespace(idx).pname = pname;

fprintf('  namespace = [%s, %s]\n', namespace(idx).name, namespace(idx).pname);
% fprintf('  namespace = [%s, %s]\n', namespace(idx).name, namespace(idx).pname);
+151 −2
Original line number Diff line number Diff line
function p3 = points_on_line(p1, p2, step, mode)
function [out1] = points_on_line(inp1, inp2, inp3, inp4, inp5)
out1 = [];
ns = getNamespace();
if isempty(ns)
    return;
end
if strcmp(ns, 'AtlasViewerGUI')
    if nargin == 0
        [out1] = points_on_line_AtlasViewerGUI();
    elseif nargin == 1
        [out1] = points_on_line_AtlasViewerGUI(inp1);
    elseif nargin == 2
        [out1] = points_on_line_AtlasViewerGUI(inp1, inp2);
    elseif nargin == 3
        [out1] = points_on_line_AtlasViewerGUI(inp1, inp2, inp3);
    elseif nargin == 4
        [out1] = points_on_line_AtlasViewerGUI(inp1, inp2, inp3, inp4);
    elseif nargin == 5
        [out1] = points_on_line_AtlasViewerGUI(inp1, inp2, inp3, inp4, inp5);
    end
elseif strcmp(ns, 'Homer3')
    if nargin == 0
        [out1] = points_on_line_Homer3();
    elseif nargin == 1
        [out1] = points_on_line_Homer3(inp1);
    elseif nargin == 2
        [out1] = points_on_line_Homer3(inp1, inp2);
    elseif nargin == 3
        [out1] = points_on_line_Homer3(inp1, inp2, inp3);
    elseif nargin == 4
        [out1] = points_on_line_Homer3(inp1, inp2, inp3, inp4);
    end
end


% ---------------------------------------------------------
function [p3] = points_on_line_AtlasViewerGUI(p1, p2, crop, mode, gridsize)

%
% USAGE:
%   
%    p3 = points_on_line_AtlasViewerGUI(p1,p2,crop,mode)
%
% DESCRIPTION:
%   
%    Function takes 2 points in 3d, p1 and p2, and a crop length
%    and finds a point on the line formed by extending p1,p2 by the 
%    amount (or fraction of p1-p2 distance) crop extends away from p1. 
%    
%    Positive crop crops p1,p2 by the crop amount.
%    Negative crop extends p1,p2 by the crop amount.
%     
%    mode = 'relative' means crop is the distance p3 extends away from p1 relative 
%    to the distance between p1 and p2. This is the default if no mode is provided. 
%
%    mode = 'absolute' means crop is the absolute distance (in unit length) that 
%    p3 extends away from p1.
%
%    mode = 'all' returns the set of all points at intervals 1/crop on the line 
%    segment between p1 and p2. 
%
% AUTHOR: Jay Dubb (jdubb@nmr.mgh.harvard.edu)
% DATE:   7/7/2012
%

if ~exist('mode','var') || isempty(mode)
    mode = 'relative';
end
if ~exist('gridsize','var') || isempty(gridsize)
    gridsize = 0;
end

p3 = p1;

if isempty(p1) || isempty(p2)
    return;
end
if all(p1==p2)
    return;
end

if ~exist('crop','var') || isempty(crop)
    crop = set_line_crop_AtlasViewerGUI(p2, p1, gridsize);
end

dx0 = p1(1)-p2(1);
dy0 = p1(2)-p2(2);
dz0 = p1(3)-p2(3);
dr = (dx0*dx0 + dy0*dy0 + dz0*dz0)^0.5;
if strcmp(mode, 'relative')
    crop = crop*dr;
    dx = crop*dx0/dr;
    dy = crop*dy0/dr;
    dz = crop*dz0/dr;
elseif strcmp(mode, 'absolute')
    crop = crop/dr;
    dx = crop*dx0;
    dy = crop*dy0;
    dz = crop*dz0;
elseif strcmp(mode, 'all')
    if crop > 1
        return;
    end    
    ii=1;
	step = crop;
    while (step*ii)<1
        crop = (step*ii)*dr;
        dx(ii) = crop*dx0/dr;
        dy(ii) = crop*dy0/dr;
        dz(ii) = crop*dz0/dr;
        ii=ii+1;
    end
end

for ii=1:length(dx)
    p3(ii,1) = p1(1)-dx(ii);
    p3(ii,2) = p1(2)-dy(ii);
    p3(ii,3) = p1(3)-dz(ii);
end


% ------------------------------------------------------------------------
function [gapRelative] = set_line_crop_AtlasViewerGUI(p1, p2, gridsize)
gapRelative = .05;

if isempty(p1) || isempty(p2) 
    return;
end

% Set desired absolute gap distance
gapAbsolute  = 1;
lineSize     = dist3(p1, p2);

% Get relative gap distance
gapRelative = gapAbsolute / lineSize;
% fprintf('Line gap: relative = %0.2f, absolute: %0.2f\n', gapRelative, gapAbsolute);

if gapRelative > .10
    gapRelative = .02;
end


    




% ---------------------------------------------------------
function [p3] = points_on_line_Homer3(p1, p2, step, mode)

%
% USAGE:
%   
%    p3 = points_on_line(p1,p2,step,mode)
%    p3 = points_on_line_Homer3(p1,p2,step,mode)
%
% DESCRIPTION:
%   
@@ -71,3 +219,4 @@ for ii=1:length(dx)
    p3(ii,3) = p1(3)-dz(ii);
end

+183 −9
Original line number Diff line number Diff line
function setGuiFonts(h, varargin)
function setGuiFonts(inp1, inp2)
ns = getNamespace();
if isempty(ns)
    return;
end
if strcmp(ns, 'AtlasViewerGUI')
    if nargin == 0
        setGuiFonts_AtlasViewerGUI();
    elseif nargin == 1
        setGuiFonts_AtlasViewerGUI(inp1);
    elseif nargin == 2
        setGuiFonts_AtlasViewerGUI(inp1, inp2);
    end
elseif strcmp(ns, 'Homer3')
    if nargin == 0
        setGuiFonts_Homer3();
    elseif nargin == 1
        setGuiFonts_Homer3(inp1);
    elseif nargin == 2
        setGuiFonts_Homer3(inp1, inp2);
    end
end


% ---------------------------------------------------------
function setGuiFonts_AtlasViewerGUI(h, varargin)

%
%   setGuiFonts(h, varargin)
%   setGuiFonts_AtlasViewerGUI(h, varargin)
%
%   handle 'userdata' data settings:
%
%    0 - AUTO_SETTING
%    1 - KEEP_AS_IS
%    2 - KEEP_FONTSIZE
%    4 - KEEP_FONTWEIGHT
%    8 - FONTSIZE_BIGGER
%   16 - TBD
%   32 - TBD


AUTO_SETTING    = 0;
KEEP_AS_IS      = 1;
KEEP_FONTSIZE   = 2;
KEEP_FONTWEIGHT = 4;
FONT_BIGGER     = 8;
FONT_SMALLER    = 16;

if ismac()
    fs_def = 13.0;
elseif ispc()
    fs_def = 10.0;
else
    fs_def = 11.0;
end

if nargin==0
    return;
end

if ~ishandles(h)
    return;
end

% Defaults for different graphics object types
font_uicontrol = initFont_AtlasViewerGUI(fs_def,'bold',[]);
if nargin==2
    font_uicontrol.size = varargin{1};
    font_uicontrol.weight = 'bold';
elseif nargin==3
    font_uicontrol.size = varargin{1};
    font_uicontrol.weight = varargin{2};
end

fc = [0.50, 0.21, 0.11];

font_uipanel   = initFont_AtlasViewerGUI(font_uicontrol.size-1,'bold',fc);
font_uibttngrp = font_uipanel;
font_axes      = initFont_AtlasViewerGUI(font_uicontrol.size+4,'normal',[]);
if ispc()
    font_listbox   = initFont_AtlasViewerGUI(font_uicontrol.size,'normal',[]);
elseif ismac()
    font_listbox   = initFont_AtlasViewerGUI(font_uicontrol.size+1,'normal',[]);
end


hc = get(h, 'children');
for ii=1:length(hc)
    
    if isempty(get(hc(ii),'userdata'))
        userdata = 0;
    else
        userdata = get(hc(ii),'userdata');
        if isstruct(userdata)
            userdata = 0;
        end
    end
    
    if userdata==KEEP_AS_IS
        continue;
    end
    
    if userdata==FONT_BIGGER
        set(hc(ii), 'fontsize',font_uipanel.size);
        set(hc(ii), 'fontweight',font_uipanel.weight);
    elseif strcmp(get(hc(ii), 'type'), 'uicontrol')
        if strcmp(get(hc(ii), 'style'), 'listbox')
            set(hc(ii), 'fontsize',font_listbox.size);
            set(hc(ii), 'fontweight','normal');        
        else
            if userdata==FONT_SMALLER
                set(hc(ii), 'fontsize',font_uicontrol.size-1);
            elseif userdata~=KEEP_FONTSIZE
                set(hc(ii), 'fontsize',font_uicontrol.size);
            end
            if userdata~=KEEP_FONTWEIGHT
                set(hc(ii), 'fontweight',font_uicontrol.weight);
            end
        end
    elseif strcmp(get(hc(ii), 'type'), 'axes')
        set(hc(ii), 'fontunits','points');
        if userdata~=KEEP_FONTSIZE
            set(hc(ii), 'fontsize',font_axes.size);
        end
        if userdata~=KEEP_FONTWEIGHT
            set(hc(ii), 'fontweight',font_axes.weight);
        end
    elseif strcmp(get(hc(ii), 'type'), 'uipanel')
        if userdata~=KEEP_FONTSIZE
            set(hc(ii), 'fontsize',font_uipanel.size);
        end
        if userdata~=KEEP_FONTWEIGHT
            set(hc(ii), 'fontweight',font_uipanel.weight);
        end
        set(hc(ii), 'foregroundcolor',font_uipanel.color);
    elseif strcmp(get(hc(ii), 'type'), 'uibuttongroup')
        if userdata~=KEEP_FONTSIZE
            set(hc(ii), 'fontsize',font_uibttngrp.size);            
        end
        if userdata~=KEEP_FONTWEIGHT
            set(hc(ii), 'fontweight',font_uibttngrp.weight);
        end
        set(hc(ii), 'foregroundcolor',font_uibttngrp.color);
    elseif strcmp(get(hc(ii), 'type'), 'uitable')
        if userdata~=KEEP_FONTSIZE
            set(hc(ii), 'fontsize',font_uicontrol.size);
        end
        if userdata~=KEEP_FONTWEIGHT
            set(hc(ii), 'fontweight',font_uicontrol.weight);
        end
    elseif strcmp(get(hc(ii), 'type'), 'uilistbox')
        if userdata~=KEEP_FONTSIZE
            set(hc(ii), 'fontsize',font_listbox.size);
        end
        set(hc(ii), 'fontweight','normal');
    end
    setGuiFonts_AtlasViewerGUI(hc(ii), font_uicontrol.size, font_uicontrol.weight);
end



% --------------------------------------------------------
function [font] = initFont_AtlasViewerGUI(fs, fw, fc)
if ~exist('fc','var') || isempty(fc)
    fc = [0, 0, 0];
end
font = struct('size',fs,'weight',fw, 'color',fc);





% ---------------------------------------------------------
function setGuiFonts_Homer3(h, varargin)

%
%   setGuiFonts_Homer3(h, varargin)
%
%   handle 'userdata' data settings:
%
@@ -38,7 +211,7 @@ if ~ishandles(h)
end

% Defaults for different graphics object types
font_uicontrol = initFont(fs_def,'bold',[]);
font_uicontrol = initFont_Homer3(fs_def,'bold',[]);
if nargin==2
    font_uicontrol.size = varargin{1};
    font_uicontrol.weight = 'bold';
@@ -49,13 +222,13 @@ end

fc = [0.50, 0.21, 0.11];

font_uipanel   = initFont(font_uicontrol.size-1,'bold',fc);
font_uipanel   = initFont_Homer3(font_uicontrol.size-1,'bold',fc);
font_uibttngrp = font_uipanel;
font_axes      = initFont(font_uicontrol.size+4,'normal',[]);
font_axes      = initFont_Homer3(font_uicontrol.size+4,'normal',[]);
if ispc()
    font_listbox = initFont(font_uicontrol.size,'normal',[]);
    font_listbox = initFont_Homer3(font_uicontrol.size,'normal',[]);
elseif ismac() || isunix()
    font_listbox = initFont(font_uicontrol.size+1,'normal',[]);
    font_listbox = initFont_Homer3(font_uicontrol.size+1,'normal',[]);
end


@@ -129,16 +302,17 @@ for ii=1:length(hc)
        end
        set(hc(ii), 'fontweight','normal');
    end
    setGuiFonts(hc(ii), font_uicontrol.size, font_uicontrol.weight);
    setGuiFonts_Homer3(hc(ii), font_uicontrol.size, font_uicontrol.weight);
end



% --------------------------------------------------------
function font = initFont(fs, fw, fc)
function [font] = initFont_Homer3(fs, fw, fc)
if ~exist('fc','var') || isempty(fc)
    fc = [0, 0, 0];
end
font = struct('size',fs,'weight',fw, 'color',fc);


Loading