CS112 Scientific Computation Department of Computer Science Wellesley College Interactive Programs Graphical User Interfaces.

Slides:



Advertisements
Similar presentations
Microsoft Expression Web-Illustrated Unit J: Creating Forms.
Advertisements

1 Chapter 8 Objects and Classes Lecture 2 Prepared by Muhanad Alkhalisy.
Why ROOT?. ROOT ROOT: is an object_oriented frame work aimed at solving the data analysis challenges of high energy physics Object _oriented: by encapsulation,
CS112 Scientific Computation Department of Computer Science Wellesley College Geese honk, but they don’t wave Sinusoidal waves.
A graphical user interface (GUI) is a pictorial interface to a program. A good GUI can make programs easier to use by providing them with a consistent.
1 How to create GUI's in MatLAB Rigo Dicochea. 2 Introduction Graphical User Interface (GUI) MatLab provides Graphical User Interface Development Environment(GUIDE)
CS112 Scientific Computation Department of Computer Science Wellesley College Divide, conquer, glue Program design.
Matlab GUIs Making Matlab Interactive. Today’s topics What is a GUI? How does a GUI work? Where do you begin? Ways to build MATLAB GUIs.
Lecture 1: Introduction Lecture series based on the text: Essential MATLAB for Engineers and Scientists By Hahn & Valentine
Chapter 3 Working with Symbols and Interactivity.
Programming a GUI Hanan sedaghat pisheh. For calling GUI, we need a function with no inputs or outputs First We create a m.file m file has the same name.
MATLAB Second Seminar. Previous lesson Last lesson We learnt how to: Interact with MATLAB in the MATLAB command window by typing commands at the command.
Database-Driven Web Sites, Second Edition1 Chapter 8 Processing ASP.NET Web Forms and Working With Server Controls.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
A short intermission about function handles and cell arrays A MATLAB function may be referenced by a handle. >> sphere(100)
Introduction to the Graphical User Interface (GUI) in MATLAB
Matlab GUIs GUIDE.
CS 170 – INTRO TO SCIENTIFIC AND ENGINEERING PROGRAMMING.
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
Introduction to Matlab & Data Analysis
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
© 2011 Delmar, Cengage Learning Chapter 3 Working with Symbols and Interactivity.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
GUI development with Matlab: GUI Front Panel Components 1 GUI front panel components In this section, we will look at -GUI front panel components -Programming.
Introduction to Matlab’s Graphical User Interface (GUI) Type “guide” “Guide” creates interface on a Figure window and code in an M-file. Some hidden code.
function varargout = MovieJoiner(varargin) % MOVIEJOINER M-file for MovieJoiner.fig % MOVIEJOINER, by itself, creates a new MOVIEJOINER or raises the.
Graphical User Interfaces Tonga Institute of Higher Education.
1 Computer Science of Graphics and Games MONT 105S, Spring 2009 Session 20 Graphical User Interface (GUI)
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
1 Chapter Nine Using GUI Objects and the Visual Studio IDE.
Introduction to Matlab & Data Analysis 2015 In this tutorial we will: Build a practical application using GUIDE Learn more about graphical user interface.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Visual Basic Programming Introduction VB is one of the High level language VB has evolved from the BASIC language. BASIC stands for Beginners All-purpose.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Building the Events Components– Lesson 111 Building the Events Components Lesson 11.
SEEM3460 Tutorial GUI in Java. Some Basic GUI Terms Component (Control in some languages) the basic GUI unit something visible something that user can.
GUI development with Matlab: GUI Front Panel Components GUI development with Matlab: Other GUI Components 1 Other GUI components In this section, we will.
Copyright © 2015 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 13 GUI Programming.
Introduction to Matlab  Matlab is a software package for technical computation.  Matlab allows you to solve many numerical problems including - arrays.
CS112 Scientific Computation Department of Computer Science Wellesley College Interactive Programs Graphical User Interfaces.
EGR 115 Introduction to Computing for Engineers
Program design and algorithm development We will consider the design of your own toolbox to be included among the toolboxes already available with your.
EGR 115 Introduction to Computing for Engineers Graphical User Interface Design in MATLAB - Part 2 Monday 24 Nov 2014 EGR 115 Introduction to Computing.
Introduction to Matlab Module #10 Page 1 Introduction to Matlab Module #10 – Creating Graphical User Interfaces Topics 1.Overview of GUI Development using.
CS112 Scientific Computation Department of Computer Science Wellesley College Blind to change More on GUIs.
Lecture (7) Introduction to GUI Eng. Osama Talaat 1.
MATLAB and SimulinkLecture 61 To days Outline Graphical User Interface (GUI) Exercise on this days topics.
PATTERN RECOGNITION LAB 8 TA : Nouf Al-Harbi::
Integrating Components and Dynamic Text Boxes with the Animated Map– Lesson 101 Integrating Components and Dynamic Text Boxes with the Animated Map Lesson.
Visual Basic/ Visual Studio Brandon Large. Connecting to prior knowledge In your notes write down what the two main parts of the computer are. The “software”
Topics Graphical User Interfaces Using the tkinter Module
Graphical User Interface in MATLAB
Chapter Topics 15.1 Graphical User Interfaces
Event loops 16-Jun-18.
Chap 7. Building Java Graphical User Interfaces
More on Graphical User Interfaces
Graphical User Interfaces -- Introduction
Event loops.
Event loops 17-Jan-19.
Event loops 17-Jan-19.
funCTIONs and Data Import/Export
Topics Graphical User Interfaces Using the tkinter Module
Chapter 15: GUI Applications & Event-Driven Programming
Event loops 8-Apr-19.
CSCI N207 Data Analysis Using Spreadsheet
Event loops.
Event loops 19-Aug-19.
Electrical and Computer Engineering Department SUNY – New Paltz
Presentation transcript:

