Skip to content
GUI.m 54.7 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
        
Colin Eles's avatar
Colin Eles committed
    end
    
    methods
        %% GUI
        %   constructor
        % inputs:
        %   h:double - handle to Tabular block in model
        % outputs;
        %   obj:GUI - object that is created
Colin Eles's avatar
Colin Eles committed
        function obj = GUI(h,mode)
Colin Eles's avatar
Colin Eles committed
            obj.block_handle = h;
Colin Eles's avatar
Colin Eles committed
            obj.mode = mode;
Colin Eles's avatar
Colin Eles committed
        end
        
        function [] = setData(obj,Data)
            obj.Data = Data;
            obj.Grid0 = Data.Grid0;
            obj.Grid1 = Data.Grid1;
            obj.Grid2 = Data.Grid2;
Colin Eles's avatar
Colin Eles committed
            obj.pvs_checked = Data.checked;
            obj.function_name_text = Data.function_name;
            obj.function_inputs_text = Data.function_inputs;
Colin Eles's avatar
Colin Eles committed
            obj.settings = Data.settings;
Colin Eles's avatar
Colin Eles committed
        %% init
        %   initialize the gui
        % inputs:
        %   obj:GUI - GUI object
        % outputs;
        %   none
        function [] = init(obj)
            
            % create the handles for the gui objects
Colin Eles's avatar
Colin Eles committed
            if obj.mode == 1
                name = get_param(obj.block_handle,'Name');
            elseif obj.mode == 0
                name = 'Table Tool';
            end
Colin Eles's avatar
Colin Eles committed
            % main figure
            obj.fig = figure('units','pixels',...
                'position',[0 0 obj.fig_width obj.fig_height],...
                '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,...
Colin Eles's avatar
Colin Eles committed
                'CloseRequestFcn',@(src,event)close_fig(obj,src,event),...
                'ResizeFcn',@(src,event)resize_fig(obj,src,event));
          
            
            % edit button
            obj.edit_tog = uicontrol('style','toggle',...
                'units','pix',...
                'string','Edit',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'Value',obj.edit,...
                'callback',@(src,event)edit_tog_call(obj,src,event));
            
            % Save button
            obj.save_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Save',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'callback',@(src,event)save_call(obj,src,event));
            
            % Close button
            obj.close_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Close',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'callback',@(src,event)close_fig(obj,src,event));
            
            % Save external button
            obj.save_ext_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Save Ext',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'callback',@(src,event)save_ext_call(obj,src,event));
            
            % PVS button
            obj.pvs_pb = uicontrol('style','push',...
                'units','pix',...
                'string','PVS',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'callback',@(src,event)pvs_ext_call(obj,src,event));
            
            % Check button
            obj.check_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Check',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'callback',@(src,event)check_call(obj,src,event));
            
            % Input/Output button
            obj.input_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Ports',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'callback',@(src,event)input_call(obj,src,event));
            
            % Settings button
            obj.settings_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Settings',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'callback',@(src,event)settings_call(obj,src,event));
            
Colin Eles's avatar
Colin Eles committed
            % Expression Name Label
            obj.name_label = uicontrol('style','text',...
                'string','Expression Name',...
                'HorizontalAlign','right',...
                'BackgroundColor',get(obj.fig,'Color'));
            
            % Expression Name Edit box
            obj.function_name_control = uicontrol('style','edit',...
                'units','pix',...
                'Parent',obj.fig,...
                'HorizontalAlign','center',...
                'FontWeight','bold',...
                'FontSize',12,...
                'Max',2.0,...
                'BackgroundColor',[1 1 1]);
            
            % input list label
            obj.input_label = uicontrol('style','text',...
                'string','Inputs',...
                'HorizontalAlign','right',...
                'BackgroundColor',get(obj.fig,'Color'));
            
            % input list edit box
            obj.function_inputs_control = uicontrol('style','edit',...
                'units','pix',...
                'Parent',obj.fig,...
                'HorizontalAlign','center',...
                'FontWeight','bold',...
                'Max',2.0,...
                'FontSize',12,...
                'BackgroundColor',[1 1 1]);
Loading
Loading full blame...