Skip to content
GUI.m 71.4 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 = [];
        function_name_control = [];
        function_name_text = [];
        function_inputs_text = [];
        function_inputs_control = [];
        edit = 1;
        initialized = 0;
        block_handle = [];
        % height of header where buttons and text is
        header_height = 100;
        % window size
        fig_height = 500;
        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 = [];
        
        PVS = [];
        
    end
    
    methods
        %% GUI
        %   constructor
        % inputs:
        %   h:double - handle to Tabular block in model
        % outputs;
        %   obj:GUI - object that is created
        function obj = GUI(h)
            obj.block_handle = h;
        end
        
        %% init
        %   initialize the gui
        % inputs:
        %   obj:GUI - GUI object
        % outputs;
        %   none
        function [] = init(obj)
            
            % create the handles for the gui objects
            
            % main figure
            obj.fig = figure('units','pixels',...
                'position',[0 0 obj.fig_width obj.fig_height],...
                'menubar','none',...
                'name','GUI_1',...
                'numbertitle','off',...
                'resize','on',...
                'Name',get_param(obj.block_handle,'Name'),...
                '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));
            
            % 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]);
            
            % load the function name and inputs
            if (~isempty(obj.function_name_text))
                set(obj.function_name_control,'String',obj.function_name_text);
            end
            if (~isempty(obj.function_inputs_text))
                set(obj.function_inputs_control,'String',obj.function_inputs_text);
            end

            obj.PVS = PVS_checker(obj);
            
            obj.set_command_pos;
            obj.reset_wh();
            obj.draw_allgrids(1);
            obj.initialized = 1;
        end
        
        %% set_command_pos
        %    sets the location of all the command buttons, labels and edit
        %    boxes, places objects at the top of the figure which it
        %    determines by looking at the height of the figure handle
        % inputs:
        %   obj:GUI - current GUI object
        % outputs;
        %   none
        function [] = set_command_pos(obj)
            figpos = get(obj.fig,'Position')
            % figure out the height of the figure
            l_fig_height = figpos(4)
            set(obj.edit_tog,'Position',[obj.pb_offset l_fig_height-obj.pb_offset-obj.pb_height obj.pb_width obj.pb_height])
            set(obj.save_pb,'Position',[obj.pb_offset*2+obj.pb_width,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
            set(obj.close_pb,'Position',[obj.pb_offset*3+obj.pb_width*2,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
            set(obj.save_ext_pb,'Position',[obj.pb_offset*4+obj.pb_width*3,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
            set(obj.check_pb,'Position',[obj.pb_offset*5+obj.pb_width*4,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
            set(obj.pvs_pb,'Position',[obj.pb_offset*6+obj.pb_width*5,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])

            set(obj.name_label,'Position',[obj.pb_offset l_fig_height-obj.pb_offset*3-obj.pb_height-obj.pb_height obj.pb_width obj.pb_height]);
            set(obj.function_name_control,'Position',[obj.pb_offset*2+obj.pb_width l_fig_height-obj.pb_offset*3-obj.pb_height-obj.pb_height obj.text_width obj.pb_height]);
            set(obj.input_label,'Position',[obj.pb_offset*2+obj.pb_width+obj.text_width l_fig_height-obj.pb_offset*3-obj.pb_height-obj.pb_height obj.pb_width obj.pb_height]);
Loading
Loading full blame...