📄 graphgiubrowsegraph.m
字号:
function GraphGIUBrowseGraph_SortOrderSelect_ButtonDown(h, eventdata, handles, varargin)
try
global GraphGUIBrowseGraphData;
if ~isempty(GraphGUIBrowseGraphData)
%SortOrder = GetSortOrder(h);
%if ~isempty(SortOrder )
%GraphGUIBrowseGraphData.PathDetails.NodeIDs = GraphGUIBrowseGraphData.PathDetails.NodeIDs (SortOrder);
%GraphGUIBrowseGraphData.PathDetails.NodeNames = GraphGUIBrowseGraphData.PathDetails.NodeNames (SortOrder);
OldPath = GraphGUIBrowseGraphData.PathDetails.Path;
ClearPath(h);
AddNodeToPath(h,[]);
if iscell(OldPath) & ~isempty(OldPath)
for i = 1 : numel(OldPath)
AddNodeToPath(h,OldPath{i});
end
end
%end
end
catch
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function SortOrder = GetSortOrder(h,NodeIDs)
SortOrder = [];
try
global GraphGUIBrowseGraphData;
if ~isempty(GraphGUIBrowseGraphData)
SortBy = get(GraphGUIBrowseGraphData.SortOrderPopup,'Value');
if SortBy == 1
if ~exist('NodeIDs','var') | isempty(NodeIDs)
[Dummy SortOrder] = sort(GraphGUIBrowseGraphData.PathDetails.NodeIDs);
else
[Dummy SortOrder] = sort(NodeIDs);
end
elseif SortBy == 2
% Sort By Name
if ~exist('NodeIDs','var') | isempty(NodeIDs)
[Dummy SortOrder] = sort(GraphGUIBrowseGraphData.PathDetails.NodeNames);
else
GraphGUIBrowseGraphData.Temp=NodeIDs;
Selected = GetVariable(h);
evalin('base','global GraphGUIBrowseGraphData;');
[NodeNames] = evalin('base',[' GraphGetNodeNames(' Selected ',GraphGUIBrowseGraphData.Temp)']);
[Dummy SortOrder] = sort(NodeNames);
end
else
% Sort by parameter:
ParameterNames = get(GraphGUIBrowseGraphData.SortOrderPopup,'String');
SortParameterName = ParameterNames{SortBy};
Selected = GetVariable(h);
if ~exist('NodeIDs','var') | isempty(NodeIDs)
evalin('base','global GraphGUIBrowseGraphData;');
SortByProperty = evalin('base',['GraphGetNodeProperty(' Selected ',''' SortParameterName ''',GraphGUIBrowseGraphData.PathDetails.NodeIDs)']);
[DummySortOrder] = sort(SortByProperty.Values);
else
GraphGUIBrowseGraphData.Temp=NodeIDs;
evalin('base','global GraphGUIBrowseGraphData;');
SortByProperty = evalin('base',['GraphGetNodeProperty(' Selected ',''' SortParameterName ''',GraphGUIBrowseGraphData.Temp)']);
[Dummy SortOrder] = sort(SortByProperty.Values);
end
end
if get( GraphGUIBrowseGraphData.SortDirectionToggleButton ,'Value')==0
SortOrder = rot90(SortOrder,3);
end
end
catch
SortOrder = [];
end
%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Selected = GetVariable(h)
%Returns the currently selected variable
Selected = '';
try
global GraphGUIBrowseGraphData;
if ~isempty(GraphGUIBrowseGraphData)
Variables = get(GraphGUIBrowseGraphData.SelectedGraphPopup,'String');
if ~isempty(Variables)
Selected = get(GraphGUIBrowseGraphData.SelectedGraphPopup,'Value');
if isempty(Selected)
Selected = '';
else
Selected = Variables{Selected(1)};
end
end
end
if isempty(Selected) | ~ObjectIsType(evalin('base',Selected),'Graph')
Selected = SetSelectedValue(h,Value);
end
catch
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function SetVariable(h,Value)
try
global GraphGUIBrowseGraphData;
if ~isempty(GraphGUIBrowseGraphData)
Variables = get(GraphGUIBrowseGraphData.SelectedGraphPopup,'String');
if ~isempty(Variables)
index = strmatch(Value,Variables,'exact');
if isempty(index)
index = 1;
end
set(GraphGUIBrowseGraphData.SelectedGraphPopup,'Value',index(1));
end
end
catch
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function GraphDetails = GetGraphDetails(h)
GraphDetails = {};
try
Selected = GetVariable(h);
GraphDetails{end+1} = ['Variable Name: ' Selected ];
GraphDetails{end+1} = [' Type: ' evalin('base',[Selected '.Type'])];
GraphDetails{end+1} = [' Signature: '];
for i = 1 : evalin('base',['numel(' Selected '.Signature)'])
GraphDetails{end+1} = [' ' evalin('base',[Selected '.Signature{' num2str(i) '}'])];
end
GraphDetails{end+1} = [' File Name: '];
[FileDir FileName FileExt] = fileparts( evalin('base',[Selected '.FileName']));
GraphDetails{end+1} = [' ' FileName FileExt];
GraphDetails{end+1} = [' Properties: '];
for i = 1 : evalin('base',['numel(' Selected '.Index.Properties)'])
GraphDetails{end+1} = [' ' evalin('base',[Selected '.Index.Properties(' num2str(i) ').PropertyName'])];
end
GraphDetails{end+1} = [' Number of Nodes: ' num2str(evalin('base',['GraphCountNumberOfNodes(' Selected ')']))];
GraphDetails{end+1} = [' Number of Links: ' num2str(evalin('base',['GraphCountNumberOfLinks(' Selected ')']))];
catch
GraphDetails{end+1} = '';
GraphDetails{end+1} = 'Error:';
GraphDetails{end+1} = lasterr;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function GraphNodeDetails = GetGraphNodeDetails(h,NodeID)
GraphNodeDetails = {};
try
Selected = GetVariable(h);
GraphNodeDetails{end+1} = ['Node ID: ' num2str(NodeID)];
NodeName = evalin('base',['GraphGetNodeNames(' Selected ', ' num2str(NodeID) ')']);
if isempty(NodeName)
NodeName =' ' ;
elseif iscell(NodeName)
NodeName= NodeName{1};
end
GraphNodeDetails{end+1} = [' Name: ' NodeName ];
Degree = evalin('base',['GraphCountNodeDegree(' Selected ',' num2str(NodeID) ')']);
GraphNodeDetails{end+1} = [' In Degree: ' num2str(Degree(1)) ];
GraphNodeDetails{end+1} = [' Out Degree: ' num2str(Degree(2)) ];
if evalin('base', ['numel(' Selected '.Index.Properties)'])
GraphNodeDetails{end+1} = [' Node Properties: ' ];
for i = 1 : evalin('base', ['numel(' Selected '.Index.Properties)'])
PropertyName = evalin('base', [Selected '.Index.Properties(' num2str(i) ').PropertyName']);
PropertyValue = evalin('base', ['GraphGetNodeProperty(' Selected ',''' PropertyName ''',' num2str(NodeID) ','''')']);
if isnumeric(PropertyValue.Values)
GraphNodeDetails{end+1} = [ ' ' PropertyName ': ' num2str(PropertyValue.Values) ];
else
GraphNodeDetails{end+1} = [ ' ' PropertyName ': ' PropertyValue.Values ];
end
end
end
catch
GraphNodeDetails{end+1} = '';
GraphNodeDetails{end+1} = 'Error:';
GraphNodeDetails{end+1} = lasterr;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function ClearPath(h)
fig = FigureHandle(h);
if ~isempty(fig)
try
global GraphGUIBrowseGraphData;
if ~isempty(GraphGUIBrowseGraphData)
GraphGUIBrowseGraphData.PathDetails.OldPath = GraphGUIBrowseGraphData.PathDetails.Path;
GraphGUIBrowseGraphData.PathDetails.Path = {};
for i = numel(GraphGUIBrowseGraphData.PathDetails.Elements) : -1 : 1
delete (GraphGUIBrowseGraphData.PathDetails.Elements{i});
delete(GraphGUIBrowseGraphData.PathDetails.ScrollButtons{1,i});
delete(GraphGUIBrowseGraphData.PathDetails.ScrollButtons{2,i});
delete(GraphGUIBrowseGraphData.PathDetails.Text{i});
end
GraphGUIBrowseGraphData.PathDetails.ScrollButtons = cell(2,0);
GraphGUIBrowseGraphData.PathDetails.Elements = {};
GraphGUIBrowseGraphData.PathDetails.Nodes = {};
GraphGUIBrowseGraphData.PathDetails.Text = {};
PathDetails.NodeIDs = [];
PathDetails.NodeNames = [];
PathDetails.ScrollPosition = [];
end
catch
end
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function GraphGIUBrowseGraph_SearchNodePushbutton_ButtonDown(h, eventdata, handles, varargin)
try
global GraphGUIBrowseGraphData;
if ~isempty(GraphGUIBrowseGraphData)
SearchValue = get(GraphGUIBrowseGraphData.SearchNodeEdit,'String');
if ~isempty(SearchValue)
% GraphGUIBrowseGraphData.SearchValue
Tag = max([ 1 numel(GraphGUIBrowseGraphData.PathDetails.Elements)-1]);
[Indeces, NumberOfElements]= FindLinkedElements(h,Tag,1);
CriteriaIndeces = [];
SearchWhat = get(GraphGUIBrowseGraphData.SortOrderPopup,'Value');
if SearchWhat==1 % By ID.
SearchValue = str2num(SearchValue)
if ~isempty(SearchValue);
CriteriaIndeces = find( GraphGUIBrowseGraphData.PathDetails.NodeIDs(Indeces) >= SearchValue );
end
elseif SearchWhat==2 % By Name
if ~isempty(SearchValue);
CriteriaIndeces = strmatch(SearchValue,GraphGUIBrowseGraphData.PathDetails.NodeNames(Indeces));
end
else % Sort by property::
ParameterNames = get(GraphGUIBrowseGraphData.SortOrderPopup,'String');
SortParameterName = ParameterNames{SearchWhat};
Selected = GetVariable(h);
GraphGUIBrowseGraphData.Temp=GraphGUIBrowseGraphData.PathDetails.NodeIDs(Indeces);
evalin('base','global GraphGUIBrowseGraphData;');
SortByProperty = evalin('base',['GraphGetNodeProperty(' Selected ',''' SortParameterName ''',GraphGUIBrowseGraphData.Temp)']);
if isnumeric(SortByProperty.Values)
CriteriaIndeces = find(SortByProperty.Values>=str2num(SearchValue));
else
CriteriaIndeces = strmatch(SearchValue,SortByProperty.Values);
end
end
if get(GraphGUIBrowseGraphData.SortDirectionToggleButton ,'Value')
GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) = min(CriteriaIndeces);
else
GraphGUIBrowseGraphData.PathDetails.ScrollPosition(Tag) = max(CriteriaIndeces);
end
GraphGIUBrowseGraph_ScrollListbox_PushDown(GraphGUIBrowseGraphData.PathDetails.Elements{Tag}, eventdata, handles, varargin);
set(GraphGUIBrowseGraphData.PathDetails.Elements{Tag},'Value',1);
% set(h,'String',['Search - ' num2str( numel(CriteriaIndeces) ); end
end
end
catch
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -