-
Notifications
You must be signed in to change notification settings - Fork 25
/
guiFracPaQ2D.m
2409 lines (1895 loc) · 101 KB
/
guiFracPaQ2D.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
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = guiFracPaQ2D(varargin)
% GUIFRACPAQ2D MATLAB code for guiFracPaQ2D.fig
% GUIFRACPAQ2D, by itself, creates a new GUIFRACPAQ2D or raises the existing
% singleton*.
%
% H = GUIFRACPAQ2D returns the handle to a new GUIFRACPAQ2D or the handle to
% the existing singleton*.
%
% GUIFRACPAQ2D('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in GUIFRACPAQ2D.M with the given input arguments.
%
% GUIFRACPAQ2D('Property','Value',...) creates a new GUIFRACPAQ2D or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before guiFracPaQ2D_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to guiFracPaQ2D_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
%% Copyright
% Permission is hereby granted, free of charge, to any person obtaining a
% copy of this software and associated documentation files (the
% "Software"), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to permit
% persons to whom the Software is furnished to do so, subject to the
% following conditions:
%
% The above copyright notice and this permission notice shall be included
% in all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
% OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
% NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
% OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
% USE OR OTHER DEALINGS IN THE SOFTWARE.
% Edit the above text to modify the response to help guiFracPaQ2D
% Last Modified by GUIDE v2.5 17-Mar-2021 16:13:32
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @guiFracPaQ2D_OpeningFcn, ...
'gui_OutputFcn', @guiFracPaQ2D_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
% my initialisation can go here...
% --- Executes just before guiFracPaQ2D is made visible.
function guiFracPaQ2D_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 guiFracPaQ2D (see VARARGIN)
% Choose default command line output for guiFracPaQ2D
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes guiFracPaQ2D wait for user response (see UIRESUME)
% uiwait(handles.figure_main);
axes(handles.axes_logo) ;
imLogo = imread('FracPaQlogo.jpeg') ;
imshow(imLogo) ;
axes(handles.axes_icon) ;
imIcon = imread('FracPaQicon.jpeg') ;
imshow(imIcon) ;
axes(handles.axes_tracemap) ;
set(handles.popupmenu_histolengthbins,'Value',2) ;
set(handles.popupmenu_histoanglebins,'Value',2) ;
set(handles.popupmenu_rosebins,'Value',2) ;
handles.FracPaQversion = '2.8' ;
disp(['FracPaQ version ', handles.FracPaQversion]) ;
handles.graphx = [0, 0] ;
handles.graphy = [0, 0] ;
% Update handles structure
guidata(hObject, handles);
v = ver('MATLAB') ;
iRelease = regexp(v.Release, 'R.....') ;
nReleaseYear = str2num(v.Release(iRelease+1:iRelease+4)) ;
if nReleaseYear < 2015
h = msgbox('Warning: FracPaQ needs MATLAB release of R2015a, or later.', 'Important Warning!') ;
uiwait(h) ;
end ;
%Reposition each panel to same location as panel 1
set(handles.uibgTabLengths,'position',get(handles.uibgTabMaps,'position'));
set(handles.uibgTabAngles,'position',get(handles.uibgTabMaps,'position'));
set(handles.uibgTabFluid,'position',get(handles.uibgTabMaps,'position'));
set(handles.uibgTabWavelets,'position',get(handles.uibgTabMaps,'position'));
set(handles.uibgTabGraphs,'position',get(handles.uibgTabMaps,'position'));
set(handles.uibgTabMaps, 'Visible', 'off') ;
set(handles.uibgTabLengths, 'Visible', 'off') ;
set(handles.uibgTabAngles, 'Visible', 'off') ;
set(handles.uibgTabFluid, 'Visible', 'off') ;
set(handles.uibgTabWavelets, 'Visible', 'off') ;
set(handles.uibgTabGraphs, 'Visible', 'off') ;
set(handles.edit_filename, 'Enable', 'on') ;
% --- Outputs from this function are returned to the command line.
function varargout = guiFracPaQ2D_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 checkbox_triangle.
function checkbox_triangle_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_triangle (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 checkbox_triangle
if get(hObject, 'Value')
set(handles.label_numblocksmap, 'Enable', 'on') ;
set(handles.edit_numblocksmap, 'Enable', 'on') ;
set(handles.label_numpixelsItoY, 'Enable', 'on') ;
set(handles.edit_numpixelsItoY, 'Enable', 'on') ;
else
set(handles.label_numblocksmap, 'Enable', 'off') ;
set(handles.edit_numblocksmap, 'Enable', 'off') ;
set(handles.label_numpixelsItoY, 'Enable', 'off') ;
set(handles.edit_numpixelsItoY, 'Enable', 'off') ;
end ;
% --- Executes on button press in checkbox_permellipse.
function checkbox_permellipse_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_permellipse (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 checkbox_permellipse
if get(hObject, 'Value')
set(handles.label_aperturefactor, 'Enable', 'on') ;
set(handles.edit_aperturefactor, 'Enable', 'on') ;
set(handles.label_apertureexponent, 'Enable', 'on') ;
set(handles.edit_apertureexponent, 'Enable', 'on') ;
set(handles.edit_lambda, 'Enable', 'on') ;
set(handles.label_lambda, 'Enable', 'on') ;
set(handles.edit_fixedaperture, 'Enable', 'on') ;
set(handles.label_fixedaperture, 'Enable', 'on') ;
set(handles.radiobutton_fixedaperture, 'Enable', 'on') ;
set(handles.radiobutton_scaledaperture, 'Enable', 'on') ;
else
set(handles.label_aperturefactor, 'Enable', 'off') ;
set(handles.edit_aperturefactor, 'Enable', 'off') ;
set(handles.label_apertureexponent, 'Enable', 'off') ;
set(handles.edit_apertureexponent, 'Enable', 'off') ;
set(handles.edit_lambda, 'Enable', 'off') ;
set(handles.label_lambda, 'Enable', 'off') ;
set(handles.edit_fixedaperture, 'Enable', 'off') ;
set(handles.label_fixedaperture, 'Enable', 'off') ;
set(handles.radiobutton_fixedaperture, 'Enable', 'off') ;
set(handles.radiobutton_scaledaperture, 'Enable', 'off') ;
end ;
% --- Executes on button press in checkbox_intensitymap.
function checkbox_intensitymap_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_intensitymap (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 checkbox_intensitymap
if get(hObject, 'Value') || get(handles.checkbox_densitymap, 'Value')
set(handles.checkbox_showcircles, 'Enable', 'on') ;
set(handles.edit_numscancircles, 'Enable', 'on') ;
set(handles.label_numscancircles, 'Enable', 'on') ;
else
set(handles.checkbox_showcircles, 'Enable', 'off') ;
set(handles.checkbox_showcircles, 'Value', 0) ;
set(handles.edit_numscancircles, 'Enable', 'off') ;
set(handles.edit_numscancircles, 'Value', 0) ;
set(handles.label_numscancircles, 'Enable', 'off') ;
end ;
% --- Executes on button press in checkbox_densitymap.
function checkbox_densitymap_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_densitymap (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 checkbox_densitymap
if get(hObject, 'Value') || get(handles.checkbox_intensitymap, 'Value')
set(handles.checkbox_showcircles, 'Enable', 'on') ;
set(handles.edit_numscancircles, 'Enable', 'on') ;
set(handles.label_numscancircles, 'Enable', 'on') ;
else
set(handles.checkbox_showcircles, 'Enable', 'off') ;
set(handles.checkbox_showcircles, 'Value', 0) ;
set(handles.edit_numscancircles, 'Enable', 'off') ;
set(handles.edit_numscancircles, 'Value', 0) ;
set(handles.label_numscancircles, 'Enable', 'off') ;
end ;
% --- Executes on button press in checkbox_tracemap.
function checkbox_tracemap_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_tracemap (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 checkbox_tracemap
if get(hObject, 'Value')
set(handles.checkbox_shownodes, 'Enable', 'on') ;
else
set(handles.checkbox_shownodes, 'Enable', 'off') ;
set(handles.checkbox_shownodes, 'Value', 0) ;
end ;
% --- Executes on button press in checkbox_shownodes.
function checkbox_shownodes_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_shownodes (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 checkbox_shownodes
% --- Executes on button press in checkbox_histolength.
function checkbox_histolength_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_histolength (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 checkbox_histolength
if get(hObject, 'Value')
set(handles.text_histolengthbins, 'Enable', 'on') ;
set(handles.popupmenu_histolengthbins, 'Enable', 'on') ;
else
set(handles.text_histolengthbins, 'Enable', 'off') ;
set(handles.popupmenu_histolengthbins, 'Enable', 'off') ;
end ;
% --- Executes on button press in checkbox_logloglength.
function checkbox_logloglength_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_logloglength (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 checkbox_logloglength
if get(hObject, 'Value')
set(handles.checkbox_censor, 'Enable', 'on') ;
set(handles.checkbox_mle, 'Enable', 'on') ;
else
set(handles.checkbox_censor, 'Enable', 'off') ;
set(handles.checkbox_mle, 'Enable', 'off') ;
set(handles.checkbox_censor, 'Value', 0) ;
set(handles.checkbox_mle, 'Value', 0) ;
set(handles.edit_lc, 'Enable', 'off') ;
set(handles.edit_uc, 'Enable', 'off') ;
set(handles.label_lc, 'Enable', 'off') ;
set(handles.label_uc, 'Enable', 'off') ;
end ;
% --- Executes on button press in checkbox_mle.
function checkbox_mle_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_mle (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 checkbox_mle
if get(hObject, 'Value')
set(handles.edit_lc, 'Enable', 'on') ;
set(handles.edit_uc, 'Enable', 'on') ;
set(handles.label_lc, 'Enable', 'on') ;
set(handles.label_uc, 'Enable', 'on') ;
else
set(handles.edit_lc, 'Enable', 'off') ;
set(handles.edit_uc, 'Enable', 'off') ;
set(handles.label_lc, 'Enable', 'off') ;
set(handles.label_uc, 'Enable', 'off') ;
end ;
% --- Executes on button press in checkbox_histoangle.
function checkbox_histoangle_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_histoangle (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 checkbox_histoangle
if get(hObject, 'Value')
set(handles.text_histoanglebins, 'Enable', 'on') ;
set(handles.popupmenu_histoanglebins, 'Enable', 'on') ;
else
set(handles.text_histoanglebins, 'Enable', 'off') ;
set(handles.popupmenu_histoanglebins, 'Enable', 'off') ;
end ;
% --- Executes on button press in checkbox_rose.
function checkbox_rose_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_rose (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 checkbox_rose
if get(hObject, 'Value')
set(handles.text_rosebins, 'Enable', 'on') ;
set(handles.popupmenu_rosebins, 'Enable', 'on') ;
set(handles.edit_degfromnorth, 'Enable', 'on') ;
set(handles.label_degfromnorth, 'Enable', 'on') ;
set(handles.checkbox_roselengthweighted, 'Enable', 'on') ;
set(handles.checkbox_showrosemean, 'Enable', 'on') ;
set(handles.checkbox_rosecolour, 'Enable', 'on') ;
else
set(handles.text_rosebins, 'Enable', 'off') ;
set(handles.popupmenu_rosebins, 'Enable', 'off') ;
set(handles.edit_degfromnorth, 'Enable', 'off') ;
set(handles.label_degfromnorth, 'Enable', 'off') ;
set(handles.checkbox_roselengthweighted, 'Enable', 'off') ;
set(handles.checkbox_showrosemean, 'Enable', 'off') ;
set(handles.checkbox_rosecolour, 'Enable', 'off') ;
set(handles.checkbox_roselengthweighted, 'Value', false) ;
set(handles.checkbox_showrosemean, 'Value', false) ;
set(handles.checkbox_rosecolour, 'Value', false) ;
end ;
% --- Executes on button press in checkbox_crossplot.
function checkbox_crossplot_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_crossplot (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 checkbox_crossplot
% --- Executes on button press in checkbox_showcircles.
function checkbox_showcircles_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_showcircles (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 checkbox_showcircles
% --- Executes on button press in checkbox_censor.
function checkbox_censor_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_censor (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 checkbox_censor
function edit_houghpeaks_Callback(hObject, eventdata, handles)
% hObject handle to edit_houghpeaks (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 edit_houghpeaks as text
% str2double(get(hObject,'String')) returns contents of edit_houghpeaks as a double
% --- Executes during object creation, after setting all properties.
function edit_houghpeaks_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_houghpeaks (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 edit_houghthreshold_Callback(hObject, eventdata, handles)
% hObject handle to edit_houghthreshold (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 edit_houghthreshold as text
% str2double(get(hObject,'String')) returns contents of edit_houghthreshold as a double
% --- Executes during object creation, after setting all properties.
function edit_houghthreshold_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_houghthreshold (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 edit_fillgap_Callback(hObject, eventdata, handles)
% hObject handle to edit_fillgap (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 edit_fillgap as text
% str2double(get(hObject,'String')) returns contents of edit_fillgap as a double
% --- Executes during object creation, after setting all properties.
function edit_fillgap_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_fillgap (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 edit_minlength_Callback(hObject, eventdata, handles)
% hObject handle to edit_minlength (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 edit_minlength as text
% str2double(get(hObject,'String')) returns contents of edit_minlength as a double
% --- Executes during object creation, after setting all properties.
function edit_minlength_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_minlength (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 edit_degfromnorth_Callback(hObject, eventdata, handles)
% hObject handle to edit_degfromnorth (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 edit_degfromnorth as text
% str2double(get(hObject,'String')) returns contents of edit_degfromnorth as a double
% --- Executes during object creation, after setting all properties.
function edit_degfromnorth_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_degfromnorth (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 edit_scaling_Callback(hObject, eventdata, handles)
% hObject handle to edit_scaling (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 edit_scaling as text
% str2double(get(hObject,'String')) returns contents of edit_scaling as a double
% --- Executes during object creation, after setting all properties.
function edit_scaling_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_scaling (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 edit_numscancircles_Callback(hObject, eventdata, handles)
% hObject handle to edit_numscancircles (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 edit_numscancircles as text
% str2double(get(hObject,'String')) returns contents of edit_numscancircles as a double
% --- Executes during object creation, after setting all properties.
function edit_numscancircles_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_numscancircles (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 edit_lambda_Callback(hObject, eventdata, handles)
% hObject handle to edit_lambda (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 edit_lambda as text
% str2double(get(hObject,'String')) returns contents of edit_lambda as a double
% --- Executes during object creation, after setting all properties.
function edit_lambda_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_lambda (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 pushbutton_exit.
function pushbutton_exit_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
close all ;
close(gcf) ;
function edit_filename_Callback(hObject, eventdata, handles)
% hObject handle to edit_filename (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 edit_filename as text
% str2double(get(hObject,'String')) returns contents of edit_filename as a double
cla(handles.axes_tracemap) ;
handles.axes_tracemap.YDir = 'normal' ;
handles.selfile = get(hObject, 'String') ;
handles.selpath = pwd ;
if ispc
handles.selpath = [handles.selpath, '\'] ;
else
handles.selpath = [handles.selpath, '/'] ;
end
if ~isempty(handles.selfile)
sFileName = char(handles.selfile) ;
if ~isempty(regexp(sFileName, 'colour', 'ONCE'))
iHex = regexp(sFileName, '[A-F,0-9]{6}', 'ONCE') ;
% check each file has 'HHHHHH' in the name i.e. a valid hex string for colour
if isempty(iHex)
hError = errordlg('For a colour file, all filenames must contain a 6 character hexadecimal colour code', 'Input error', 'modal') ;
uicontrol(handles.edit_filename) ;
flagError = true ;
return ;
else
iRGB = strfind(sFileName, 'colour') ;
sRGB = sFileName(iRGB+6:iRGB+11) ;
sColour = hexRGB(sRGB) ;
handles.cstrColours = cellstr(sColour) ;
end ;
else
% MATLAB default blue
sColour = '[0, 0, 1]' ;
handles.cstrColours = cellstr(sColour) ;
end ;
handles.iCurrentColour = 1 ;
set(handles.pushbutton_preview, 'Enable', 'on') ;
if ~isempty(strfind(upper(handles.selfile), '.TIF')) || ...
~isempty(strfind(upper(handles.selfile), '.TIFF')) || ...
~isempty(strfind(upper(handles.selfile), '.JPEG')) || ...
~isempty(strfind(upper(handles.selfile), '.JPG'))
set(handles.radiobutton_image, 'Value', 1) ;
set(handles.radiobutton_node, 'Value', 0) ;
set(handles.edit_houghpeaks, 'Enable', 'on') ;
set(handles.edit_houghthreshold, 'Enable', 'on') ;
set(handles.edit_fillgap, 'Enable', 'on') ;
set(handles.edit_minlength, 'Enable', 'on') ;
else
set(handles.radiobutton_node, 'Value', 1) ;
set(handles.radiobutton_image, 'Value', 0) ;
set(handles.edit_houghpeaks, 'Enable', 'off') ;
set(handles.edit_houghthreshold, 'Enable', 'off') ;
set(handles.edit_fillgap, 'Enable', 'off') ;
set(handles.edit_minlength, 'Enable', 'off') ;
end ;
end
set(handles.pushbutton_flipx, 'Enable', 'off') ;
set(handles.pushbutton_flipy, 'Enable', 'off') ;
set(handles.pushbutton_run, 'Enable', 'off') ;
set(handles.text_message, 'String', 'Click Preview to view the file contents.') ;
% Update handles structure
guidata(hObject, handles);
% --- Executes during object creation, after setting all properties.
function edit_filename_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_filename (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 pushbutton_selectgraphendpoints.
function pushbutton_selectgraphendpoints_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_selectgraphendpoints (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[x, y] = ginput(2) ;
handles.graphx = x ;
handles.graphy = y ;
cla(handles.axes_tracemap) ;
% allow for multiple files, one for each colour
if ~isempty(handles.selmultifile)
hold on ;
for i = 1:length(handles.selmultifile)
sFilename = [ char(handles.selpath), char(handles.selmultifile(i)) ] ;
sColour = char(handles.cstrColours(i)) ;
[ ~, ~, ~, ~, ~ ] = guiFracPaQ2Dlist(sFilename, handles.nPixels, handles.axes_tracemap, sColour) ;
end ;
plot(handles.axes_tracemap, x, y, '-sr', 'LineWidth', 1) ;
hold off ;
else
hold on ;
[ ~, ~, ~, ~, ~ ] = guiFracPaQ2Dlist(handles.sFilename, handles.nPixels, handles.axes_tracemap, handles.sColour) ;
plot(handles.axes_tracemap, x, y, '-sr', 'LineWidth', 1) ;
hold off ;
end ;
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in pushbutton_browse.
function pushbutton_browse_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_browse (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
cla(handles.axes_tracemap) ;
handles.axes_tracemap.YDir = 'normal' ;
% from v1.8 - all platforms get access to .svg input files
sFileTypes = {'*.txt'; '*.svg'; '*.jpeg'; '*.jpg'; '*.tiff'; '*.tif'} ;
[ handles.selfile, handles.selpath ] = uigetfile(sFileTypes, 'Select input file(s) for FracPaQ2D') ;
if ~isempty(handles.selfile)
sFileName = char(handles.selfile) ;
if ~isempty(regexp(sFileName, 'colour', 'ONCE'))
iHex = regexp(sFileName, '[A-F,0-9]{6}', 'ONCE') ;
% check each file has 'HHHHHH' in the name i.e. a valid hex string for colour
if isempty(iHex)
hError = errordlg('For a colour file, all filenames must contain a 6 character hexadecimal colour code', 'Input error', 'modal') ;
uicontrol(handles.edit_filename) ;
flagError = true ;
return ;
else
iRGB = strfind(sFileName, 'colour') ;
sRGB = sFileName(iRGB+6:iRGB+11) ;
sColour = hexRGB(sRGB) ;
handles.cstrColours = cellstr(sColour) ;
end ;
else
% MATLAB default blue
sColour = '[0, 0, 1]' ;
handles.cstrColours = cellstr(sColour) ;
end ;
handles.iCurrentColour = 1 ;
set(handles.edit_filename, 'String', sFileName) ;
set(handles.pushbutton_preview, 'Enable', 'on') ;
if ~isempty(strfind(upper(sFileName), '.TIF')) || ...
~isempty(strfind(upper(sFileName), '.TIFF')) || ...
~isempty(strfind(upper(sFileName), '.JPEG')) || ...
~isempty(strfind(upper(sFileName), '.JPG'))
set(handles.radiobutton_image, 'Value', 1) ;
set(handles.radiobutton_node, 'Value', 0) ;
set(handles.edit_houghpeaks, 'Enable', 'on') ;
set(handles.edit_houghthreshold, 'Enable', 'on') ;
set(handles.edit_fillgap, 'Enable', 'on') ;
set(handles.edit_minlength, 'Enable', 'on') ;
else
set(handles.radiobutton_node, 'Value', 1) ;
set(handles.radiobutton_image, 'Value', 0) ;
set(handles.edit_houghpeaks, 'Enable', 'off') ;
set(handles.edit_houghthreshold, 'Enable', 'off') ;
set(handles.edit_fillgap, 'Enable', 'off') ;
set(handles.edit_minlength, 'Enable', 'off') ;
end ;
else
set(handles.edit_filename, 'String', '(no file selected)') ;
set(handles.pushbutton_preview, 'Enable', 'off') ;
end ;
set(handles.pushbutton_flipx, 'Enable', 'off') ;
set(handles.pushbutton_flipy, 'Enable', 'off') ;
set(handles.pushbutton_run, 'Enable', 'off') ;
set(handles.text_message, 'String', 'Click Preview to view the file contents.') ;
% Update handles structure
guidata(hObject, handles);
% --- Executes on button press in pushbutton_preview.
function pushbutton_preview_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_preview (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global sTag ;
cla(handles.axes_tracemap) ;
flagError = false ;
% image file validation
if get(handles.radiobutton_image, 'Value')
sValue = get(handles.edit_houghpeaks, 'String') ;
if isnan(str2double(sValue)) || str2double(sValue) < 100 || str2double(sValue) > 5000
hError = errordlg('Hough peaks must be a whole number, 100-5000', 'Input error', 'modal') ;
uicontrol(handles.edit_houghpeaks) ;
flagError = true ;
return ;
end ;
sValue = get(handles.edit_houghthreshold, 'String') ;
if isnan(str2double(sValue)) || str2double(sValue) <= 0.0 || str2double(sValue) > 1.0
hError = errordlg('Hough threshold must be a number > 0.0, and <= 1.0', 'Input error', 'modal') ;
uicontrol(handles.edit_houghthreshold) ;
flagError = true ;
return ;
end ;
sValue = get(handles.edit_fillgap, 'String') ;
if isnan(str2double(sValue)) || str2double(sValue) <= 1.0
hError = errordlg('Merge gap must be a number of pixels, > 1 and < max. image size', 'Input error', 'modal') ;
uicontrol(handles.edit_fillgap) ;
flagError = true ;
return ;
end ;
sValue = get(handles.edit_minlength, 'String') ;
if isnan(str2double(sValue)) || str2double(sValue) <= 1
hError = errordlg('Discard length must be a number of pixels, > 1 and < max. image size', 'Input error', 'modal') ;
uicontrol(handles.edit_minlength) ;
flagError = true ;
return ;
end ;
Iinfo = imfinfo(get(handles.edit_filename, 'String')) ;
if Iinfo.BitDepth ~= 8 || ~strcmp('grayscale', Iinfo.ColorType)
disp('Image file format error - check BitDepth (8) and ColorType(''grayscale'')') ;
disp(Iinfo) ;
hError = errordlg({'Selected image file is not 8-bit & grayscale';'Check Command Window for file info, BitDepth and ColorType'}, ...
'Input error', 'modal') ;
uicontrol(handles.edit_filename) ;
flagError = true ;
return ;
end ;
handles.selmultifile = { } ;
% node file validation
else
sFilename = [ char(handles.selpath), char(handles.selfile) ] ;
% convert .svg file to .txt file
if ~isempty(strfind(sFilename, '.svg'))
nConvert = convertSVG2txt_colour2(sFilename) ;
if nConvert > 0
% now handle possible multiple files
if nConvert > 1
sFilenameHead = sFilename(1:strfind(sFilename, '.svg')-1) ;
infoConvertedFiles = dir([sFilenameHead, '_colour*_converted.txt']) ;
handles.selmultifile = { infoConvertedFiles.name } ;
sColour = '' ;
for i = 1:nConvert
sThisFileName = char(handles.selmultifile(i)) ;
iHex = regexp(sThisFileName, '[A-F,0-9]{6}', 'ONCE') ;
% disp(sThisFileName) ;
% disp(iHex) ;
% check each file has 'HHHHHH' in the name i.e. a valid hex string for colour
if isempty(iHex)
hError = errordlg('For a colour file, all filenames must contain a 6 character hexadecimal colour code', 'Input error', 'modal') ;
uicontrol(handles.edit_filename) ;
flagError = true ;
return ;
else
iRGB = strfind(sThisFileName, 'colour') ;
sRGB = sThisFileName(iRGB+6:iRGB+11) ;
sColour = [ sColour ; hexRGB(sRGB) ] ;
end ;
end ;
handles.cstrColours = cellstr(sColour) ;
else
handles.selmultifile = { } ;
handles.selfile = strrep(handles.selfile, '.svg', '_converted.txt') ;
end ;
else
hError = errordlg('Error converting .svg file to .txt; check .svg file is version 1.1', 'Input error', 'modal') ;
uicontrol(handles.edit_filename) ;
flagError = true ;
end ;
else
handles.selmultifile = { } ;
end ;
end ;
sValue = get(handles.edit_scaling, 'String') ;
if ~isempty(sValue)
if isnan(str2double(sValue)) || str2double(sValue) <= 0.0
hError = errordlg('Scaling can be blank (i.e. scale as is) or a positive number', 'Input error', 'modal') ;
uicontrol(handles.edit_scaling) ;
flagError = true ;
return ;
end ;
end ;
if ~flagError
sFilename = [ char(handles.selpath), char(handles.selfile) ] ;
% get the current RGB colour string
sColour = char(handles.cstrColours(handles.iCurrentColour)) ;
if isempty(get(handles.edit_scaling, 'String'))
nPixels = 0 ;
else
nPixels = str2double(get(handles.edit_scaling, 'String')) ;
end ;
handles.nPixels = nPixels ;
handles.sColour = sColour ;
handles.sFilename = sFilename ;
if get(handles.radiobutton_image, 'Value')
nHoughPeaks = str2double(get(handles.edit_houghpeaks, 'String')) ;
dHoughThreshold = str2double(get(handles.edit_houghthreshold, 'String')) ;
dfillgap = str2double(get(handles.edit_fillgap, 'String')) ;
dminlength = str2double(get(handles.edit_minlength, 'String')) ;
set(handles.text_message, 'String', 'Running Hough transform on image...') ;
[ handles.traces, handles.xmin, handles.ymin, handles.xmax, handles.ymax ] = guiFracPaQ2Dimage(sFilename, nPixels, ...
nHoughPeaks, dHoughThreshold, dfillgap, dminlength, handles.axes_tracemap) ;
else
set(handles.text_message, 'String', 'Reading node file...') ;
% allow for multiple files, one for each colour
if ~isempty(handles.selmultifile)
handles.traces = struct([]) ;
handles.nTraces = 0 ;
handles.nSegments = 0 ;
handles.nNodes = 0 ;
handles.xmin = 3e38 ;
handles.ymin = 3e38 ;
handles.xmax = -3e38 ;
handles.ymax = -3e38 ;
hold on ;
for i = 1:length(handles.selmultifile)
sFilename = [ char(handles.selpath), char(handles.selmultifile(i)) ] ;
sColour = char(handles.cstrColours(i)) ;
[ traces, xmin, ymin, xmax, ymax ] = guiFracPaQ2Dlist(sFilename, nPixels, handles.axes_tracemap, sColour) ;
handles.traces = [ handles.traces, traces ] ;
if xmin < handles.xmin
handles.xmin = xmin ;
end ;
if ymin < handles.ymin
handles.ymin = ymin ;
end ;
if xmax > handles.xmax
handles.xmax = xmax ;
end ;
if ymax > handles.ymax
handles.ymax = ymax ;
end ;
end ;
hold off ;
else
hold on ;
[ handles.traces, handles.xmin, handles.ymin, handles.xmax, handles.ymax ] = guiFracPaQ2Dlist(sFilename, nPixels, handles.axes_tracemap, sColour) ;
hold off ;
end ;
end ;
set(handles.text_message, 'String', 'Collecting fracture trace data...') ;
setappdata(handles.pushbutton_run, 'Traces', handles.traces) ;
setappdata(handles.pushbutton_run, 'xMax', handles.xmax) ;
setappdata(handles.pushbutton_run, 'yMax', handles.ymax) ;
setappdata(handles.pushbutton_run, 'xMin', handles.xmin) ;
setappdata(handles.pushbutton_run, 'yMin', handles.ymin) ;
sTag = ['_', get(handles.edit_FilenameTag, 'String')] ;