0001 function graph = AddGraph_jd(hObject, eventdata, handles);
0002
0003
0004
0005
0006 graph = [];
0007
0008
0009
0010 NumberOfScenarios = length(handles.scenarios);
0011
0012 if NumberOfScenarios == 0
0013 h = warndlg('There are no scenario in memory. Go to File -> Load to add a scenario','No scenario');
0014 return
0015 elseif NumberOfScenarios > 1
0016
0017 for iScenario = 1:NumberOfScenarios,
0018 ListOfScenario{iScenario} = handles.scenarios{iScenario}.name;
0019 end
0020
0021 iScenario = listdlg('PromptString','Select a scenario',...
0022 'SelectionMode','single',...
0023 'ListString',ListOfScenario);
0024
0025 if isempty(iScenario)
0026 return
0027 end
0028 else
0029 iScenario = 1;
0030 end
0031
0032 scenario = handles.scenarios{iScenario}.name;
0033
0034
0035
0036 ListOfGraphTypes = handles.listofgraphtypes;
0037 NumberOfGraphs = length(handles.graphs);
0038
0039 iGraphType = listdlg('PromptString','Select a graph',...
0040 'SelectionMode','single',...
0041 'ListString',ListOfGraphTypes);
0042
0043 type = ListOfGraphTypes{iGraphType};
0044
0045 for iGraph = 1:NumberOfGraphs,
0046 if isequal(handles.graphs{iGraph}.type,type)...
0047 & isequal(handles.graphs{iGraph}.scenario,scenario)...
0048 & isequal(handles.graphs{iGraph}.axes,hObject),
0049 h = warndlg('The graph you are calling is already displayed in the current axes.','Existing graph');
0050 return
0051 end
0052 end
0053
0054 graph.type = type;
0055 graph.scenario = scenario;
0056 graph.axes = hObject;
0057
0058
0059
0060 [x,y,z,xlab,ylab,zlab,warnstr] = GetGraphData_jd(handles, graph);
0061
0062 if ~isempty(warnstr),
0063 h = warndlg(warnstr,'Operation aborted');
0064 graph = [];
0065 return
0066 end
0067
0068 axxlab = get(get(hObject,'xlabel'),'string');
0069 axylab = get(get(hObject,'ylabel'),'string');
0070 axzlab = get(get(hObject,'zlabel'),'string');
0071
0072
0073
0074 if isempty(z),
0075
0076 if (~isempty(axxlab) & ~isequal(axxlab,xlab)) | ~isempty(axzlab),
0077 h = warndlg('The graph you are calling is not compatible with the current axis.','Incompatible graph');
0078 graph = [];
0079 return
0080 end
0081
0082 graph.hgraph = line(x,y,'parent',hObject);
0083 graph.cgraph = NaN;
0084 graph.xlab = xlab;
0085 graph.ylab = ylab;
0086
0087 set(get(hObject,'xlabel'),'string',xlab,'fontsize',get(hObject,'fontsize'));
0088
0089 else
0090
0091 if (~isempty(axxlab) & ~isequal(axxlab,xlab))...
0092 | (~isempty(axylab) & ~isequal(axylab,ylab)),
0093 h = warndlg('The graph you are calling is not compatible with the current axis.','Incompatible graph');
0094 graph = [];
0095 return
0096 end
0097
0098 [graph.cgraph,graph.hgraph] = contour(x,y,z,'parent',hObject);
0099 graph.xlab = xlab;
0100 graph.ylab = ylab;
0101 graph.zlab = zlab;
0102
0103 set(get(hObject,'xlabel'),'string',xlab,'fontsize',get(hObject,'fontsize'));
0104 set(get(hObject,'ylabel'),'string',ylab,'fontsize',get(hObject,'fontsize'));
0105 end