Skip to content
Settings.m 7.57 KiB
Newer Older
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