Skip to content
GUI.m 60.8 KiB
Newer Older
Colin Eles's avatar
Colin Eles committed
classdef GUI < handle
   
    
    properties
        % vertical grid
        Grid2 = [];
        
        % horizontal grid
        Grid1 = [];
        %output grid
        Grid0 = [];
        main_fig = [];
        frame = [];
        fig = [];
        scroll_v = [];
        edit_tog = [];
        save_pb = [];
        pvs_pb = [];
        close_pb = [];
        save_ext_pb = [];
        check_pb = [];
        input_pb = [];
        settings_pb = [];
Colin Eles's avatar
Colin Eles committed
        function_name_control = [];
        function_name_text = [];
        function_inputs_text = [];
        function_inputs_control = [];
        edit = 1;
        initialized = 0;
        block_handle = [];
        settings = [];
Colin Eles's avatar
Colin Eles committed
        % height of header where buttons and text is
        header_height = 100;
        % window size
Colin Eles's avatar
Colin Eles committed
        fig_width = 800;
        % space inbetween buttons in header
        pb_offset = 5;
        % width of push buttons in header
        pb_width = 80;
        % height of push buttons in header
        pb_height = 40;
        % width of text boxes
        text_width = 250;
        name_label = [];
        input_label = [];
Colin Eles's avatar
Colin Eles committed
        PVS = [];
Colin Eles's avatar
Colin Eles committed
        pvs_checked = [];
Colin Eles's avatar
Colin Eles committed
        mode = [];
Colin Eles's avatar
Colin Eles committed
        saved = [];
Colin Eles's avatar
Colin Eles committed
    end
    
    methods
        %% GUI
        %   constructor
        % inputs:
        %   h:double - handle to Tabular block in model
Colin Eles's avatar
Colin Eles committed
        %   mode:boolean - the mode of the gui, 1 for simuink, 0 for matlab
Colin Eles's avatar
Colin Eles committed
        % outputs:
Colin Eles's avatar
Colin Eles committed
        %   object:GUI - object that is created
        function object = GUI(h,mode)
            object.block_handle = h;
            object.mode = mode;
Colin Eles's avatar
Colin Eles committed
        end
        
Colin Eles's avatar
Colin Eles committed
        %% setData
        %   set the gui data object based on inputed data structure
        % inputs:
        %   obj:GUI - GUI object
        %   Data:Data - Data object
Colin Eles's avatar
Colin Eles committed
        % outputs:
Colin Eles's avatar
Colin Eles committed
        %   object:GUI - object that is created
        function [] = setData(object,Data)
            object.Data = Data;
            object.Grid0 = Data.Grid0;
            object.Grid1 = Data.Grid1;
            object.Grid2 = Data.Grid2;
            object.pvs_checked = Data.checked;
            object.function_name_text = Data.function_name;
            object.function_inputs_text = Data.function_inputs;
            object.settings = Data.settings;
Colin Eles's avatar
Colin Eles committed
        %% init
        %   initialize the gui
        % inputs:
        %   obj:GUI - GUI object
Colin Eles's avatar
Colin Eles committed
        % outputs:
Colin Eles's avatar
Colin Eles committed
        %   none
        function [] = init(object)
Colin Eles's avatar
Colin Eles committed
            
            % create the handles for the gui objects
            if object.mode == 1
                name = get_param(object.block_handle,'Name');
            elseif object.mode == 0
Colin Eles's avatar
Colin Eles committed
                name = 'Table Tool';
            end
Colin Eles's avatar
Colin Eles committed
            % main figure
            object.fig = figure('units','pixels',...
                'position',[0 0 object.fig_width object.fig_height],...
Colin Eles's avatar
Colin Eles committed
                'menubar','none',...
                'name','Table Tool',...
Colin Eles's avatar
Colin Eles committed
                'numbertitle','off',...
                'resize','on',...
Colin Eles's avatar
Colin Eles committed
                'Name',name,...
                'CloseRequestFcn',@(src,event)close_fig(object,src,event),...
                'ResizeFcn',@(src,event)resize_fig(object,src,event));