CS112 Scientific Computation Department of Computer Science Wellesley College Interactive Programs Graphical User Interfaces

GUIs15-2 Structures A structure can store multiple values of different types gold.name = 'gold'; gold.type = 'metal'; gold.symbol = 'Au'; gold.atomNum = 79; gold.mbPoints = [ ]; gold.bohrmodel = goldPict; name'gold' type'metal' symbol 'Au' atomNum 79 mbPoints bohrModel structure name field name field value gold

GUIs15-3 Structures make sharing easy function describeElement (element) % shows the properties stored in the input element structure disp(['name of element: ' element.name]); disp(['type of element: ' element.type]); disp(['atomic symbol: ' element.symbol]); disp(['atomic number: ' num2str(element.atomNum)]); disp(['melting point: ' num2str(element.mbPoints(1))... ' degrees Celcius' ]); disp(['boiling point: ' num2str(element.mbPoints(2))... ' degrees Celcius']); imshow(element.bohrModel);

GUIs15-4 Sharing structures >> describeElement(gold) name of element: gold type of element: metal atomic symbol: Au atomic number: 79 melting point: 1064 degrees Celcius boiling point: 2856 degrees Celcius name 'gold' type'metal' symbol 'Au' atomNum 79 mbPoints bohrModel gold

GUIs15-5 Properties of graphics objects All plotting and graphics functions create graphic objects Each graphics object is identified by a unique number call a handle that can be assigned to a variable: p1=plot([0 1 2], [2 1 3]); Graphics objects have properties that control their appearance on the screen and can be viewed with the Property Inspector: inspect(p1)

GUIs15-6 Accessing properties using MATLAB code Graphics object properties can be accessed with the get function: get(object, property) For example, >> get(p1, 'LineWidth'); 0.5

GUIs15-7 Graphics object properties may be set* by...editing the value in the Property Inspector window...specifying the property name and value when creating the graphics object: p1 = plot([0 1 2], [2 1 3], … 'LineWidth', 1);... using the set function: set(object, property, value) >> set(p1, 'LineWidth', 1); * true for any graphics function, e.g. figure, fill, scatter, surf

