-
Notifications
You must be signed in to change notification settings - Fork 176
/
matRadGUI.m
101 lines (80 loc) · 2.6 KB
/
matRadGUI.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
function hGUI = matRadGUI(varargin)
% matRad compatability function to call the matRad_MainGUI
% The function checks input parameters and handles the GUI as a
% singleton, so following calls will not create new windows
%
% call
% hGUI = matRadGUI
% matRadGUI
%
% References
% -
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Copyright 2015 the matRad development team.
%
% This file is part of the matRad project. It is subject to the license
% terms in the LICENSE file found in the top-level directory of this
% distribution and at https://github.com/e0404/matRad/LICENSE.md. No part
% of the matRad project, including this file, may be copied, modified,
% propagated, or distributed except according to the terms contained in the
% LICENSE file.
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
persistent hMatRadGUI;
p = inputParser;
addParameter(p,'devMode',false,@(x) validateModeValue(x));
addParameter(p,'eduMode',false,@(x) validateModeValue(x));
p.KeepUnmatched = true; %No error with incorrect parameters
parse(p,varargin{:});
parsedInput = p.Results;
if ischar(parsedInput.devMode) || isstring(parsedInput.devMode)
parsedInput.devMode = str2double(parsedInput.devMode);
end
if ischar(parsedInput.eduMode) || isstring(parsedInput.eduMode)
parsedInput.eduMode = str2double(parsedInput.eduMode);
end
matRad_cfg = matRad_rc;
%If devMode is true, error dialogs will include the full stack trace of the error
%If false, only the basic error message is shown (works for errors that
%handle the MException object)
matRad_cfg.devMode = logical(parsedInput.devMode);
if matRad_cfg.devMode
disp('matRadGUI starting in developer mode!');
end
%Enables simple educational mode which removes certain functionality from
%the GUI
matRad_cfg.eduMode = logical(parsedInput.eduMode);
if matRad_cfg.eduMode
disp('matRadGUI starting in educational mode!');
end
if matRad_cfg.disableGUI
matRad_cfg.dispInfo('matRad GUI disabled in matRad_cfg!\n');
return;
end
handleValid = true;
try
handleValid = ishandle(hMatRadGUI.guiHandle);
catch
handleValid = false;
end
if handleValid
figure(hMatRadGUI.guiHandle);
hMatRadGUI.update();
else
matRad_rc(false);
hMatRadGUI = matRad_MainGUI;
end
if nargout > 0
hGUI = hMatRadGUI;
end
end
%Validates the attributes for the command line Modes
function validateModeValue(x)
%When passed from OS terminal (or inline in Command Window) everything is a string
if isdeployed || ischar(x) || isstring(x)
x=str2double(x);
end
validateattributes(x,{'logical','numeric'},{'scalar','binary'});
end