Posted By

bfrank on 04/09/11


Tagged

1010


Versions (?)

mygui


 / Published in: MatLab
 

  1. % 10.10 Project
  2. % Spring 2011
  3. % Jackie Simpson and Ben Frank
  4.  
  5. %==========================================================================
  6. % GUI Creation ||
  7. %==========================================================================
  8. function mygui
  9. % This method creates a figure as the GUI to facilitate user interaction
  10. % with the simulation.
  11. global ReactorHeater ReactionHeatingPeriod AmountSolvent_S2
  12. %necessary global variables throughout all functions
  13.  
  14. %==========================================================================
  15. % Purely Aesthetic Stuff ||
  16. %==========================================================================
  17. % Initialization tasks
  18. fh = figure('Name', 'Project OLED Simulation (Prepared by Jackie Simpson and Ben Frank)', ...
  19. 'NumberTitle', 'off', 'Visible', 'on', 'Position', [520, 280, 583, 423]);
  20.  
  21. % Now construct the components
  22.  
  23. %prompt to push a button
  24. prompt = uicontrol(fh,'Style','text',...
  25. 'String','Would you like to run a simulation or automatic optimization?',...
  26. 'BackgroundColor', 'black', 'FontWeight', 'bold', 'FontSize',...
  27. 14.0, 'ForegroundColor', 'white', 'Position',[32, 378, 529, 25]);
  28.  
  29. %bordering frames to make it easier on the eyes to distinguish functions
  30. frame1 = uicontrol(fh, 'Style', 'frame', 'Position', [34,23,273,346]);
  31. frame2 = uicontrol(fh, 'Style', 'frame', 'Position', [306,23,245,346]);
  32.  
  33. %instructions for each option
  34. instruct1 = uicontrol(fh,'Style','text',...
  35. 'String','Input the optimization parameters and simulate the process.',...
  36. 'Position',[47, 329, 237, 31]);
  37.  
  38. instruct2 = uicontrol(fh,'Style','text',...
  39. 'String','...Or let the program automatically find the optimal values.',...
  40. 'Position',[334, 242, 192, 48]);
  41.  
  42.  
  43. % %simulation Panel
  44. % simPanel = uipanel('Parent',fh,'Title','Simulation',...
  45. % 'HighlightColor', 'Red', 'Units', 'normalized','Position',[520, 136, 640, 567]);
  46.  
  47. % three text labels for input fields
  48. label1 = uicontrol(fh, 'Style', 'text', 'String', 'Reactor Heater Output',...
  49. 'Position', [50, 400, 175, 30]);
  50.  
  51.  
  52. label2 = uicontrol(fh, 'Style', 'text', 'String', 'Reactor Heating Period',...
  53. 'Position', [50, 300, 175, 30]);
  54.  
  55.  
  56. label3 = uicontrol(fh, 'Style', 'text', 'String', 'Amount of Solvent',...
  57. 'Position', [50, 200, 175, 30]);
  58.  
  59. align([label1, label2, label3], 'Left', 'Fixed', 5);
  60.  
  61.  
  62. %three corresponding input fields
  63. global field1 field2 field3
  64. field1 = uicontrol(fh,'Style','edit',...
  65. 'BackgroundColor', [0.8, 0.8, 0.8], 'Position',[325, 400, 50, 30]);
  66.  
  67. field2 = uicontrol(fh,'Style','edit',...
  68. 'BackgroundColor', [0.8, 0.8, 0.8], 'Position',[325, 300, 50, 30]);
  69.  
  70. field3 = uicontrol(fh,'Style','edit',...
  71. 'BackgroundColor', [0.8, 0.8, 0.8], 'Position',[325, 200, 50, 30]);
  72.  
  73. %alignment issues
  74. align([field1, field2, field3], 'Left', 'Fixed', 5);
  75. align([label1, field1], 'Fixed', 10, 'Top');
  76. align([label2, field2], 'Fixed', 10, 'Top');
  77. align([label3, field3], 'Fixed', 10, 'Top');
  78.  
  79.  
  80. %simulation button
  81. simButton = uicontrol(fh,'Style','pushbutton','String','Simulate',...
  82. 'BackgroundColor', 'red', 'ForegroundColor', 'white','Position',[100, 40, 116, 40]);
  83.  
  84.  
  85. %optimization button
  86. opButton = uicontrol(fh,'Style','pushbutton','String','Optimize',...
  87. 'BackgroundColor', 'blue', 'ForegroundColor', 'white','Position',[380, 40, 116, 40]);
  88.  
  89.  
  90. %==========================================================================
  91. % Event Handlers ||
  92. %==========================================================================
  93. % Initialization tasks
  94. set(simButton,'Callback',@simCaller)
  95. set(opButton,'Callback',@Optimizer)
  96. %when one of the buttons is pressed, program control shifts to either
  97. %simCaller or Optimizer
  98.  
  99. end %end of main gui flow function

Report this snippet  

You need to login to post a comment.