From b206bdecb7e590688c856d95f622972e11274cd2 Mon Sep 17 00:00:00 2001
From: Colin Eles <elesc@mcmaster.ca>
Date: Wed, 11 Jan 2012 01:19:30 +0000
Subject: [PATCH] Rename Settings to TTSettings, to avoid conflict with Matlab
 class

git-svn-id: https://groke.mcmaster.ca/svn/grad/colin/trunk/TableTool@8190 57e6efec-57d4-0310-aeb1-a6c144bb1a8b
---
 @GUI/init.m               |   2 +-
 @TTSettings/Settings.m    |  49 ++++++++++++
 @TTSettings/apply_call.m  |  15 ++++
 @TTSettings/cancel_call.m |  13 ++++
 @TTSettings/close_fig.m   |  16 ++++
 @TTSettings/elipse_call.m |  30 +++++++
 @TTSettings/init.m        |  16 ++++
 @TTSettings/ok_call.m     |  17 ++++
 @TTSettings/save.m        |  38 +++++++++
 @TTSettings/setvalues.m   |  20 +++++
 @TTSettings/show.m        | 159 ++++++++++++++++++++++++++++++++++++++
 11 files changed, 374 insertions(+), 1 deletion(-)
 create mode 100644 @TTSettings/Settings.m
 create mode 100644 @TTSettings/apply_call.m
 create mode 100644 @TTSettings/cancel_call.m
 create mode 100644 @TTSettings/close_fig.m
 create mode 100644 @TTSettings/elipse_call.m
 create mode 100644 @TTSettings/init.m
 create mode 100644 @TTSettings/ok_call.m
 create mode 100644 @TTSettings/save.m
 create mode 100644 @TTSettings/setvalues.m
 create mode 100644 @TTSettings/show.m

diff --git a/@GUI/init.m b/@GUI/init.m
index 8c3f1c3..44e552a 100644
--- a/@GUI/init.m
+++ b/@GUI/init.m
@@ -185,7 +185,7 @@ object.setPBenable;
 object.default_prover = object.CVC_const;
 
 
-object.settings = Settings();
+object.settings = TTSettings();
 if isfield(object.Data.settings,'set')
     object.settings.setvalues(object.Data.settings);
 else
diff --git a/@TTSettings/Settings.m b/@TTSettings/Settings.m
new file mode 100644
index 0000000..ec08cf1
--- /dev/null
+++ b/@TTSettings/Settings.m
@@ -0,0 +1,49 @@
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+classdef Settings < handle
+    %UNTITLED Summary of this class goes here
+    %   Detailed explanation goes here
+    
+    properties
+        % settings
+        pvs_includes = [];
+        counter_trials = [];
+        counter_range = [];
+        except = [];
+        
+        % 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;
+        
+        include_text = [];
+        count_text = [];
+        range_text = [];
+        except_check = [];
+    end
+    
+    methods
+        
+        %% Settings
+        %    constructor
+        % inputs:
+        %   none
+        % outputs:
+        %   object:Settings - created object
+        function object = Settings()
+        end
+        
+        
+        
+    end
+    
+end
+
diff --git a/@TTSettings/apply_call.m b/@TTSettings/apply_call.m
new file mode 100644
index 0000000..c50cb3e
--- /dev/null
+++ b/@TTSettings/apply_call.m
@@ -0,0 +1,15 @@
+%% apply_call
+%    callback for apply button, save the settings but do not close
+%    figure.
+% inputs:
+%   object:Settings - current object
+%   src - source of the callback calling
+%   event - event that triggered the callback
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function err = apply_call(object,src,event)
+object.save;
+end
+
diff --git a/@TTSettings/cancel_call.m b/@TTSettings/cancel_call.m
new file mode 100644
index 0000000..ea47f52
--- /dev/null
+++ b/@TTSettings/cancel_call.m
@@ -0,0 +1,13 @@
+%% cancel_call
+%    callback for cancel button, cose figure don't save settings
+% inputs:
+%   object:Settings - current object
+%   src - source of the callback calling
+%   event - event that triggered the callback
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function [] = cancel_call(object,src,event)
+object.close_fig([],[]);
+end
diff --git a/@TTSettings/close_fig.m b/@TTSettings/close_fig.m
new file mode 100644
index 0000000..d764de0
--- /dev/null
+++ b/@TTSettings/close_fig.m
@@ -0,0 +1,16 @@
+%% close_fig
+%    when close button is pressed delete the figure, allow a new
+%    one to be opened
+% inputs:
+%   object:Settings - current object
+%   src - source of the callback calling
+%   event - event that triggered the callback
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function [] = close_fig(object,src,event)
+delete(object.fig);
+object.open = 0;
+end
+
diff --git a/@TTSettings/elipse_call.m b/@TTSettings/elipse_call.m
new file mode 100644
index 0000000..90b198a
--- /dev/null
+++ b/@TTSettings/elipse_call.m
@@ -0,0 +1,30 @@
+%% elipse_call
+%    callback for when the elipses button is pressed, show file
+%    picker, update the textbox of selected files.
+% inputs:
+%   object:Settings - current object
+%   src - source of the callback calling
+%   event - event that triggered the callback
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function [] = elipse_call(object,src,event)
+files = uigetfile('*.pvs','Select pvs files','MultiSelect','on');
+string = [];
+if iscell(files)
+    for i = 1:size(files,2)
+        string = strcat(string,files(i));
+      
+        if i ~= size(files,2)
+            string = strcat(string,', ');
+           
+        end
+    end
+    
+else
+    string = files;
+end
+set(object.include_text,'String',char(string));
+end
+
diff --git a/@TTSettings/init.m b/@TTSettings/init.m
new file mode 100644
index 0000000..867e03a
--- /dev/null
+++ b/@TTSettings/init.m
@@ -0,0 +1,16 @@
+%% init
+%
+% inputs:
+%   object:Settings - current object
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function [] = init(object)
+% initialize the default values of the properties
+object.pvs_includes = [];
+object.counter_trials = 1000;
+object.counter_range = 100;
+object.except = 0;
+end
+
diff --git a/@TTSettings/ok_call.m b/@TTSettings/ok_call.m
new file mode 100644
index 0000000..5b29545
--- /dev/null
+++ b/@TTSettings/ok_call.m
@@ -0,0 +1,17 @@
+
+%% ok_call
+%    save settings and close figure
+% inputs:
+%   object:Settings - current object
+%   src - source of the callback calling
+%   event - event that triggered the callback
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function [] = ok_call(object,src,event)
+if ~(object.save);
+    object.close_fig([],[]);
+end
+
+end
\ No newline at end of file
diff --git a/@TTSettings/save.m b/@TTSettings/save.m
new file mode 100644
index 0000000..c8c9d1d
--- /dev/null
+++ b/@TTSettings/save.m
@@ -0,0 +1,38 @@
+%% save
+%    save the settigns to the object properties, check to ensure
+%    that user input validates.
+% inputs:
+%   object:Settings - current object
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function err = save(object)
+msg = []    ;
+err = 0;
+if isempty(str2num(get(object.count_text,'String')))
+    msg = [msg get(object.count_text,'String') ' is not a valid number'];
+    err = 1;
+else
+    object.counter_trials = str2num(get(object.count_text,'String'));
+end
+
+if isempty(str2num(get(object.range_text,'String')))
+    msg = [msg sprintf('\n') get(object.count_text,'String') ' is not a valid number'];
+    err = 1;
+else
+    object.counter_range = str2num(get(object.range_text,'String'));
+end
+object.pvs_includes = get(object.include_text,'String');
+
+if (get(object.except_check,'value') == get(object.except_check,'Max'))
+    object.except = true;
+else
+    object.except = false;
+end
+
+if err
+    msgbox(msg);
+end
+end
+
diff --git a/@TTSettings/setvalues.m b/@TTSettings/setvalues.m
new file mode 100644
index 0000000..7e5a755
--- /dev/null
+++ b/@TTSettings/setvalues.m
@@ -0,0 +1,20 @@
+%% setvalues
+%    update the object settings based on an inputed structure
+%    containing these desired values
+% inputs:
+%   object:Settings - current object
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function [] = setvalues(object,settings)
+
+object.pvs_includes = settings.inputs;
+object.counter_trials = settings.count;
+object.counter_range = settings.range;
+if ~isfield(settings,'except')
+    settings.except = 0;
+end
+object.except = settings.except;
+end
+
diff --git a/@TTSettings/show.m b/@TTSettings/show.m
new file mode 100644
index 0000000..c1c7311
--- /dev/null
+++ b/@TTSettings/show.m
@@ -0,0 +1,159 @@
+%% show
+%    create the figure to show the gui used to change the settings
+% inputs:
+%   object:Settings - current object
+% outputs:
+%   none
+% Author: Colin Eles elesc@mcmaster.ca
+% Organization: McMaster Centre for Software Certification
+function [] = show(object)
+if (object.open)
+    figure(object.fig);
+else
+    
+    object.fig = figure('units','pixels',...
+        'position',[0 0 object.fig_width object.fig_height],...
+        'menubar','none',...
+        'name','Settings',...
+        'numbertitle','off',...
+        'resize','off',...
+        'CloseRequestFcn',@(src,event)close_fig(object,src,event));
+end
+
+% Ok Button
+uicontrol('style','push',...
+    'units','pix',...
+    'string','Ok',...
+    'HorizontalAlign','left',...
+    'Parent',object.fig,...
+    'Position',[object.fig_width - object.button_width*3 - object.button_offset*3, object.button_offset, object.button_width, object.button_height],...
+    'callback',@(src,event)ok_call(object,src,event));
+
+% Cancel Button
+uicontrol('style','push',...
+    'units','pix',...
+    'string','Cancel',...
+    'HorizontalAlign','left',...
+    'Parent',object.fig,...
+    'Position',[object.fig_width - object.button_width*2 - object.button_offset*2, object.button_offset, object.button_width, object.button_height],...
+    'callback',@(src,event)cancel_call(object,src,event));
+
+
+% Apply Button
+uicontrol('style','push',...
+    'units','pix',...
+    'string','Apply',...
+    'HorizontalAlign','left',...
+    'Parent',object.fig,...
+    'Position',[object.fig_width - object.button_width - object.button_offset, object.button_offset, object.button_width, object.button_height],...
+    'callback',@(src,event)apply_call(object,src,event));
+
+% main label
+uicontrol('style','text',...
+    'string','Table Tool Settings',...
+    'HorizontalAlign','center',...
+    'FontWeight','bold',...
+    'Parent',object.fig,...
+    'Position',[0, object.fig_height-object.text_offset-object.title_height, object.fig_width, object.title_height],...
+    'BackgroundColor',get(object.fig,'Color'));
+
+panel_height = object.text_offset*7+object.label_height*4;
+panel_width = object.fig_width-object.text_offset*2;
+panel = uipanel('Title','PVS',...
+    'visible','on',...
+    'units','pix',...
+    'BackgroundColor',get(object.fig,'Color'),...
+    'Position',[object.text_offset,object.fig_height-object.text_offset-object.title_height-panel_height,panel_width,panel_height]);
+
+
+% imports label
+uicontrol('style','text',...
+    'string','Imports:',...
+    'HorizontalAlign','left',...
+    'parent',panel,...
+    'Position',[object.text_offset, panel_height-object.text_offset*3-object.label_height, object.label_width, object.label_height],...
+    'BackgroundColor',get(object.fig,'Color'));
+
+elipse_width = 20;
+% import text box
+object.include_text = uicontrol('style','edit',...
+    'units','pix',...
+    'Parent',panel,...
+    'String',object.pvs_includes,...
+    'HorizontalAlign','center',...
+    'BackgroundColor',get(object.fig,'Color'),...
+    'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*2-object.label_height, panel_width - (object.text_offset*3+object.label_width+elipse_width), object.label_height]);
+
+% elipsis button
+uicontrol('style','push',...
+    'units','pix',...
+    'string','...',...
+    'HorizontalAlign','left',...
+    'Parent',panel,...
+    'Position',[panel_width-elipse_width-object.text_offset, panel_height-object.text_offset*2-object.label_height, elipse_width, object.label_height],...
+    'callback',@(src,event)elipse_call(object,src,event));
+
+
+
+% count label
+uicontrol('style','text',...
+    'string','Test Count:',...
+    'HorizontalAlign','left',...
+    'parent',panel,...
+    'Position',[object.text_offset, panel_height-object.text_offset*4-object.label_height*2, object.label_width, object.label_height],...
+    'BackgroundColor',get(object.fig,'Color'));
+
+% count text box
+object.count_text = uicontrol('style','edit',...
+    'units','pix',...
+    'Parent',panel,...
+    'String',object.counter_trials,...
+    'HorizontalAlign','center',...
+    'BackgroundColor',get(object.fig,'Color'),...
+    'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*3-object.label_height*2, panel_width - (object.text_offset*2+object.label_width), object.label_height]);
+
+
+% range label
+uicontrol('style','text',...
+    'string','Test Range:',...
+    'HorizontalAlign','left',...
+    'parent',panel,...
+    'Position',[object.text_offset, panel_height-object.text_offset*5-object.label_height*3, object.label_width, object.label_height],...
+    'BackgroundColor',get(object.fig,'Color'));
+
+% range text box
+object.range_text = uicontrol('style','edit',...
+    'units','pix',...
+    'Parent',panel,...
+    'String',object.counter_range,...
+    'HorizontalAlign','center',...
+    'BackgroundColor',get(object.fig,'Color'),...
+    'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*4-object.label_height*3, panel_width - (object.text_offset*2+object.label_width), object.label_height]);
+
+% range label
+uicontrol('style','text',...
+    'string','Exception Output',...
+    'HorizontalAlign','left',...
+    'parent',panel,...
+    'Position',[object.text_offset, panel_height-object.text_offset*6-object.label_height*4, object.label_width, object.label_height],...
+    'BackgroundColor',get(object.fig,'Color'));
+
+
+% range text box
+object.except_check = uicontrol('style','checkbox',...
+    'units','pix',...
+    'Parent',panel,...
+    'HorizontalAlign','center',...
+    'BackgroundColor',get(object.fig,'Color'),...
+    'Position',[object.text_offset+object.label_width, panel_height-object.text_offset*5-object.label_height*4, panel_width - (object.text_offset*2+object.label_width), object.label_height]);
+
+if (object.except)
+    set(object.except_check,'value',get(object.except_check,'Max'));
+else
+    set(object.except_check,'value',get(object.except_check,'Min'));
+
+end
+object.open = 1;
+end
+
+
-- 
GitLab