Duda axes
Publicado por Aless (10 intervenciones) el 20/04/2012 02:25:52
Hola, estoy haciendo una GUI en la que hay tres paneles y un axes. Quiero dibujar los puntos x=[1 2 3 4] con y=[0 0 0 0].
Los paneles se llaman: Símbolo (puedes escoger el tipo de símbolo: cuadrado, círculo), Línea (Continua, a trozos...su ancho) y Color (negro, azul...).
Cuando hayas seleccionado cada opción, se dibujaría. Si hubiese un botón DIBUJAR, sería fácil, porque en ese botón (su callback) le diría que cogiese los valores de los otros paneles y pintase.
Sin embargo, me gustaría que fuese automático, que el sólo ya lo dibujase. Puedo establecer que inicialmente se dibujase en color negro, línea continua y de símbolo el círculo. Pero cuando cambie la opción...símbolo cuadrado, pues que automáticamente se cambie eso. Por lo tanto, hacer todo esto sin un botón.
Os pongo el código que tengo hecho hasta ahora:
Los paneles se llaman: Símbolo (puedes escoger el tipo de símbolo: cuadrado, círculo), Línea (Continua, a trozos...su ancho) y Color (negro, azul...).
Cuando hayas seleccionado cada opción, se dibujaría. Si hubiese un botón DIBUJAR, sería fácil, porque en ese botón (su callback) le diría que cogiese los valores de los otros paneles y pintase.
Sin embargo, me gustaría que fuese automático, que el sólo ya lo dibujase. Puedo establecer que inicialmente se dibujase en color negro, línea continua y de símbolo el círculo. Pero cuando cambie la opción...símbolo cuadrado, pues que automáticamente se cambie eso. Por lo tanto, hacer todo esto sin un botón.
Os pongo el código que tengo hecho hasta ahora:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
function varargout = opciones_visualizar(varargin)
clc
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @opciones_visualizar_OpeningFcn, ...
'gui_OutputFcn', @opciones_visualizar_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 opciones_visualizar is made visible.
function opciones_visualizar_OpeningFcn(hObject, eventdata, handles, varargin)
handles.output = hObject;
guidata(hObject, handles);
% --- Outputs from this function are returned to the command line.
function varargout = opciones_visualizar_OutputFcn(hObject, eventdata, handles)
varargout{1} = handles.output;
% --- Executes on slider movement.
function slider1_Callback(hObject, eventdata, handles)
handles.slider1=get(hObject,'Value');
handles.slider1= handles.slider1*10;
if handles.slider1==0
handles.slider1=handles.slider1+0.1;
end
set(handles.ancho,'String',handles.slider1);
guidata(hObject,handles);
% --- Executes during object creation, after setting all properties.
function slider1_CreateFcn(hObject, eventdata, handles)
% hObject handle to slider1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor',[.9 .9 .9]);
end
% --- Executes when selected object is changed in Panel_simbolos.
function Panel_simbolos_SelectionChangeFcn(hObject, ~, handles)
if hObject==handles.uno
simbolo='o';
elseif hObject==handles.dos
simbolo='+';
elseif hObject==handles.tres
simbolo='s';
elseif hObject==handles.cuatro
simbolo='x';
elseif hObject==handles.cinco
simbolo='*';
elseif hObject==handles.seis
simbolo='h';
elseif hObject==handles.siete
simbolo='p';
elseif hObject==handles.ocho
simbolo='.';
elseif hObject==handles.nueve
simbolo='v';
elseif hObject==handles.diez
simbolo='^';
elseif hObject==handles.once
simbolo='>';
elseif hObject==handles.doce
simbolo='<';
elseif hObject==handles.trece
simbolo='';
end
handles.simbolo=simbolo;
guidata(hObject,handles);
% --- Executes when selected object is changed in Panel_lineas.
function Panel_lineas_SelectionChangeFcn(hObject, ~, handles)
if hObject==handles.uno
linea='-';
elseif hObject==handles.dos
linea=':';
elseif hObject==handles.tres
linea='--';
elseif hObject==handles.cuatro
linea='-.';
elseif hObject==handles.cinco
linea='';
end
handles.linea=linea;
guidata(hObject,handles);
% --- Executes when selected object is changed in Panel_color.
function Panel_color_SelectionChangeFcn(hObject, eventdata, handles)
if hObject==handles.uno
color='y';
elseif hObject==handles.dos
color='b';
elseif hObject==handles.tres
color='c';
elseif hObject==handles.cuatro
color='m';
elseif hObject==handles.cinco
color='k';
elseif hObject==handles.seis
color='r';
elseif hObject==handles.siete
color='g';
elseif hObject==handles.ocho
color=uisetcolor();
end
handles.color=color;
guidata(hObject,handles);
Valora esta pregunta


0