function [] = PID_Entwurf()

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% PID_Entwurf.m %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% M-File erstellt die Benutzeroberfläche für den Entwurf
% des PID-Reglers

disp(sprintf('\n------------------------------------------------------------------'));
disp('Schnittstelle: PID_Entwurf.m');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Vordefinition %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Ermitteln der Bildschirmgröße %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
scrsz = get(0,'ScreenSize');
disp(['Ermittelte Bildschirmgröße: ',num2str(scrsz)]);

% Benutzeroberfläche mit angepassten Seitenverhältnis 
% zur Bildschirmgröße erstellen
if scrsz(3)/(5/3)>scrsz(4);

    scrsz(3) = scrsz(4)*(5/3)-.1*scrsz(3);          % scrsz(3) verkleinern
    scrsz(4) = scrsz(4)-.1*scrsz(3);
else
    scrsz(4) = scrsz(3)/(5/3)-.1*scrsz(4);          % scrsz(4) verkleinern
    scrsz(3) = scrsz(3)-.1*scrsz(4);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Größendefinitionen %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
fontsz_1 = 11;%(11.0*scrsz(3))/1300;
fontsz_2 = 12;%(12.0*scrsz(3))/1300;

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Farbdefinitionen %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
midnightblue = [25/255 25/255 112/255];
grey95 = [242/255 242/255 242/255];
Magenta = [255/255 0/255 255/255];
MediumBlue = [0/255 0/255 205/255];
Chocolate1 = [255/255 127/255 36/255];
Green4 = [0/255 139/255 0/255];
Red = [255/255 0/255 0/255];

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Hauptfenster %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.main = figure(...
    'WindowStyle','normal',...
    'Position',[scrsz(1) scrsz(2) scrsz(3) scrsz(4)],...
    'MenuBar','none',...
    'Toolbar','none',...
    'units','normalized',...
    'Interruptible','on',...
    'NumberTitle','off',...
    'DockControls','off',...
    'Name','PID-Reglerentwurf',...
    'Resize','off',...
    'DeleteFcn','closereq',...
    'HandleVisibility','on',...
    'ButtonDownFcn','',...
    'Color',grey95,...
    'Tag','pid.main');
movegui(handles.pid.entwurf.main,'center');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Toolbar setzen %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.toolbar = uitoolbar(handles.pid.entwurf.main);

[X,~,alpha] = imread('file_print.png');
icon_print = double(X)/256/256;
icon_print(~alpha) = NaN;
handles.pid.entwurf.tb.icon.print = uipushtool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_print,...
    'Tag','toggle_print',...
    'TooltipString','Print and Save Plots',...
    'ClickedCallback','set_zoom_options(''eventSrc'',''eventData'','''')');

icon_save_regler = iconRead(fullfile('Icons\icon_save_regler.mat'));
handles.pid.entwurf.tb.icon.saveregler = uipushtool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_save_regler,...
    'Tag','toggle_save_regler',...
    'TooltipString','Regler speichern',...
    'ClickedCallback','pid_update(Gruppendaten,options,''savecontr'')');

[X,~,alpha] = imread('tool_pointer.png');
icon_pointer = double(X)/256/256;
icon_pointer(~alpha) = NaN;
handles.pid.entwurf.tb.icon.pointer = uipushtool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_pointer,...
    'Tag','toggle_pointer',...
    'TooltipString','normale Ansicht',...
    'ClickedCallback','set_zoom_options(''eventSrc'',''eventData'','''')');

