Advertisement
Guest User

Untitled

a guest
Oct 3rd, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scilab 11.88 KB | None | 0 0
  1. function SetupGUI()
  2.     exec('berechnung.sce');
  3.     exec('setup_helpWindow.sce');
  4.     exec('setup_constWindow.sce');
  5.     exec('export.sce');
  6.     mainWindow = setup_mainWindow();
  7.     mainWindow.immediate_drawing = "off";
  8.     setup_menubar();
  9.     subWindow_inputs_tab = setup_subWindow_inputs();
  10.     subWindow_button = setup_subWindow_button();
  11.     subWindow_diagramms = setup_subWindow_diagramms();
  12.     tab = createTab("tab");
  13.     mainWindow.immediate_drawing = "on";
  14.     setup_helpWindow();
  15.     setup_constWindow();
  16. endfunction
  17. function [mainWindow_local] = setup_mainWindow() // Settings of the mainwindow
  18.     mainWindow_local = figure( ...
  19.         "dockable", "off", ...
  20.         "infobar_visible", "off", ...
  21.         "toolbar_visible", "off", ...
  22.         "toolbar", "none", ...
  23.         "menubar_visible", "on", ...
  24.         "menubar", "none", ...
  25.         "layout", "none", ...
  26.         "resize", "off", ...
  27.         "visible", "off");
  28.    
  29.     mainWindow_local.figure_id = 1;
  30.     mainWindow_local.background = -2;
  31.     mainWindow_local.color_map = jetcolormap(128);
  32.     mainWindow_local.figure_position = [0 0];
  33.     mainWindow_local.figure_name = gettext("Fahrradsimulator");
  34.     mainWindow_local.axes_size = [1024 600];
  35.     mainWindow_local.immediate_drawing = "on";
  36.     mainWindow_local.visible = "on";
  37. endfunction
  38. function show_helpWindow()
  39.     help_window = get_figure_handle(2);
  40.     help_window.visible = "on";
  41. endfunction
  42. function show_constWindow()
  43.     const_window = get_figure_handle(3);
  44.     const_window.visible = "on";
  45. endfunction
  46. function setup_menubar() // Settings of the menubar
  47.     mainWindow_para = get_figure_handle(1);
  48.     menubar_datei = uimenu(mainWindow_para, "label", "Datei");
  49.     //uimenu(menubar_datei, "label", "Exportieren als PDF", "callback", "export_pdf();");
  50.     //uimenu(menubar_datei, "label", "Exportieren als JPG", "callback", "export_jpg();");
  51.     //uimenu(menubar_datei, "label", "Exportieren als XLS", "callback", "export_xls();");
  52.     uimenu(menubar_datei, "label", "Schließen", "callback", "mainwindow=get_figure_handle(1);delete(mainwindow);", "tag", "close_menu");
  53.     menubar_help = uimenu(mainWindow_para, "label", "Hilfe");
  54.     uimenu(menubar_help, "label", "Hilfe", "callback", "show_helpWindow();", "tag", "help_menu");
  55.     menubar_const = uimenu(mainWindow_para, "label", "Einstellungen");
  56.     uimenu(menubar_const, "label", "Konstanten", "callback", "show_constWindow();", "tag", "const_menu");
  57. endfunction
  58. function subWindow_inputs_tab = setup_subWindow_inputs()
  59.     mainWindow_para = get_figure_handle(1);
  60.     subWindow_inputs_local = uicontrol(mainWindow_para, ...
  61.         "style", "frame", ...
  62.         "position", [0 0 350 600], ...
  63.         "backgroundcolor", [0.9 0.9 0.9], ...
  64.         "layout", "none", ...
  65.         "scrollable", "on");
  66.        
  67.     subWindow_inputs_header = uicontrol(subWindow_inputs_local, "style", "text");
  68.     subWindow_inputs_header.layout = "none";
  69.     subWindow_inputs_header.position = [133 550 100 20];
  70.     subWindow_inputs_header.backgroundcolor = [0.9 0.9 0.9];
  71.     subWindow_inputs_header.fontsize = 14;
  72.     subWindow_inputs_header.fontweight = "bold";
  73.     subWindow_inputs_header.string = "Eingabewerte";
  74.    
  75.     subWindow_inputs_tab = uicontrol(subWindow_inputs_local, ...
  76.         "style", "frame", ...
  77.         "position", [5 0 350 535], ...
  78.         "layout", "border", ...
  79.         "scrollable", "on");
  80.        
  81.     subWindow_inputs_grid = uicontrol(subWindow_inputs_tab, ...
  82.         "style", "frame", ...
  83.         "position", [5 0 350 535], ...
  84.         "backgroundcolor", [1 1 1], ...
  85.         "scrollable", "on", ...
  86.         "layout", "grid");
  87.        
  88.     lay_opt = createLayoutOptions("grid", [21,3]);
  89.     set(subWindow_inputs_grid, "layout_options", lay_opt);
  90.    
  91.     constraints_grid = createConstraints("grid");
  92.                    
  93.     ListeEingaben = list("Masse Fahrrad", "spinner", 15, 5, 50, 0.1, "$kg$", ...
  94.          "Masse Fahrer", "spinner", 75, 40, 150, 0.1, "$kg$", ...
  95.          "Stirnfläche Fahrer", "spinner", 0.4, 0.1, 2 , 0.1, "$m^2$", ...
  96.          "Raddurchmesser", "spinner", 28, 16, 34, 0.5, "$Zoll$", ...
  97.          "Anzahl Speichen", "spinner", 36, 10, 50, 1, "$Stk$", ...
  98.          "Pedalradius", "spinner", 0.18, 0.1, 0.3, 0.01, "$m$", ...
  99.          "Gesamtwirkungsgrad", "spinner", 96, 0, 100, 0.1, "$\%$", ...
  100.          "Fahrradtyp (cw-Wert)", "edit", 999, 999, 999, 0.1, "", ...
  101.          "Zähnezahl vorne", "edit", 999, 999, 999, 1, "", ...
  102.          "Zähnezahl hinten", "edit", 999, 999, 999, 1, "", ...
  103.          "Rollwiderstandszahl", "spinner", 0.01, 0, 0.1, 0.001, "", ...
  104.          "Bodenwerte", "edit", 999, 999, 999, 0.1, "", ...
  105.          "Steigungswinkel", "spinner", 7, 0, 150, 0.1, "$\%$", ...
  106.          "Fahrgeschwindigkeit", "spinner", 6, 1, 30, 0.1, "$m/s$", ...
  107.          "Windgeschwindigkeit", "spinner", 0, 0, 10, 0.1, "$m/s$", ...
  108.          "Windrichtung", "spinner", 180, -180, 180, 1, "$°$", ...
  109.          "Zurückgelegte Strecke", "spinner", 5000, 100, 100000, 1, "$m$", ...
  110.          "Transl. Beschleunigung", "spinner", 2, 0, 10, 0.1, "$m/s^2$", ...
  111.          "Temperatur", "spinner", 293, 253, 313, 0.5, "$K$");
  112.                          
  113.     myList = list(uicontrol);
  114.     k = 0;
  115.     for i = 1:21
  116.         if i == 21 then
  117.             uicontrol(subWindow_inputs_grid, "style", "frame");
  118.             headerline1 = uicontrol(subWindow_inputs_grid, ...
  119.                 "style", "text", ...
  120.                 "layout", "none", ...
  121.                 "string", "Interne Größen", ...
  122.                 "horizontalalignment", "center", ...
  123.                 "fontsize", 12, ...
  124.                 "fontweight", "bold", ...
  125.                 "constraints", constraints_grid);
  126.             uicontrol(subWindow_inputs_grid, "style", "frame");
  127.         elseif i == 15 then
  128.             uicontrol(subWindow_inputs_grid, "style", "frame");
  129.             headline2 = uicontrol(subWindow_inputs_grid, ...
  130.                 "style", "text", ...
  131.                 "layout", "none", ...
  132.                 "string", "Externe Größen", ...
  133.                 "horizontalalignment", "center", ...
  134.                 "fontsize", 12, ...
  135.                 "fontweight", "bold", ...
  136.                 "constraints", constraints_grid);
  137.             uicontrol(subWindow_inputs_grid, "style", "frame");
  138.         else
  139.             k = k + 1;
  140.             myList(3*i-2) = uicontrol(subWindow_inputs_grid, ...
  141.                 "style", "text", ...
  142.                 "layout", "none", ...
  143.                 "string", ListeEingaben((19*7)-(7*k-7)), ...
  144.                 "constraints", constraints_grid);
  145.             if i == 8 then
  146.                 auswahl = [
  147.                     "Harter Beton (1,0)", "#D0D0D0", "#000000";
  148.                     "Kopfsteinpfl. (1,5)", "#FFFFFF", "#000000";
  149.                     "Schlaglöcher (3,0)", "#D0D0D0", "#000000";
  150.                     "Fester Sand (4,0)", "#FFFFFF", "#000000";
  151.                     "Loser Sand (20,0)", "#D0D0D0", "#000000"];
  152.                c = createConstraints("gridbag", [2, 4, 1, 1], [0 0], "both");
  153.                myList(3*i-1)= uicontrol(subWindow_inputs_grid, "style", "popupmenu", ...
  154.                     "constraints", c, ...
  155.                     "margins", [5 5 5 5], ...
  156.                     "tag", ListeEingaben((19*7)-(7*k-1)), ...
  157.                     "string", auswahl, ...
  158.                     "value", 1);
  159.             elseif i == 10 then
  160.                 auswahl = [
  161.                     "14", "#D0D0D0", "#000000";
  162.                     "15", "#FFFFFF", "#000000";
  163.                     "17", "#D0D0D0", "#000000";
  164.                     "20", "#FFFFFF", "#000000";
  165.                     "24", "#D0D0D0", "#000000";
  166.                     "30", "#FFFFFF", "#000000"];
  167.                c = createConstraints("gridbag", [2, 4, 1, 1], [0 0], "both");
  168.                myList(3*i-1)= uicontrol(subWindow_inputs_grid, "style", "popupmenu", ...
  169.                     "constraints", c, ...
  170.                     "margins", [5 5 5 5], ...
  171.                     "tag", ListeEingaben((19*7)-(7*k-1)), ...
  172.                     "string", auswahl, ...
  173.                     "value", 1);
  174.             elseif i == 11 then
  175.                 auswahl = [
  176.                     "30", "#D0D0D0", "#000000";
  177.                     "38", "#FFFFFF", "#000000";
  178.                     "46", "#D0D0D0", "#000000"];
  179.                c = createConstraints("gridbag", [2, 4, 1, 1], [0 0], "both");
  180.                myList(3*i-1)= uicontrol(subWindow_inputs_grid, "style", "popupmenu", ...
  181.                     "constraints", c, ...
  182.                     "margins", [5 5 5 5], ...
  183.                     "tag", ListeEingaben((19*7)-(7*k-1)), ...
  184.                     "string", auswahl, ...
  185.                     "value", 1);
  186.  
  187.             elseif i == 12 then
  188.                 auswahl = [
  189.                     "BMX (1,10)", "#D0D0D0", "#000000";
  190.                     "Tourenrad (1,00)", "#FFFFFF", "#000000";
  191.                     "Rennrad (0,88)", "#D0D0D0", "#000000";
  192.                     "Rekordrad (0,11)", "#FFFFFF", "#000000";
  193.                     "Perf. Rad (0,05)", "#D0D0D0", "#000000"];
  194.                c = createConstraints("gridbag", [2, 4, 1, 1], [0 0], "both");
  195.                myList(3*i-1)= uicontrol(subWindow_inputs_grid, "style", "popupmenu", ...
  196.                     "constraints", c, ...
  197.                     "margins", [5 5 5 5], ...
  198.                     "tag", ListeEingaben((19*7)-(7*k-1)), ...
  199.                     "string", auswahl, ...
  200.                     "value", 1);
  201.             else
  202.               myList(3*i-1) = uicontrol(subWindow_inputs_grid, ...
  203.                     "style", ListeEingaben((19*7)-(7*k-2)), ...
  204.                     "layout", "none", ...
  205.                     "tag", ListeEingaben((19*7)-(7*k-1)), ...
  206.                     "value", ListeEingaben((19*7)-(7*k-3)), ...
  207.                     "min", ListeEingaben((19*7)-(7*k-4)), ...
  208.                     "max", ListeEingaben((19*7)-(7*k-5)), ...
  209.                     "sliderstep", ListeEingaben((19*7)-(7*k-6)), ...
  210.                     "constraints", constraints_grid);
  211.             end
  212.             myList(3*i) = uicontrol(subWindow_inputs_grid, ...
  213.                 "style", "text", ...
  214.                 "layout", "none", ...
  215.                 "string", ListeEingaben((19*7)-(7*k-1)), ...
  216.                 "constraints", constraints_grid);
  217.             if modulo(i,2) == 0 then
  218.                 myList(3*i-2).backgroundcolor = [0.9 0.9 0.9];
  219.                 myList(3*i).backgroundcolor = [0.9 0.9 0.9];
  220.             else
  221.                 myList(3*i-2).backgroundcolor = [0.8 0.8 0.8];
  222.                 myList(3*i).backgroundcolor = [0.8 0.8 0.8];
  223.             end
  224.         end
  225.     end
  226. endfunction
  227. function [subWindow_button] = setup_subWindow_button()
  228.     mainWindow_para = get_figure_handle(1);
  229.     subWindow_button = uicontrol(get_figure_handle(1), ...
  230.         "style", "pushbutton", ...
  231.         "string", "Berechnung starten", ...
  232.         "font", "bold", ...
  233.         "fontsize", 14, ...
  234.         "position", [351 0 672 50]);
  235.     subWindow_button.callback = "Berechnung()";
  236. endfunction
  237. function [subWindow_diagramms_local] = setup_subWindow_diagramms()
  238.     mainWindow_para = get_figure_handle(1);
  239.     subWindow_diagramms_local = uicontrol(mainWindow_para, ...
  240.         "style", "frame", ...
  241.         "position", [351 50 674 532], ...
  242.         "layout", "border", ...
  243.         "tag", "subWindow_diagramms", ...
  244.         "scrollable", "on");
  245. endfunction
  246. function tabs = createTab(uiType)
  247.     subWindow_diagramms_local = findobj("tag", "subWindow_diagramms");
  248.     tabs = uicontrol(subWindow_diagramms_local, "style", uiType, "tag" ,"tab", "constraints", createConstraints("border", "center"));
  249.     tab_aufgabe2 = uicontrol(tabs, "style", "frame", "tag", "tab_aufgabe2", "string", "Rollwiderstandsleistung", "layout", "border");
  250.     tab_ergebnisse = uicontrol(tabs, "style", "frame", "tag", "tab_ergebnisse", "string", "Ergebnisse", "layout", "border");
  251.     subWindow_diagramms_local.visible = "on";
  252. endfunction
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement