📄 bvqxfigure.m
字号:
'UserData', '', '', []; ...
'Units', 'char' fieldnames(bvqxfigure_factory.units), 'pixels'; ...
'Visible', 'char', {'on', 'off'}, 'on' ...
};
% valid and default options for uicontrols (for checkstruct)
bvqxfigure_factory.optuic = { ...
'Callback', 'char', 'expression', ''; ...
'CallbackClick', 'char', 'expression', ''; ...
'CallbackDblClick', 'char', 'expression', ''; ...
'CallbackDelete', 'char', 'expression', ''; ...
'Caption', '', '', ''; ...
'ColorBG', 'double', 'noinfnan', []; ...
'ColorFG', 'double', 'noinfnan', []; ...
'ContextMenu', 'char', 'label', ''; ...
'EGroups', 'char', 'deblank', ''; ...
'Enabled', 'char', {'on', 'off'}, 'on'; ...
'FontItalic', 'char', {'normal', 'italique', 'oblique'}, 'normal'; ...
'FontName', 'char', 'nonempty', 'default'; ...
'FontSize', '', '', 10; ...
'FontUnits', 'char', fieldnames(bvqxfigure_factory.funits), 'points'; ...
'FontWeight', 'char', {'light', 'normal', 'demi', 'bold'}, 'normal'; ...
'HAlign', 'char', {'left', 'center', 'right'}, 'center'; ...
'Interrupts', 'char', {'on', 'off'}, 'on'; ...
'MinMaxTop', 'double', 'noinfnan', []; ...
'Page', 'double', 'noinfnan', []; ...
'Position', 'double', 'nonempty', [0, 0, 1, 1]; ...
'RGroup', 'char', 'label', ''; ...
'ResizeSpec', 'cell', '', {}; ...
'Rotation', 'double', 'noinfnan', ''; ...
'SGroup', 'char', 'label', ''; ...
'Selectable', 'char', {'on', 'off'}, 'on'; ...
'SliderStep', 'double', 'noinfnan', []; ...
'Tag', 'char', 'label', ''; ...
'ToolTip', 'char', 'deblank', ''; ...
'Type', 'char', 'label', ''; ...
'UserData', '', '', []; ...
'Units', 'char' fieldnames(bvqxfigure_factory.units), 'pixels'; ...
'VAlign', 'char', {'top', 'middle', 'bottom'}, 'bottom'; ...
'VGroups', 'char', 'deblank', ''; ...
'Value', 'double', '', []; ...
'Visible', 'char', {'on', 'off'}, 'on' ...
};
% valid and default options for uimenus (for checkstruct)
bvqxfigure_factory.optuim = { ...
'Accelerator', 'char', 'nonempty', ''; ...
'Callback', 'char', 'expression', ''; ...
'CallbackDelete', 'char', 'expression', ''; ...
'Caption', 'char', 'nonempty', ''; ...
'Checked', 'char', {'on', 'off'}, 'off'; ...
'Color', 'double', 'noinfnan', []; ...
'EGroups', 'char', 'deblank', ''; ...
'Enabled', 'char', {'on', 'off'}, 'on'; ...
'Interrupts', 'char', {'on', 'off'}, 'on'; ...
'Position', 'double', 'noinfnan', []; ...
'Separator', 'char', {'on', 'off'}, 'off'; ...
'Tag', 'char', 'label', ''; ...
'UserData', '', '', []; ...
'VGroups', 'char', 'deblank', ''; ...
'Visible', 'char', {'on', 'off'}, 'on' ...
};
% valid and default options for uicontextmenus (for checkstruct)
bvqxfigure_factory.optuix = { ...
'Callback', 'char', 'expression', ''; ...
'CallbackDelete', 'char', 'expression', ''; ...
'Interrupts', 'char', {'on', 'off'}, 'on'; ...
'Tag', 'char', 'label', ''; ...
'UserData', '', '', [] ...
};
% display output fields: figure
bvqxfigure_factory.outfig = struct( ...
'CallbackClReq', 'CloseRequestFcn', ...
'CallbackKey', 'KeyPressFcn', ...
'CallbackMDown', 'WindowButtonDownFcn', ...
'CallbackMMove', 'WindowButtonMotionFcn', ...
'CallbackMUp', 'WindowButtonUpFcn', ...
'CallbackResize', 'ResizeFcn', ...
'Color', 'Color', ...
'ContextMenu', 'UIContextMenu', ...
'NormalOrModal', 'WindowStyle', ...
'Resizable', 'Resize', ...
'Title', 'Name', ...
'UserData', 'UserData', ...
'Visible', 'Visible');
% uicontrol
bvqxfigure_factory.outuic = struct( ...
'Callback', 'Callback', ...
'Caption', 'String', ...
'ContextMenu', 'UIContextMenu', ...
'Enabled', 'Enable', ...
'Position', 'Position', ...
'ToolTip', 'TooltipString', ...
'Type', 'Style', ...
'Units', 'Units', ...
'UserData', 'UserData', ...
'Value', 'Value', ...
'Visible', 'Visible');
% uimenu
bvqxfigure_factory.outuim = struct( ...
'Accelerator', 'Accelerator', ...
'Callback', 'Callback', ...
'Caption', 'Label', ...
'Checked', 'Checked', ...
'Children', 'Children', ...
'Enabled', 'Enable', ...
'Separator', 'Separator', ...
'UserData', 'UserData', ...
'Visible', 'Visible');
% uicontextmenu
bvqxfigure_factory.outuix = struct( ...
'Callback', 'Callback', ...
'Children', 'Children', ...
'UserData', 'UserData', ...
'Visible', 'Visible');
% get maximum figure size for each units' name
unitnames = fieldnames(bvqxfigure_factory.units);
for ucount = 1:numel(unitnames)
set(0, 'Units', unitnames{ucount});
bvqxfigure_factory.units.(unitnames{ucount}) = get(0, 'ScreenSize');
end
set(0, 'Units', bvqxfigure_factory.rp_init.Units);
% try to findout what to do with XLinks
if ispc
% for Windows we use explorer.exe
bvqxfigure_factory.linkhandler = {'explorer ',' &'};
else
% on unix/linux systems we search for a suitable browser...
[suczero, sucfound] = system('which mozilla');
if suczero
[suczero, sucfound] = system('which netscape');
end
if suczero
[suczero, sucfound] = system('which konqueror');
end
if suczero
sucfound = '';
end
% if nothing found, disable link handler
if isempty(sucfound)
bvqxfigure_factory.linkhandler=cell(0);
% otherwise set handler up
else
bvqxfigure_factory.linkhandler={[deblank(sucfound) ' '],' &'};
end
end
% create ROOT object, type 1 (ROOT)
I_ROOT = makeobj(1, 0, bvqxfigure_factory.objtypes.root);
bvqxfigure_factory.I_ROOT = I_ROOT;
bvqxfigure_factory.contextobject = I_ROOT;
bvqxfigure_factory.tags.I_ROOT = I_ROOT;
% initialize global variables for figures and lookups
rootobj = makeostruct(bvqxfigure_factory.objtypes.root);
rootobj.loadprops = rootprops;
rootobj.prevprops = rootprops;
bvqxfigures = rootobj;
bvqxfig_ilup = I_ROOT.ihnd;
bvqxfig_mlup = I_ROOT.mhnd;
bvqxfig_type = I_ROOT.type;
% class is init now
bvqxfigure_factory.is_init = true;
end
% no or empty first argument
if nargin < 1 || ...
isempty(varargin{1})
varargout{1} = bvqxfigure_factory.tags.I_ROOT;
return;
end
% initialize output arguments
if nargout > 0
varargout = cell(1, nargout);
end
% for objects
if isa(varargin{1}, 'BVQXfigure') && ...
numel(varargin{1}) == 1
hFigure = varargin{1};
% for numeric input
elseif isa(varargin{1}, 'double') && ...
numel(varargin{1}) == 1 && ...
~isinf(varargin{1}) && ...
~isnan(varargin{1})
% internal handle lookup first
myhnd = varargin{1};
hFigure = [];
ilup = find(bvqxfig_ilup == myhnd);
if ~isempty(ilup)
% handle no longer exists
if ~ishandle(bvqxfig_mlup(ilup(1)))
% remove from lookups and internal field
bvqxfig_ilup(ilup) = [];
bvqxfig_mlup(ilup) = [];
bvqxfig_type(ilup) = [];
bvqxfigures(ilup) = [];
varargout{1} = false;
return;
end
% otherwise make object from it
hFigure = makeobj(myhnd, bvqxfig_mlup(ilup), bvqxfig_type(ilup));
end
% MATLAB handle lookup
if isempty(ilup)
ilup = find(bvqxfig_mlup == myhnd);
if ~isempty(ilup)
% handle no longer exists
if ~ishandle(myhnd)
% remove from lookups and internal field
bvqxfig_ilup(ilup) = [];
bvqxfig_mlup(ilup) = [];
bvqxfig_type(ilup) = [];
bvqxfigures(ilup) = [];
varargout{1} = false;
return;
end
% otherwise make object from it
hFigure = makeobj(bvqxfig_ilup(ilup), myhnd, bvqxfig_type(ilup));
end
end
% special case -> MATLAB handle, child of BVQXfigure object
if isempty(ilup) && ...
ishandle(myhnd)
% check type first
myhtype = get(myhnd, 'Type');
if isfield(bvqxfigure_factory.xobjtypes, myhtype)
% get UserData
pv = get(myhnd, 'UserData');
% if that is an BVQXfigure
if numel(pv) == 1 && ...
isBVQXfigure(pv, 1)
hFigure = pv;
% numeric ID of BVQXfigure
elseif isa(pv, 'double') && ...
numel(pv) == 1 && ...
~isnan(pv) && ...
~isinf(pv)
% try lookup of UserData value in internal handles
ilup = find(bvqxfig_ilup == pv);
if ~isempty(ilup)
hFigure = makeobj(pv, bvqxfig_mlup(ilup), bvqxfig_type(ilup));
end
% or in MATLAB handles
if isempty(ilup)
mlup = find(bvqxfig_mlup == pv);
if ~isempty(mlup)
hFigure = makeobj(bvqxfig_ilup(mlup), pv, bvqxfig_type(mlup));
end
end
if isempty(ilup)
if nargin > 1 && ...
ischar(varargin{2}) && ...
any(strcmpi(varargin{2}(:)', {'delete'}))
try
set(pv, 'DeleteFcn', '');
delete(pv);
catch
% do nothing
end
varargout{1} = false;
return;
end
% is deletion requested for object ?
if nargin > 1 && ...
ischar(varargin{2}) && ...
any(strcmp(varargin{2}(:)', {'delete'}))
try
set(myhnd, 'DeleteFcn', '');
delete(myhnd);
catch
% do nothing
end
varargout{1} = false;
return;
end
end
end
end
end
% error if lookup failed
if isempty(hFigure)
if nargin < 2 || ...
~ischar(varargin{2}) || ...
~strcmpi(varargin{2}(:)', 'isvalid')
error( ...
'BVQXfigure:LookupFailed', ...
'Lookup of type double failed.' ...
);
end
varargout{1} = false;
return;
end
% second argument type char and == 'delete'
if nargin > 1 && ...
ischar(varargin{2}) && ...
strcmpi(varargin{2}(:)', 'delete')
% delete all objects found and return
try
BVQXfigure(hFigure, 'delete');
catch
% do nothing
end
return;
end
% re-set varargin{1}
varargin{1} = hFigure;
% char constructor
elseif ischar(varargin{1}) && ...
~isempty(varargin{1})
% is it a file
tchar = varargin{1}(:)';
if exist(tchar, 'file') == 2
% create figure from file then
try
myobj = BVQXfigure(bvqxfigure_factory.I_ROOT, ...
'CreateFigureFromFile', tchar, varargin{2:nargin});
if ~isBVQXfigure(myobj, 1)
error('FIGURE_NOT_CREATED');
end
varargout{1} = myobj;
return;
catch
error( ...
'BVQXfigure:FigureCreationFailed', ...
'Couldn''t create figure from TFG file (%s): %s.', ...
tchar, ...
lasterr ...
);
end
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -