⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bvqxfigure.m

📁 toolbox of BVQX, This is the access between BV and matlab. It will help you to analysis data from BV
💻 M
📖 第 1 页 / 共 5 页
字号:
        elseif numel(iStr.MinMaxTop) > 2
            iStr.MinMaxTop = iStr.MinMaxTop(1:3);
        else
            iStr.MinMaxTop = [0 1 1];
        end
        
        % start building struct for MATLAB uicontrol() call
        oStr = struct( ...
            'Parent',             iPar, ...
            'Units',              iStr.Units, ...
            'Position',           iPos, ...
            'ButtonDownFcn',      cbclick, ...
            'Callback',           iStr.Callback, ...
            'DeleteFcn',          dfcn, ...
            'Enable',             iStr.Enabled, ...
            'FontAngle',          iStr.FontItalic, ...
            'FontName',           iStr.FontName, ...
            'FontSize',           iStr.FontSize, ...
            'FontWeight',         iStr.FontWeight, ...
            'ForegroundColor',    iCFG, ...
            'HorizontalAlign',    iStr.HAlign, ...
            'Interruptible',      iStr.Interrupts, ...
            'ListboxTop',         iStr.MinMaxTop(3), ...
            'Max',                iStr.MinMaxTop(2), ...
            'Min',                iStr.MinMaxTop(1), ...
            'SelectionHighlight', iStr.Selectable, ...
            'Style',              iRTyp, ...
            'Tag',                utag, ...
            'TooltipString',      iStr.ToolTip, ...
            'UserData',           iStr.UserData, ...
            'Visible',            iVis ...
        );
        if ~isempty(iStr.Value)
            oStr.Value = iStr.Value;
        end
        
        % background color specified ?
        if hasBGColor
            oStr.BackgroundColor = iCBG;
        end
        
        % make images loadable for button and toggle UIControls
        if any(strcmp(iCTyp,{'button', 'toggle'})) && ...
           ~isempty(iStr.Caption)
            
            % caption = filename?
            if ischar(iStr.Caption) && ...
                any(iStr.Caption(:)' == '.') && ...
                exist(iStr.Caption(:)', 'file') == 2
                try
                    oStr.CData = double(imread(iStr.Caption(:)')) / 256;
                    iStr.ImageFile = iStr.Caption(:)';
                    iStr.Caption = '';
                catch
                    warning( ...
                        'BVQXfigure:BadImageFile', ...
                        'Not a valid image file: %s.', ...
                        iStr.Caption(:)' ...
                    );
                end
                
            % binary caption = image
            elseif isnumeric(iStr.Caption) && ...
               ~isempty(iStr.Caption) && ...
                ndims(iStr.Caption) == 3
                oStr.CData = double(iStr.Caption);
                if any(oStr.CData(:) > 1)
                    oStr.CData = oStr.CData ./ 256;
                end
                iStr.ImageData = iStr.Caption;
                iStr.Caption = '';
                
            % otherwise copy caption
            else
                oStr.String = iStr.Caption;
            end
            
        % otherwise simply copy caption
        else
            oStr.String = iStr.Caption;
        end
        
        % set style and do your job
        hOut        = uicontrol(oStr);
        iStr.xtype  = '';
    end
    
    % update UIControl unique counter and make sure we're deleted correctly
    cout = makeobj(uuid, hOut, bvqxfigure_factory.objtypes.uicontrol);
    oStr.MLHandle = hOut;
    
    % uicontext menu
    if ~isempty(iStr.ContextMenu)
        uicm = findobj('Type', 'uicontextmenu', 'Tag', iStr.ContextMenu);
        if ~isempty(uicm)
            try
                set(hOut, 'UIContextMenu', uicm(1));
            catch
                % do nothing
            end
        end
    end
    
    % any Enable-groups ?
    iGroups = splittocell(iStr.EGroups, ',; ', 1);
    for iGroupC = numel(iGroups):-1:1
        iGroup = deblank(iGroups{iGroupC});
        if isrealvarname(iGroup)
            if isfield(bvqxfigures(ihPos).figprops.egroups, iGroup)
                bvqxfigures(ihPos).figprops.egroups.(iGroup)(end + 1) = uuid;
            else
                bvqxfigures(ihPos).figprops.egroups.(iGroup) = uuid;
            end
        else
            iGroups(iGroupC) = [];
        end
    end
    iStr.EGroups = iGroups;
    
    % any RadioGroup ?
    iGroup = iStr.RGroup;
    if ~isempty(iGroup)
        if isfield(bvqxfigures(ihPos).figprops.rgroups, iGroup)
            bvqxfigures(ihPos).figprops.rgroups.(iGroup)(end + 1) = uuid;
        else
            bvqxfigures(ihPos).figprops.rgroups.(iGroup) = uuid;
        end
    end
    
    % any SlideXY-group ?
    iGroup = iStr.SGroup;
    if ~isempty(iGroup)
        if isfield(bvqxfigures(ihPos).figprops.sgroups, iGroup)
            bvqxfigures(ihPos).figprops.sgroups.(iGroup)(end + 1) = uuid;
        else
            bvqxfigures(ihPos).figprops.sgroups.(iGroup) = uuid;
        end
    end
    
    % a page named ?
    iPg  = unique(iStr.Page);
    myVG = deblank(iStr.VGroups);
    if ~isempty(iPg)
        
        % just add the Pages to the VGroups field
        
        % positive page number -> groups: pageno and anypage
        if iPg(1) > 0
            myVG = [myVG sprintf(',UICPage%d', iPg(:)')];
            myVG = [myVG ',UICPage_any'];
            
        % number = -1 -> groups: allpages
        elseif iPg(1) == -1
            myVG = [myVG ',UICPage_all'];
            iStr.Page = [];
            
        % number < -1 or number == 0 , same as no pages -> no groups
        else
            iStr.Page = [];
        end
        
        % set back iStr.VGroups for correct handling
        if ~isempty(myVG) && ...
            myVG(1) == ','
            myVG(1) = [];
        end
        
        % then add to figure's array
        bvqxfigures(ihPos).figprops.pages = ...
            union(bvqxfigures(ihPos).figprops.pages, iStr.Page);
    end
    
    % any Visible-groups (or pages)
    iGroups = splittocell(myVG, ',; ', 1);
    for iGroupC = numel(iGroups):-1:1
        iGroup = deblank(iGroups{iGroupC});
        if isrealvarname(iGroup)
            if isfield(bvqxfigures(ihPos).figprops.vgroups, iGroup)
                bvqxfigures(ihPos).figprops.vgroups.(iGroup)(end+1) = uuid;
            else
                bvqxfigures(ihPos).figprops.vgroups.(iGroup) = uuid;
            end
        else
            iGroups(iGroupC) = [];
        end
    end
    iStr.VGroups = iGroups;
    
    % any valid resize spec
    if numel(iStr.ResizeSpec) ~= 2 || ...
       ~isrealvarname(iStr.ResizeSpec{1}) || ...
       ~isa(iStr.ResizeSpec{2}, 'double') || ...
        numel(iStr.ResizeSpec{2}) ~= 8
        iStr.ResizeSpec = {};
    else
        iStr.ResizeSpec = {iStr.ResizeSpec{1}(:)', iStr.ResizeSpec{2}(:)'};
    end
    
    % complete object represetation
    oObj = makeostruct(bvqxfigure_factory.objtypes.uicontrol);
    oObj.callbacks = iStr.Callbacks;
    oObj.loadprops = iStr;
    oObj.prevprops = get(hOut);
    oObj.timeclick = {0, 0};
    if isfield(oStr, 'progress')
        oObj.uicprops(1).progress = oStr.progress;
    end
    oObj.uicprops(1).xchildren = xchildren;
    bvqxfig_ilup(end + 1) = uuid;
    bvqxfig_mlup(end + 1) = hOut;
    bvqxfig_type(end + 1) = cout.type;
    bvqxfigures(end + 1) = oObj;
    
    % set info to parent object...
    bvqxfigures(ihPos).figprops.lilookup = -1;
    if ~isempty(iStr.ResizeSpec) && ...
       ~isempty(iStr.Tag)
        bvqxfigures(ihPos).figprops.rszuics(end+1) = {cout};
    end
    
    % if progress bar has initial value issue command
    if iRSpec && ...
        strcmp(iCTyp, 'xprogress') && ...
       ~isempty(iStr.Value)
        BVQXfigure(cout, 'ProgressBar', iStr.Value(1));
    
    % if listbox and no line is to be selected
    elseif strcmp(iCTyp, 'listbox') && ...
       ~isempty(iStr.Value) && ...
        iStr.Value(1) == 0
        set(hOut, 'Value', []);
    end
    
    % add to global tag lookup struct
    bvqxfigure_factory.tags.(['UIC_' iStr.Tag]) = cout;
    
    % return appropriate object
    varargout{1} = cout;
    
    
% adding a uimenu object
case {'adduimenu'}
    
    % only valid for figures or UIMenus
    if ~any([bvqxfigure_factory.objtypes.figure, ...
             bvqxfigure_factory.objtypes.uicontextmenu, ...
             bvqxfigure_factory.objtypes.uimenu] == hFigType)
        error( ...
            'BVQXfigure:InvalidObjectType', ...
            'Bad object type (%s) for AddUIMenu(...).', ...
            get(hFigMHnd, 'Type') ...
        );
    end
    
    % test iStr
    if ~isstruct(iStr)
        error( ...
            'BVQXfigure:BadPropertyStruct', ...
            'Uimenu properties must be of type struct.' ...
        );
    end

    % perform some checks on struct
    iStr = checkstruct(iStr, bvqxfigure_factory.optuim);
    if isempty(iStr.Caption)
        error( ...
            'BVQXfigure:BadPropertyStruct', ...
            'Bad uimenu property struct supplied.' ...
        );
    end

    % get new OUID
    uuid = handlenew(bvqxfigure_factory.objtypes.uimenu, bvqxfig_ilup);
    dfcn = sprintf('BVQXfigure(%0.0f,''Delete'');', uuid);

    % use tag from iStr?
    if ~isempty(iStr.Tag) && ...
        numel(iStr.Tag) < 28 && ...
        isrealvarname(iStr.Tag(:)')
        utag = iStr.Tag(:)';
    else
        iStr.Tag = sprintf('UIM_%010.0f', uuid);
        utag = ['BVQXfigure_' iStr.Tag];
    end
    
    % accelerator
    if ~isempty(iStr.Accelerator)
        iStr.Accelerator = iStr.Accelerator(1);
    end
    
    % text color
    if numel(iStr.Color) == 1
        iStr.Color(1:3) = iStr.Color;
    elseif numel(iStr.Color) ~= 3
        iStr.Color = [0, 0, 0];
    end
    iCFG = max(0, min(1, iStr.Color));
    iPos  = iStr.Position;
    
    % any Enable-groups ?
    iGroups = splittocell(iStr.EGroups, ',; ', 1);
    for iGroupC = numel(iGroups):-1:1
        iGroup = deblank(iGroups{iGroupC});
        if isrealvarname(iGroup)
            if isfield(bvqxfigures(ihFPos).figprops.egroups, iGroup)
                bvqxfigures(ihFPos).figprops.egroups.(iGroup)(end + 1) = uuid;
            else
                bvqxfigures(ihFPos).figprops.egroups.(iGroup) = uuid;
            end
        else
            iGroups(iGroupC) = [];
        end
    end
    iStr.EGroups = iGroups;
    
    % any Visible-groups (or pages)
    iGroups = splittocell(iStr.VGroups, ',; ', 1);
    for iGroupC = numel(iGroups):-1:1
        iGroup = deblank(iGroups{iGroupC});
        if isrealvarname(iGroup)
            if isfield(bvqxfigures(ihFPos).figprops.vgroups, iGroup)
                bvqxfigures(ihFPos).figprops.vgroups.(iGroup)(end + 1) = uuid;
            else
                bvqxfigures(ihFPos).figprops.vgroups.(iGroup) = uuid;
            end
        else
            iGroups(iGroupC) = [];
        end
    end
    iStr.VGroups = iGroups;

    % prepare output structure
    oStr = struct( ...
        'Parent',          hFigMHnd, ...
        'Label',           iStr.Caption, ...
        'Accelerator',     iStr.Accelerator, ...
        'Callback',        iStr.Callback, ...
        'Checked',         iStr.Checked, ...
        'DeleteFcn',       dfcn, ...
        'Enable',          iStr.Enabled, ...
        'ForegroundColor', iCFG, ...
        'Separator',       iStr.Separator, ...
        'Tag',             utag, ...
        'UserData',        iStr.UserData, ...
        'Visible',         iStr.Visible);
    if ~isempty(iPos) && ...
       ~isnan(iPos(1)) && ...
       ~isinf(iPos(1))
        oStr.Position = fix(iPos(1));
    end
    
    % create object and fill/update fields as necessary
    hOut = uimenu(oStr);
    cout = makeobj(uuid, hOut, bvqxfigure_factory.objtypes.uimenu);
    oStr.MLHandle = hOut;
    
    % complete object representation
    oObj           = makeostruct(bvqxfigure_factory.objtypes.uimenu);
    oObj.callbacks = {iStr.Callback, '', '', iStr.CallbackDelete};
    oObj.loadprops = iStr;
    oObj.prevprops = get(hOut);
    bvqxfig_ilup(end + 1) = uuid;
    bvqxfig_mlup(end + 1) = hOut;
    bvqxfig_type(end + 1) = cout.type;
    bvqxfigures(end + 1) = oObj;
    
    % finally, add to global tag lookup

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -