Files
miSim/@miSim/updatePlots.m

50 lines
1.9 KiB
Matlab

function [obj] = updatePlots(obj, updatePartitions)
arguments (Input)
obj (1, 1) {mustBeA(obj, 'miSim')};
updatePartitions (1, 1) logical = false;
end
arguments (Output)
obj (1, 1) {mustBeA(obj, 'miSim')};
end
% Update agent positions, collision geometries
for ii = 1:size(obj.agents, 1)
obj.agents{ii}.updatePlots();
end
% The remaining updates might be possible to do in a clever way
% that moves existing lines instead of clearing and
% re-plotting, which is much better for performance boost
% Update agent connections plot
delete(obj.connectionsPlot);
obj = obj.plotConnections();
% Update network graph plot
delete(obj.graphPlot);
obj = obj.plotGraph();
% Update partitioning plot
if updatePartitions
delete(obj.partitionPlot);
obj = obj.plotPartitions();
end
% reset plot limits to fit domain
for ii = 1:size(obj.spatialPlotIndices, 2)
xlim(obj.f.Children(1).Children(obj.spatialPlotIndices(ii)), [obj.domain.minCorner(1), obj.domain.maxCorner(1)]);
ylim(obj.f.Children(1).Children(obj.spatialPlotIndices(ii)), [obj.domain.minCorner(2), obj.domain.maxCorner(2)]);
zlim(obj.f.Children(1).Children(obj.spatialPlotIndices(ii)), [obj.domain.minCorner(3), obj.domain.maxCorner(3)]);
end
drawnow;
% Update performance plot
% Re-normalize performance plot
normalizingFactor = 1/max(obj.performance(end));
obj.performancePlot(1).YData(1:length(obj.performance)) = obj.performance * normalizingFactor;
obj.performancePlot(1).XData(find(isnan(obj.performancePlot(1).XData), 1, 'first')) = obj.t;
for ii = 2:(size(obj.agents, 1) + 1)
obj.performancePlot(ii).YData(1:length(obj.performance)) = obj.agents{ii - 1}.performance * normalizingFactor;
obj.performancePlot(ii).XData(find(isnan(obj.performancePlot(ii).XData), 1, 'first')) = obj.t;
end
end