-
Notifications
You must be signed in to change notification settings - Fork 0
/
NC.m
781 lines (595 loc) · 31 KB
/
NC.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
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
function varargout = NC(varargin)
% NC MATLAB code for NC.fig
% NC, by itself, creates a new NC or raises the existing
% singleton*.
%
% H = NC returns the handle to a new NC or the handle to
% the existing singleton*.
%
% NC('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in NC.M with the given input arguments.
%
% NC('Property','Value',...) creates a new NC or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before NC_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to NC_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 NC
% Last Modified by GUIDE v2.5 30-May-2024 20:18:08
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @NC_OpeningFcn, ...
'gui_OutputFcn', @NC_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 NC is made visible.
function NC_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 NC (see VARARGIN)
% Choose default command line output for NC
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
deep = 0;
speed = 0;
fast = 0;
assignin('base', 'deep', deep);
assignin('base', 'fast', fast);
assignin('base', 'speed', speed);
% UIWAIT makes NC wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = NC_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)
set(handles.uipanel1,'visible','on')
set(handles.uipanel2,'visible','off')
set(handles.uipanel3,'visible','off')
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.uipanel2,'visible','on')
set(handles.uipanel3,'visible','off')
% --- Executes on button press in pushbutton8.
function pushbutton8_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.uipanel2,'visible','on')
set(handles.uipanel3,'visible','on')
% --- Executes on button press in importbotton.
function importbotton_Callback(hObject, eventdata, handles)
% hObject handle to importbotton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% 获取用户选择的文件
[filename, pathname] = uigetfile('*.dxf', '选择DXF文件');
if isequal(filename, 0) || isequal(pathname, 0)
% 用户取消选择
return;
end
fullFilePath = fullfile(pathname, filename);
dxf = DXFtool(fullFilePath);
handles.dxf = dxf;
assignin('base', 'dxf',dxf);
handles.filename = filename;
handles.pathname = pathname;
guidata(hObject, handles); % 更新 handles 结构体
% 显示选择的文件名
set(handles.filenametextbox, 'String', filename);
% --- Executes on button press in generationcodebotton.
function generationcodebotton_Callback(hObject, eventdata, handles)
% hObject handle to generationcodebotton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
speed = evalin('base', 'speed');
fast = evalin('base', 'fast');
%设置变量通过静态文本框是否有内容判断是否已经读入dxf文件
filenamejudge = get(handles.filenametextbox,'String');
%判断是否输入相关参数及导入dxf文件,如果没有则弹出警报
if (speed == 0 || fast == 0||isempty(filenamejudge))
% 如果变量没有值,弹出警告框
errordlg('没有正确输入参数或导入相关文件。', '警告');
else
handles.dxf.list;
entities = handles.dxf.entities;
entities = BFS(entities);
%生成G代码
Pway = evalin('base', 'Pway');
if(Pway == 1)
generateGCode(entities, ' C:\Users\Administrator\Desktop\DXFtool_v1.0\DXFtool_v1.0\output.txt');
%读取生成的G代码并显示到软件上
Gcode = fileread( ' C:\Users\Administrator\Desktop\DXFtool_v1.0\DXFtool_v1.0\output.txt');
set(handles.Gcodebox,'String',Gcode, 'HorizontalAlignment', 'left');
else
generateGCode2(entities, 'C:\Users\Administrator\Desktop\DXFtool_v1.0\DXFtool_v1.0\output2.txt');
%读取生成的G代码并显示到软件上
Gcode = fileread( ' C:\Users\Administrator\Desktop\DXFtool_v1.0\DXFtool_v1.0\output2.txt');
set(handles.Gcodebox,'String',Gcode, 'HorizontalAlignment', 'left');
end
%生成走刀路径图像
plot_tool_path('C:\Users\Administrator\Desktop\DXFtool_v1.0\DXFtool_v1.0\output.txt');
end
% --- Executes during object creation, after setting all properties.
function InputFigure_CreateFcn(hObject, eventdata, handles)
% hObject handle to InputFigure (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate InputFigure
function deep_inter_Callback(hObject, eventdata, handles)
% hObject handle to deep_inter (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 deep_inter as text
% str2double(get(hObject,'String')) returns contents of deep_inter as a double
% --- Executes during object creation, after setting all properties.
function deep_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to deep_inter (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
function fast_inter_Callback(hObject, eventdata, handles)
% hObject handle to fast_inter (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 fast_inter as text
% str2double(get(hObject,'String')) returns contents of fast_inter as a double
% --- Executes during object creation, after setting all properties.
function fast_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to fast_inter (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
function speed_inter_Callback(hObject, eventdata, handles)
% hObject handle to speed_inter (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 speed_inter as text
% str2double(get(hObject,'String')) returns contents of speed_inter as a double
% --- Executes during object creation, after setting all properties.
function speed_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to speed_inter (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 button press in SaveValueBotton.
function SaveValueBotton_Callback(hObject, eventdata, handles)
% hObject handle to SaveValueBotton (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%获取切削深度
deep_ = get(handles.deep_inter, 'String');
% 获取进给速度
fast_ = get(handles.fast_inter, 'String');
% 获取主轴转速
speed_ = get(handles.speed_inter, 'String');
% 获取刀补方式,2是左刀补,3是右刀补,1报错
compensation_way_= get(handles.compensation_inter, 'Value');
% 获取刀具号码 1号刀具是2,2号刀具是3,以此类推
tool_num_ = get(handles.tool_choosing, 'Value');
%获取编程方式代码
Pway_ = get(handles.Pway_inter,'Value');
%获取对刀点x坐标
duidaox_= get(handles.duidaox_inter,'String');
%获取对刀点y坐标
duidaoy_= get(handles.duidaoy_inter,'String');
%获取对刀点xz坐标
duidaoz_= get(handles.duidaoz_inter,'String');
%获取加工方向
direction = get(handles.popupmenu4,'Value');
% 存储到变量中
speed_ = str2double(speed_);
fast_ = str2double(fast_);
deep_ = str2double(deep_);
duidaox_ = str2double(duidaox_);
duidaoy_ = str2double(duidaoy_);
duidaoz_ = str2double(duidaoz_);
% 判断输入的是否是数字
if (isnan(speed_) || isnan(fast_) || isnan(deep_)||(tool_num_ == 1)||(compensation_way_ == 1)||(Pway_ == 1))
% 如果输入不是有效的数字,弹出警告框
errordlg('没有正确输入相关参数或未选择相关参数。', '输入错误');
else
assignin('base', 'deep', deep_);
assignin('base', 'fast', fast_);
assignin('base', 'speed', speed_);
assignin('base', 'tool_num', tool_num_);
assignin('base', 'Pway', Pway_-1);
assignin('base','duidaox',duidaox_);
assignin('base','duidaoy',duidaoy_);
assignin('base','duidaoz',duidaoz_);
assignin('base','direction',direction-1);
%转换刀补成g代码
assignin('base', 'conpensation_way', compensation_way_+39);
end
% --- Executes during object deletion, before destroying properties.
function CNCcodetext_DeleteFcn(hObject, eventdata, handles)
% hObject handle to CNCcodetext (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on selection change in Gcodebox.
function Gcodebox_Callback(hObject, eventdata, handles)
% hObject handle to Gcodebox (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 Gcodebox contents as cell array
% contents{get(hObject,'Value')} returns selected item from Gcodebox
% --- Executes during object creation, after setting all properties.
function Gcodebox_CreateFcn(hObject, eventdata, handles)
% hObject handle to Gcodebox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: listbox 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 tool_path_figurebox_CreateFcn(hObject, eventdata, handles)
% hObject handle to tool_path_figurebox (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate tool_path_figurebox
function length_inter_Callback(hObject, eventdata, handles)
% hObject handle to length_inter (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 length_inter as text
% str2double(get(hObject,'String')) returns contents of length_inter as a double
% --- Executes during object creation, after setting all properties.
function length_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to length_inter (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
function width_inter_Callback(hObject, eventdata, handles)
% hObject handle to width_inter (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 width_inter as text
% str2double(get(hObject,'String')) returns contents of width_inter as a double
% --- Executes during object creation, after setting all properties.
function width_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to width_inter (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
function height_inter_Callback(hObject, eventdata, handles)
% hObject handle to height_inter (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 height_inter as text
% str2double(get(hObject,'String')) returns contents of height_inter as a double
% --- Executes during object creation, after setting all properties.
function height_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to height_inter (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 compensation_inter.
function compensation_inter_Callback(hObject, eventdata, handles)
% hObject handle to compensation_inter (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 compensation_inter contents as cell array
% contents{get(hObject,'Value')} returns selected item from compensation_inter
% --- Executes during object creation, after setting all properties.
function compensation_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to compensation_inter (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 selection change in tool_choosing.
function tool_choosing_Callback(hObject, eventdata, handles)
% hObject handle to tool_choosing (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 tool_choosing contents as cell array
% contents{get(hObject,'Value')} returns selected item from tool_choosing
% --- Executes during object creation, after setting all properties.
function tool_choosing_CreateFcn(hObject, eventdata, handles)
% hObject handle to tool_choosing (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 button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% 读取生成的走刀路径图像并显示到软件上
imageData = imread('C:\Users\Administrator\Desktop\DXFtool_v1.0\DXFtool_v1.0\plot_image.png');
imshow(imageData, 'Parent', handles.tool_path_figurebox);
% --- Executes on button press in pushbutton9.
function pushbutton9_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
dxf=evalin('base','dxf');
entities = dxf.entities;
entities = BFS(entities);
fixOffsetPath2(entities);
imageData3 = imread('C:\Users\Administrator\Desktop\DXFtool_v1.0\DXFtool_v1.0\plot_image_daobu.png');
imshow(imageData3, 'Parent', handles.compensation_figurebox);
function Gcenter_x_inter_Callback(hObject, eventdata, handles)
% hObject handle to Gcenter_x_inter (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 Gcenter_x_inter as text
% str2double(get(hObject,'String')) returns contents of Gcenter_x_inter as a double
% --- Executes during object creation, after setting all properties.
function Gcenter_x_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to Gcenter_x_inter (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
function Gcenter_y_inter_Callback(hObject, eventdata, handles)
% hObject handle to Gcenter_y_inter (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 Gcenter_y_inter as text
% str2double(get(hObject,'String')) returns contents of Gcenter_y_inter as a double
% --- Executes during object creation, after setting all properties.
function Gcenter_y_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to Gcenter_y_inter (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
function Gcenter_z_inter_Callback(hObject, eventdata, handles)
% hObject handle to Gcenter_z_inter (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 Gcenter_z_inter as text
% str2double(get(hObject,'String')) returns contents of Gcenter_z_inter as a double
% --- Executes during object creation, after setting all properties.
function Gcenter_z_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to Gcenter_z_inter (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 button press in pushbutton11.
function pushbutton11_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton11 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in save_botton2.
function save_botton2_Callback(hObject, eventdata, handles)
% hObject handle to save_botton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%获取模具长度
length_ = get(handles.length_inter,'String');
%获取模具宽度
width_ = get(handles.width_inter, 'String');
% 获取模具高度
height_ = get(handles.height_inter, 'String');
% 获取几何中心x坐标
Gcenter_x_= get(handles.Gcenter_x_inter, 'String');
% 获取几何中心y坐标
Gcenter_y_= get(handles.Gcenter_y_inter, 'String');
% 获取几何中心z坐标
Gcenter_z_= get(handles.Gcenter_z_inter, 'String');
% 存储到变量中
length_ = str2double(length_);
width_ = str2double(width_);
height_ = str2double(height_);
Gcenter_x_ = str2double(Gcenter_x_);
Gcenter_y_ = str2double(Gcenter_y_);
Gcenter_z_= str2double(Gcenter_z_);
% 判断输入的是否是数字
if (isnan(length_) || isnan(width_) || isnan(height_)||isnan(Gcenter_x_)||isnan(Gcenter_y_)||isnan(Gcenter_z_))
% 如果输入不是有效的数字,弹出警告框
errordlg('没有输入相关参数或输入有误。', '输入错误');
else
assignin('base', 'length', length_);
assignin('base', 'width',width_);
assignin('base', 'height',height_);
assignin('base', 'Gcenter_x',Gcenter_x_);
assignin('base', 'Gcenter_y',Gcenter_y_);
assignin('base', 'Gcenter_z',Gcenter_z_);
end
% --- Executes on button press in pushbutton12.
function pushbutton12_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton12 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
axes(handles.axes6);
%% 调用函数显示刀具行进动画
create_tool_path_animation_3D('C:\Users\Administrator\Desktop\DXFtool_v1.0\DXFtool_v1.0\output.txt');
% --- Executes when figure1 is resized.
function figure1_SizeChangedFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes during object creation, after setting all properties.
function axes6_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes6 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes6
%旋转功能
%rotate3d(hObject,'on');
%缩放功能
%zoom(hObject,'on');
% --- Executes on selection change in Pway_inter.
function Pway_inter_Callback(hObject, eventdata, handles)
% hObject handle to Pway_inter (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 Pway_inter contents as cell array
% contents{get(hObject,'Value')} returns selected item from Pway_inter
% --- Executes during object creation, after setting all properties.
function Pway_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to Pway_inter (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 button press in radiobutton1.
function radiobutton1_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton1
rotate3d(handles.axes6,'on');
zoom(handles.axes6,'off');
if get(hObject, 'Value') == 1
set(handles.radiobutton2, 'Value', 0);
end
% --- Executes on button press in radiobutton2.
function radiobutton2_Callback(hObject, eventdata, handles)
% hObject handle to radiobutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hint: get(hObject,'Value') returns toggle state of radiobutton2
if get(hObject, 'Value') == 1
set(handles.radiobutton1, 'Value', 0);
end
rotate3d(handles.axes6,'off');
zoom(handles.axes6,'on');
% --- Executes during object creation, after setting all properties.
function radiobutton1_CreateFcn(hObject, eventdata, handles)
% hObject handle to radiobutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
function duidaox_inter_Callback(hObject, eventdata, handles)
% hObject handle to duidaox_inter (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 duidaox_inter as text
% str2double(get(hObject,'String')) returns contents of duidaox_inter as a double
% --- Executes during object creation, after setting all properties.
function duidaox_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to duidaox_inter (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
function duidaoy_inter_Callback(hObject, eventdata, handles)
% hObject handle to duidaoy_inter (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 duidaoy_inter as text
% str2double(get(hObject,'String')) returns contents of duidaoy_inter as a double
% --- Executes during object creation, after setting all properties.
function duidaoy_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to duidaoy_inter (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
function duidaoz_inter_Callback(hObject, eventdata, handles)
% hObject handle to duidaoz_inter (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 duidaoz_inter as text
% str2double(get(hObject,'String')) returns contents of duidaoz_inter as a double
% --- Executes during object creation, after setting all properties.
function duidaoz_inter_CreateFcn(hObject, eventdata, handles)
% hObject handle to duidaoz_inter (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 popupmenu4.
function popupmenu4_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu4 (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 popupmenu4 contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu4
% --- Executes during object creation, after setting all properties.
function popupmenu4_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu4 (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