Colin Eles's avatar
Colin Eles committed
          
            
            % edit button
            object.edit_tog = uicontrol('style','toggle',...
Colin Eles's avatar
Colin Eles committed
                'units','pix',...
                'string','Edit',...
                'HorizontalAlign','left',...
                'Parent',object.fig,...
                'Value',object.edit,...
                'callback',@(src,event)edit_tog_call(object,src,event));
Colin Eles's avatar
Colin Eles committed
            
            % Save button
            object.save_pb = uicontrol('style','push',...
Colin Eles's avatar
Colin Eles committed
                'units','pix',...
                'string','Save',...
                'HorizontalAlign','left',...
                'Parent',object.fig,...
                'callback',@(src,event)save_call(object,src,event));
Colin Eles's avatar
Colin Eles committed
            
            % Close button
            object.close_pb = uicontrol('style','push',...
Colin Eles's avatar
Colin Eles committed
                'units','pix',...
                'string','Close',...
                'HorizontalAlign','left',...
                'Parent',object.fig,...
                'callback',@(src,event)close_fig(object,src,event));
Colin Eles's avatar
Colin Eles committed
            
            % Save external button
            object.save_ext_pb = uicontrol('style','push',...
Colin Eles's avatar
Colin Eles committed
                'units','pix',...
                'string','Save Ext',...
                'HorizontalAlign','left',...
                'Parent',object.fig,...
                'callback',@(src,event)save_ext_call(object,src,event));
Colin Eles's avatar
Colin Eles committed
            
            % PVS button
            object.pvs_pb = uicontrol('style','push',...
Colin Eles's avatar
Colin Eles committed
                'units','pix',...
                'string','PVS',...
                'HorizontalAlign','left',...
                'Parent',object.fig,...
                'callback',@(src,event)pvs_ext_call(object,src,event));
Colin Eles's avatar
Colin Eles committed
            
            % Check button
            object.check_pb = uicontrol('style','push',...
Colin Eles's avatar
Colin Eles committed
                'units','pix',...
                'string','Check',...
                'HorizontalAlign','left',...
                'Parent',object.fig,...
                'callback',@(src,event)check_call(object,src,event));
Colin Eles's avatar
Colin Eles committed
            
            % Input/Output button
            object.input_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Ports',...
                'HorizontalAlign','left',...
                'Parent',object.fig,...
                'callback',@(src,event)input_call(object,src,event));
            % Settings button
            object.settings_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Settings',...
                'HorizontalAlign','left',...
                'Parent',object.fig,...
                'callback',@(src,event)settings_call(object,src,event));
Colin Eles's avatar
Colin Eles committed
            % Expression Name Label
            object.name_label = uicontrol('style','text',...
Colin Eles's avatar
Colin Eles committed
                'string','Expression Name',...
                'HorizontalAlign','right',...
                'BackgroundColor',get(object.fig,'Color'));
Colin Eles's avatar
Colin Eles committed
            
            % Expression Name Edit box
            object.function_name_control = uicontrol('style','edit',...
Colin Eles's avatar
Colin Eles committed
                'units','pix',...
                'Parent',object.fig,...
Colin Eles's avatar
Colin Eles committed
                'HorizontalAlign','center',...
                'FontWeight','bold',...
                'FontSize',12,...
                'Max',2.0,...
                'BackgroundColor',[1 1 1]);
            
            % input list label
            object.input_label = uicontrol('style','text',...
Colin Eles's avatar
Colin Eles committed
                'string','Inputs',...
                'HorizontalAlign','right',...
                'BackgroundColor',get(object.fig,'Color'));
Colin Eles's avatar
Colin Eles committed
            
            % input list edit box
Loading
Loading full blame...