📄 graphgiubrowsegraph.m
字号:
function [varargout] = GraphGIUBrowseGraph(varargin)
% Loads GIU dialog which allows browsing a graph
%
% Receives:
% Graph - structure - (optional) The graph loaded with GraphLoad or WikiGraphLoad
% Returns:
% Path - vector - Path; list of nodes selected by the user.
%
% See Also:
% GraphLoad, GraphGetGraphVariables, WikiGraphLoad, GraphGIUBrowseGraph
%
% Example:
% Path = GraphGIUBrowseGraph(WikiGraph);
% Created:
%
% Lev Muchnik 27/07/2005, lev@topspin.co.il, +972-54-4326496
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
%% Dispatcher
if nargin>0 & ischar(varargin{1}) % INVOKE NAMED SUBFUNCTION OR CALLBACK
try
% [varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
[varargout{1:nargout}] = feval(varargin{:}); % FEVAL switchyard
catch
disp([lasterr ' ( ' varargin{1} ' )' ]);
end
else % Just load:
fig = GraphGIUBrowseGraph('InitGUI');
% uiwait(fig);
if nargout > 0 & ishandle(fig)
varargout{1} = [];
% delete(fig);
elseif nargout > 0
varargout{1} = [];
% elseif ishandle(fig)
% delete (fig);
end
end
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Properties = GetProperties()
Properties = [];
Properties.ControlPanelHeight = 30;
Properties.ButtonPanelHeight = 30;
Properties.PathPanelHeight = 20;
Properties.ButtonSize = [60 17];
Properties.PopupMenuSize = [120 17];
Properties.InterbuttonGap = 10;
Properties.DetailsPanelWidth = 175;
Properties.ScrollBarWidth = 14;
Properties.NodeDetailsListBoxWidth = 200;
Properties.NodeDetailsListBoxGap = 20;
Properties.MaxNumberOfListElements = 500;
Properties.Font = [];
[FilePath FileName] = fileparts(mfilename('fullpath'));
FileName = [FilePath '\' FileName '.mat'];
if exist(FileName,'file')==2
try
Loaded = load(FileName,'-mat');
Fields = fieldnames(Loaded.Properties);
for i = 1 : numel(Fields)
Properties = setfield(Properties,Fields{i},getfield(Loaded.Properties,Fields{i}));
end
catch
end
end
%% Initialize
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function fig = InitGUI
%% Initialize parameters
Properties = GetProperties();
ScreenSize = get(0,'ScreenSize');
FigureSize = [ScreenSize(3)*3/4 ScreenSize(4)*3/4];
FigureSize = round([(ScreenSize(3)-FigureSize(1))/2 (ScreenSize(4)-FigureSize(2))/2 FigureSize(1) FigureSize(2) ]);
set(0,'Units','points');
%% Create Figure;
fig = figure('Units','Points','Position',FigureSize,...
'Tag',['Figure_' mfilename],'DoubleBuffer','on',...
'MenuBar','none','NumberTitle','off','WindowStyle','normal','Resize','on',...
'Color',get(0,'defaultUicontrolBackgroundColor'),'Visible','on',...
'ResizeFcn','GraphGIUBrowseGraph(''Figure_GraphGIUBrowseGraph_ResizeFcn'',gcbo,[],guidata(gcbo));',...
'DeleteFcn','GraphGIUBrowseGraph(''Figure_GraphGIUBrowseGraph_DeleteFcn'',gcbo,[],guidata(gcbo));',...
'Name','Graph Select Dialog'...
);
%
% 'CreateFcn','BAS_MainFigure(''Figure_BrukerAnalysis_CreateFcn'',gcbo,[],guidata(gcbo));',...
%
FigureSize = get(fig,'Position');
Sz = [1 FigureSize(4)-Properties.ControlPanelHeight-1 FigureSize(3)-2 Properties.ControlPanelHeight];
ControlsPanel = uicontrol(fig,'Style','frame','Units','Points','Position',round(Sz),...
'Visible','on','Tag','ControlsPanel_Frame');
Sz = [1 FigureSize(4)-Properties.PathPanelHeight-Properties.ControlPanelHeight-2 FigureSize(3)-2 Properties.PathPanelHeight];
PathPanel = uicontrol(fig,'Style','frame','Units','Points','Position',round(Sz),...
'Visible','on','Tag','PathPanel_Frame');
Sz = get(ControlsPanel,'Position');
Sz = [Sz(3)-Properties.ButtonSize(1)-Properties.InterbuttonGap Sz(2) + (Properties.ControlPanelHeight-Properties.ButtonSize(2))/2 Properties.ButtonSize(1) Properties.ButtonSize(2)];
CloseButton = uicontrol(fig,'Style','pushbutton','Units','Points','Position',round(Sz),...
'Visible','on','Tag','CloseButton_PushButton','String','Close',...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_CloseButton_Click'',gcbo,[],guidata(gcbo));'...
);
Sz = get(ControlsPanel,'Position');
Sz = [Properties.InterbuttonGap Sz(2) + (Properties.ControlPanelHeight-Properties.PopupMenuSize(2))/2 Properties.PopupMenuSize(1) Properties.PopupMenuSize(2)];
SelectedGraphPopup = uicontrol(fig,'Style','popupmenu','Units','Points','Position',round(Sz),...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_VariablesListbox_ButtonDown'',gcbo,[],guidata(gcbo));',...
'Visible','on','Tag','SelectedGraphButton_PushButton','String',GraphGetGraphVariables()...
);
Sz = get(SelectedGraphPopup,'Position');
Sz = [Sz(1)+Sz(3)+1 Sz(2) Properties.ButtonSize(1) Properties.ButtonSize(2)];
VariablesListRefreshPushButton = uicontrol(fig,'Style','pushbutton','Units','Points','Position',round(Sz),...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_VariablesListbox_ButtonDown'',gcbo,[],guidata(gcbo));',...
'Visible','on','Tag','VariablesListRefresh_PushButton','String','Refresh'...
);
Sz = get(ControlsPanel,'Position');
Sz2 = Sz(2) + (Properties.ControlPanelHeight-Properties.PopupMenuSize(2))/2;
Sz = get(VariablesListRefreshPushButton,'Position');
Sz = [Sz(1)+Sz(3)+Properties.InterbuttonGap Sz2 Properties.PopupMenuSize(1) Properties.PopupMenuSize(2)];
SortOrderPopup = uicontrol(fig,'Style','popupmenu','Units','Points','Position',round(Sz),...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_SortOrderSelect_ButtonDown'',gcbo,[],guidata(gcbo));',...
'Visible','on','Tag','SortOrder_Popup','String',{ 'ID', 'Name' }...
);
Sz = get(ControlsPanel,'Position');
Sz2 = Sz(2) + (Properties.ControlPanelHeight-Properties.ButtonSize(2))/2;
Sz = get(SortOrderPopup,'Position');
Sz = [Sz(1)+Sz(3)+Properties.InterbuttonGap Sz2 Properties.ButtonSize(1)*1.5 Properties.ButtonSize(2)];
SortDirectionToggleButton = uicontrol(fig,'Style','togglebutton','Units','Points','Position',round(Sz),...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_SortDirection_ToggleButton'',gcbo,[],guidata(gcbo));',...
'Visible','on','Tag','SortDirection_ToggleButton','String','Now: Ascending' , 'Value',1 ...
);
Sz = get(ControlsPanel,'Position');
Sz2 = Sz(2) + (Properties.ControlPanelHeight-Properties.ButtonSize(2))/2;
Sz = get(SortDirectionToggleButton ,'Position');
Sz = [Sz(1)+Sz(3)+Properties.InterbuttonGap Sz2 Properties.ButtonSize(1) Properties.ButtonSize(2)];
FontSelectPushbutton = uicontrol(fig,'Style','pushbutton','Units','Points','Position',round(Sz),...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_FontSelectSelect_ButtonDown'',gcbo,[],guidata(gcbo));',...
'Visible','on','Tag','FontSelect_Pushbutton','String','Select Font'...
);
Sz = get(FontSelectPushbutton,'Position');
Sz1 = Sz(1)+Sz(3) + Properties.InterbuttonGap;
Sz = get(ControlsPanel,'Position');
Sz = [Sz1 Sz(2) + (Properties.ControlPanelHeight-Properties.PopupMenuSize(2))/2 0.5*Properties.PopupMenuSize(1) Properties.PopupMenuSize(2)];
BrowseDirectionPopup = uicontrol(fig,'Style','popupmenu','Units','Points','Position',round(Sz),...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_BrowseDirectionbox_ButtonDown'',gcbo,[],guidata(gcbo));',...
'Visible','on','Tag','BrowseDirection_Popup ','String',{'direct','inverse','both'}...
);
Sz = get(BrowseDirectionPopup ,'Position');
Sz1 = Sz(1)+Sz(3) + Properties.InterbuttonGap;
Sz = get(ControlsPanel,'Position');
Sz = [Sz1 Sz(2) + (Properties.ControlPanelHeight-Properties.ButtonSize(2))/2 Properties.ButtonSize(1) Properties.ButtonSize(2)];
SearchNodeEdit = uicontrol(fig,'Style','edit','Units','Points','Position',round(Sz),...
'Visible','on','Tag','SearchNode_Edit','String',''...
);
% 'KeyPressFcn','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_SearchNodeEdit_KeyPress'',gcbo,[],guidata(gcbo));',...
Sz = get(SearchNodeEdit,'Position');
Sz1 = Sz(1)+Sz(3) ;
Sz = get(ControlsPanel,'Position');
Sz = [Sz1 Sz(2) + (Properties.ControlPanelHeight-Properties.ButtonSize(2))/2 Properties.ButtonSize(1) Properties.ButtonSize(2)];
SearchNodeButton = uicontrol(fig,'Style','pushbutton','Units','Points','Position',round(Sz),...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_SearchNodePushbutton_ButtonDown'',gcbo,[],guidata(gcbo));',...
'Visible','on','Tag','SearchNode_Button','String','Search'...
);
Sz = get(PathPanel,'Position');
Sz = [FigureSize(3)-Properties.DetailsPanelWidth-1 1 Properties.DetailsPanelWidth FigureSize(4)-Properties.PathPanelHeight-Properties.ControlPanelHeight-4];
DetailsPanel = uicontrol(fig,'Style','frame','Units','Points','Position',round(Sz),...
'Visible','on','Tag','DetailsPanel_Frame');
Sz = get(DetailsPanel,'Position');
Sz = [Sz(1)+1 Sz(2)+Sz(4)/2+1 Sz(3)-3 (Sz(4)-4)/2];
GraphDetailsEdit = uicontrol(fig,'Style','edit','Units','Points','Position',round(Sz),...
'Enable','inactive','HorizontalAlignment','left','Max',2,'Min',0,'String','',...
'Visible','on','Tag','GraphDetails_Edit');
Sz = get(DetailsPanel,'Position');
Sz = [Sz(1)+1 2 Sz(3)-3 (Sz(4)-4)/2];
NodeDetailsEdit = uicontrol(fig,'Style','edit','Units','Points','Position',round(Sz),...
'Enable','inactive','HorizontalAlignment','left','Max',2,'Min',0,'String','',...
'Visible','on','Tag','NodeDetails_Edit');
if isempty(Properties.Font)
Properties.Font = GetFont(NodeDetailsEdit);
end
Sz = get(DetailsPanel,'Position');
Sz = [1 1 FigureSize(3)-3-Sz(3) Properties.ScrollBarWidth];
PathDetailsSlider = uicontrol(fig,'Style','slider','Units','Points','Position',round(Sz),...
'Callback','GraphGIUBrowseGraph(''GraphGIUBrowseGraph_PathDetailsSlider_ButtonDown'',gcbo,[],guidata(gcbo));',...
'SliderStep',[1 1],...
'Visible','on','Tag','PathDetails_Slider');
Sz = get(DetailsPanel,'Position');
Sz = [1 Properties.ScrollBarWidth+1 FigureSize(3)-3-Sz(3) Sz(4)-Properties.ScrollBarWidth-2];
PathBrowserPanel = uicontrol(fig,'Style','frame','Units','Points','Position',round(Sz),...
'Visible','on','Tag','PathBrowserPanel_Frame');
%% Path Details Structure:
PathDetails = [];
PathDetails.Path = {};
PathDetails.OldPath = {};
PathDetails.NodeIDs = [];
PathDetails.SortOrder = [];
PathDetails.NodeNames = [];
PathDetails.Elements = {};
PathDetails.Text = {};
PathDetails.ScrollPosition = [];
PathDetails.ScrollButtons = cell(2,0);
%% store handles in the Global Variable
global GraphGUIBrowseGraphData;
GraphGUIBrowseGraphData = [];
GraphGUIBrowseGraphData.Properties = Properties;
GraphGUIBrowseGraphData.ControlsPanel = ControlsPanel;
GraphGUIBrowseGraphData.PathPanel = PathPanel;
GraphGUIBrowseGraphData.CloseButton = CloseButton;
GraphGUIBrowseGraphData.SelectedGraphPopup = SelectedGraphPopup;
GraphGUIBrowseGraphData.VariablesListRefreshPushButton = VariablesListRefreshPushButton;
GraphGUIBrowseGraphData.SortOrderPopup = SortOrderPopup;
GraphGUIBrowseGraphData.FontSelectPushbutton = FontSelectPushbutton;
GraphGUIBrowseGraphData.DetailsPanel = DetailsPanel;
GraphGUIBrowseGraphData.GraphDetailsEdit = GraphDetailsEdit;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -