-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathorig_structural_plotter.m
178 lines (131 loc) · 5.2 KB
/
orig_structural_plotter.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
function orig_structural_plotter(nodes, restraints, forces, elements)
%%%
%%% commento da rivedere
%%%
%%% Plot a structural system composed of "nodes", "restraints" (if res = 1)
%%% labels near the node (if "label" = 1 and there is not a restrain),
%%% forces in kN (if "forc" = 1) and beams (according to "conn" connectivity
%%% matrix. It also uses magnification factors (separatelly for x and y directions.
%%% As "colour" it needs a rgb vector.
%%%
%%% This funcion needs "restraints_draw" and "forces_drawer" functions.
%%%
%% First parameters
% Colours of the structures
orig_col= [0 0 0];
% Magnification factors
x_max = max(nodes(:,2));
y_max = max(nodes(:,3));
x_min = min(nodes(:,2));
y_min = min(nodes(:,3));
magn_fact_x = (x_max+x_min)/20;
magn_fact_y = (y_max+y_min)/10;
%% Figure
% Full screen windows
fig = figure('units','normalized','outerposition',[0 0 1 1],'Color',[1 1 1],'Visible','off');
hold on
%% Option panel
p = uipanel(fig,'Title','Plot options','Position',[.1 .1 .1 .15]);
% Save button
ok_push = uicontrol(fig,'Style','pushbutton',...
'String','Proceed','Callback',@doitpushbutton_Callback,'Units','normalized', 'Position', [.21 .1 .08 .04]);
calculating = uicontrol(fig,'Style','text',...
'String',"Let's do it!",'Units','normalized', 'Position', [.2 .05 .1 .04],'Visible','off');
% Check boxes
elem_label = uicontrol(p,'Style','checkbox','Value',1,...
'String','Elements n.','Callback',@elemlabel_Callback,'Units','normalized', 'Position', [.2 .75 .8 .25]);
node_label = uicontrol(p,'Style','checkbox','Value',1,...
'String','Nodes n.','Callback',@nodelabel_Callback,'Units','normalized', 'Position', [.2 .5 .8 .25]);
% section_label = uicontrol(p,'Style','checkbox','Value',1,...
% 'String','Section type','Callback',@sectionlabel_Callback,'Units','normalized', 'Position', [.2 .25 .8 .25]);
%% Non deformed shape
% Non-deformed beams
for i = 1:size(elements,1)
eval('orig_beam_%i',i) = plot([nodes(elements(i,2),2) nodes(elements(i,3),2)],...
[nodes(elements(i,2),3) nodes(elements(i,3),3)], 'Color', orig_col);
end
clear i
% Restraints
for i = 1:size(restraints,1)
% Hinge
if restraints(i,2) == 1 && restraints(i,3) == 1
restrain_type = 2;
% Roller
elseif restraints(i,2) == 1 || restraints(i,3) == 1
restrain_type = 1;
end
restraints_drawer(nodes(restraints(i,1),2),nodes(restraints(i,1),3),...
magn_fact_x,magn_fact_y,restrain_type,orig_col);
end
clear i
% Non-deformed nodes
for i = 1:size(nodes,1)
eval('orig_nodes_%i',i) = scatter(nodes(i,2),nodes(i,3),[], orig_col,...
'HandleVisibility','off','MarkerFaceColor',[1 1 1]);
end
clear i
% Forces
magn = (magn_fact_x+magn_fact_y)/2;
for i=1:size(forces,1)
forces_drawer(nodes, forces(i,:), magn, orig_col)
end
clear i
%% Labels
% Labels near the elements
x = zeros(size(elements,1),1);
y = zeros(size(elements,1),1);
for i = 1:size(elements,1)
x(i) = (nodes(find(nodes(:,1) == elements(i,2),1),2) + nodes(find(nodes(:,1) == elements(i,3),1),2))/2 + magn_fact_x*sin(elements(i,5));
y(i) = (nodes(find(nodes(:,1) == elements(i,2),1),3) + nodes(find(nodes(:,1) == elements(i,3),1),3))/2 + magn_fact_y*cos(elements(i,5))/2;
end
t_elem_labels = text(x,y,num2str(elements(:,1)), 'HandleVisibility', 'off','Visible','on');
%t_section_labels = text(x,y,num2str(elements(:,7)), 'HandleVisibility', 'off','Visible','on');
% Labels near the nodes
node_labels = num2str(nodes(:,1));
t_node_labels = text(nodes(:,2)+magn_fact_x/2,nodes(:,3)+ magn_fact_y/2,node_labels, 'HandleVisibility', 'off');
% Magnification factor
str = sprintf("This is not the output, click 'Proceed' to run the code!");
title(str)
set(get(gca,'title'),'Position',[(x_max+x_min)/2 y_min-7*magn_fact_y], 'FontSize',11,'Color',[1 .1 0])
%% Plot dimentions
% ricontrollare
ylim([y_min-10*magn_fact_y y_max+5*magn_fact_y])
xlim([x_min-4*magn_fact_x x_max+4*magn_fact_x])
% Other parameters
axis off
fig.Visible = 'on';
%% Figure options
% Checkbox element labels
function elemlabel_Callback(hObject, eventdata, handles)
if (get(hObject,'Value') == get(hObject,'Max'))
set(t_elem_labels,'Visible','on');
else
set(t_elem_labels, 'Visible','off');
end
end
% Checkbox node labels
function nodelabel_Callback(hObject, eventdata, handles)
if (get(hObject,'Value') == get(hObject,'Max'))
set(t_node_labels,'Visible','on')
else
set(t_node_labels,'Visible','off');
end
end
% Checkbox section labels
%function sectionlabel_Callback(hObject, eventdata, handles)
% if (get(hObject,'Value') == get(hObject,'Max'))
% set(t_section_labels,'Visible','on')
% else
% set(t_section_labels,'Visible','off');
% end
%end
% Push button to proceed the calculation
push_counter = 1;
function doitpushbutton_Callback(hObject,eventdata,handles)
% Preparation to save
set(p,'Visible','off')
set(calculating,'Visible','on')
pause(0.6)
close(fig)
end
end