-
Notifications
You must be signed in to change notification settings - Fork 3
/
RebarTool.m
480 lines (414 loc) · 17.3 KB
/
RebarTool.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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
function varargout = RebarTool(varargin)
% REBARTOOL MATLAB code for RebarTool.fig
% REBARTOOL, by itself, creates a new REBARTOOL or raises the existing
% singleton*.
%
% H = REBARTOOL returns the handle to a new REBARTOOL or the handle to
% the existing singleton*.
%
% REBARTOOL('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in REBARTOOL.M with the given input arguments.
%
% REBARTOOL('Property','Value',...) creates a new REBARTOOL or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before RebarTool_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to RebarTool_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help RebarTool
% Last Modified by GUIDE v2.5 20-Dec-2015 06:31:16
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @RebarTool_OpeningFcn, ...
'gui_OutputFcn', @RebarTool_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before RebarTool is made visible.
function RebarTool_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to RebarTool (see VARARGIN)
% Choose default command line output for RebarTool
handles.output = hObject;
hObject.CloseRequestFcn = @close;
% precnici sipki
handles.ds = [12 14 16 18 19 20 22 25 26 28 30 32 36];
% Update handles structure
guidata(hObject, handles);
% provjera da li je proslijedjen CrossSection objekat zajedno sa ostalim
% handles-ima
if nargin>=4
% preuzimanje potrebnih referenci za objekte
ConcreteToolHandles = varargin{1};
% crossSection handle
handles.crossSection = ConcreteToolHandles.crossSection;
% As_uitable handle iz ConcreteTool prozora
handles.As_uitable = ConcreteToolHandles.As_uitable;
% section_axes iz ConcreteTool prozora
handles.section1_axes = ConcreteToolHandles.section_axes;
% Update handles structure
guidata(hObject, handles);
% popunjavanje tabele rebar_uitable
% table handle
cs = handles.crossSection;
% podrzane dimenzije sipki armature
ds = handles.ds; % [12 14 16 19 20 22 25 28 32 36]
table = handles.rebar_uitable;
table.Position = [380 402 300 204]; % h=18.6*(length(ds)+1)
% podesavanje da su nazivi po redovima precnici armature
set(table, 'RowName', ds);
tableData = zeros(length(ds), 4);
% definise N/red i As kolone
zone = 1; % prvo otvaramo zategnutu zonu
tableData(:,1) = [cs.RPR(ds, zone)]'; % N/red
tableData(:,2) = [ds.^2*pi/4]'; % As
% Potrebna kolicina zategnute armature za Med i Ted
vt = cs.vt;
As1_req = cs.As1_req+vt.Asl/vt.uk*vt.bk; % str2double(handles.As1_edit.String)
% potreban broj sipki
tableData(:,3) = ceil(As1_req./tableData(:,2));
% As_uk
tableData(:,4) = tableData(:,2).*tableData(:,3);
table.Data = tableData;
% formatiranje kolona (numeric za cijele brojeve, bank za 2 decimale)
set(table, 'ColumnFormat',{'numeric', 'bank', 'numeric', 'bank'});
% unos podataka u As1_uitable
% potrebna kolicina poduzne armature u pritisnutoj zoni:
As2_req = max([cs.As2_req vt.Asl/vt.uk*vt.bk]);
% potrebna kolicina konturne armature za Ted
As3_req = vt.Asl/vt.uk*vt.hk*2;
table = handles.As1_uitable;
tableData = zeros(3, 3);
tableData(1, :) = [As1_req As2_req As3_req];
tableData(2, :) = [cs.As1 cs.As2 cs.As3];
tableData(3, :) = tableData(1, :) - tableData(2, :);
table.Data = tableData;
table.RowName = {'Potrebno', 'Ugradjeno', 'Nedostaje'};
table.ColumnName = {'Zat.', 'Prit.', 'Kont.'};
table.ColumnFormat = {'bank', 'bank', 'bank'};
% fino podesavanje dimenzija tabele za As
table.Position(3:4) = [285 76]; %253 76
%handles.As1_req_edit.String = num2str(cs.As1_req,'%.2f');
% setup dsmax_popup
zone = 1;
index = find(ds==cs.ds_max(zone),1);
handles.dsmax_popup.String = ds;
handles.dsmax_popup.Value = index;
% setup ds_popup
setDsPopup(handles);
% prikaz presjeka
ax = handles.section_axes;
cs.plotSection(ax);
% Ogranicava prikaz na zategnutu zonu presjeka
ax.XLim = [0.5*cs.dims.h cs.dims.h];
ax.YLim = [(cs.dims.bf-cs.dims.bw)/2 (cs.dims.bf-cs.dims.bw)/2+cs.dims.bw];
% prikaz pomocnih linija
cs.plotGrid(ax, zone);
% prikaz sipki armature
cs.drawRebar(ax);
% dodaje right click funkcionalnost nacrtanim objektima, da bi se
% ranije nacrtane sipke mogle brisati (nakon ponovnog otvaranja
% RebarTool prozora)
rebars = findobj(ax, 'Type', 'rectangle');
for i = 1:numel(rebars)
set(rebars(i), 'ButtonDownFcn', {@RebarOnClick, handles});
end
else
disp('Nije definisan poprecni presjek');
end
function close(obj, eventdata, handles)
delete(obj);
% podesava popup meni za odabir sipke za ugradnju
function setDsPopup(handles)
% setup ds_popup
cs = handles.crossSection;
zone = handles.zone_popup.Value;
if zone == 3
handles.dsmax_popup.Enable = 'off';
handles.ds_popup.String = handles.ds(1:end);
else
handles.dsmax_popup.Enable = 'on';
index = find(handles.ds==cs.ds_max(zone), 1);
handles.dsmax_popup.Value = index;
ds = handles.dsmax_popup.String;
handles.ds_popup.String = handles.ds(1:index);
handles.ds_popup.Value = index;
end
% --- Outputs from this function are returned to the command line.
function varargout = RebarTool_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
keyboard
% --- Executes on selection change in dsmax_popup.
function dsmax_popup_Callback(hObject, eventdata, handles)
% hObject handle to dsmax_popup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns dsmax_popup contents as cell array
% contents{get(hObject,'Value')} returns selected item from dsmax_popup
cs = handles.crossSection;
zone = handles.zone_popup.Value;
index = handles.dsmax_popup.Value;
cs.ds_max(zone) = str2double(handles.dsmax_popup.String(index,:));
% podesava popup meni za odabir sipke za ugradnju
setDsPopup(handles);
reset_pushbutton_Callback(0, 0, handles);
% --- Executes during object creation, after setting all properties.
function dsmax_popup_CreateFcn(hObject, eventdata, handles)
% hObject handle to dsmax_popup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function As1_req_edit_Callback(hObject, eventdata, handles)
% hObject handle to As1_req_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of As1_req_edit as text
% str2double(get(hObject,'String')) returns contents of As1_req_edit as a double
% --- Executes during object creation, after setting all properties.
function As1_req_edit_CreateFcn(hObject, eventdata, handles)
% hObject handle to As1_req_edit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on selection change in ds_popup.
function ds_popup_Callback(hObject, eventdata, handles)
% hObject handle to ds_popup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns ds_popup contents as cell array
% contents{get(hObject,'Value')} returns selected item from ds_popup
% --- Executes during object creation, after setting all properties.
function ds_popup_CreateFcn(hObject, eventdata, handles)
% hObject handle to ds_popup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes on mouse press over axes background.
function section_axes_ButtonDownFcn(ax, eventdata, handles)
% hObject handle to section_axes (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
fig = handles.RebarTool_figure;
% left click action
if strcmp(fig.SelectionType, 'normal')
cs = handles.crossSection;
% ocitava index odabrane vrijednosti ds
index = handles.ds_popup.Value;
% na osnovu ocitanog index-a, cita vrijednost i pretvara je u broj
ds = str2double(handles.ds_popup.String(index,:));
% ocitava koordinate misa u ax koord. sistemu
cp = ax.CurrentPoint;
mouseX = cp(1,1);
mouseY = cp(1,2);
zone = handles.zone_popup.Value;
% dodaje sipku armature na odgovarajuci polozaj u presjeku
% rectangle object koji predstavlja sipku
rebar = cs.addRebar(ax, ds, mouseX, mouseY, zone);
set(rebar, 'ButtonDownFcn', {@RebarOnClick, handles});
updateView(handles);
end
function updateView(handles)
% As_uitable iz ConcreteTool prozora
As_uitable = handles.As_uitable;
% As_uitable iz ovog prozora
As1_uitable = handles.As1_uitable;
% CrossSection objekat
cs = handles.crossSection;
% azurira As_uitable tabelu u ConcreteTool prozoru (As1 usvojeno)
As_uitable.Data(2) = cs.As1;
As_uitable.Data(4) = cs.As2;
% azurira As1_uitable u ovom prozoru
As1_uitable.Data(2:3,1) = [cs.As1 As1_uitable.Data(1)-cs.As1]';
As1_uitable.Data(2:3,2) = [cs.As2 As1_uitable.Data(4)-cs.As2]';
% treca kolona - konturna armatura
As1_uitable.Data(2:3,3) = [cs.As3 As1_uitable.Data(7)-cs.As3]';
% azuriranje crteza armature u ConcreteTool prozoru
% ponovo crta sipke armature u PRVOM ConcreteTool prozoru
cs.drawRebar(handles.section1_axes);
% ponovo crta sipke armature u RebarTool prozoru
ax = handles.section_axes;
zone = handles.zone_popup.Value;
cs.plotGrid(ax, zone);
cs.drawRebar(ax)
% dodaje right click funkcionalnost nacrtanim objektima, da bi se
% ranije nacrtane sipke mogle brisati (nakon ponovnog otvaranja
% RebarTool prozora)
rebars = findobj(ax, 'Type', 'rectangle');
for i = 1:numel(rebars)
set(rebars(i), 'ButtonDownFcn', {@RebarOnClick, handles});
end
% azuriranje rebar tabele
table = handles.rebar_uitable;
tableData = table.Data;
% Nedostaje As
if zone == 1
As1_req = As1_uitable.Data(3,1);
elseif zone == 2
As1_req = As1_uitable.Data(3,2);
else
As1_req = As1_uitable.Data(3,3);
end
if As1_req < 0
As1_req = 0;
end
% potreban broj sipki
tableData(:,3) = ceil(As1_req./tableData(:,2));
% As_uk
tableData(:,4) = tableData(:,2).*tableData(:,3);
table.Data = tableData;
function RebarOnClick(rect, ~, handles)
fig = handles.RebarTool_figure;
cs = handles.crossSection;
seltype = fig.SelectionType;
% provjera da li je napravljen desni klik
if strcmp(seltype,'alt')
row = rect.UserData(1);
column = rect.UserData(2);
zone = rect.UserData(3);
% ukloni Rebar objekat iz section.Rebars niza
rebar = findobj(cs.Rebars, 'row', row, 'column', column, 'zone', zone);
cs.Rebars(cs.Rebars == rebar) = [];
% ukoliko je prikazan, obrisi rebar tag (balon koji prikazuje precnik
% armature)
tag = findobj(handles.section_axes, 'Tag', 'rebarTag');
delete(tag);
% ukloni rectangle i Rebar objekte koji su predstavljali tu sipku
delete(rect);
delete(rebar);
% azuriraj prikaz
updateView(handles);
end
% --- Executes on button press in reset_pushbutton.
function reset_pushbutton_Callback(hObject, eventdata, handles)
% hObject handle to reset_pushbutton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cs = handles.crossSection;
zone = handles.zone_popup.Value;
rebars = findobj(cs.Rebars, 'zone', zone);
% uklanja sipke iz odgovarajuce zone
for i = 1:numel(rebars)
cs.Rebars(cs.Rebars == rebars(i)) = [];
end
% ponovo iscrtava sve sipke
updateView(handles);
% --- Executes on selection change in zone_popup.
function zone_popup_Callback(hObject, eventdata, handles)
% hObject handle to zone_popup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = cellstr(get(hObject,'String')) returns zone_popup contents as cell array
% contents{get(hObject,'Value')} returns selected item from zone_popup
updateView(handles);
cs = handles.crossSection;
zone = handles.zone_popup.Value;
setDsPopup(handles);
ax = handles.section_axes;
if zone == 1
ax.XLim = [0.5*cs.dims.h cs.dims.h];
ax.YLim = [(cs.dims.bf-cs.dims.bw)/2 (cs.dims.bf-cs.dims.bw)/2+cs.dims.bw];
elseif zone == 2
ax.XLim = [0 0.5*cs.dims.h];
ax.YLim = [0 cs.dims.bf];
else
ax.XLim = [0 cs.dims.h];
ax.YLim = [0 cs.dims.bf];
end
% --- Executes during object creation, after setting all properties.
function zone_popup_CreateFcn(hObject, eventdata, handles)
% hObject handle to zone_popup (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
% --- Executes during object creation, after setting all properties.
function rebar_uitable_CreateFcn(hObject, eventdata, handles)
% hObject handle to rebar_uitable (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% --- Executes on scroll wheel click while the figure is in focus.
function RebarTool_figure_WindowScrollWheelFcn(hObject, eventdata, handles)
% hObject handle to RebarTool_figure (see GCBO)
% eventdata structure with the following fields (see MATLAB.UI.FIGURE)
% VerticalScrollCount: signed integer indicating direction and number of clicks
% VerticalScrollAmount: number of lines scrolled for each click
% handles structure with handles and user data (see GUIDATA)
% podesavanje precnika armature pomocu tockica na misu
ds_popup = handles.ds_popup;
if eventdata.VerticalScrollCount > 0
if ds_popup.Value < size(ds_popup.String, 1)
ds_popup.Value = ds_popup.Value + 1;
end
else
if ds_popup.Value > 1
ds_popup.Value = ds_popup.Value - 1;
end
end
% --- Executes on mouse motion over figure - except title and menu.
function RebarTool_figure_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject handle to RebarTool_figure (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
ax = handles.section_axes;
% provjerava da li je ucitan CrossSection objekat
% i prekida izvrsavanje funkcije ako nije
if isfield(handles, 'crossSection')
cs = handles.crossSection;
else
return;
end
% provjerava da li se mis nalazi iznad neke od sipki
% i prikazuje precnik sipke u popup prozoru
cp = ax.CurrentPoint;
tags = findobj(ax, 'Tag', 'rebarTag');
if ~isempty(tags)
delete(tags);
end
for i = 1:numel(cs.Rebars)
rebar = cs.Rebars(i);
if rebar.mouseOver(cp)
rebar.showTag(ax, cp);
end
end