Newer
Older
% MGUI GUI for data analysis programmes.
% MGUI starts a GUI and supplies Matlab programmes
% for their easy application to data which are in
% the Matlab workspace.
%
% The presented programmes are stored in the file
% MGUI.RC where own programmes can be added. Just
% include a line with the name of the programme and
% the minimal and maximal number of arguments, divided
% by a blank space or tabulator as a separator, e.g.
%
% plot 1 4
%
% If the embedded programmes provide an output, then
% this output will be stored in the variable ANS in
% the Matlab workspace.
%
% See also MGUICLEAN.
% Copyright (c) 2008-2009
% Norbert Marwan, Potsdam Institute for Climate Impact Research, Germany
% http://www.pik-potsdam.de
%
% Copyright (c) 2002-2008
% Christian Hoennicke, Norbert Marwan, Andre Sitz, Potsdam University, Germany
% http://www.agnld.uni-potsdam.de
% All rights reserved.
%
% Redistribution and use in source and binary forms, with or without
% modification, are permitted provided that the following conditions
% are met:
%
% * Redistributions of source code must retain the above
% copyright notice, this list of conditions and the following
% disclaimer.
% * Redistributions in binary form must reproduce the above
% copyright notice, this list of conditions and the following
% disclaimer in the documentation and/or other materials provided
% with the distribution.
% * All advertising materials mentioning features or use of this
% software must display the following acknowledgement:
% This product includes software developed by the University of
% Potsdam, Germany, the Potsdam Institute for Climate Impact
% Research (PIK), and its contributors.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
% CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
% INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
% MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
% DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
% BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
% EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
% TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
% DATA, OR PROFITS; OR BUSINESS
%
% Revision 1.13 2009/03/24 08:32:57 marwan
% copyright address changed
%
% Revision 1.12 2006/03/29 13:07:55 marwan
% problems regarding OPRPs and embedding resolved
%
% Revision 1.11 2006/03/16 14:55:57 marwan
% code flattened
%
% Revision 1.10 2006/02/14 11:45:49 marwan
% *** empty log message ***
%
% Revision 1.9 2004/11/10 07:05:21 marwan
% initial import
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
warning off
if nargin==0
action='init';
end
font.FontName=get(0,'factoryTextFontName');
font.FontUnits=get(0,'factoryTextFontUnits');
font.FontSize=get(0,'factoryTextFontSize');
font.FontWeight=get(0,'factoryTextFontWeight');
font.FontAngle=get(0,'factoryTextFontAngle');
props.root.defaultUIControlBackgroundColor=get(0,'factoryUIControlBackgroundColor');
props.root.defaultUIControlForegroundColor=get(0,'factoryUIControlForegroundColor');
props.root.defaultTextColor=get(0,'factoryUIControlForegroundColor');
props.window.Color=[0.8008 0.7500 0.6875];
props.window.Units='Char';
props.window.Colormap=[[0 0 0];[props.window.Color]];
props.newwindow.Color=[.8 .8 .8];
props.newwindow.Units='Pixels';
props.frame=font;
props.frame.Style='frame';
props.frame.BackgroundColor=props.window.Color;
props.frame.ForegroundColor=[0 0 0];
props.frame.Units='Char';
props.listbox=font;
props.listbox.FontName='lucida';
props.listbox.FontSize=10;
props.listbox.Style='listbox';
props.listbox.BackgroundColor=[0.9297 0.8711 0.7969];
props.listbox.ForegroundColor=[0 0 0];
props.listbox.Units='Char';
props.button=font;
props.button.Style='pushbutton';
props.button.BackgroundColor=[0.8008 0.7500 0.6875];
props.button.ForegroundColor=[0 0 0];
props.button.Units='Char';
props.checkbox=font;
props.checkbox.Style='checkbox';
props.checkbox.HorizontalAlignment='left';
props.checkbox.BackgroundColor=props.window.Color;
props.checkbox.ForegroundColor=[0 0 0];
props.checkbox.Units='Char';
props.text=font;
props.text.Style='text';
props.text.HorizontalAlignment='left';
props.text.BackgroundColor=props.window.Color;
props.text.ForegroundColor=[0 0 0];
props.text.Units='Char';
props.msgbox=font;
props.msgbox.FontSize=get(0,'factoryUIControlFontSize');
props.msgbox.BackgroundColor=props.window.Color;
props.msgbox.ForegroundColor=[0 0 0];
props.msgboxwin.Color=props.msgbox.BackgroundColor;
v=version;
if str2double(v(findstr(v,'(R')+2:findstr(v,')')-1))<= 12;
props.msgboxwin.Colormap=[[0 0 0];[props.msgbox.BackgroundColor]];
end
props.logo.Visible='off';
props.logo.Units='Char';
props.logo.Color=props.window.Color;
set(0,'Units','Character'), sc=get(0,'ScreenSize');
set(0,'Units','Pixels'), sc2=get(0,'ScreenSize');
po=get(0,'defaultFigurePosition');
props.window.Position=[4 sc(4)-32 125.1667 29.0714]; % Mainframe
props.newwindow.Position=[sc2(3)-1.05*po(3) po(2) po(3) po(4)]; % Ausgabefenster
props.frame.Position=[28.0000 5.5 94.8333 21.67]; % frame um die parameterliste
props.listbox_function_select.Position=[ 3.1667 5.5 23.5000 22.1000]; % Funktionselect [.1 .8 .8 .1]
props.button_apply.Position=[ 99.8333 1.8571 16.8333 2.1429]; % Knopf 1 :: Ausfhren [.52 .05 .38 .10]
props.button_parm_le.Position=[ 28.9 24.3 3.5000 1.5000]; % parm_le :: Parameter verringern [.1 .1 .3 .1]
props.button_parm_ge.Position=[117.9 24.3 3.5000 1.5000]; % parm_ge :: Parameter erhhen [.1 .2 .3 .1]
props.listbox_parm.Position=[ 34. 7.9000 18.5000 16.5000]; % PopupBox (Listbox)
props.button_ok.Position=[ 34. 6.4 18.5000 1.5000]; % Knopf schliesen
props.button_parm.Position=[ 34. 24.3 18.5000 1.5000]; % ParameterButton
props.button_help.Position=[ 76.5000 1.8571 10.1667 2.1429]; % Knopf 5 :: Help
props.button_close.Position=[ 88.1667 1.8571 10.1667 2.1429]; % Knopf 6 :: Close
props.text_disclaimer.Position=[ 11.5 0.7 23.5000 3.6429]; % Disclaimer
props.logo.Position=[ 3.1667 0.9 6.8 3.5]; % Disclaimer
props.checkbox_CheckNewWindow.Position=[ 36.1667 1.3571 35.1667 1.5000]; % CheckNewWindow
props.checkbox_ForceSameLength.Position=[ 36.1667 3.0000 35.1667 1.5000]; % ForceSameLength
props.text_funktion_helptext.Position=[ 29 26.2857 93.5000 1.2857]; % funktion_helptext
set(0,'defaultUIControlBackgroundColor',props.msgbox.BackgroundColor,...
'defaultUIControlForegroundColor',props.msgbox.ForegroundColor,...
'defaultTextColor',props.text.ForegroundColor)
bsdrc_path=[strrep(which_res,[filename,'.m'],''), 'private'];
bsdrc_file=[bsdrc_path, filesep, '.bsd.',filename];
if ~exist(bsdrc_path,'dir')
if ~exist(bsdrc_file,'file')
fid=fopen(bsdrc_file,'w');
fprintf(fid,'%s\n','If you delete this file, the BSD License will');
fprintf(fid,'%s','splash up at the next time the programme starts.');
fclose(fid);
end
h=figure('NumberTitle','off',...,
'ButtonDownFcn','close',...
ha=get(h,'Position');
h=uicontrol('Style','Listbox',...
'ButtonDownFcn','close',...
'CallBack','close',...
'Position',[0 0 ha(3) ha(4)],...
'FontName','Courier',...
'BackgroundColor',[.8 .8 .8],...
'String',txt);
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
waitfor(h)
end
hMF = findobj('Tag','MainFrame');
if ~(isempty(hMF)), props = get(hMF,'UserData'); end
if ~isempty(findobj('Tag','helpdlgbox')), delete(findobj('tag','helpdlgbox')), end
hfs = findobj('Tag','function_select');
select = get(hfs,'Value');
funktion = get(hfs,'UserData');
if ~isempty(funktion)
FktName = char(funktion(select).name);
if strcmp(FktName,'------------');
select=select+1;
set(hfs,'Value',select)
mgui action
end
end
set(0,'ShowHiddenHandles','off')
% Und "Aktion!" - hier geht es los
switch(action)
case 'init'
%%% Hier wird der Programmablauf vorbereitet,
%%% * die Graphikkoordinaten festgelegt
%%% * die Funktionslisten aus der Datei generiert
%%% * das Grundfenster gezeichnet
% Lsche bestehende Fenster gleichen Tags
if ~isempty(findobj('Tag','MainFrame'))
delete(findobj('Tag','MainFrame'))
end
% Die Funktionen Load und Save am Anfang einfuegen
i = 1;
funktion(i).name = cellstr('load');
funktion(i).min = 0;
funktion(i).max = 0;
funktion(i).akt = 0;
funktion(i).klicklist{4}=[];
funktion(i).klickstring{4}=[];
i=i+1;
funktion(i).name = cellstr('save');
funktion(i).min = 1;
funktion(i).max = 1;
funktion(i).akt = 1;
funktion(i).klicklist{4}=[];
funktion(i).klickstring{4}=[];
i=i+1;
funktion(i).name = cellstr('add programme');
funktion(i).min = 0;
funktion(i).max = 0;
funktion(i).akt = 0;
funktion(i).klicklist{4}=[];
funktion(i).klickstring{4}=[];
i=i+1;
funktion(i).name = cellstr('------------');
funktion(i).min = 0;
funktion(i).max = 0;
funktion(i).akt = 0;
funktion(i).klicklist{4}=[];
funktion(i).klickstring{4}=[];
%% Einlesen der Funktionsliste
% ffnen der Datei mit den Funktionensnamen und -parametern
fid = fopen('mgui.rc','r');
if (fid ~= -1) % fopen liefert im Fehlerfall "-1"
line = fgetl(fid);
while (line ~=-1) %EOF
if ~isempty(line) & line(1)~='%' %einlesen erster Parameter
i = i + 1;
[name,line] = strtok(line);
funktion(i).name = cellstr(name);
[min,line] = strtok(line);
if ~isempty(min)
if ~isempty(max)
% Hack : mehr als 4 Parameter werden nicht zugelassen
funktion(i).akt = str2double(min);
funktion(i).klicklist{4}=[];
funktion(i).klickstring{4}=[];
% Fehlerfall min > max
if funktion(i).min > funktion(i).max
h=errordlg([' Error in data structure at: ' char(funktion(i).name) ' -> (min>max)'],'Initialization');
set(h,props.msgboxwin),h2=guihandles(h);set(h2.OKButton,props.msgbox)
end
% Fehler: "Zu wenige Parameter" einsammeln
else
h=errordlg([' Error in data structure at: ' char(funktion(i).name) ' -> (to less parameter)'],'Initialization');
set(h,props.msgboxwin),h2=guihandles(h);set(h2.OKButton,props.msgbox)
funktion(i).min = 0;
funktion(i).max = 0;
funktion(i).akt = 0;
end
else
h=errordlg([' Error in data structure at: ' char(funktion(i).name) ' -> (to less parameter)'],'Initialization');
set(h,props.msgboxwin),h2=guihandles(h);set(h2.OKButton,props.msgbox)
waitfor(h)
funktion(i).min = 0;
funktion(i).max = 0;
funktion(i).akt = 0;
end
end
line = fgetl(fid); % Zeilenweises lesen
end
fclose(fid); % schliesen der Datei
% Wenn fopen() fehlgeschlagen ist
else
% funktion.name = cellstr('Empty');
% funktion.min = 0;
% funktion.max = 0;
% funktion.akt = 0;
% funktion.klicklist{4}=[];
% funktion(i).klickstring{4}=[];
end
% Schmeie alle unbekannten Funktionen raus...
j = size(funktion,2); i=5;
while i<=j
if isempty(double(which(char(funktion(i).name))))
funktion(i) = [];
i = i-1;
j = j-1;
end
i=i+1;
end
%% Zeichnen der Obeflche
% Zeichnen des Grundfensters (Hack: Koordinaten sind fix)
figure(props.window,'Tag','MainFrame',...
'NumberTitle','off',...
'Name','Controlpanel',...
'MenuBar','None',...
'UserData',props,...
'Resize','Off');
uicontrol(props.frame);
if length(funktion)>4, select=5; else select=3; end
uicontrol(props.listbox, props.listbox_function_select,...
'Tag','function_select',...
'String', [funktion.name]',...
'UserData', funktion,...
'Callback', 'mgui mod2', 'ButtonDownFcn','helpwin mgui');
% Knopf 3 :: Parameter verringern
b=[fliplr(triu(ones(10,10))),triu(ones(10,10))];
b=rot90(b(:,1:2:end));
for i=1:3,
c=(b==1)*props.button.BackgroundColor(i)+(b==0)*props.button.ForegroundColor(i);
icon(:,:,i)=c(:,1:2:end);
end
uicontrol(props.button, props.button_parm_le,...
'Tag','parm_le',...
'Visible', 'off',...
'Callback','mgui ChangeNumberOfParameters',...
'ToolTip','Decreases the number of parameters.');
for i =1:4,
uicontrol(props.button, 'Tag',['button_parm' num2str(i)],...
'Position', [(props.button_parm.Position(1) + ((i - 1) * 21.2)), props.button_parm.Position(2), props.button_parm.Position(3), props.button_parm.Position(4)],...
'String', ['Parm' num2str(i)],...
'Visible', 'off',...
'Callback', 'mgui Vis');
uicontrol(props.listbox, 'Tag',['listbox_parm' num2str(i)],...
'Value',[],...
'Max',2,... %Hack: scheinbar beliebig Zahl(>1) mglich...
'Visible', 'off',...
'Position', [(props.listbox_parm.Position(1) + ((i - 1) * 21.2)), props.listbox_parm.Position(2), props.listbox_parm.Position(3), props.listbox_parm.Position(4)],...
'Callback','mgui klickreihenfolge');
uicontrol(props.button, 'Tag',['button_close_parm' num2str(i)],...
'String', 'OK',...
'Visible', 'off',...
'Position', [(props.button_ok.Position(1) + ((i - 1) * 21.2)), props.button_ok.Position(2), props.button_ok.Position(3), props.button_ok.Position(4)],...
'Callback', 'mgui UnVis',...
'UserData',[]);
end
% Knopf 4:: Parameter erhhen
b=[fliplr(triu(ones(10,10))),triu(ones(10,10))];
b=rot90(b(:,1:2:end),-1);
for i=1:3,
c=(b==1)*props.button.BackgroundColor(i)+(b==0)*props.button.ForegroundColor(i);
icon(:,:,i)=c(:,1:2:end);
end
uicontrol(props.button, props.button_parm_ge,...
'Tag','parm_ge',...
'Visible', 'on',...
'Callback','mgui ChangeNumberOfParameters',...
'ToolTip','Increases the number of parameters.');
uicontrol(props.checkbox, props.checkbox_ForceSameLength, ...
'Tag','ForceSameLength',...
'Value',0,...
'ToolTip','Fills parameter vectors with NaN in order to get the same vector lengths.',...
'String','Force equal data length.');
uicontrol(props.checkbox, props.checkbox_CheckNewWindow, ...
'Tag','CheckNewWindow',...
'Value',0,...
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
'String','Create new figure.');
% Knopf 5 :: Help
uicontrol(props.button, props.button_help,...
'Tag','help',...
'String','Help',...
'Callback', 'mgui help',...
'ToolTip','Helpwindow.', 'ButtonDownFcn','helpwin mgui');
% Knopf 6 :: Close
uicontrol(props.button, props.button_close, ...
'Tag','close',...
'String','Close',...
'Callback', 'mgui close',...
'ToolTip','Closing the GUI.', 'ButtonDownFcn','helpwin mgui');
% Knopf 1 :: Ausfhren
uicontrol(props.button, props.button_apply, 'Tag','apply',...
'String','Apply',...
'Enable','off',...
'Callback', 'mgui apply',...
'ToolTip','Apply the choosen function.', 'ButtonDownFcn','helpwin mgui');
h=axes;
logo=load('logo');
imagesc([logo.logo fliplr(logo.logo)], 'ButtonDownFcn','helpwin mgui')
set(h,props.logo)
h=uicontrol(props.text, props.text_disclaimer, ...
'HandleVis','off',...
'Tag','disclaimer',...
h2=textwrap(h,{[char(169),' AGNLD'],'University of Potsdam','2002-2006'});
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
set(h,'String',h2)
mgui mod2;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'mod2'
%%% erlegt den ganzen init-kram, wenn eine Funktion ausgewhlt wurde
% Anzahl der Parameter und Auswahlboxen beim Start anpassen und zeichnen
% lesen der Anzahl der minimalen/maximalen Parameter
FN_Min = funktion(select).min;
FN_Max = funktion(select).max;
FN_Akt = funktion(select).akt;
FN_Name = funktion(select).name;
%%% kurzhilfe einblenden
if strcmp(FN_Name, 'add programme');
fnhelptext='ADD PROGRAMME Adds a programme into the MGUI and its related RC file.';
ind=length(fnhelptext);
else
fnhelptext=help(char(FN_Name));
ind=findstr(char(10),fnhelptext);
end
hfh=findobj('Tag','funktion_helptext');
if isempty(hfh)
hfh=uicontrol(props.text, props.text_funktion_helptext,...
'Tag','funktion_helptext',...
'String',fnhelptext(1:ind(1)),...
'ButtonDownFcn','helpwin mgui');
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
end
h=get(hfh,'Extent');h2=get(hfh,'Position');
set(hfh,'Position',[h2(1:2) h(3) h2(4)])
drawnow
%% Knppe in Ausgangsstellung bringen
% Wenn, mehrere Parameter erlaubt sind, die Knpfe aktivieren
% Es sind mehr Parameter mglich
set(findobj('Tag','parm_le'),'Visible','on');
set(findobj('Tag','parm_ge'),'Visible','on');
if (FN_Akt == FN_Max)
set(findobj('Tag','parm_ge'),'Visible','off');
end
if (FN_Akt == FN_Min)
set(findobj('Tag','parm_le'),'Visible','off');
end
check_workspace;
check_apply
%% aufdecken
for i = 1 : FN_Akt
hparm = findobj('Tag',['button_parm' num2str(i)]);
hlbox = findobj('Tag',['listbox_parm' num2str(i)]);
hbcp = findobj('Tag',['button_close_parm' num2str(i)]);
set(hparm,'Visible','on');
set(hlbox,'Visible','on');
set(hbcp,'Visible','on');
end
%% Verdeckt
for i = (FN_Akt +1) : 4 % HACK: es sind nicht mehr als 4 paramter vorgesehen
hparm = findobj('Tag',['button_parm' num2str(i)]);
hlbox = findobj('Tag',['listbox_parm' num2str(i)]);
hbcp = findobj('Tag',['button_close_parm' num2str(i)]);
set(hparm,'Visible','off');
set(hlbox,'Visible','off');
set(hbcp,'Visible','off');
end
if strcmp(FN_Name, 'load');
mgui load
end
if strcmp(FN_Name, 'add programme');
mgui add_programme
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'apply'
%%% Alle Parameter werden ausgelesen und hintereinander zusammengestellt und ausgefhrt
%% Init
FN_Akt = funktion(select).akt;
FktName = char(funktion(select).name);
%% 'save' und 'load' rausfischen -> selbst geschrieben
if strcmp(FktName,'save')
mgui save;
return;
end
if strcmp(FktName,'load')
mgui load;
return;
end
if strcmp(FktName, 'add programme');
mgui add_programme;
return;
end
%% Auszufhrenden String zusammenbasteln
Argumente = '(';
for j=1 : FN_Akt
Arg = ['Arg',num2str(j)];
% %% Init
var_list = get(findobj('Tag',['listbox_parm' num2str(j)]),'UserData');
temp=funktion(select).klicklist;
if isempty(klick_list), klick_list=get(findobj('Tag',['button_close_parm', num2str(j)]),'UserData'); end
Matrix = []; % Zu speichernder Inhalt
%% Parameterinhalt zusammenstellen
for i = 1:size(klick_list,2);
% Einlesen des Variablennamens und zuweisen seines Inhaltes
VarName = var_list(klick_list(1,i)).name;
try
VarValue = evalin('base',VarName);
catch
h=warndlg(['Variable ' VarName ' could not be found and will be ignored henceforth.'],'Scan workspace');
set(h,props.msgboxwin),h2=guihandles(h);set(h2.OKButton,props.msgbox)
set(h,'Tag','helpdlgbox','HandleVisibility','On');
continue;
end
% Zeilenvektor in Spaltenvektor transformieren
if (size(VarValue,1)) == 1
VarValue = VarValue';
end
% Feststellen der gewnschten Reihen
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
SelectRows(1,:) = []; % Lsche Kopf (Enthlt Verweis auf den Variablennamen)
% Wenn Spalten gewhlt wurden, dann den Varibleninhalt darauf begrenzen
if ~isempty(SelectRows)
VarValue = VarValue(:,SelectRows);
end
% Unterschiedliche Lnge -> Auffllen mit "NaN"
if (size(Matrix,1) ~= size(VarValue,1)) & (size(Matrix,1) ~= 0)
% Matrix zu lang
if (size(Matrix,1) > size(VarValue,1))
VarValue((size(VarValue,1)+1):size(Matrix,1),:) = NaN;
% Spaltenvektor zu lang
else
Matrix((size(Matrix,1)+1):size(VarValue,1),:) = NaN;
end
end
Matrix = [Matrix VarValue];
end
% zusammenfgen aller gewhlten Variablen
% Wertzuweisung eines Paramters
eval([Arg '= Matrix;']);
Argumente = strcat(Argumente, Arg);
% if j < FN_Akt
Argumente = strcat(Argumente,',');
% end
end
Argumente(end) = [];
Argumente = strcat(Argumente,')');
%% Alle Parameter erhalten die gleiche Lnge (wenn gewnscht)
if get(findobj('Tag','ForceSameLength'),'Value')
% Init
MaxLength = 0;
% Suche des lngsten Parameters
for i = 1:FN_Akt
Matrix = eval(['Arg' num2str(i)]);
if (size(Matrix, 1) > MaxLength)
MaxLength = size(Matrix, 1);
end
end
% Alle Parameter auf die gleiche Lnge trimmen
for i = 1:FN_Akt
Matrix = eval(['Arg' num2str(i)]); % laden
Matrix(size(Matrix,1):MaxLength,:)= NaN;
eval([['Arg' num2str(i)] '= Matrix;']); % speichern
end
end
%% Ausgabe der Funktionswerte
% Erstellt auf Wunsch ein neues Ausgabefenster
hnpw = findobj('Tag','CheckNewWindow');
bNewWindow = get(hnpw,'Value');
if bNewWindow
figure(props.newwindow,'Tag','PrintWindow');
end
%% Ausfhren der ganzen Mhe (mit Errorhandling)
% Schreibschutz aktivieren
set(hMF, 'HandleVisibility','Off');
% Ausfhren
try
set(0,props.root);
eval([FktName Argumente]);
% if ~isempty(ans)
% assignin('base','ans',ans)
% end
catch
set(0,'defaultUIControlBackgroundColor',props.msgbox.BackgroundColor,...
'defaultUIControlForegroundColor',props.msgbox.ForegroundColor,...
'defaultTextColor',props.text.ForegroundColor)
h=errordlg(lasterr,['Call ',upper(FktName)]);
set(h,props.msgboxwin),h2=guihandles(h);set(h2.OKButton,props.msgbox)
waitfor(h);
end
% Schreibschutz deaktivieren
set(hMF, 'HandleVisibility','on');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'ChangeNumberOfParameters'
%%% verndern der aktuellen Parameteranzahl
%%% parm_le => verringern; parm_ge => vergroessern
%% Init
hcall = gcbo;
caller = get(hcall,'Tag');
FN_Akt = funktion(select).akt;
FN_Min = funktion(select).min;
FN_Max = funktion(select).max;
%% Anzahl sichtbarer Parameter verringern
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
if FN_Akt > FN_Min
set(findobj('Tag',['button_parm' num2str(FN_Akt)]),'Visible','off');
set(findobj('Tag',['button_close_parm' num2str(FN_Akt)]),'Visible','off');
set(findobj('Tag',['listbox_parm' num2str(FN_Akt)]),'Visible','off');
funktion(select).akt = FN_Akt - 1;
set(hfs,'UserData',funktion);
if funktion(select).akt <= FN_Min
set(hcall,'Visible','off');
end
set(findobj('Tag','parm_ge'),'Visible','on');
end
%if ~isempty(get(findobj('Tag',['button_close_parm', num2str(FN_Akt-1)]),'UserData'))
% set(findobj('Tag','apply'),'Enable','on');
%end
%% Anzahl sichtbarer Parameter erhhen (parm_ge)
else
if FN_Akt < FN_Max
funktion(select).akt = FN_Akt + 1;
set(findobj('Tag',['button_parm' num2str(FN_Akt+1)]),'Visible','on');
set(findobj('Tag',['button_close_parm' num2str(FN_Akt+1)]),'Visible','on');
set(findobj('Tag',['listbox_parm' num2str(FN_Akt+1)]),'Visible','on');
set(hfs,'UserData',funktion);
if funktion(select).akt >= FN_Max
set(hcall,'Visible','off');
end
set(findobj('Tag','parm_le'),'Visible','on');
% Den Apply-Knopf deaktivieren
% if isempty(get(findobj('Tag',['button_close_parm', num2str(FN_Akt+1)]),'UserData'))
% set(findobj('Tag','apply'),'Enable','off');
% end
end
end
%% Alle "Klick_listen" durchsuchen, ob "Apply" ausgefhrt werden darf
FN_Akt = funktion(select).akt;
trigger = 0;
% Alle "Klick_list"en durchsuchen
for i = 1 : FN_Akt
hbcp = findobj('Tag',['button_close_parm' num2str(i)]);
temp=funktion(select).klicklist;
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
if isempty(klick_list), klick_list=get(hbcp,'UserData'); end
if isempty(klick_list)
trigger = 1;
end
end
% Wenn mindestens eine leere dabei, dann die Ausfhrung verhindern
if trigger
set(findobj('Tag','apply'),'Enable','off');
else
set(findobj('Tag','apply'),'Enable','on');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'Vis'
%%% Macht die geforderte Listbox + Closebutton sichtbar
% Aufrufender = akt. Parameter wird rot gefrbt
hcall = gcbo;
%% Bestimmen des zugehrigen Auswahlfensters und Closebuttons
caller = get(hcall,'Tag');
caller_lbox = strrep(caller,'button','listbox');
caller_bc = strrep(caller,'button','button_close');
lokal_ws=check_workspace;
%%%%%%%%%%%%%%
% check for erased variables
tmplist = funktion(select).klicklist{nparm};
tmpstr = funktion(select).klickstring{nparm};
if ~isempty(tmpstr)
ParmBereiche =[0 find(tmpstr == ',') size(tmpstr,2)+1];
% jeden Parameter einzeln checken
for i = 1:size(ParmBereiche,2)-1
varname = tmpstr(ParmBereiche(i)+1:ParmBereiche(i+1)-1);
trigger = 0;
for j = 1:size(lokal_ws,2)
if strcmp(lokal_ws(j).name,varname)
trigger =1;
tmplist(1,i) = j;
break;
end
end
if trigger == 0
tmplist(i) = NaN;
tmpstr(ParmBereiche(i)+1:ParmBereiche(i+1)-1) = ' ';
end
end
end
%% hier noch die richtigen pfade eintragen
%set(findobj('tag',caller_bc),'UserData',tmplist);
%set(hparm,'String',tmpstr);
funktion(select).klicklist{nparm}= tmplist;
funktion(select).klickstring{nparm}=tmpstr;
set(hfs,'UserData',funktion);
%%%%%%%%%%%%%%
%% Aktivieren der angeforderten Listbox + Closebutton
% Erst Listbox
set(hlbox,'Visible','on');
% set(hlbox,'String',[Ausgabe]);
% set(hlbox,'UserData',lokal_ws);
if isempty(get(hcall,'tooltip'))
set(hlbox,'Value',[]); % beim oeffnen ist nichts ausgewaehlt
end
% Dann Closebutton
set(hbcp,'Visible','on');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'UnVis'
%%% macht die Listbox + Closebutton unsichtbar
%% bestimmen des zugehrigen Auswahlfensters und Closebuttons
hcall = gcbo;
caller = get(hcall,'Tag');
caller_lbox = strrep(caller,'button_close','listbox');
%% deaktivieren der angeforderten Elemente
set(hlbox,'Visible','off');
set(hcall,'Visible','off');
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'help'
%%% Es werden die die Standart-Matlab-Hilfetexte angezeigt
%% Entsprechenden Hilfetext auswhlen und anzeigen
if ~isempty(select)
% 'Load' und 'Save' haben eigenen Hilfstext
if strcmp(funktion(select).name,'load') | strcmp(funktion(select).name,'save') | strcmp(funktion(select).name,'add programme')
if strcmp(funktion(select).name,'load')
h=helpdlg(['Load workspace variables from an extern data file.',char(10),'Additionally text lines (e.g. header lines) will be skipped.'],'Help');
elseif strcmp(funktion(select).name,'save') % (funktion(select).name == 'SAVE')
h=helpdlg(['Save workspace variables into an extern data file.',char(10),'The file format will be plain ASCII.'],'Help');
else
h=helpdlg(['Adds a new programme into the function list of this MGUI.',char(10),...
'The minimal and maximal number of input parameters for this',char(10),...
'programme has to be specified. Finally, this changing will', char(10),...
'be done in the mgui.rc file.'],'Help');
end
set(h,props.msgboxwin),h2=guihandles(h);set(h2.OKButton,props.msgbox)
set(h,'Tag','helpdlgbox','HandleVisibility','On');
else
% Hilfstext
eval(['helpwin ', char(funktion(select).name)]);
end
else % wenn keine Funktion ausgewhlt wurde
helpwin mgui;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'close'
% beendet das Programm
close(hMF)
warning on
% clear all
tx{1}='Thank you for your blind trust.';
tx{3}='Thanks, that you believe in us.';
tx{4}='We hope we could satisfy you.';
tx{5}='Thank you for working with us.';
tx{6}='Now you should go home.';
tx{7}='Did you already find us in the WorldWideWeb?';
tx{8}='Your cat might be hungry.';
tx{9}='Maybe your Matlab license will be needed by others?';
tx{10}='Can you imagine, how long we have worked for that?';
tx{11}='Thank you for your responsiveness.';
tx{12}='Now ready for publishing?';
disp(tx{round((length(tx)-1)*rand)+1})
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'winclose'
% koennte noetig werden, wenn noch irgendwelche settings
% zurueckgestellt werden muessen
set(0,props.root);
warning on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case 'klickreihenfolge'
%%% Die Klickreihenfolge wird im parm_button_close gespeichert
%% Bestimmung des Aufrufers
hlbox = gcbo;
% die passenden Handel initialisieren
tmp = strrep(get(hlbox,'Tag'),'listbox','button_close');
temp=funktion(select).klicklist;
if ~isempty(temp),
klick_list=temp{nparm};
else
klick_list = [];
end
if isempty(klick_list), klick_list = get(hbcp,'UserData'); end
klick_akt = get(hlbox,'Value');
if isempty(var_list(1).name), return; end; % Keine Variable vorhanden
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
%% Akualisieren der Klick_list (und anzeigen)
% Wenn ausversehen mehr als ein Wert gewhlt wurde
if (size(klick_akt,2) > 1)
h=errordlg('Choose only one variable.','Parameter selection');
set(h,props.msgboxwin),h2=guihandles(h);set(h2.OKButton,props.msgbox)
waitfor(h)
set(hlbox,'Value',klick_list(1,:));
return;
else
% Aktualisieren
if isempty(klick_list)
posi=[];
else
posi = find(klick_list(1,:) == klick_akt);
end
if(isempty(posi))
% Einfgen
klick_list(1,(end +1)) = klick_akt;
else
% Lschen
klick_list(:,posi) = [];
end
% Das der Nutzer sein klicken sieht (Listbox)
set(hlbox,'Value',klick_list(1,:));
set(hparm,'String',klick_string);
set(hparm,'ToolTip',klick_string);
% Speichern der ganzen Mhe
set(hbcp,'UserData',klick_list);
funktion(select).klicklist{nparm}=klick_list;
funktion(select).klickstring{nparm}=klick_string;
set(hfs,'UserData',funktion)
end
check_apply
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case('selectcolumn')
%%% Hier erfolgt die Auswahl der Spalten
%% Bestimmung des Aufrufers
hcall = gcbo;
caller= get(hcall,'Tag');
% die passenden Handel initialisieren
tmp = strrep(caller,'listbox','button_close');
hlbox = hcall;
tmp = strrep(caller,'listbox','button');
if ~isempty(temp), klick_list=temp{nparm}; else klick_list = []; end
if isempty(var_list(1).name), return; end; % Keine Variable vorhanden