GUIs15-8 Subfunctions An M-file can only contain one function that can be called from the Command Window or from another code file This function must be placed at the beginning of the file and its name must be the same as the file name Other subfunctions can be defined in an M-File, but can only be called by functions in the same M-File

GUIs15-9 Subfunctions for a ferris wheel movie function ferrisMovie = ferrisWheel % creates and returns a movie of a rotating ferris wheel for frame = 1:36 drawBase; hold on spokeCoords = drawWheel(10.0*frame); drawCars(spokeCoords); ferrisMovie(frame) = getframe; hold off end function drawBase % draw the filled-in base of the ferris wheel function spokeCoords = drawWheel (angle) % draw the spoked wheel at the input angle of rotation and % return the coordinates of the endpoints of the spokes function drawCars (spokeCoords) % draw a car at each location in spokeCoords

GUIs15-10 Graphical User Interface (GUI) For our programs to date, we called a function or script from the Command Window and the program was executed with minimal input from the user GUI-based programs put the user in the driver’s seat through interactions with components of a graphical display

GUIs15-11 MATLABS Graphical User Interface Development Environment (GUIDE)

GUIs15-12 Saving the GUI layout When our energyGUI layout is saved the first time, MATLAB generates two files: energyGUI.fig: Layout Editor window with the developing GUI, which can be modified later by entering >> guide energyGUI.fig energyGUI.m: file that contains code to create the GUI display

GUIs15-13 Functions defined in energyGUI.m energyGUI: top-level function at the beginning of the file that is called from the Command Window. This function initializes the GUI program and opens the GUI window. We will not modify this function energyGUI_OpeningFcn: executed just before the GUI window is made visible. We will modify this function to set up data for the program energyGUI_OutputFcn: returns outputs to the Command Window. We will not modify this function

GUIs15-14 Callback functions For each component, the header of a Callback function is created. These functions are invoked automatically when the user interacts with the corresponding component Invokes closeButton_Callback when clicked by user

GUIs15-15 Inputs to GUI functions hObject is a number, the graphics handle, that uniquely identifies the GUI component and its associated properties eventdata is not used in the current version of MATLAB handles is a structure that contains information that needs to be shared between functions in this file. Initially it contains a field for each GUI component created, using Tag property as name: handles.axes1 handles.sourceMenu handles.sourceToggle handles.titleLabel handles.titleBox handles.widthCheckbox handles.plotButton handles.closeButton handles.figure1 Value of each field is the graphics handle for that component

GUIs15-16 Adding actions function energyGUI_OpeningFcn (hObject, eventdata, handles, varargin) % setup data to use for plotting [handles.years handles.produce handles.consume] = setupEnergy; function sourceToggle_Callback (hObject, eventdata, handles) % use state of toggle button to set text label on button if (get(hObject, 'Value') == 0) set(hObject, 'String', 'produce'); else set(hObject, 'String', 'consume'); end guidata(hObject, handles); copy changes to global handles structure

GUIs15-17 More action function plotButton_Callback (hObject, eventdata, handles) % setup data source requested by user from state of toggle button if (get(handles.sourceToggle, 'Value') == 0) dataSource = handles.produce; else dataSource = handles.consume; end % get index of selected energy source sourceIndex = get(handles.sourceMenu, 'Value'); % use state of checkbox to determine line width linewidth = get(handles.widthCheckbox, 'Value') + 1; % plot the data with the requested properties plot(handles.years, dataSource(sourceIndex, :), 'Linewidth’, linewidth); xlabel('years') ylabel('quadrillion btu') title(get(handles.titleBox, 'String'))

GUIs15-18 Time for you to leave function closeButton_Callback (hObject, eventdata, handles) % close GUI figure window delete(handles.figure1);