forked from tsumpf/arrShow
-
Notifications
You must be signed in to change notification settings - Fork 1
/
asBrowse.m
855 lines (657 loc) · 21.4 KB
/
asBrowse.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
% Copyright (C) 2009-2013 Biomedizinische NMR Forschungs GmbH
% http://www.biomednmr.mpg.de
% Author: Tilman Johannes Sumpf <[email protected]>
%
% Distributed under the Boost Software License, Version 1.0.
% (See accompanying file LICENSE_1_0.txt or copy at
% http://www.boost.org/LICENSE_1_0.txt)
function asBrowse(objs)
if nargin < 1 || isempty(objs)
objs = arrShow.findAllObjects;
tit = 'asBrowse( global asObjs array )';
par.workOnGlobalArray = true;
else
tit = ['asBrowse(',inputname(1),')'];
par.workOnGlobalArray = false;
end
if isempty(objs)
error('asBrowse:noObjs','no arrShow objects found');
end
par.objs = objs;
par.objsBackup = objs;
% create main figure
par.figureHandle = figure( 'MenuBar','none',...
'Name',tit,...
'NumberTitle','off',...
'Visible','off');
set(par.figureHandle,'WindowKeyPressFcn',@(src, evnt)abKeyPressCb(evnt, par.figureHandle));
% set heigth of the figure to 1 to avoid GUI "flashing effect"
pos = get(par.figureHandle,'position');
set(par.figureHandle,'position',[pos(1:3),1]);
% create toolbar
iconpath = [fileparts(mfilename('fullpath')), filesep, 'icons'];
toolBar = uitoolbar(par.figureHandle);
uipushtool('Parent',toolBar,'Tag','Annotation.refreshRelativesList',...
'TooltipString', 'Refresh list of relatives',...
'ClickedCallback', @(src,evnt)refreshTable(par.figureHandle),...
'CData',iconRead(fullfile(iconpath,'refresh.png')));
uipushtool('Parent',toolBar,'Tag','Annotation.sortByFigureNumber',...
'TooltipString', 'Sort asObjs array by figure number',...
'ClickedCallback', @(src,evnt)sortByFigureNumber(par.figureHandle));
% create header
ColumnName = {'Show','Focus','Title', 'dim', 'norm', 'min', 'mean', 'max'};
noCols = length(ColumnName);
par.noCols = noCols;
RowName = 'numbered';
% set editable
columneditable = false(1,noCols);
columneditable(1) = ~par.workOnGlobalArray; % show-column is only
% editable only if we are not
% working on the global
% asObjs array
columneditable(3) = true; % the title-column
% create context menu -----------------------
par.cMenuHandle = uicontextmenu;
uimenu(par.cMenuHandle,'Label','Lineup objects' ,...
'callback',@(src,evnt)lineupCb(par.figureHandle));
uimenu(par.cMenuHandle,'Label','Minimize figure' ,...
'callback',@(src,evnt)minimizeCb(par.figureHandle));
uimenu(par.cMenuHandle,'Label','Close' ,...
'callback',@(src,evnt)closeCb(par.figureHandle));
% Algebra
uiAlg = uimenu(par.cMenuHandle,'Label','Algebra',...
'Separator','on');
uimenu(uiAlg,'Label','Sum' ,...
'callback',@(src,evnt)algCb(par.figureHandle,'sum'));
uimenu(uiAlg,'Label','Diff' ,...
'callback',@(src,evnt)algCb(par.figureHandle,'diff'));
uimenu(uiAlg,'Label','Mean' ,...
'callback',@(src,evnt)algCb(par.figureHandle,'mean'));
uimenu(uiAlg,'Label','Min' ,...
'callback',@(src,evnt)algCb(par.figureHandle,'min'));
uimenu(uiAlg,'Label','Max' ,...
'callback',@(src,evnt)algCb(par.figureHandle,'max'));
uimenu(uiAlg,'Label','./' ,...
'callback',@(src,evnt)algCb(par.figureHandle,'rdivide'));
uimenu(uiAlg,'Label','.*' ,...
'callback',@(src,evnt)algCb(par.figureHandle,'times'));
uimenu(uiAlg,'Label','Difference to last selected' ,...
'callback',@(src,evnt)diffCb(par.figureHandle),...
'Separator', 'on');
% multi object operations
uimenu(par.cMenuHandle,'Label','Abs wdw from last selected' ,...
'callback',@(src,evnt)absWdwCb(par.figureHandle));
uimenu(par.cMenuHandle,'Label','Compare infotext' ,...
'callback',@(src,evnt)compareInfotext(par.figureHandle));
uimenu(par.cMenuHandle,'Label','Create WS object' ,'Separator','on',...
'callback',@(src,evnt)createWorkspaceObject(par.figureHandle));
uimenu(par.cMenuHandle,'Label','Save selected objects' ,...
'callback',@(src,evnt)saveSelectedObjects(par.figureHandle));
% cmenu: export selected images
sub2 = uimenu(par.cMenuHandle,'Label','Export selected objects current image');
uimenu(sub2,'Label','Use title as filename' ,...
'callback',@(src,evnt)exportImages(par.figureHandle,'.png',false,false));
uimenu(sub2,'Label','Use title and add appendix' ,...
'callback',@(src,evnt)exportImages(par.figureHandle,'.png',true,false));
uimenu(sub2,'Label','Use title, add appendix and include overlays' ,...
'callback',@(src,evnt)exportImages(par.figureHandle,'.png',true,true));
uimenu(par.cMenuHandle,'Label','Batch export' ,...
'callback',@(src,evnt)batchExport(par.figureHandle));
% cmenu: title manipulation
sub1 = uimenu(par.cMenuHandle,'Label','All titles...' ,...
'Separator','on');
uimenu(sub1,'Label','Change' ,...
'callback',@(src,evnt)changeAllTitles(par.figureHandle,'replace'));
uimenu(sub1,'Label','Add appendix' ,...
'callback',@(src,evnt)changeAllTitles(par.figureHandle,'end'));
uimenu(sub1,'Label','Add prefix' ,...
'callback',@(src,evnt)changeAllTitles(par.figureHandle,'start'));
uimenu(sub1,'Label','Delete N chars from beginning' ,...
'callback',@(src,evnt)deleteCharsFromTitles(par.figureHandle,'start'),...
'Separator','on');
uimenu(sub1,'Label','Delete N chars from end' ,...
'callback',@(src,evnt)deleteCharsFromTitles(par.figureHandle,'end'));
uimenu(par.cMenuHandle,'Label','Change image selection' ,...
'callback',@(src,evnt)setSelectedImages(par.figureHandle));
uimenu(par.cMenuHandle,'Label','Refresh table' ,...
'callback',@(src,evnt)refreshTable(par.figureHandle),...
'Separator','on');
% ----------------------------------------
% create table
par.tableHandle = uitable('ColumnName',ColumnName,...
'RowName',RowName,...
'ColumnEditable', columneditable,...
'Units','normalized',...
'Position',[0,0,1,1],...
'UIContextMenu',par.cMenuHandle,...
'Enable','on',...
'HitTest','on',...
'SelectionHighlight','off',...
'CellEditCallback',@(src,evnt)cellEditCb(par.figureHandle,evnt),...
'CellSelectionCallback',@(src,evnt)cellSelectCb(par.figureHandle,evnt));
%'FontName','FixedWidth');
% Set all column width except the first to 'auto'
cWidth = cell([1,noCols]);
for i = 2 : noCols
cWidth{i} = 'auto';
end
% create an empty selection
par.selection = [];
% write parameter to main figure userData
set(par.figureHandle,'UserData',par);
% create table data
updateTableData(par.figureHandle);
% enable GUI visibility (I'd like to do that after updating the column
% width. However, this doen't seem to work properly as the table property
% "extend" doesn't seem to be correctly calculated within an invisible
% figure :-/ )
set(par.figureHandle,'Visible','on');
% set first column size to length the longest title
updateColumnWidth(par.figureHandle)
if ~verLessThan('matlab','8.4.0')
% I honestly have no idea why this is apparently sometimes necessary
% with matlab 2014b... :-/
set(par.tableHandle,'Position',[0,0,1,1]);
end
set(par.figureHandle,'HandleVisibility','off');
end
% -----------------------------------------
% table related functions
% -----------------------------------------
function refreshTable(fh)
if ishandle(fh)
set(fh,'HandleVisibility','on');
updateTableData(fh);
updateColumnWidth(fh);
set(fh,'HandleVisibility','off');
end
end
function sortByFigureNumber(fh)
par = get(fh,'UserData');
if(par.workOnGlobalArray)
% find new objects
objs = arrShow.findAllObjects;
N = length(objs);
figureNumbers = zeros(N,1);
for i = 1 : N
figureNumbers(i) = objs(i).getFigureNumber();
end
[~,inds] = sort(figureNumbers);
objs = objs(inds);
global asObjs
asObjs = objs;
end
refreshTable(fh);
end
function updateTableData(fh)
% set first cSize to length the longest title
par = get(fh,'UserData');
if(par.workOnGlobalArray)
% % find new objects
% objs = arrShow.findAllObjects();
% if ~isempty(objs)
% global asObjs
% asObjs = objs;
% evalin('base','global asObjs');
% end
global asObjs
objs = asObjs;
else
% restore destroyed objects from backup
objs = par.objs;
invinds = find(~isvalid(objs));
objs(invinds) = par.objsBackup(invinds);
% objs(~isvalid(objs)) = [];
end
noObjs = length(objs);
par.objs = objs;
set(fh,'UserData',par);
% create data cells
Data = cell([noObjs, par.noCols]);
for i = 1 : noObjs
% cell1: 'Show'
Data{i,1} = objs(i).isInitialized;
% cell2: 'Fig'
Data{i,2} = num2str(objs(i).getFigureNumber);
% cell3: 'Title'
Data{i,3} = objs(i).getFigureTitle;
% cell4: 'Dims'
Data{i,4} = num2str(objs(i).getImageDimensions);
% cell 5 - 8: min mean max norm
if objs(i).isInitialized
stats = objs(i).statistics.getImageStats;
Data{i,5} = num2str(stats(4)); % norm
Data{i,6} = num2str(stats(1)); % min
Data{i,7} = num2str(stats(2)); % mean
Data{i,8} = num2str(stats(3)); % max
else
for j = 5 : 8
Data{i,j} = '';
end
end
end
set(par.tableHandle,'Data',Data);
end
function updateColumnWidth(fh)
% set first cSize to length the longest title
% fixed size for the 'show'-column
cWidth{1} = 33;
% fixed size for the 'focus'-column
cWidth{2} = 35;
par = get(fh,'UserData');
Data = get(par.tableHandle,'Data');
if ispc
charSize = 10; %pixel
else
charSize = 11; %pixel
end
maxWidth = 40 * charSize;
minWidth = 6 * charSize;
noChars = findMaxLength(Data,3) + 1; % leave one additional char space
if isempty(noChars)
noChars = 1; % this strange line is necessary, because if 'findMaxLength'
% returns [], than ([] + 1) stays [] in matlab...
end
cWidth{3} = noChars * charSize;
cWidth{3} = min(cWidth{3}, maxWidth);
cWidth{3} = max(cWidth{3}, minWidth);
set(par.tableHandle,'ColumnWidth',cWidth);
adaptWindowSize(fh);
end
function cellEditCb(fh, evnt)
% callback is executed whenever a table entry has been
% get selection
index = evnt.Indices;
if ~isempty(index)
selRow = index(end,1); % selected row
selCol = index(end,2); % selected column
% save selection to par struct
par = get(fh,'UserData');
par.selection = index;
set(fh,'UserData',par);
% figure out, what column has been changed and call the according
% function
switch selCol
case 1 % the 'show'-column
toggleShowSelectedFigure(fh);
case 3 % the title column
Data = get(par.tableHandle,'Data');
newTitle = Data{selRow,selCol};
selObj = getSelectedObjects(fh);
selObj.setFigureTitle(newTitle);
updateColumnWidth(fh);
otherwise
%nop
end
end
end
function cellSelectCb(fh, evnt)
% get selection
index = evnt.Indices;
if ~isempty(index)
par = get(fh,'UserData');
if isempty(par.selection)
prevSelect = [];
else
prevSelect = par.selection(:,1);
end
newSelect = elementsNotInArr2(index(:,1),prevSelect);
if isempty(newSelect)
newSelect = index(:,1);
end
if length(newSelect) == 1
lastSelect = newSelect;
else
if ~isempty(prevSelect) && prevSelect(end) < newSelect(end)
lastSelect = newSelect(end);
else
lastSelect = newSelect(1);
end
end
par.selection = index;
par.lastSelectedRow = lastSelect;
set(fh,'UserData',par);
% check if row 2 is selected
if index(end,2) == 2
putWindowOnTop(par,index(end,1));
end
end
end
function adaptWindowSize(fh)
par = get(fh,'UserData');
origTableUnits = get(par.tableHandle,'Units');
origFigureUnits= get(fh,'Units');
set(par.tableHandle,'Units','pixels');
tableSize = get(par.tableHandle,'Extent');
set(par.tableHandle,'Units',origTableUnits);
set(fh,'Units','pixels');
figureSize= get(fh,'Position');
h1 = figureSize(4);
b1 = figureSize(2);
h2 = tableSize(4);
b2 = b1 - (h2 - h1);
figureSize(2) = b2;
figureSize(3:4) = tableSize(3:4);
set(fh, 'Position', figureSize);
set(fh,'Units',origFigureUnits);
end
function putWindowOnTop(par,selectedRow)
% check, if the selected window is initialized
selObj = par.objs(selectedRow);
if ~isvalid(selObj)
% restore backup
par.objs(selectedRow) = par.objsBackup(selectedRow);
% set table boolean to false
Data = get(par.tableHandle,'Data');
Data{selectedRow,1} = false;
set(par.tableHandle,'Data',Data);
else
if selObj.isInitialized
% put selected asObj on top
selObj.putFigureOnTop;
end
end
end
function l = findMaxLength( cellArr, col)
noRows = size(cellArr,1);
l = [];
for i = 1 : noRows
l = max([ length(cellArr{i,col}) , l]);
end
end
function [selObjs, lastSelObj] = getSelectedObjects(fh)
par = get(fh,'UserData');
% get selected rows
sel = par.selection(:,1);
% all selected objects
selObjs = par.objs(sel);
% get the object which has been selected at last
if nargout > 1
lastSelObj = par.objs(par.lastSelectedRow);
end
end
% -----------------------------------------
% functions to manipulate arrShow objects
% -----------------------------------------
function createWorkspaceObject(fh)
selObjs = getSelectedObjects(fh);
selObjs(end).createWorkspaceObject;
end
function changeAllTitles(fh, mode)
% promt for the new text
newText = inputdlg;
if isempty(newText)
return;
end
% get selected objects
selObjs = getSelectedObjects(fh);
for i = 1 : length(selObjs)
switch mode
case 'replace'
newTitle = newText{1};
case 'start'
newTitle = [newText{1},selObjs(i).getFigureTitle];
case 'end'
newTitle = [selObjs(i).getFigureTitle, newText{1}];
end
if iscell(newTitle)
newTitle = cell2mat(newTitle);
end
selObjs(i).setFigureTitle(newTitle);
end
refreshTable(fh);
end
function deleteCharsFromTitles(fh,mode)
noChars = inputdlg;
noChars = str2num(noChars{1});
% get selected objects
selObjs = getSelectedObjects(fh);
for i = 1 : length(selObjs)
fullTitle = selObjs(i).getFigureTitle;
switch mode
case 'start'
newTitle = fullTitle(noChars +1 : end);
case 'end'
newTitle = fullTitle(1 : end - noChars);
end
if iscell(newTitle)
newTitle = cell2mat(newTitle);
end
selObjs(i).setFigureTitle(newTitle);
end
refreshTable(fh);
end
function exportImages(fh, fileExtension, addAppendix, saveRoi)
if addAppendix
appendix = inputdlg;
if isempty(appendix)
return;
end
appendix = appendix{1};
else
appendix = '';
end
% get selected objects
selObjs = getSelectedObjects(fh);
for i = 1 : length(selObjs)
initName = selObjs(i).getFigureTitle;
% remove special characters from initname
initName = arrShow.removeSpecialCharsFromString(initName);
initName = [initName, appendix];
selObjs(i).exportCurrentImage([initName,fileExtension], saveRoi);
end
end
function saveSelectedObjects(fh)
initName = 'asObjects';
% promt user tu pick a filename
[fileName, filePath] = uiputfile({'*.mat'},'Save asObjects as', initName);
if fileName == 0
return;
end
% choose a variable name for the asObjects, which is the filename
% without the tailing '.mat'
storeVarName = textscan(fileName,'%s %s','delimiter','.');
storeVarName = storeVarName{1}{1};
% get selected objects
selObjs = getSelectedObjects(fh);
% remove possible links to relatives and store objects position
for i = 1 : length(selObjs)
if ~verLessThan('matlab','8.4.0')
% apparently, since matlab 2014b, saving objects containing
% graphic elements was sustantially changed. As a consequence
% the normal save commant now tries to recursively store all
% graphic objects. As almost all arrayShow subclasses
% are linked to graphic elements, it is
% rather complicated to get rit of them prior saving. As a
% workaround, I currently just create a copy of the object
% and then delete the main figure graphic object (which
% automatically also deletes all parent graphics). The
% object can then be saved as in previous matlab versions.
% This sux a bit in terms of performance, but seems
% to work for now.
selObjs(i) = selObjs(i).rebuildObject('renderUI',false);
delete(selObjs(i).getFigureHandle);
else
selObjs(i).storeFigurePosition;
selObjs(i).wipeRelativesList;
end
end
% copy objects to a variable named like the file
eval([storeVarName, ' = selObjs;']); % I didn't find a more elegant solution yet, since
% "assignin('caller',...)" doesn't seem to work. If anyone
% knows a better solution, let me know :)
% ...write the variable to harddisk
fprintf('saving data... ');
tic;
save(fullfile(filePath,fileName),storeVarName, '-v7.3');
fprintf('done in %2.2f seconds.\n',toc);
end
function setSelectedImages(fh)
% get selected objects
selObjs = getSelectedObjects(fh);
% get selection string
str = inputdlg('Enter selection','',1,{selObjs(1).selection.getValue});
if ~isempty(str)
for i = 1 : length(selObjs)
selObjs(i).selection.setValue(str{1});
end
end
end
function toggleShowSelectedFigure(fh)
par = get(fh,'UserData');
index = par.selection;
Data = get(par.tableHandle,'Data');
selObj = par.objs(index(end,1));
if par.workOnGlobalArray
% check, if the selected window is not already deleted
if isvalid(selObj)
% close it
selObj.close;
end
% refresh table data
refreshTable(fh);
else
if isvalid(selObj)
if selObj.isInitialized
% close it
selObj.close;
% set table boolean to false
Data{index(end,1),1} = false;
% restore backup
par.objs(index(end,1)) = par.objsBackup(index(end,1));
else
% rebuild object
newObj = selObj.rebuildObject;
par.objs(index(end,1))= newObj;
% append to global array
arrShow.cleanGlobalAsArray();
evalin('base','global asObjs');
global asObjs;
asObjs = [asObjs,newObj];
% set table boolean to true
Data{index(end,1),1} = true;
end
else
% restore backup
par.objs(index(end,1)) = par.objsBackup(index(end,1));
% set table boolean to false
Data{index(end,1),1} = false;
end
set(par.tableHandle,'Data',Data);
set(fh,'UserData',par);
end
end
function minimizeCb(fh)
asObjs = getSelectedObjects(fh);
for i = 1 : length(asObjs)
asObjs(i).minimizeFigure;
end
end
function lineupCb(fh)
% get selected objects
[selObjs, refObj] = getSelectedObjects(fh);
% treat the last selected object as reference
asLineup([refObj,selObjs]);
end
function diffCb(fh)
% get selected objects
[selObjs, refObj] = getSelectedObjects(fh);
% treat the last selected object as reference
asMultiDiffMaps([refObj, selObjs]);
refreshTable(fh);
end
function algCb(fh, operation)
% get selected objects
selObjs = getSelectedObjects(fh);
% treat the last selected object as reference
asAlgebra(selObjs, operation);
refreshTable(fh);
end
function compareInfotext(fh)
par = get(fh,'UserData');
% get selected rows
sel = par.selection(:,1);
% check number of selected objects
if length(sel) > 2
fprintf('need exactly 2 selected asObjs\n');
return
end
% get objects
obj1 = par.objs(sel(1));
obj2 = par.objs(sel(2));
% create temporary info text files
mfn =mfilename('fullpath'); % get mfile name and oath
mfn = fileparts(mfn); % isolate path
fi1 = fullfile(mfn,'infotextTemp1.txt');
fi2 = fullfile(mfn,'infotextTemp2.txt');
% add current figure numbers to the beginning of the files
fid = fopen(fi1,'wt');
fprintf(fid,'Figure: %d\n\n',obj1.getFigureNumber());
fclose(fid);
fid = fopen(fi2,'wt');
fprintf(fid,'Figure: %d\n\n',obj2.getFigureNumber());
fclose(fid);
% append infotext to files
obj1.exportImageInfos(fi1,true);
obj2.exportImageInfos(fi2,true);
% compare files
visdiff(fi1,fi2);
% delete temporary files
% this unfortunately does not work since it drives visdiff into trouble...
% delete([mfn,filesep,'infotextTemp*.txt']);
end
function batchExport(fh)
% get batch export dimension
dim = mydlg('Enter dimension','Enter dimension for batch export',3);
dim = str2double(dim);
if isnan(dim)
return
end
% get selected objects
selObjs = getSelectedObjects(fh);
wh = waitbar(0);
noObjs = length(selObjs);
for i = 1 : noObjs
waitbar(i/noObjs,wh);
selObjs(i).batchExportDimension(dim);
end
if ~isempty(wh) && ishandle(wh)
close(wh);
end
end
function absWdwCb(fh)
par = get(fh,'UserData');
% get selected objs
selObjs = par.objs(par.selection(:,1));
% treat the last selected object as reference
refObj = par.objs(par.lastSelectedRow);
refCW = refObj.window.getCW;
for i = 1 : length(selObjs)
selObjs(i).window.setCW(refCW);
end
end
function closeCb(fh)
par = get(fh,'UserData');
% get selected rows
sel = par.selection(:,1);
par.objs(sel).close;
refreshTable(fh)
end
function el = elementsNotInArr2(arr1, arr2)
l1 = length(arr1);
l2 = length(arr2);
for i = 1 : l1
for j = 1 : l2;
if arr1(i) == arr2(j)
arr1(i) = -1;
end
end
end
el = arr1(arr1~=-1);
end
function abKeyPressCb(evnt, fh)
switch evnt.Key
case 'f5' % refresh relatives list
refreshTable(fh);
end
end