[X,~,alpha] = imread('tool_hand.png');
icon_hand = double(X)/256/256;
icon_hand(~alpha) = NaN;
handles.pid.entwurf.tb.icon.panon = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_hand,...
    'Tag','toggle_pan on',...
    'TooltipString','Plot bewegen',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'',''pan on'')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'','''')');

icon_zoom_in = iconRead(fullfile('Icons\icon_zoom_in.mat'));
handles.pid.entwurf.tb.icon.zoomin = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_zoom_in,...
    'Tag','toggle_zoom_in',...
    'TooltipString','Zoom In',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom in'')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom off'')');

icon_zoom_out = iconRead(fullfile('Icons\icon_zoom_out.mat'));
handles.pid.entwurf.tb.icon.zoomout = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_zoom_out,...
    'Tag','toggle_zoom_out',...
    'TooltipString','Zoom Out',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom out'')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom off'')');

icon_zoom_off = iconRead(fullfile('Icons\icon_zoom_off.mat'));
handles.pid.entwurf.tb.icon.zoomoff = uipushtool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_zoom_off,...
    'Tag','toggle_zoom_off',...
    'TooltipString','Zoom Off',...
    'ClickedCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom off'')');

icon_zoom_reset = iconRead(fullfile('Icons\icon_zoom_reset.mat'));
handles.pid.entwurf.tb.icon.zoomreset = uipushtool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_zoom_reset,...
    'Tag','toggle_zoom_reset',...
    'TooltipString','Zoom Reset',...
    'ClickedCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom reset'')');

icon_zoom_x_in = iconRead(fullfile('Icons\icon_zoom_x_p.mat'));
handles.pid.entwurf.tb.icon.zoomxin = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_zoom_x_in,...
    'Tag','toggle_zoom_x_in',...
    'TooltipString','Zoom X In',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom x in'')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom off'')');

icon_zoom_x_out = iconRead(fullfile('Icons\icon_zoom_x_m.mat'));
handles.pid.entwurf.tb.icon.zoomxout = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_zoom_x_out,...
    'Tag','toggle_zoom_x_out',...
    'TooltipString','Zoom X Out',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom x out'')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom off'')');

icon_zoom_y_in = iconRead(fullfile('Icons\icon_zoom_y_p.mat'));
handles.pid.entwurf.tb.icon.zoomyin = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_zoom_y_in,...
    'Tag','toggle_zoom_y_in',...
    'TooltipString','Zoom Y In',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom y in'')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom off'')');

icon_zoom_y_out = iconRead(fullfile('Icons\icon_zoom_y_m.mat'));
handles.pid.entwurf.tb.icon.zoomyout = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_zoom_y_out,...
    'Tag','toggle_zoom_y_out',...
    'TooltipString','Zoom Y Out',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom y out'')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'',''zoom off'')');

[X,~,alpha] = imread('tool_data_cursor.png');
icon_cursor = double(X)/256/256;
icon_cursor(~alpha) = NaN;
handles.pid.entwurf.tb.icon.cursor = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_cursor,...
    'Tag','toggle_cursor',...
    'TooltipString','Data Cursor',...
    'Separator','on',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'','''')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'','''')');

[X,~,alpha] = imread('tool_legend.png');
icon_legend = double(X)/256/256;
icon_legend(~alpha) = NaN;
handles.pid.entwurf.tb.icon.legend = uitoggletool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_legend,...
    'Tag','toggle_legend',...
    'TooltipString','Legende einblenden',...
    'OnCallback','set_zoom_options(''eventSrc'',''eventData'','''')',...
    'OffCallback','set_zoom_options(''eventSrc'',''eventData'','''')');

[X,~,alpha] = imread('grid.png');
icon_grid = double(X)/256/256;
icon_grid(~alpha) = NaN;
handles.pid.entwurf.tb.icon.grid = uipushtool(...
    handles.pid.entwurf.toolbar,...
    'CData',icon_grid,...
    'Tag','toggle_grid',...
    'TooltipString','Grid on/off',...
    'ClickedCallback','set_zoom_options(''eventSrc'',''eventData'',''grid'')');

% [X map] = imread(fullfile(matlabroot,'toolbox','matlab','icons',...
%                     'tool_pointer.png'));
% icon_zoom_off = ind2rgb(X,map);
% handles.pid.entwurf.toolbar.icon.zoomoff = uipushtool(...
%     handles.pid.entwurf.toolbar,...
%     'CData',icon_zoom_off,...
%     'TooltipString','Zoom Off',...
%     'ClickedCallback','zoom off, datacursormode off');
% [X map] = imread(fullfile(matlabroot,'toolbox','matlab','icons',...
%                     'tool_dat_cursor.png'));
% icon_data_cursor = ind2rgb(X,map);
% handles.pid.entwurf.toolbar.icon.zoomoff = uipushtool(...
%     handles.pid.entwurf.toolbar,...
%     'CData',icon_data_cursor,...
%     'TooltipString','Data Cursor',...
%     'ClickedCallback','datacursormode on');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% UiContextMenu setzen %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pis.entwurf.uictm = uicontextmenu;
handles.pid.entwurf.uictmgrid = uimenu(handles.pis.entwurf.uictm,'Label','Grid');
handles.pid.entwurf.uictmgridonoff = uimenu(handles.pid.entwurf.uictmgrid,'Label','Grid on/off','Callback','set_zoom_options(''eventSrc'',''eventData'',''grid on/off'')');
handles.pid.entwurf.uictmxgridonoff = uimenu(handles.pid.entwurf.uictmgrid,'Label','XGrid on/off','Callback','set_zoom_options(''eventSrc'',''eventData'',''xgrid on/off'')');
handles.pid.entwurf.uictmygridonoff = uimenu(handles.pid.entwurf.uictmgrid,'Label','YGrid on/off','Callback','set_zoom_options(''eventSrc'',''eventData'',''ygrid on/off'')');   
handles.pid.entwurf.uictmzoom = uimenu(handles.pis.entwurf.uictm,'Label','Gruppendaten','Callback','GD2WS(Gruppendaten)');
handles.pid.entwurf.uictmzoomon = uimenu(handles.pid.entwurf.uictmgrid,'Label','Grid on/off','Callback','set_zoom_options(''eventSrc'',''eventData'',''grid on/off'')');
handles.pid.entwurf.uictmzoomoff = uimenu(handles.pid.entwurf.uictmgrid,'Label','XGrid on/off','Callback','set_zoom_options(''eventSrc'',''eventData'',''xgrid on/off'')');
handles.pid.entwurf.uictmygridonoff = uimenu(handles.pid.entwurf.uictmgrid,'Label','YGrid on/off','Callback','set_zoom_options(''eventSrc'',''eventData'',''ygrid on/off'')');   

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Menue %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.panel.Reglerentwurf = uimenu(...
    'Parent',handles.pid.entwurf.main,...
    'Label','Reglerentwurf',...
    'Callback','pid_init(Gruppendaten,options)');
handles.pid.panel.Robustheitsuntersuchung = uimenu(...
    'Parent',handles.pid.entwurf.main,...
    'Label','Robustheitsuntersuchung',...
    'Callback','pid_init(Gruppendaten,options)');
handles.pid.panel.Diskretisierung = uimenu(...
    'Parent',handles.pid.entwurf.main,...
    'Label','Diskretisierung',...
    'Callback','pid_init(Gruppendaten,options)');
handles.pid.panel.gruppendaten = uimenu(...
    'Parent',handles.pid.entwurf.main,...
    'Label','Gruppendaten',...
    'Enable','on',...
    'Visible','on',...
    'Tag','Gruppendaten');
handles.pid.panel.gd.st2ws = uimenu(...
    'Parent',handles.pid.panel.gruppendaten,...
    'Label','als Struct zum Workspace',...
    'Enable','on',...
    'Visible','on',...
    'Callback','GD2WS(Gruppendaten)',...
    'Tag','GruppendatenWS');
handles.pid.panel.abbrechen = uimenu(...
    'Parent',handles.pid.entwurf.main,...
    'Label','Close',...
    'Callback','closereq');
handles.pid.panel.closeml = uimenu(...
    'Parent',handles.pid.entwurf.main,...
    'Label','Close Matlab',...
    'Callback','exit',...
    'Separator','on',...
    'Accelerator','Q');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Hauptpanel %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Axes für Bode Diagramm %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Betrag Axes %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.bode.mag.axes = axes(...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.05 .65 .5 .3],...
    'HandleVisibility','On',...
    'Tag','bode.mag.axes',...
    'Visible','on',...
    'xscale','log',...
    'DrawMode','fast', ...
    'XLimMode','auto', ...
    'YLimMode','auto',...
    'XTickLabel',[],...
    'UiContextMenu',handles.pis.entwurf.uictm);
set(get(handles.pid.entwurf.bode.mag.axes,'Xlabel'),...
    'String','');
set(get(handles.pid.entwurf.bode.mag.axes,'Ylabel'),...
    'String','Betrag (dB)');
set(get(handles.pid.entwurf.bode.mag.axes,'Title'),...
    'String','Bodediagramm offener Regelkreis');
handles.pid.entwurf.bode.mag.nulldb = line([0.000001 100000],[0 0],...
    'LineStyle','--',...
    'Color','k',...
    'LineWidth',1.5,...
    'Parent',handles.pid.entwurf.bode.mag.axes);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Phase Axes %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.bode.phase.axes = axes(...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.05 .3 .5 .3],...
    'HandleVisibility','On',...
    'Tag','bode.phase.axes',...
    'Visible','on',...
    'xscale','log',...
    'DrawMode','fast', ...
    'XLimMode','auto', ...
    'YLimMode','auto');
set(get(handles.pid.entwurf.bode.phase.axes,'Xlabel'),...
    'String','Frequenz (rad/sec)');
set(get(handles.pid.entwurf.bode.phase.axes,'Ylabel'),...
    'String','Phase (Grad)');
set(get(handles.pid.entwurf.bode.phase.axes,'Title'),...
    'String','');
handles.pid.entwurf.bode.phase.minus180 = line([0.000001 100000],[-180 -180],...
    'LineStyle','--',...
    'Color','k',...
    'LineWidth',1.5,...
    'Parent',handles.pid.entwurf.bode.phase.axes);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Axes für Sprungantworten w auf x %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.clw2x.axes = axes(...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.05 .65 .5 .3],...
    'HandleVisibility','On',...
    'Tag','clw2x.axes',...
    'Visible','on',...
    'xscale','linear',...
    'DrawMode','fast', ...
    'XLim',[-0.2 1.5],...
    'XLimMode','auto', ...
    'YLimMode','auto',...
    'XTickLabel',[]);
set(get(handles.pid.entwurf.clw2x.axes,'Xlabel'),...
    'String','');
set(get(handles.pid.entwurf.clw2x.axes,'Ylabel'),...
    'String','Amplitude');
set(get(handles.pid.entwurf.clw2x.axes,'Title'),...
    'String','Führungssprungantwort w auf x');
line([0 1000],[0 0],...
    'LineStyle','--',...
    'Color','k',...
    'LineWidth',1.5,...
    'Parent',handles.pid.entwurf.clw2x.axes);
line([0 1000],[1 1],...
    'LineStyle','-',...
    'Color',Red,...
    'LineWidth',1.5,...
    'Parent',handles.pid.entwurf.clw2x.axes);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Axes für Sprungantworten w auf y %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.clw2y.axes = axes(...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.05 .3 .5 .3],...
    'HandleVisibility','On',...
    'Tag','clw2y.axes',...
    'Visible','on',...
    'xscale','linear',...
    'DrawMode','fast', ...
    'XLimMode','auto', ...
    'YLimMode','auto');
set(get(handles.pid.entwurf.clw2y.axes,'Xlabel'),...
    'String','Zeit (sec)');
set(get(handles.pid.entwurf.clw2y.axes,'Ylabel'),...
    'String','Amplitude');
set(get(handles.pid.entwurf.clw2y.axes,'Title'),...
    'String','Führungssprungantwort w auf y');

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Axes für Sprungantworten z auf x %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.clz2x.axes = axes(...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.05 .65 .5 .3],...
    'HandleVisibility','On',...
    'Tag','clz2x.axes',...
    'Visible','on',...
    'xscale','linear',...
    'DrawMode','fast', ...
    'XLim',[-0.2 1.5],...
    'XLimMode','auto', ...
    'YLimMode','auto',...
    'XTickLabel',[]);
set(get(handles.pid.entwurf.clz2x.axes,'Xlabel'),...
    'String','');
set(get(handles.pid.entwurf.clz2x.axes,'Ylabel'),...
    'String','Amplitude');
set(get(handles.pid.entwurf.clz2x.axes,'Title'),...
    'String','Störsprungantwort z auf x');
line([0 10],[0 0],...
    'LineStyle','-',...
    'Color',Red,...
    'LineWidth',1.5,...
    'Parent',handles.pid.entwurf.clz2x.axes);

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Axes für Sprungantworten z auf y %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.clz2y.axes = axes(...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.05 .3 .5 .3],...
    'HandleVisibility','On',...
    'Tag','clz2y.axes',...
    'Visible','on',...
    'xscale','linear',...
    'DrawMode','fast', ...
    'XLimMode','auto', ...
    'YLimMode','auto');
set(get(handles.pid.entwurf.clz2y.axes,'Xlabel'),...
    'String','Zeit (sec)');
set(get(handles.pid.entwurf.clz2y.axes,'Ylabel'),...
    'String','Amplitude');
set(get(handles.pid.entwurf.clz2y.axes,'Title'),...
    'String','Störsprungantwort z auf y');

set(handles.pid.entwurf.clz2x.axes,'Visible','off');
set(allchild(handles.pid.entwurf.clz2x.axes),'Visible','off');
set(handles.pid.entwurf.clz2y.axes,'Visible','off');
set(allchild(handles.pid.entwurf.clz2y.axes),'Visible','off');
set(handles.pid.entwurf.clw2x.axes,'Visible','off');
set(allchild(handles.pid.entwurf.clw2x.axes),'Visible','off');
set(handles.pid.entwurf.clw2y.axes,'Visible','off');
set(allchild(handles.pid.entwurf.clw2y.axes),'Visible','off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Popup Plot Typ %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
listItems = {'Bode Diagramm',...
            'Führungssprungantworten',...
            'Störsprungantworten'};
handles.pid.entwurf.plot.popup.panel = uipanel(...
    'Title','Plot',...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.575 .925 .135 .07],...
    'Visible','on',...
    'Tag','plot.popup.panel',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'FontWeight','bold');
handles.pid.entwurf.plot.popup = uicontrol(...
    'Style','popup',...
    'parent',handles.pid.entwurf.plot.popup.panel,...
    'units','normalized',...
    'FontUnits','normalized',...
    'Position',[.05 .05 .85 .85],...
    'Visible','on',...
    'Tag','plot.popup',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'String', listItems,...
    'FontWeight','bold',...
    'Callback','pid_update(Gruppendaten,options,''typ_plot'')');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Popup Regler Typ %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
listItems = {'P',...
            'I',...
            'PI',...
            'PD',...
            'PID'};
handles.pid.entwurf.controller.popup.panel = uipanel(...
    'Title','Typ',...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.72 .925 .1 .07],...
    'Visible','on',...
    'Tag','controller.popup.panel',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'FontWeight','bold');
handles.pid.entwurf.controller.popup = uicontrol(...
    'Style','popup',...
    'parent',handles.pid.entwurf.controller.popup.panel,...
    'units','normalized',...
    'Position',[.05 .05 .85 .85],...
    'Visible','on',...
    'Tag','controller.popup',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'String', listItems,...
    'FontWeight','bold',...
    'Callback','pid_update(Gruppendaten,options,''typ_pid'')');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Table PID-Performance %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Panel Performance %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.performance.panel = uipanel(...
    'Title','PID Performance',...
    'units','normalized',...
    'Position',[.675 .01 .3 .35],...
    'parent',handles.pid.entwurf.main,...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Table Performance %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.performance.PID.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','PID',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold',...
    'position',[0.5 0.9 .25 .05]);
handles.pid.entwurf.performance.PIDTuned.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','PID Tuned',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold',...
    'position',[0.75 0.9 .25 .05]);
handles.pid.entwurf.performance.Bodediagramm.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','Bodediagramm:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold',...
    'position',[0.05 0.85 .45 .05]);
handles.pid.entwurf.performance.GM.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','Amplituden Reserve [dB]:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.8 .45 .05]);
handles.pid.entwurf.performance.GM.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.8 .25 .05]);
handles.pid.entwurf.performance.GMTuned.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.75 0.8 .25 .05]);
handles.pid.entwurf.performance.GMF.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','AR Frequenz [rad/s]:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.75 .45 .05]);
handles.pid.entwurf.performance.GMF.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.75 .25 .05]);
handles.pid.entwurf.performance.GMFTuned.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.75 0.75 .25 .05]);
handles.pid.entwurf.performance.PM.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','Phasenreserve [°]:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.7 .45 .05]);
handles.pid.entwurf.performance.PM.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.7 .25 .05]);
handles.pid.entwurf.performance.PMTuned.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.75 0.7 .25 .05]);
handles.pid.entwurf.performance.PMF.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','PR Frequenz [rad/s]:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.65 .45 .05]);
handles.pid.entwurf.performance.PMF.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.65 .25 .05]);
handles.pid.entwurf.performance.DM.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','Totzeitreserve [s]:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.6 .45 .05]);
handles.pid.entwurf.performance.DM.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.6 .25 .05]);
handles.pid.entwurf.performance.DMF.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','TR Frequenz [rad/s]:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.55 .45 .05]);
handles.pid.entwurf.performance.DMF.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.55 .25 .05]);
handles.pid.entwurf.performance.Fuehrungssprung.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','Führungssprung w auf x:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold',...
    'position',[0.05 0.5 .45 .05]);
handles.pid.entwurf.performance.clw2xOvershoot.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','Überschwingweite [°]:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.45 .45 .05]);
handles.pid.entwurf.performance.clw2xOvershoot.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.45 .25 .05]);
handles.pid.entwurf.performance.Allgemein.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','Allgemein:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold',...
    'position',[0.05 0.05 .45 .05]);
handles.pid.entwurf.performance.Stabilitaet.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','Stabilität:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.0 .45 .05]);
handles.pid.entwurf.performance.Stabilitaet.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.performance.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.0 .25 .05]);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Table PID-Parameter %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Panel Parameter %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.parameter.panel = uipanel(...
    'Title','PID Parameter',...
    'units','normalized',...
    'Position',[.675 .37 .3 .15],...
    'parent',handles.pid.entwurf.main,...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Table Parameter %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.performance.PID.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.parameter.panel,...
    'units','normalized',...
    'String','PID',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold',...
    'position',[0.5 0.8 .25 .1]);
handles.pid.entwurf.performance.PIDTuned.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.parameter.panel,...
    'units','normalized',...
    'String','PID Tuned',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'FontWeight','bold',...
    'position',[0.75 0.8 .25 .1]);
handles.pid.entwurf.performance.Kp.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.parameter.panel,...
    'units','normalized',...
    'String','Kp:',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.05 0.6 .45 .1]);
handles.pid.entwurf.performance.Kp.Value = uicontrol('style','text',...
    'parent',handles.pid.entwurf.parameter.panel,...
    'units','normalized',...
    'String','',...
    'horiz','left',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.5 0.6 .25 .1]);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ButtonGroup Tune PID %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% handles.pid.entwurf.tune.buttongroup = uipanel(...
%     'units','normalized',...
%     'Visible','on',...
%     'Title','Tune Regler (MATLAB)',...
%     'Tag','tune.popup.panel',...
%     'ForegroundColor',midnightblue,...
%     'BackgroundColor',grey95,...
%     'FontWeight','bold',...
%     'parent',handles.pid.entwurf.main,...
%     'Position',[.675 .01 .3 .06]);
% handles.pid.entwurf.tune.button = uicontrol(...
%     'Style','Radio',...
%     'String','Tune Regler',...
%     'pos',[10 10 250 20],...
%     'parent',handles.pid.entwurf.tune.buttongroup,...
%     'Visible','on',...
%     'HandleVisibility','on',...
%     'Value',0,...
%     'Tag','button.tune',...
%     'callback','pid_update(Gruppendaten,options,''tune'')');
% set(handles.pid.entwurf.tune.button,'Value',0);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ButtonGroup Options Plot %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.plotopts.buttongroup = uipanel(...
    'units','normalized',...
    'Visible','on',...
    'Title','Plot Optionen',...
    'Tag','bode.popup.panel',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'FontWeight','bold',...
    'parent',handles.pid.entwurf.main,...
    'Position',[.05 .01 .5 .2]);
handles.pid.entwurf.plotopts.Bode.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'units','normalized',...
    'String','Bode Diagramm:',...
    'horiz','left',...
    'FontWeight','bold',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.01 0.8 .4 .1]);
handles.pid.entwurf.Gr.button = uicontrol(...
    'Style','Radio',...
    'units','normalized',...
    'String','Gr anzeigen',...
    'position',[0.01 0.625 .4 .1],...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'ForegroundColor',Red,...
    'BackgroundColor',grey95,...
    'Visible','on',...
    'HandleVisibility','on',...
    'Value',0,...
    'Tag','button.Gr',...
    'FontWeight','bold',...
    'callback','pid_update(Gruppendaten,options,''Gr'')');
set(handles.pid.entwurf.Gr.button,'Value',0);
handles.pid.entwurf.Gs.button = uicontrol(...
    'Style','Radio',...
    'units','normalized',...
    'String','Gs anzeigen',...
    'position',[0.01 0.45 0.4 0.1],...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'ForegroundColor',Chocolate1,...
    'BackgroundColor',grey95,...
    'Visible','on',...
    'HandleVisibility','on',...
    'Value',0,...
    'FontWeight','bold',...
    'Tag','button.Gr',...
    'callback','pid_update(Gruppendaten,options,''Gs'')');
set(handles.pid.entwurf.Gs.button,'Value',0);
handles.pid.entwurf.GM.button = uicontrol(...
    'Style','Radio',...
    'units','normalized',...
    'String','Amplitudenreserve anzeigen',...
    'position',[0.01 0.275 0.4 0.1],...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'ForegroundColor',Magenta,...
    'BackgroundColor',grey95,...
    'Visible','on',...
    'HandleVisibility','on',...
    'Value',0,...
    'FontWeight','bold',...
    'Tag','button.GM',...
    'callback','pid_update(Gruppendaten,options,''GM'')');
set(handles.pid.entwurf.Gs.button,'Value',0);
handles.pid.entwurf.PM.button = uicontrol(...
    'Style','Radio',...
    'units','normalized',...
    'String','Phasenreserve anzeigen',...
    'position',[0.01 0.1 0.4 0.1],...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'ForegroundColor',Magenta,...
    'BackgroundColor',grey95,...
    'Visible','on',...
    'HandleVisibility','on',...
    'Value',0,...
    'FontWeight','bold',...
    'Tag','button.PM',...
    'callback','pid_update(Gruppendaten,options,''PM'')');
set(handles.pid.entwurf.Gs.button,'Value',0);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Führungssprungantwort Plot Optionen %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.plotopts.clw2x.Text = uicontrol('style','text',...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'units','normalized',...
    'FontUnits','normalized',...
    'String','Führungssprungantwort:',...
    'horiz','left',...
    'FontWeight','bold',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue,...
    'position',[0.41 0.8 .4 .1]);
handles.pid.entwurf.Tan.button = uicontrol(...
    'Style','Radio',...
    'units','normalized',...
    'FontUnits','normalized',...
    'String','Anregelzeit (Tan) anzeigen',...
    'position',[0.41 0.625 .4 .1],...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'ForegroundColor',Red,...
    'BackgroundColor',grey95,...
    'Visible','on',...
    'HandleVisibility','on',...
    'Value',0,...
    'Tag','button.Gr',...
    'FontWeight','bold',...
    'callback','pid_update(Gruppendaten,options,''Gr'')');
set(handles.pid.entwurf.Tan.button,'Value',0);
handles.pid.entwurf.Taus.button = uicontrol(...
    'Style','Radio',...
    'units','normalized',...
    'FontUnits','normalized',...
    'String','Ausregelzeit (Taus) anzeigen',...
    'position',[0.41 0.45 0.4 0.1],...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'ForegroundColor',Chocolate1,...
    'BackgroundColor',grey95,...
    'Visible','on',...
    'HandleVisibility','on',...
    'Value',0,...
    'FontWeight','bold',...
    'Tag','button.Gr',...
    'callback','pid_update(Gruppendaten,options,''Gs'')');
set(handles.pid.entwurf.Taus.button,'Value',0);
handles.pid.entwurf.Xm.button = uicontrol(...
    'Style','Radio',...
    'units','normalized',...
    'String','Überschwingweite (Xm) anzeigen',...
    'position',[0.41 0.275 0.4 0.1],...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'ForegroundColor',Magenta,...
    'BackgroundColor',grey95,...
    'Visible','on',...
    'HandleVisibility','on',...
    'Value',0,...
    'FontWeight','bold',...
    'Tag','button.GM',...
    'callback','pid_update(Gruppendaten,options,''clw2xPeak'')');
set(handles.pid.entwurf.Xm.button,'Value',0);
handles.pid.entwurf.eb.button = uicontrol(...
    'Style','Radio',...
    'units','normalized',...
    'FontUnits','normalized',...
    'String','bleibende Regeldifferenz (eb) anzeigen',...
    'position',[0.41 0.1 0.4 0.1],...
    'parent',handles.pid.entwurf.plotopts.buttongroup,...
    'ForegroundColor',Magenta,...
    'BackgroundColor',grey95,...
    'Visible','on',...
    'HandleVisibility','on',...
    'Value',0,...
    'FontWeight','bold',...
    'Tag','button.PM',...
    'callback','pid_update(Gruppendaten,options,''PM'')');
set(handles.pid.entwurf.eb.button,'Value',0);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% ButtonGroup Discretize PID %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.discretize.panel = uipanel(...
    'Title','Discretize',...
    'units','normalized',...
    'Visible','off',...
    'Tag','discretize.popup.panel',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'FontWeight','bold',...
    'parent',handles.pid.entwurf.main,...
    'Position',[.65 .925 .15 .07]);
handles.pid.entwurf.discretize.button = uicontrol(...
    'Style','Radio',...
    'String','discretize Controller',...
    'pos',[10 10 150 14],...
    'parent',handles.pid.entwurf.discretize.panel,...
    'Visible','off',...
    'HandleVisibility','on',...
    'Value',0,...
    'Tag','button.tune',...
    'callback','pid_update(Gruppendaten,options,''discretize'')');
set(handles.pid.entwurf.discretize.button,'Value',0);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Parameter Kp %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Kp Panel %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Kp.panel = uipanel(...
    'Title','Kp',...
    'units','normalized',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'FontWeight','bold',...
    'Parent',handles.pid.entwurf.main,...
    'Position',[.575 .8 .4 .075],...
    'Visible','on',...
    'HandleVisibility','on',...
    'Tag','Kp.panel');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Kp Edit %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Kp.edit = uicontrol(...
    'Style','edit',...
    'parent',handles.pid.entwurf.Kp.panel,...
    'units','normalized',...
    'Visible','on',...
    'Tag','Kp.edit',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'String','',...
    'Position',[.01 .1 .2 .8],...
    'FontWeight','bold',...
    'Callback','pid_update(Gruppendaten,options,''controller_param'')',...
    'Enable','off');
Kp_init = get(handles.pid.entwurf.Kp.edit,'Position');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Kp Button Minus %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Kp.button.minus = uicontrol(...
    'Style','pushbutton',...
    'parent',handles.pid.entwurf.Kp.panel,... 
    'units','normalized',...
    'Visible','on',...
    'Tag','Kp.button.minus',...
    'String','<html><center><b>-</b></center>',...
    'FontSize',fontsz_2,...
    'FontWeight','bold',...
    'Position',[Kp_init(1)+Kp_init(3)+0.003 Kp_init(2) .075 Kp_init(4)],...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'Callback','pid_update(Gruppendaten,options,''controller_button'',''Kp_minus'')',...
    'Enable','off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Kp Button Plus %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Kp.button.plus = uicontrol(...
    'Style','pushbutton',...
    'parent',handles.pid.entwurf.Kp.panel,... 
    'units','normalized',...
    'Visible','on',...
    'Tag','Kp.button.plus',...
    'String','<html><center><b>+</b></center>',...
    'FontSize',fontsz_2,...
    'FontWeight','bold',...
    'Position',[Kp_init(1)+Kp_init(3)+0.081 Kp_init(2) .075 Kp_init(4)],...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'Callback','pid_update(Gruppendaten,options,''controller_button'',''Kp_plus'')',...
    'Enable','off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Kp Slider %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Kp Slider axes %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Kp.slider.axes = axes(...
    'Parent',handles.pid.entwurf.Kp.panel,...
    'Position',[Kp_init(1)+Kp_init(3)+0.168 Kp_init(2) .6 Kp_init(4)],...
    'XLim',[0.001 100],...
    'YLim',[-1 1],...
    'XLimMode','manual',...
    'DrawMode','fast',...
    'XScale','log',...
    'Visible','off',...
    'HandleVisibility','On',...
    'Tag','Kp.slider.axes');
Kp_tick = get(handles.pid.entwurf.Kp.slider.axes,'XLim');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Kp Slider lines %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Kp.slider.line = line(...
    'Parent',handles.pid.entwurf.Kp.slider.axes,...
    'Clipping','off',...
    'XData',[Kp_tick(1) Kp_tick(2) NaN Kp_tick(1) Kp_tick(1) NaN Kp_tick(2) Kp_tick(2) NaN],...
    'YData',[0 0 NaN -1 1 NaN -1 1 NaN],...
    'LineWidth',1.25);
handles.pid.entwurf.Kp.slider.marker = line(...
    'Parent',handles.pid.entwurf.Kp.slider.axes,...
    'XData',3,...
    'YData',0,...
    'Tag','Kp.slider.marker',...
    'Color',midnightblue,...
    'MarkerFaceColor',midnightblue,...
    'Marker','s',...
    'MarkerSize',8,...
    'LineWidth',1.25);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Parameter Tn %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tn Panel %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tn.panel = uipanel(...
    'Title','Tn',...
    'units','normalized',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'FontWeight','bold',...
    'Parent',handles.pid.entwurf.main,...
    'Position',[.575 .725 .4 .075],...
    'Visible','on',...
    'HandleVisibility','on',...
    'Tag','Tn.panel');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tn Edit %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tn.edit = uicontrol(...
    'Style','edit',...
    'parent',handles.pid.entwurf.Tn.panel,...
    'units','normalized',...
    'Visible','on',...
    'Tag','Tn.edit',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'String','',...
    'Position',[.01 .1 .2 .8],...
    'FontWeight','bold',...
    'Callback','pid_update(Gruppendaten,options,''controller_param'')',...
    'Enable','off');
Tn_init = get(handles.pid.entwurf.Tn.edit,'Position');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tn Button Minus %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tn.button.minus = uicontrol(...
    'Style','pushbutton',...
    'parent',handles.pid.entwurf.Tn.panel,... 
    'units','normalized',...
    'Visible','on',...
    'Tag','Tn.button.minus',...
    'String','<html><center><b>-</b></center>',...
    'FontSize',fontsz_2,...
    'FontWeight','bold',...
    'Position',[Tn_init(1)+Tn_init(3)+0.003 Tn_init(2) .075 Tn_init(4)],...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'Callback','pid_update(Gruppendaten,options,''controller_button'',''Tn_minus'')',...
    'Enable','off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tn Button Plus %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tn.button.plus = uicontrol(...
    'Style','pushbutton',...
    'parent',handles.pid.entwurf.Tn.panel,... 
    'units','normalized',...
    'Visible','on',...
    'Tag','Tn.button.plus',...
    'String','<html><center><b>+</b></center>',...
    'FontSize',fontsz_2,...
    'FontWeight','bold',...
    'Position',[Tn_init(1)+Tn_init(3)+0.081 Tn_init(2) .075 Tn_init(4)],...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'Callback','pid_update(Gruppendaten,options,''controller_button'',''Tn_plus'')',...
    'Enable','off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tn Slider %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tn Slider axes %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tn.slider.axes = axes(...
    'Parent',handles.pid.entwurf.Tn.panel,...
    'Position',[Tn_init(1)+Tn_init(3)+0.168 Tn_init(2) .6 Tn_init(4)],...
    'XLim',[0.001 100],...
    'YLim',[-1 1],...
    'XLimMode','manual',...
    'DrawMode','fast',...
    'XScale','log',...
    'Visible','on',...
    'HandleVisibility','on',...
    'Tag','Tn.slider.axes');
Tn_tick = get(handles.pid.entwurf.Tn.slider.axes,'XLim');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tn Slider lines %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tn.slider.line = line(...
    'Parent',handles.pid.entwurf.Tn.slider.axes,...
    'Clipping','off',...
    'XData',[Tn_tick(1) Tn_tick(2) NaN Tn_tick(1) Tn_tick(1) NaN Tn_tick(2) Tn_tick(2) NaN],...
    'YData',[0 0 NaN -1 1 NaN -1 1 NaN],...
    'LineWidth',1.25);
handles.pid.entwurf.Tn.slider.marker = line(...
    'Parent',handles.pid.entwurf.Tn.slider.axes,...
    'XData',3,...
    'YData',0,...
    'Tag','Tn.slider.marker',...
    'Color',midnightblue,...
    'MarkerFaceColor',midnightblue,...
    'Marker','s',...
    'MarkerSize',8,...
    'LineWidth',1.25);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Parameter Tv %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tv Panel %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tv.panel = uipanel(...
    'Title','Tv',...
    'units','normalized',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'FontWeight','bold',...
    'Parent',handles.pid.entwurf.main,...
    'Position',[.575 .65 .4 .075],...
    'Visible','on',...
    'HandleVisibility','on',...
    'Tag','Tv.panel');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tv Edit %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tv.edit = uicontrol(...
    'Style','edit',...
    'parent',handles.pid.entwurf.Tv.panel,...
    'units','normalized',...
    'Visible','on',...
    'Tag','Tv.edit',...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'String','',...
    'Position',[.01 .1 .2 .8],...
    'FontWeight','bold',...
    'Callback','pid_update(Gruppendaten,options,''controller_param'')',...
    'Enable','off');
Tv_init = get(handles.pid.entwurf.Tv.edit,'Position');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tv Button Minus %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tv.button.minus = uicontrol(...
    'Style','pushbutton',...
    'parent',handles.pid.entwurf.Tv.panel,... 
    'units','normalized',...
    'Visible','on',...
    'Tag','Tv.button.minus',...
    'String','<html><center><b>-</b></center>',...
    'FontSize',fontsz_2,...
    'FontWeight','bold',...
    'Position',[Tv_init(1)+Tv_init(3)+0.003 Tv_init(2) .075 Tv_init(4)],...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'Callback','pid_update(Gruppendaten,options,''controller_button'',''Tv_minus'')',...
    'Enable','off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tv Button Plus %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tv.button.plus = uicontrol(...
    'Style','pushbutton',...
    'parent',handles.pid.entwurf.Tv.panel,... 
    'units','normalized',...
    'Visible','on',...
    'Tag','Tv.button.plus',...
    'String','<html><center><b>+</b></center>',...
    'FontSize',fontsz_2,...
    'FontWeight','bold',...
    'Position',[Tv_init(1)+Tv_init(3)+0.081 Tv_init(2) .075 Tv_init(4)],...
    'BackgroundColor',grey95,...
    'ForegroundColor',midnightblue',...
    'Callback','pid_update(Gruppendaten,options,''controller_button'',''Tv_plus'')',...
    'Enable','off');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tv Slider %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tv Slider axes %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tv.slider.axes = axes(...
    'Parent',handles.pid.entwurf.Tv.panel,...
    'Position',[Tv_init(1)+Tv_init(3)+0.168 Tv_init(2) .6 Tv_init(4)],...
    'XLim',[0.001 100],...
    'YLim',[-1 1],...
    'XLimMode','manual',...
    'DrawMode','fast',...
    'XScale','log',...
    'Visible','on',...
    'HandleVisibility','on',...
    'Tag','Tv.slider.axes');
Tv_tick = get(handles.pid.entwurf.Tv.slider.axes,'XLim');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Tv Slider lines %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
handles.pid.entwurf.Tv.slider.line = line(...
    'Parent',handles.pid.entwurf.Tv.slider.axes,...
    'Clipping','off',...
    'XData',[Tv_tick(1) Tv_tick(2) NaN Tv_tick(1) Tv_tick(1) NaN Tv_tick(2) Tv_tick(2) NaN],...
    'YData',[0 0 NaN -1 1 NaN -1 1 NaN],...
    'LineWidth',1.25);
handles.pid.entwurf.Tv.slider.marker = line(...
    'Parent',handles.pid.entwurf.Tv.slider.axes,...
    'XData',3,...
    'YData',0,...
    'Tag','Tv.slider.marker',...
    'Color',midnightblue,...
    'MarkerFaceColor',midnightblue,...
    'Marker','s',...
    'MarkerSize',8,...
    'LineWidth',1.25);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Popup Discretize Typ %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
listItems = {'ForwardEuler',...
            'BackwardEuler',...
            'Trapezoidal'};
handles.pid.entwurf.discretize.popup.panel = uipanel(...
    'Title','Discretize method',...
    'parent',handles.pid.entwurf.main,...
    'units','normalized',...
    'Position',[.45 .925 .15 .07],...
    'Visible','off',...
    'Tag','discretize.popup.panel',...
    'ForegroundColor',midnightblue,...
    'BackgroundColor',grey95,...
    'FontWeight','bold');
handles.pid.entwurf.discretize.popup = uicontrol(...
    'Style','popup',...
    'parent',handles.pid.entwurf.discretize.popup.panel,...
    'units','normalized',...
    'Position',[.1 .85 .8 .1],...
    'Visible','off',...
    'Tag','discretize.popup',...
    'BackgroundColor',grey95,...
    'String', listItems,...
    'FontWeight','bold',...
    'Callback','pid_update(Gruppendaten,options,''discretize'')');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% handles speichern %%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
guidata(findobj('Type','figure','-and','Tag','pid.main'),handles);

end