Skip to content

Commit

Permalink
more thorough graphics debug routine
Browse files Browse the repository at this point in the history
  • Loading branch information
RR-N committed Nov 21, 2024
1 parent 811cc76 commit 7c79f76
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 9 deletions.
19 changes: 19 additions & 0 deletions +Program/+Helpers/save_and_open.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function path = save_and_open(filename, input)

if isstruct(input)
save(filename, '-struct', 'input');

else
save(filename, 'input');

end

[path, ~, ~] = fileparts(which(filename));

if ispc
winopen(path);
else
unix(path)
end
end

20 changes: 20 additions & 0 deletions +Program/+Routines/+Debug/graphics.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function debug_struct = graphics(save_flag)
graphics_keys = {'ScreenPixelsPerInch', 'MonitorPositions', 'FixedWidthFontName', 'Units'};

for n=1:length(graphics_keys)
key = graphics_keys{n};
value = get(0, key);
if exist('debug_struct', 'var')
debug_struct.(key) = {value};

else
debug_struct = struct(key, {value});

end
end

if nargin > 0
Program.Helpers.save_and_open(fullfile('debug', 'graphics_debug.mat'), debug_struct);
end
end

14 changes: 5 additions & 9 deletions +Program/+Routines/+Debug/rotation.m
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
function rotation()
function debug_struct = rotation(save_flag)
app = Program.GUIHandling.app;
rotation_stack = app.rotation_stack;
rotation_stack.screencap = {Program.Helpers.screenshot()};
save('rotation_debug.mat', '-struct', 'rotation_stack');
[path, ~, ~] = fileparts(which('rotation_debug.mat'));
debug_struct = app.rotation_stack;
debug_struct.screencap = {Program.Helpers.screenshot()};

if ispc
winopen(path);
else
unix(path)
if nargin > 0
Program.Helpers.save_and_open(fullfile('debug', 'rotation_debug.mat'), debug_struct);
end
end

0 comments on commit 7c79f76

Please sign in to comment.