function varargout = uilinespec(varargin)
% UILINESPEC GUI to prompt user for linespec properties.
%
% S = UILINESPEC returns a structure S with linespec properties.
%
% S = UILINESPEC(D) accepts the default linespec properties struct D.
%
% Both S and D are structures with the following fields (and default value):
% LineWidth: 0.5000
% LineStyle: '-'
% Color: 'Blue'
% Marker: ''
% MarkerSize: 6
% MarkerEdgeColor: 'Blue'
% MarkerFaceColor: 'Blue'
%
% EXAMPLE
% h = plot(rand(20,1));
% LineSpec = uilinespec();
% set(h,LineSpec);
% pause
% LineSpec = uilinespec(LineSpec);
% set(h,LineSpec);
%
% Jos Pina 2006
% Last Modified by GUIDE v2.5 07-Feb-2007 15:15:46
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @uilinespec_OpeningFcn, ...
'gui_OutputFcn', @uilinespec_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before uilinespec is made visible.
function uilinespec_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to uilinespec (see VARARGIN)
% Choose default command line output for uilinespec
handles.output = hObject;
colors = get(handles.popupmenu_color,'string');
markers = {'none' '.' 'o' 'x' '+' '*' 's' 'd' 'p' 'h' };
% read defaults if supplied
if nargin>3
def = varargin{1};
flds = fieldnames(varargin{1});
for n=1:length(flds)
defval = lower(def.(flds{n}));
switch lower(flds{n})
case 'linewidth'
set(handles.edit_lineWidth,'string',num2str(defval));
case 'linestyle'
m = strmatch(defval,{'-' '--' ':' '-.' 'none'});
set(handles.popupmenu_lineStyle,'value',m(1));
case 'color'
m = strmatch(defval,lower(colors));
set(handles.popupmenu_color,'value',m);
case 'marker'
m = strmatch(defval,markers);
set(handles.popupmenu_marker,'value',m);
case 'markersize'
set(handles.edit_markerSize,'string',num2str(defval));
case 'markeredgecolor'
m = strmatch(defval,lower(colors));
set(handles.popupmenu_markerEdgeColor,'value',m);
case 'markerfacecolor'
m = strmatch(defval,lower(colors));
set(handles.popupmenu_markerFaceColor,'value',m);
end
end
end
popupmenu_marker_Callback(handles.popupmenu_marker,[],handles);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes uilinespec wait for user response (see UIRESUME)
uiwait(handles.figure_linespecgui);
% --- Outputs from this function are returned to the command line.
function varargout = uilinespec_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
close(gcf)
function edit_lineWidth_Callback(hObject, eventdata, handles)
% hObject handle to edit_lineWidth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_lineWidth as text
% str2double(get(hObject,'String')) returns contents of edit_lineWidth as a double
if str2double(get(hObject,'String'))<=0
set(hObject,'string',0.5);
end
% --- Executes during object creation, after setting all properties.
function edit_lineWidth_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_lineWidth (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
function edit_markerSize_Callback(hObject, eventdata, handles)
% hObject handle to edit_markerSize (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit_markerSize as text
% str2double(get(hObject,'String')) returns contents of edit_markerSize as a double
% --- Executes during object creation, after setting all properties.
function edit_markerSize_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit_markerSize (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in popupmenu_lineStyle.
function popupmenu_lineStyle_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_lineStyle (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu_lineStyle contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_lineStyle
% --- Executes during object creation, after setting all properties.
function popupmenu_lineStyle_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_lineStyle (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in popupmenu_color.
function popupmenu_color_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_color (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu_color contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_color
% --- Executes during object creation, after setting all properties.
function popupmenu_color_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_color (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in popupmenu_marker.
function popupmenu_marker_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_marker (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu_marker contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_marker
% marker == 'none' -> hide other controls
if get(hObject,'Value')==1
set(handles.edit_markerSize,'visible','off');
set(handles.popupmenu_markerEdgeColor,'visible','off');
set(handles.popupmenu_markerFaceColor,'visible','off');
set(handles.text4,'visible','off');
set(handles.text5,'visible','off');
set(handles.text6,'visible','off');
else
set(handles.edit_markerSize,'visible','on');
set(handles.popupmenu_markerEdgeColor,'visible','on');
set(handles.popupmenu_markerFaceColor,'visible','on');
set(handles.text4,'visible','on');
set(handles.text5,'visible','on');
set(handles.text6,'visible','on');
end
% --- Executes during object creation, after setting all properties.
function popupmenu_marker_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_marker (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in popupmenu_markerEdgeColor.
function popupmenu_markerEdgeColor_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_markerEdgeColor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu_markerEdgeColor contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_markerEdgeColor
% --- Executes during object creation, after setting all properties.
function popupmenu_markerEdgeColor_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_markerEdgeColor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on selection change in popupmenu_markerFaceColor.
function popupmenu_markerFaceColor_Callback(hObject, eventdata, handles)
% hObject handle to popupmenu_markerFaceColor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: contents = get(hObject,'String') returns popupmenu_markerFaceColor contents as cell array
% contents{get(hObject,'Value')} returns selected item from popupmenu_markerFaceColor
% --- Executes during object creation, after setting all properties.
function popupmenu_markerFaceColor_CreateFcn(hObject, eventdata, handles)
% hObject handle to popupmenu_markerFaceColor (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: popupmenu controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc
set(hObject,'BackgroundColor','white');
else
set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
% --- Executes on button press in pushbutton_cancel.
function pushbutton_cancel_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_cancel (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = [];
guidata(hObject,handles);
uiresume(gcf)
return
% --- Executes on button press in pushbutton_ok.
function pushbutton_ok_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton_ok (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.output = [];
lineStyles = {'-' '--' ':' '-.' 'none'};
colors = get(handles.popupmenu_color,'string');
markers = {'none' '.' 'o' 'x' '+' '*' 's' 'd' 'p' 'h' };
LineSpec.LineWidth = str2num(get(handles.edit_lineWidth,'string'));
LineSpec.LineStyle = lineStyles{get(handles.popupmenu_lineStyle,'value')};
LineSpec.Color = colors{get(handles.popupmenu_color,'value')};
LineSpec.Marker = markers{get(handles.popupmenu_marker,'value')};
LineSpec.MarkerSize = str2num(get(handles.edit_markerSize,'string'));
LineSpec.MarkerEdgeColor = colors{get(handles.popupmenu_markerEdgeColor,'value')};
LineSpec.MarkerFaceColor = colors{get(handles.popupmenu_markerFaceColor,'value')};
handles.output = LineSpec;
guidata(hObject,handles);
uiresume(gcf);
return