-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNCAView.m
More file actions
111 lines (86 loc) · 3.41 KB
/
Copy pathNCAView.m
File metadata and controls
111 lines (86 loc) · 3.41 KB
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
102
103
104
105
106
107
108
109
110
classdef NCAView < handle
properties ( Access = private )
NCApanel
GridLayout
Model
end
properties ( Hidden )
% Leave these properties Hidden but public to enable access for any test generated
% with Copilot during workshop
NCAtable
end
properties ( Access = public )
FontName (1,1) string = "Helvetica"
NCAoptions % options for NCA calculations
end
properties (SetObservable)
ConcentrationColumnName (1,1) string = "Complex"
BackgroundColor (1,3) double {mustBeBetween(BackgroundColor,0,1)} = [1,1,1]
end
properties( Access = private )
DataListener % listener
end
methods
function obj = NCAView(parent, model, responseName)
arguments
parent
model (1,1) SimulationModel
responseName (1,1) string = "Complex"
end
% Create Panel
ncapanel = uipanel(parent);
ncapanel.BackgroundColor = obj.BackgroundColor;
ncapanel.FontName = obj.FontName;
ncapanel.BorderType = 'none';
% Create GridLayout
gl = uigridlayout(ncapanel);
gl.ColumnWidth = {'1x'};
gl.RowHeight = {'1x'};
gl.Padding = [0 0 0 0];
gl.BackgroundColor = obj.BackgroundColor;
% Create NCAtable
ncat = uitable(gl);
% Save NCA options
opt = sbioncaoptions;
opt.concentrationColumnName = responseName;
opt.timeColumnName = 'Time';
opt.IVDoseColumnName = 'Dose';
% Save objects
obj.NCAoptions = opt;
obj.NCApanel = ncapanel;
obj.GridLayout = gl;
obj.NCAtable = ncat;
obj.Model = model;
obj.ConcentrationColumnName = responseName;
% Update Panel title
updateTitle(obj);
% Instantiate listener for model
obj.DataListener = event.listener( model, 'DataChanged', ...
@obj.update );
% Instantiate listeners for properties
addlistener(obj,'ConcentrationColumnName','PostSet',@obj.setColumnName);
addlistener(obj,'BackgroundColor','PostSet',@obj.setColor);
end % constructor
end % public methods
methods ( Access = private )
function update(obj,srcModel,~)
% compute NCA parameters and display them in table
ncaParameters = sbionca(srcModel.SimDataTable, obj.NCAoptions);
obj.NCAtable.ColumnName = ncaParameters.Properties.VariableNames(2:end);
obj.NCAtable.Data = ncaParameters(:,2:end);
end % update
function setColor(obj,~,~)
obj.NCApanel.BackgroundColor = obj.BackgroundColor;
obj.GridLayout.BackgroundColor = obj.BackgroundColor;
end % setColor
function setColumnName(obj,~,~)
obj.NCAoptions.concentrationColumnName = obj.ConcentrationColumnName;
update(obj,obj.Model,[]);
updateTitle(obj)
end % setColumnName
function updateTitle(obj)
obj.NCApanel.Title = "NCA parameters for species '" + ...
obj.ConcentrationColumnName + "'";
end % updateTitle
end % private method
end % class