-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtoggleVectorLineamentsVisibility.m
More file actions
55 lines (48 loc) · 1.91 KB
/
toggleVectorLineamentsVisibility.m
File metadata and controls
55 lines (48 loc) · 1.91 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
function toggleVectorLineamentsVisibility(checkbox_handle, iter_idx)
%toggleVectorLineamentsVisibility - Toggle vector lineament visibility for a specific tab
%
% This function finds all vector lineament lines in the specified axes and
% toggles their visibility based on the checkbox state.
%
% Inputs:
% checkbox_handle (uicontrol handle): The checkbox control (contains axes and line handles in UserData)
% iter_idx (integer): The iteration index (for tag matching)
% Get UserData from checkbox
user_data = get(checkbox_handle, 'UserData');
if isempty(user_data) || ~isfield(user_data, 'ax') || ~isfield(user_data, 'handles')
% Fallback: find axes in the checkbox's parent (tab)
parent = get(checkbox_handle, 'Parent');
ax = findobj(parent, 'Type', 'axes');
if isempty(ax)
return; % Can't find axes, exit
end
ax = ax(1); % Take first axes if multiple found
% Try to find vector lineament lines by tag
all_children = get(ax, 'Children');
vector_lines = [];
for i = 1:length(all_children)
if isprop(all_children(i), 'Tag')
tag = get(all_children(i), 'Tag');
if ~isempty(tag) && contains(tag, ['VectorLineament_', num2str(iter_idx)])
vector_lines = [vector_lines; all_children(i)];
end
end
end
if isempty(vector_lines)
return; % Can't find vector lineaments, exit
end
else
ax = user_data.ax;
vector_lines = user_data.handles;
end
% Get checkbox value
show_vectors = get(checkbox_handle, 'Value');
% Toggle visibility
if ~isempty(vector_lines)
if show_vectors
set(vector_lines, 'Visible', 'on');
else
set(vector_lines, 'Visible', 'off');
end
end
end