Commit c3ef19b0 authored by Colin Eles's avatar Colin Eles
Browse files

added form for tweaking the settings of PVS

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/trunk/TableTool@5806 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
parent 3bd4c75d
Loading
Loading
Loading
Loading
+41 −1
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ classdef GUI < handle
        close_pb = [];
        save_ext_pb = [];
        check_pb = [];
        input_pb = [];
        settings_pb = [];
        function_name_control = [];
        function_name_text = [];
        function_inputs_text = [];
@@ -26,6 +28,7 @@ classdef GUI < handle
        edit = 1;
        initialized = 0;
        block_handle = [];
        settings = [];
        % height of header where buttons and text is
        header_height = 100;
        % window size
@@ -80,7 +83,7 @@ classdef GUI < handle
            obj.fig = figure('units','pixels',...
                'position',[0 0 obj.fig_width obj.fig_height],...
                'menubar','none',...
                'name','GUI_1',...
                'name','Table Tool',...
                'numbertitle','off',...
                'resize','on',...
                'Name',get_param(obj.block_handle,'Name'),...
@@ -137,6 +140,22 @@ classdef GUI < handle
                '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));
            
            % Input/Output button
            obj.settings_pb = uicontrol('style','push',...
                'units','pix',...
                'string','Settings',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'callback',@(src,event)settings_call(obj,src,event));
            
            % Expression Name Label
            obj.name_label = uicontrol('style','text',...
                'string','Expression Name',...
@@ -185,6 +204,10 @@ classdef GUI < handle
            
            obj.setPBenable;
            
            
            obj.settings = Settings();
            obj.settings.init();
            
            obj.initialized = 1;
            obj.Data.open = 1;
            obj.Data.fig = obj.fig;
@@ -210,6 +233,8 @@ classdef GUI < handle
            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.input_pb,'Position',[obj.pb_offset*7+obj.pb_width*6,l_fig_height-obj.pb_offset-obj.pb_height,obj.pb_width,obj.pb_height])
            set(obj.settings_pb,'Position',[obj.pb_offset*8+obj.pb_width*7,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]);
@@ -262,6 +287,21 @@ classdef GUI < handle
            fclose(fileid);
        end
        
        %%
        function [] = input_call(object,src,event)
            %da = DAStudio.ModelExplorer
            %dataddg
            modelddg(object.block_handle)
                
            %da.show;
            %da = DAStudio.DiagnosticViewer('test');
        end
        
         %%
        function [] = settings_call(object,src,event)
            object.settings.show;
            
        end
        %% pvs_ext_call
        function [] = pvs_ext_call(object,src,event)
            error = object.check_call;

Settings.m

0 → 100644
+201 −0
Original line number Diff line number Diff line
classdef Settings < handle
    %UNTITLED Summary of this class goes here
    %   Detailed explanation goes here
    
    properties
        % settings
        pvs_includes = [];
        counter_trials = [];
        counter_range = [];
        
        % gui elements
        fig_width = 400;
        fig_height = 300;
        open = 0;
        fig = [];
        button_width = 60;
        button_height = 30;
        button_offset = 10;
        title_height = 30;
        label_height = 30;
        label_width = 75;
        text_offset = 10;
        
        inlude_text = []
        count_text = []
        range_text = []
    end
    
    methods
        
        function obj = Settings()
        end
        
        function [] = init(obj)
            % initialize the default values of the properties
            obj.pvs_includes = [];
            obj.counter_trials = 1000;
            obj.counter_range = 100;
            
        end
        
        function [] = show(obj)
            if (obj.open)
                figure(obj.fig)
            else
                
            obj.fig = figure('units','pixels',...
                'position',[0 0 obj.fig_width obj.fig_height],...
                'menubar','none',...
                'name','Settings',...
                'numbertitle','off',...
                'resize','off',...
                'CloseRequestFcn',@(src,event)close_fig(obj,src,event));
            end
            
            % Ok Button
             uicontrol('style','push',...
                'units','pix',...
                'string','Ok',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,... 
                'Position',[obj.fig_width - obj.button_width*3 - obj.button_offset*3, obj.button_offset, obj.button_width, obj.button_height],...
                'callback',@(src,event)ok_call(obj,src,event));
            
            % Cancel Button
             uicontrol('style','push',...
                'units','pix',...
                'string','Cancel',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'Position',[obj.fig_width - obj.button_width*2 - obj.button_offset*2, obj.button_offset, obj.button_width, obj.button_height],...
                'callback',@(src,event)cancel_call(obj,src,event));
            
            
            % Apply Button
            uicontrol('style','push',...
                'units','pix',...
                'string','Apply',...
                'HorizontalAlign','left',...
                'Parent',obj.fig,...
                'Position',[obj.fig_width - obj.button_width - obj.button_offset, obj.button_offset, obj.button_width, obj.button_height],...
                'callback',@(src,event)apply_call(obj,src,event));
            
            % main label
            uicontrol('style','text',...
                'string','Table Tool Settings',...
                'HorizontalAlign','center',...
                'FontWeight','bold',...
                'Parent',obj.fig,...
                'Position',[0, obj.fig_height-obj.text_offset-obj.title_height, obj.fig_width, obj.title_height],...
                'BackgroundColor',get(obj.fig,'Color'));
            
            panel_height = obj.text_offset*6+obj.label_height*3
            panel_width = obj.fig_width-obj.text_offset*2
            panel = uipanel('Title','PVS',...
                'visible','on',...
                'units','pix',...
                'BackgroundColor',get(obj.fig,'Color'),...
                'Position',[obj.text_offset,obj.fig_height-obj.text_offset-obj.title_height-panel_height,panel_width,panel_height]);
            
            
            % imports label
            uicontrol('style','text',...
                'string','Imports:',...
                'HorizontalAlign','left',...
                'parent',panel,...
                'Position',[obj.text_offset, panel_height-obj.text_offset*3-obj.label_height, obj.label_width, obj.label_height],...
                'BackgroundColor',get(obj.fig,'Color'));
            
            elipse_width = 20;
            % import text box
            uicontrol('style','edit',...
                'units','pix',...
                'Parent',panel,...
                'HorizontalAlign','center',...
                'BackgroundColor',get(obj.fig,'Color'),...
                'Position',[obj.text_offset+obj.label_width, panel_height-obj.text_offset*2-obj.label_height, panel_width - (obj.text_offset*3+obj.label_width+elipse_width), obj.label_height]);
            
            % elipsis button
            uicontrol('style','push',...
                'units','pix',...
                'string','...',...
                'HorizontalAlign','left',...
                'Parent',panel,...
                'Position',[panel_width-elipse_width-obj.text_offset, panel_height-obj.text_offset*2-obj.label_height, elipse_width, obj.label_height],...
                'callback',@(src,event)elipse_call(obj,src,event));
            
            
            
            % count label
            uicontrol('style','text',...
                'string','Test Count:',...
                'HorizontalAlign','left',...
                'parent',panel,...
                'Position',[obj.text_offset, panel_height-obj.text_offset*4-obj.label_height*2, obj.label_width, obj.label_height],...
                'BackgroundColor',get(obj.fig,'Color'));
            
            % count text box
            obj.count_text = uicontrol('style','edit',...
                'units','pix',...
                'Parent',panel,...
                'String',obj.counter_trials,...
                'HorizontalAlign','center',...
                'BackgroundColor',get(obj.fig,'Color'),...
                'Position',[obj.text_offset+obj.label_width, panel_height-obj.text_offset*3-obj.label_height*2, panel_width - (obj.text_offset*2+obj.label_width), obj.label_height]);
            
            
            % range label
            uicontrol('style','text',...
                'string','Test Range:',...
                'HorizontalAlign','left',...
                'parent',panel,...
                'Position',[obj.text_offset, panel_height-obj.text_offset*5-obj.label_height*3, obj.label_width, obj.label_height],...
                'BackgroundColor',get(obj.fig,'Color'));
            
            % range text box
            obj.range_text = uicontrol('style','edit',...
                'units','pix',...
                'Parent',panel,...
                'String',obj.counter_range,...
                'HorizontalAlign','center',...
                'BackgroundColor',get(obj.fig,'Color'),...
                'Position',[obj.text_offset+obj.label_width, panel_height-obj.text_offset*4-obj.label_height*3, panel_width - (obj.text_offset*2+obj.label_width), obj.label_height]);
            
            
            obj.open = 1;
        end
                        %'Position',[0, obj.fig_height-obj.button_offset-obj.title_height, obj.fig_width, obj.title_height],...

        
        
        function [] = close_fig(obj,src,event)
            delete(obj.fig);
            obj.open = 0;
        end
        
        function [] = elipse_call(obj,src,event)
            uigetfile
        end
        
        function [] = apply_call(obj,src,event)
            obj.counter_trials = str2num(get(obj.count_text,'String'))
            obj.counter_range = str2num(get(obj.range_text,'String'))

        end
        
        function [] = cancel_call(obj,src,event)
            obj.close_fig([],[]);
        end
        
        
        function [] = ok_call(obj,src,event)
            obj.apply_call([],[]);
            obj.close_fig([],[]);
            
        end
       
    end
    
end
+7 −39
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ switch Action,
    case 'Copy',
        blockHandleTTTopMask = orig_gcbh;
        LocalCopyBlockFcn(blockHandleTTTopMask);
        
        DAStudio.ModelExplorer
        
    otherwise,
        DAStudio.error('Simulink:dialog:UnknownAction',Action);
@@ -34,11 +34,7 @@ function LocalCopyBlockFcn(blockHandleTTTopMask)
    data = get(blockHandleTTTopMask,'UserData')
    if(~isempty(data))
        data_new = data.clone(blockHandleTTTopMask);  
    %    gui_new = copy(gui,blockHandleTTTopMask)
    %    gui_new.function_name_text = get_param(blockHandleTTTopMask,'Name');
    %    gui_new.fig = [];
    %    gui_new.block_handle = blockHandleTTTopMask;
    % TEMPORARY SOLUTION
  
        set_param(blockHandleTTTopMask,'UserData',data_new)
    end
end
@@ -66,17 +62,6 @@ function LocalOpenBlockFcn(blockHandleTTTopMask)
        data = Data();
        data.init();

%         gui.block_handle = blockHandleTTTopMask;
%         if ishghandle(gui.fig)
%             set(gui.fig,'Visible','on')
%             figure(gui.fig)
%            %gui.init(); 
% %           gui.reset_wh();
% %            gui.draw_allgrids();
%         else
%             gui.init();
%         end
       % set_param(gui.fig,'Visible','on')
    else
        if ~data.valid
             errordlg(...
@@ -98,24 +83,7 @@ function LocalOpenBlockFcn(blockHandleTTTopMask)
    
    gui.setData(data)
    gui.init();
%         
%         Grid2 = Grid(2,[]);
%         Grid1 = Grid(1,[]);
%         rGrid = RGrid(Grid1,Grid2);
%         Grid1.set_rGrid(rGrid);
%         Grid2.set_rGrid(rGrid);
%         Grid2.new_Cell;
%         Grid1.new_Cell;
%         
%         gui = GUI(blockHandleTTTopMask);
%         %gui.init();
%         gui.set_grid(Grid2,Grid1,rGrid);
%         gui.init();
%         %gui.reset_wh();
%         %gui.draw_allgrids();
%                         set(Grid2.delete_cell_pb,'Enable','off');
%                         set(Grid1.delete_cell_pb,'Enable','off');
%         
        
        set_param(blockHandleTTTopMask,'UserData',data); 
        set_param(blockHandleTTTopMask, 'UserDataPersistent', 'on');