source: trunk/src/set_object.m @ 67

Last change on this file since 67 was 67, checked in by sommeria, 14 years ago

civ: RUN civ lounched out of the Matlab work space. RUN and BATCH now runned by a unique sub-function lounch.m.
FiLE PARAM.xml modified to provide different paths for Batch and Run !!!!!
RUN_FIX: minor error message modif
geometry_calib: calib point editing by the mouse
improvement of the interactions between the different GUIs. Close function...

File size: 30.8 KB
Line 
1%'set_object': GUI to edit a projection object
2%------------------------------------------------------------------------
3% function hset_object= set_object(data, PlotHandles,ZBounds)
4% associated with the GUI set_object.fig
5%
6% OUTPUT:
7% hset_object: handle of the GUI figure
8%
9% INPUT:
10% data: structure describing the object properties
11%    .Style=...
12%    .ProjMode
13%    .CoordType: 'phys' or 'px'
14%    .DX,.DY,.DZ : mesh along each dirction
15%    .RangeX, RangeY
16%    .Coord(j,i), i=1, 2, 3,  components x, y, z of j=1...n position(s) characterizing the object components
17% PlotHandles: handles for projection plots
18% Zbounds: bounds on Z ( 3D case)
19%
20%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
21%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
22%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
23%     This file is part of the toolbox UVMAT.
24%
25%     UVMAT is free software; you can redistribute it and/or modify
26%     it under the terms of the GNU General Public License as published by
27%     the Free Software Foundation; either version 2 of the License, or
28%     (at your option) any later version.
29%
30%     UVMAT is distributed in the hope that it will be useful,
31%     but WITHOUT ANY WARRANTY; without even the implied warranty of
32%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
34%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
35
36function varargout = set_object(varargin)
37
38% Last Modified by GUIDE v2.5 24-Nov-2008 14:29:06
39
40% Begin initialization code - DO NOT PLOT
41gui_Singleton = 1;
42gui_State = struct('gui_Name',       mfilename, ...
43                   'gui_Singleton',  gui_Singleton, ...
44                   'gui_OpeningFcn', @set_object_OpeningFcn, ...
45                   'gui_OutputFcn',  @set_object_OutputFcn, ...
46                   'gui_LayoutFcn',  [] , ...
47                   'gui_Callback',   []);
48if nargin & isstr(varargin{1})
49    gui_State.gui_Callback = str2func(varargin{1});
50end
51
52if nargout
53    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
54else
55    gui_mainfcn(gui_State, varargin{:});
56end
57% End initialization code - DO NOT PLOT
58
59%-------------------------------------------------------------------
60% --- Executes just before set_object is made visible.
61%INPUT:
62% handles: handles of the set_object interface elements
63%'IndexObj': NON USED ANYMORE (To suppress) index of the object (on the UvData list) that set_object will modify
64%        if =[] or absent: index still undefined (create mode in uvmat)
65%        if=0; no associated object (used for series), the button 'PLOT' is  then unvisible
66%'data': read from an existing object selected in the interface
67%      .TITLE : class of object ('POINTS','LINE',....)
68%      .DX,DY,DZ; meshes for regular grids
69%      .Coord: object position coordinates
70%      .ParentButton: handle of the uicontrol object calling the interface
71% PlotHandles: set of handles of the elements contolling the plotting of the projected field:
72%  if =[] or absent, no plot (mask mode in uvmat)
73% parameters on the uvmat interface (obtained by 'get_plot_handle.m')
74function set_object_OpeningFcn(hObject, eventdata, handles, data, PlotHandles,ZBounds)
75%-------------------------------------------------------------------
76% Choose default command line output for set_object
77handles.output = hObject;
78
79% Update handles structure
80guidata(hObject, handles);
81
82%default
83if ~exist('ZBound','var')
84    ZBound=0; %default
85end
86set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function (allow action on uvmat when set_object is in front)
87set(handles.MenuCoord,'ListboxTop',1)
88if ~exist('PlotHandles','var')
89     PlotHandles=[];
90end
91enable_plot=0;%default
92SetData.PlotHandles=PlotHandles;
93% if exist('data','var') && isfield(data,'ParentButton')
94%         SetData.ParentButton=data.ParentButton;
95%         set(hObject,'DeleteFcn',{@closefcn,SetData.ParentButton})%
96% end
97set(hObject,'UserData',SetData)
98
99% fill the interface as set in the input data:
100if exist('data','var')
101    if isfield(data,'desable_plot')
102        enable_plot=~data.desable_plot;%test to desable button PLOT (display mode)
103    end
104    if ~isfield(data,'NbDim')||~isequal(data.NbDim,3)%2D case
105        set(handles.ZObject,'Visible','off')
106        set(handles.z_slider,'Visible','off')
107    else
108        set(handles.ZObject,'Visible','on')
109        set(handles.z_slider,'Visible','on')
110        if isfield(data,'Coord') && size(data.Coord,2)==3
111            set(handles.ZObject,'String',num2str(data.Coord(1,3),4))
112        end
113    end
114    if isfield(data,'Style')
115        menu=get(handles.ObjectStyle,'String');
116        for iline=1:length(menu)
117            if isequal(menu{iline},data.Style)
118                set(handles.ObjectStyle,'Value',iline)
119                break
120            end
121        end
122    end
123    ObjectStyle_Callback(hObject, eventdata, handles)
124    if isfield(data,'ProjMode')
125        menu=get(handles.ProjMode,'String');
126        for iline=1:length(menu)
127            if isequal(menu{iline},data.ProjMode)
128                set(handles.ProjMode,'Value',iline)
129                break
130            end
131        end
132    end
133    ProjMode_Callback(hObject, eventdata, handles)
134    if isfield(data,'Coord')
135        if ischar(data.Coord)
136            data.Coord=str2num(data.Coord);
137        elseif iscell(data.Coord)
138            CoordCell=data.Coord;
139            data.Coord=zeros(numel(CoordCell),3);
140            for iline=1:numel(CoordCell)
141                data.Coord(iline,:)=str2num(CoordCell{iline});
142            end
143        end
144        if size(data.Coord,2)>=2
145            sizcoord=size(data.Coord);
146            for i=1:sizcoord(1)
147                XObject{i}=num2str(data.Coord(i,1),4);
148                YObject{i}=num2str(data.Coord(i,2),4);
149            end
150            set(handles.XObject,'String',XObject)
151            set(handles.YObject,'String',YObject)
152            if sizcoord(2)>3
153                for i=1:sizcoord(1)
154                    ZObject{i}=num2str(data.Coord(i,3),4);
155                end
156                set(handles.ZObject,'String',ZObject)
157            end
158        end
159    end
160    if isfield(data,'DX')
161        if ~ischar(handles.DX)
162            data.DX=num2str(data.DX,3);
163        end
164        set(handles.DX,'String',data.DX)
165    end
166    if isfield(data,'DY')
167        if ~ischar(handles.DY)
168            data.DY=num2str(data.DY,3);
169        end
170        set(handles.DY,'String',data.DX)
171    end
172    if isfield(data,'RangeZ') && length(ZBounds) >= 2
173        set(handles.ZMax,'String',num2str(max(data.RangeZ),3))
174        DZ=max(data.RangeZ);%slider step
175        if ZBounds(2)~=ZBounds(1)
176            rel_step(1)=min(DZ/(ZBounds(2)-ZBounds(1)),0.2);%must be smaller than 1
177            rel_step(2)=0.1;
178            set(handles.z_slider,'Visible','on')
179            set(handles.z_slider,'Min',ZBounds(1))
180            set(handles.z_slider,'Max',ZBounds(2))
181            set(handles.z_slider,'SliderStep',rel_step)
182            set(handles.z_slider,'Value',(ZBounds(1)+ZBounds(2))/2)
183        end
184    end
185    if isfield(data,'RangeX')
186        if ischar(data.RangeX)
187            data.RangeX=str2num(data.RangeX);
188        end
189        set(handles.XMax,'String',num2str(max(data.RangeX),3))
190        set(handles.XMin,'String',num2str(min(data.RangeX),3))
191    end
192    if isfield(data,'RangeY')
193        if ischar(data.RangeY)
194            data.RangeY=str2num(data.RangeY);
195        end
196        set(handles.YMax,'String',num2str(max(data.RangeY),3))
197        set(handles.YMin,'String',num2str(min(data.RangeY),3))
198    end
199    if isfield(data,'RangeZ')
200        if ischar(data.RangeZ)
201            data.RangeZ=str2num(data.RangeZ);
202        end
203        set(handles.ZMax,'String',num2str(max(data.RangeZ),3))
204        set(handles.ZMin,'String',num2str(min(data.RangeZ),3))
205    end 
206    if isfield(data,'Phi')
207        if ~ischar(handles.Phi)
208            data.DY=num2str(data.Phi,3);
209        end
210         set(handles.Phi,'String',data.Phi)
211    end
212    if isfield(data,'Theta')
213        if ~ischar(handles.Theta)
214            data.DY=num2str(data.Theta,3);
215        end
216        set(handles.Theta,'String',data.Theta)
217    end
218    if isfield(data,'Psi')
219         if ~ischar(handles.Psi)
220            data.DY=num2str(data.Psi,3);
221        end
222         set(handles.Psi,'String',data.Psi)
223    end 
224    if isfield(data,'DZ')
225        if ~ischar(handles.DZ)
226            data.DY=num2str(data.DZ,3);
227        end
228        set(handles.DZ,'String',data.DZ)
229    end
230    if isfield(data,'CoordType')
231        if isequal(data.CoordType,'phys')
232            set(handles.MenuCoord,'Value',1)
233        elseif isequal(data.CoordType,'px')
234             set(handles.MenuCoord,'Value',2)
235        end
236    end
237end
238% if desable_open
239%     set(handles.OPEN,'Visible','off')
240% else
241%     set(handles.OPEN,'Visible','on')
242% end
243if enable_plot
244   set(handles.PLOT,'enable','on')
245else
246   set(handles.PLOT,'enable','off')
247end
248
249
250% --- Outputs from this function are returned to the command line.
251function varargout = set_object_OutputFcn(hObject, eventdata, handles)
252% varargout  cell array for returning output args (see VARARGOUT);
253% hObject    handle to figure
254% eventdata  reserved - to be defined in a future version of MATLAB
255% handles    structure with handles and user data (see GUIDATA)
256
257% Get default command line output from handles structure
258varargout{1} = handles.output;
259varargout{2}=handles;
260
261%-----------------------------------------------
262% --- Executes on selection change in ObjectStyle.
263function ObjectStyle_Callback(hObject, eventdata, handles)
264style_prev=get(handles.ObjectStyle,'UserData');%previous object style
265str=get(handles.ObjectStyle,'String');
266val=get(handles.ObjectStyle,'Value');
267style=str{val};
268% make correspondance between different object styles
269% if ~isequal(str{val},style_prev)
270Xcolumn=get(handles.XObject,'String');
271Ycolumn=get(handles.YObject,'String');
272if ischar(Xcolumn)
273    sizchar=size(Xcolumn);
274    for icol=1:sizchar(1)
275        Xcolumn_cell{icol}=Xcolumn(icol,:);
276    end
277    Xcolumn=Xcolumn_cell;
278end
279if ischar(Ycolumn)
280    sizchar=size(Ycolumn);
281    for icol=1:sizchar(1)
282        Ycolumn_cell{icol}=Ycolumn(icol,:);
283    end
284    Ycolumn=Ycolumn_cell;
285end
286Zcolumn={};%default
287z_new={};
288if isequal(get(handles.ZObject,'Visible'),'on')
289    data.NbDim=3; %test 3D object
290    Zcolumn=get(handles.ZObject,'String');
291    if ischar(Zcolumn)
292        Zcolumn={Zcolumn};
293    end
294end
295x_new{1}=Xcolumn{1};
296y_new{1}=Ycolumn{1};
297if ~isempty(Zcolumn)
298    z_new{1}=Zcolumn{1};
299end
300if isequal(style,'line')
301    if isequal(style_prev,'rectangle')|isequal(style_prev,'ellipse')
302        XMax=get(handles.XMax,'String');
303        YMax=get(handles.YMax,'String');
304        x_new{2}=num2str(XMax,4);
305        y_new{2}=num2str(YMax,4);
306        set(handles.XObject,'String',x_new)
307        set(handles.YObject,'String',y_new)
308        set(handles.ZObject,'String',z_new)
309    end
310elseif isequal(style,'polyline')
311elseif isequal(style,'rectangle')| isequal(style,'ellipse')
312     set(handles.XObject,'String',x_new)
313     set(handles.YObject,'String',y_new)
314     set(handles.ZObject,'String',z_new)
315end
316% end
317switch style
318    case {'points','line','polyline','plane'}
319        menu_proj={'projection';'interp';'filter';'none'};
320    case {'polygon','rectangle','ellipse'}
321        menu_proj={'inside';'outside';'mask_inside';'mask_outside'};
322    case 'volume'
323        menu_proj={'none'};
324end   
325proj_index=get(handles.ProjMode,'Value');
326if proj_index<numel(menu_proj)
327    set(handles.ProjMode,'Value',1);% value index must not exceed the menu length
328end
329set(handles.ProjMode,'String',menu_proj)
330ProjMode_Callback(hObject, eventdata, handles)
331%store the current option
332str=get(handles.ObjectStyle,'String');
333val=get(handles.ObjectStyle,'Value');
334set(handles.ObjectStyle,'UserData',style)
335
336%----------------------------------------------
337function xObject_Callback(hObject, eventdata, handles)
338
339
340function yObject_Callback(hObject, eventdata, handles)
341
342
343% --- Executes on selection change in zObject.
344function zObject_Callback(hObject, eventdata, handles)
345
346
347
348% --- Executes on selection change in ProjMode.
349function ProjMode_Callback(hObject, eventdata, handles)
350menu=get(handles.ProjMode,'String');
351value=get(handles.ProjMode,'Value');
352ProjMode=menu{value};
353menu=get(handles.ObjectStyle,'String');
354value=get(handles.ObjectStyle,'Value');
355ObjectStyle=menu{value};
356test3D=isequal(get(handles.ZObject,'Visible'),'on');%3D case
357
358%default setting
359set(handles.Phi,'Visible','off')
360set(handles.Theta,'Visible','off')
361set(handles.Psi,'Visible','off')
362set(handles.XMin,'Visible','off')
363set(handles.XMax,'Visible','off')
364set(handles.YMin,'Visible','off')
365if isequal(ProjMode,'interp')
366    set(handles.YMax,'Visible','off')
367else
368    set(handles.YMax,'Visible','on')
369end
370if isequal(ObjectStyle,'rectangle')|isequal(ObjectStyle,'ellipse')
371    set(handles.XMax,'Visible','on')
372else
373   set(handles.XMax,'Visible','off')
374end
375set(handles.ZMin,'Visible','off')
376set(handles.ZMax,'Visible','off')
377set(handles.DX,'Visible','off')
378set(handles.DY,'Visible','off')
379set(handles.DZ,'Visible','off')
380
381switch ObjectStyle
382    case 'points'
383        set(handles.YMax,'TooltipString','YMax: range of averaging around each point')
384        set(handles.XObject,'TooltipString','XObject: set of x coordinates of the points')
385        set(handles.YObject,'TooltipString','YObject: set of y coordinates of the points')
386        set(handles.ZObject,'TooltipString','ZObject: set of z coordinates of the points')
387    case {'line','polyline','polygon'}
388        set(handles.YMax,'TooltipString','YMax: range of averaging around the line')
389        set(handles.XObject,'TooltipString','XObject: set of x coordinates defining the line')
390        set(handles.YObject,'TooltipString','YObject: set of y coordinates defining the line')
391        set(handles.ZObject,'TooltipString','ZObject: set of z coordinates defining the line')
392        if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
393            set(handles.DX,'Visible','on')
394            set(handles.DX,'TooltipString','DX: mesh for the interpolated field along the line')
395        end       
396    case {'rectangle','ellipse'}
397        set(handles.XMax,'TooltipString',['XMax: half length of the ' ObjectStyle])
398        set(handles.YMax,'TooltipString',['YMax: half width of the ' ObjectStyle])
399        set(handles.XObject,'TooltipString',['XObject:  x coordinate of the ' ObjectStyle ' centre'])
400        set(handles.YObject,'TooltipString',['YObject:  y coordinate of the ' ObjectStyle ' centre'])
401    case {'plane','volume'} 
402        set(handles.Phi,'Visible','on')
403        set(handles.XMin,'Visible','on')
404        set(handles.XMax,'Visible','on')
405        set(handles.YMin,'Visible','on')
406        set(handles.YMax,'Visible','on')
407        set(handles.XObject,'TooltipString',['XObject:  x coordinate of the axis origin for the ' ObjectStyle])
408        set(handles.YObject,'TooltipString',['YObject:  y coordinate of the axis origin for the ' ObjectStyle])
409        if test3D
410            set(handles.Theta,'Visible','on')
411            set(handles.Psi,'Visible','on')
412            set(handles.ZMin,'Visible','on')
413            set(handles.ZMax,'Visible','on')
414        end
415        if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
416            set(handles.DX,'Visible','on')
417            set(handles.DY,'Visible','on')
418        else
419            set(handles.DX,'Visible','off')
420            set(handles.DY,'Visible','off')
421        end
422        if isequal(ObjectStyle,'volume') && isequal(ProjMode,'interp')
423            set(handles.DZ,'Visible','on') 
424        end
425end
426%
427% %---------------------------------------------
428% % --- Executes on selection change in TITLE.
429% function TITLE_Callback(style, handles)
430% %---------------------------------------------
431% switch style
432%     case {'points','line','polyline','plane'}
433%         menu_proj={'projection';'interp';'filter';'none'};
434%     case {'polygon','rectangle','ellipse'}
435%         menu_proj={'inside';'outside';'mask_inside';'mask_outside'};
436%     case 'volume'
437%         menu_proj={'none'};
438% end
439%
440%
441% old_menu=get(handles.ObjectStyle,'String');
442% value=get(handles.ObjectStyle,'Value');
443% old_style=old_menu{value};
444% teststyle=0;
445% for iline=1:length(menu_style)
446%     if isequal(menu_style{iline},old_style)
447%         styleval=iline;
448%         teststyle=1;
449%         break
450%     end
451% end
452% if ~teststyle
453%     new_style=[];%default
454%     switch old_style
455%         case 'polyline'
456%             new_style='polygon';
457%         case 'polygon'
458%             new_style='polyline';
459%     end
460%     if ~isempty(new_style)
461%         for iline=1:length(menu_style)
462%             if isequal(menu_style{iline},new_style)
463%                 styleval=iline;
464%                 teststyle=1;
465%                 break
466%             end
467%         end
468%     end
469% end
470% if ~teststyle
471%     styleval=1;
472% end
473% set(handles.ObjectStyle,'String',menu_style)
474% set(handles.ObjectStyle,'Value',styleval)
475% set(handles.ProjMode,'String',menu_proj)
476% set(handles.ProjMode,'Value',1)
477% ObjectStyle_Callback(hObject, eventdata, handles) 
478
479%---------------------------------------------
480function Phi_Callback(hObject, eventdata, handles)
481update_slider(hObject, eventdata,handles)
482%---------------------------------------------
483
484function Theta_Callback(hObject, eventdata, handles)
485update_slider(hObject, eventdata,handles)
486
487function update_slider(hObject, eventdata,handles)
488%rotation angles
489Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian
490Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian
491
492%components of the unitiy vector normal to the projection plane
493NormVec_X=-sin(Phi)*sin(Theta);
494NormVec_Y=cos(Phi)*sin(Theta);
495NormVec_Z=cos(Theta);
496huvmat=findobj('Tag','uvmat');%find the current uvmat interface handle
497UvData=get(huvmat,'UserData');%Data associated to the current uvmat interface
498if isfield(UvData,'X') & isfield(UvData,'Y') & isfield(UvData,'Z')
499    Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z);
500    set(handles.z_slider,'Min',min(Z))
501    set(handles.z_slider,'Max',max(Z))
502    ZMax_Callback(hObject, eventdata, handles)
503end
504
505function DX_Callback(hObject, eventdata, handles)
506
507
508function DY_Callback(hObject, eventdata, handles)
509
510
511function DZ_Callback(hObject, eventdata, handles)
512
513
514
515%-----------------------------------------------------
516% --- Executes on button press in OPEN: DESACTIVATED use uvmat browser
517function OPEN_Callback(hObject, eventdata, handles)
518%get the object file
519oldfile=' ';
520huvmat=findobj('Tag','uvmat');
521hchild=get(huvmat,'Children');
522hrootpath=findobj(hchild,'Tag','RootPath');
523if ~isempty(hrootpath)
524    oldfile=get(hrootpath,'String');
525    if iscell(oldfile)
526        oldfile=oldfile{1};
527    end
528end
529[FileName, PathName, filterindex] = uigetfile( ...
530       {'*.xml;*.mat', ' (*.xml,*.mat)';
531       '*.xml',  '.xml files '; ...
532        '*.mat',  '.mat matlab files '}, ...
533        'Pick a file',oldfile);
534fileinput=[PathName FileName];%complete file name
535testblank=findstr(fileinput,' ');%look for blanks
536if ~isempty(testblank)
537    msgbox_uvmat('ERROR','forbidden input file name: contain blanks')
538    return
539end
540sizf=size(fileinput);
541if (~ischar(fileinput)||~isequal(sizf(1),1)),return;end
542
543%read the file
544 t=xmltree(fileinput);
545 s=convert(t);
546 if ~isfield(s,'Style')
547     s.Style='points';
548 end
549 if ~isfield(s,'ProjMode')
550     s.ProjMode='none';
551 end
552%Display title
553% title=set_title(s.Style,s.ProjMode);%update the title
554% if ~isempty(huvmat)
555%     hhuvmat=guidata(huvmat);
556% end
557% menu=get(handles.TITLE,'String');
558% for iline=1:length(menu)
559%      if isequal(menu{iline},title)
560%          set(handles.TITLE,'Value',iline)
561%          break
562%      end
563% end
564%TITLE_Callback(hObject, eventdata, handles)
565teststyle=0;
566
567switch s.Style
568    case {'points','line','polyline','plane'}
569        menu_proj={'projection';'interp';'filter';'none'};
570    case {'polygon','rectangle','ellipse'}
571        menu_proj={'inside';'outside';'mask_inside';'mask_outside'};
572    case 'volume'
573        menu_proj={'none'};
574end
575set(handles.ObjectStyle,'String',menu_proj)
576menu=get(handles.ObjectStyle,'String');
577for iline=1:length(menu)
578    if isequal(menu{iline},s.Style)
579        set(handles.ObjectStyle,'Value',iline)
580        teststyle=1;
581        break
582    end
583end
584testmode=0;
585%menu=get(handles.ProjMode,'String');
586for iline=1:length(menu_proj)
587    if isequal(menu_proj{iline},s.ProjMode)
588        set(handles.ProjMode,'Value',iline)
589        testmode=1;
590        break
591    end
592end
593
594ProjMode_Callback(hObject, eventdata, handles);%visualize the appropriate edit boxes
595if isfield(s,'CoordType')
596    if isequal(s.CoordType,'phys')
597        set(handles.MenuCoord,'Value',1)
598    elseif isequal(s.CoordType,'px')
599        set(handles.MenuCoord,'Value',2)
600    else
601        warndlg('unknown CoordType (px or phys) in set_object.m')
602    end
603end
604if isfield(s,'XMax')
605    set(handles.XMax,'String',s.XMax)
606end
607if isfield(s,'XMin')
608    set(handles.XMin,'String',s.XMin)
609end
610if isfield(s,'YMax')
611    set(handles.YMax,'String',s.YMax)
612end
613if isfield(s,'YMin')
614    set(handles.YMin,'String',s.YMin)
615end
616Range=0;
617if isfield(s,'Range')
618    if ischar(s.Range)
619        Range=str2num(s.Range);
620    else
621        Range(1,:)=str2num(s.Range{1});
622        Range(2,:)=str2num(s.Range{2});
623    end
624end
625if size(Range,2)>=3
626    if size(Range,1)>=2
627       set(handles.ZMin,'String',num2str(Range(2,3),3))
628    end
629    if size(Range,1)>=2
630       set(handles.ZMax,'String',num2str(Range(1,3),3))
631    end
632end
633if size(Range,2)>=2
634    if size(Range,1)>=2
635       set(handles.YMin,'String',num2str(Range(2,2),3))
636    end
637    if size(Range,1)>=2
638       set(handles.YMax,'String',num2str(Range(1,2),3))
639    end
640end
641if size(Range,2)>=1
642    if size(Range,1)>=2
643       set(handles.XMin,'String',num2str(Range(2,1),3))
644    end
645    if size(Range,1)>=2
646       set(handles.XMax,'String',num2str(Range(1,1),3))
647    end
648end
649if isfield(s,'RangeX') & ischar(s.RangeX)
650     RangeX=str2num(s.RangeX);
651    set(handles.XMax,'String',num2str(max(RangeX),3))
652    set(handles.XMin,'String',num2str(min(RangeX),3))
653end
654
655if isfield(s,'RangeY')
656    if ischar(s.RangeY)
657        RangeY=str2num(s.RangeY);
658        set(handles.YMax,'String',num2str(max(RangeY),3))
659        set(handles.YMin,'String',num2str(min(RangeY),3))
660    end
661end
662if isfield(s,'RangeZ')
663    if ischar(s.RangeZ)
664        RangeZ=str2num(s.RangeZ);
665        set(handles.ZMax,'String',num2str(max(RangeZ),3))
666        set(handles.ZMin,'String',num2str(min(RangeZ),3))
667    end
668end
669if isfield(s,'Phi')
670    set(handles.Phi,'String',s.Phi)
671end
672if isfield(s,'Theta')
673    set(handles.Theta,'String',s.Theta)
674end
675if isfield(s,'Psi')
676    set(handles.Psi,'String',s.Psi)
677end
678
679if isfield(s,'DX')
680    set(handles.DX,'String',s.DX)
681end
682if isfield(s,'DY')
683    set(handles.DY,'String',s.DY)
684end
685if ~isfield(s,'Coord')
686    XObject='0';%default
687    YObject='0';
688elseif ischar(s.Coord)
689    line=str2num(s.Coord);
690    XObject=num2str(line(1),4);
691    YObject=num2str(line(2),4);
692else
693    for i=1:length(s.Coord)
694        line=str2num(s.Coord{i});
695        XObject{i}=num2str(line(1),4);
696        YObject{i}=num2str(line(2),4);
697    end
698end
699set(handles.XObject,'String',XObject)
700set(handles.YObject,'String',YObject)
701%METTRA A JOUR ASPECT DE L'INTERFACE (COMME set_object_Opening
702
703%----------------------------------------------------
704% executed when closing: set the parent interface button to value 0
705function closefcn(gcbo,eventdata,parent_button)
706
707huvmat=findobj(allchild(0),'Name','uvmat');%find the current uvmat interface handle
708if ~isempty(huvmat)
709    hhuvmat=guidata(huvmat);
710%     set(hhuvmat.create,'Value',0)
711%     set(hhuvmat.create,'BackgroundColor',[0 1 0])%put unactivated buttons to green
712%     set(hhuvmat.LINE,'Value',0)
713%     set(hhuvmat.LINE,'BackgroundColor',[0 1 0])%put unactivated buttons to green
714%     set(hhuvmat.PATCH,'Value',0)
715%     set(hhuvmat.PATCH,'BackgroundColor',[0 1 0])%put unactivated buttons to green
716%     set(hhuvmat.PLANE,'Value',0)
717%     set(hhuvmat.PLANE,'BackgroundColor',[0 1 0])%put unactivated buttons to green
718%     set(hhuvmat.VOLUME,'Value',0)
719%     set(hhuvmat.VOLUME,'BackgroundColor',[0 1 0])%put unactivated buttons to green
720    set(hhuvmat.edit,'Value',0)
721    set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])%put unactivated buttons to gree
722end
723hseries=findobj(allchild(0),'Name','series');%find the current series interface handle
724if ~isempty(hseries)
725    hhseries=guidata(hseries);
726    set(hhseries.GetObject,'Value',0)
727    set(hhseries.GetObject,'BackgroundColor',[0 1 0])%put unactivated buttons to green
728end
729
730%-----------------------------------------------------------------------
731% --- Executes on button press in PLOT: PLOT the defined object and its projected field
732function PLOT_Callback(hObject, eventdata, handles)
733
734SetData=get(handles.set_object,'UserData');%get the hidden interface data
735huvmat=findobj('Name','uvmat');%find the current uvmat interface handle
736hlist_object=findobj(huvmat,'Tag','list_object_1');%handles of the object list in the GUI uvmat
737IndexObj=get(hlist_object,'Value');%position in the objet list
738UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
739ObjectData=read_set_object(handles);%read the input parameters defining the object in the GUI set_object
740ObjectData.HandlesDisplay=[]; % new object plot by default
741if length(UvData.Object) >= IndexObj && isfield(UvData.Object{IndexObj},'HandlesDisplay')
742    hdisplay=UvData.Object{IndexObj}.HandlesDisplay;
743    if isequal(UvData.Object{IndexObj}.Style, ObjectData.Style) && isequal(UvData.Object{IndexObj}.ProjMode, ObjectData.ProjMode)
744        ObjectData.HandlesDisplay=UvData.Object{IndexObj}.HandlesDisplay;
745    else  % for a new object styl, delete the existing object plots
746        for ih=1:length(hdisplay)
747            PlotData=get(hdisplay(ih),'UserData');
748            if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
749                    delete(PlotData.SubObject);
750            end
751            if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
752                   delete(PlotData.DeformPoint);
753            end
754            if ~isequal(hdisplay(ih),0)
755                delete(hdisplay(ih));
756            end
757        end
758        if isfield(ObjectData,'plotaxes') && ishandle(ObjectData.plotaxes)
759            delete(ObjectData.plotaxes)%delete the axes for plotting the current projection result
760        end
761    end     
762end
763
764% update the object plot and projection field
765UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles);
766
767
768set(huvmat,'UserData',UvData)%update the data in the uvmat interface
769list_str=get(hlist_object,'String');
770% TITLE=set_title(ObjectData.Style,ObjectData.ProjMode);
771% list_str{IndexObj}=[num2str(IndexObj) '-' TITLE];
772list_str{IndexObj}=[num2str(IndexObj) '-' ObjectData.Style];
773% if isequal(length(list_str),IndexObj)
774%     list_str{IndexObj+1}='more...';
775% end
776set(hlist_object_1,'String',list_str)
777set(hlist_object_1,'Value',IndexObj)
778
779%update create buttons on the GUI uvmat: set to object edit mode after object plotting
780hhuvmat=guidata(huvmat);%handles of elements in the uvmat GUI
781%desactivate all create buttons in mode edit
782% if isequal(get(hhuvmat.edit,'Value'),0)
783%     set(hhuvmat.create,'Value',0)
784%     set(hhuvmat.create,'BackgroundColor',[0 1 0])%put unactivated buttons to green
785%     set(hhuvmat.LINE,'Value',0)
786%     set(hhuvmat.LINE,'BackgroundColor',[0 1 0])%put unactivated buttons to green
787%     set(hhuvmat.PATCH,'Value',0)
788%     set(hhuvmat.PATCH,'BackgroundColor',[0 1 0])%put unactivated buttons to green
789%     set(hhuvmat.PLANE,'Value',0)
790%     set(hhuvmat.PLANE,'BackgroundColor',[0 1 0])%put unactivated buttons to green
791%     set(hhuvmat.VOLUME,'Value',0)
792%     set(hhuvmat.VOLUME,'BackgroundColor',[0 1 0])%put unactivated buttons to green
793% end
794set(hhuvmat.MenuEditObject,'enable','on')
795set(hhuvmat.edit,'Value',1)
796set(hhuvmat.edit,'BackgroundColor',[1 1 0]);% paint the edit text in yellow
797UvData.MouseAction='edit_object'; % set the edit button to 'on'
798set(huvmat,'UserData',UvData)
799
800% --- Executes on button press in MenuCoord.
801function MenuCoord_Callback(hObject, eventdata, handles)
802
803%----------------------------------------------------
804function YMin_Callback(hObject, eventdata, handles)
805
806
807function ZMin_Callback(hObject, eventdata, handles)
808
809
810function ZMax_Callback(hObject, eventdata, handles)
811DZ=str2num(get(handles.ZMax,'String'));
812ZMin=get(handles.z_slider,'Min');
813ZMax=get(handles.z_slider,'Max');
814if ~isequal(ZMax-ZMin,0)
815    rel_step(1)=DZ/(ZMax-ZMin);
816    rel_step(2)=0.2;
817    set(handles.z_slider,'SliderStep',rel_step)
818end
819
820function YMax_Callback(hObject, eventdata, handles)
821
822
823function XMin_Callback(hObject, eventdata, handles)
824
825
826function XMax_Callback(hObject, eventdata, handles)
827
828
829% ------------------------------------------------------
830function SAVE_Callback(hObject, eventdata, handles)
831% ------------------------------------------------------
832Object=read_set_object(handles);
833huvmat=findobj('Tag','uvmat');
834% UvData=get(huvmat,'UserData');
835if isempty(huvmat)
836    huvmat=findobj(allchild(0),'Name','series');
837end
838hchild=get(huvmat,'Children');
839hrootpath=findobj(hchild,'Tag','RootPath');
840if isempty(hrootpath)
841    RootPath='';
842else
843    RootPath=get(hrootpath,'String');
844    if iscell(RootPath)
845        RootPath=RootPath{1};
846    end
847end
848title={'object name'};
849dir_save=uigetdir(RootPath);
850def={fullfile(dir_save,['Object' Object.CoordType '.xml'])};
851options.Resize='on';
852displ_txt='save object as an .xml file';%default display
853menu=get(handles.ProjMode,'String');
854value=get(handles.ProjMode,'Value');
855ProjMode=menu{value};
856if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside')
857    displ_txt='save mask contour as an .xml file: to create a mask image, use save_mask on the GUI uvmat (lower right)';
858end
859answer=msgbox_uvmat('INPUT_TXT','save object as an .xml file',def);
860%answer=inputdlg('','save object in a new .xml file',1,def,'on');
861if ~isempty(answer)
862    t=struct2xml(Object);
863    save(t,answer{1})
864end
865msgbox_uvmat('CONFIRMATION',[answer{1}  ' saved'])
866
867%---------------------------------------------------------
868% --- Executes on slider movement.
869function z_slider_Callback(hObject, eventdata, handles)
870%---------------------------------------------------------
871%A ADAPTER
872Z_value=get(handles.z_slider,'Value');
873
874%rotation angles
875Phi=(pi/180)*str2num(get(handles.Phi,'String'));%first Euler angle in radian
876Theta=(pi/180)*str2num(get(handles.Theta,'String'));%second Euler angle in radian
877
878%components of the unity vector normal to the projection plane
879NormVec_X=-sin(Phi)*sin(Theta);
880NormVec_Y=cos(Phi)*sin(Theta);
881NormVec_Z=cos(Theta);
882
883%set new plane position and update graph
884set(handles.XObject,'String',num2str(NormVec_X*Z_value,4))
885set(handles.YObject,'String',num2str(NormVec_Y*Z_value,4))
886set(handles.ZObject,'String',num2str(NormVec_Z*Z_value,4))
887PLOT_Callback(hObject, eventdata, handles)
888
889
890% --- Executes on button press in HELP.
891function HELP_Callback(hObject, eventdata, handles)
892path_to_uvmat=which ('uvmat');% check the path of uvmat
893pathelp=fileparts(path_to_uvmat);
894helpfile=fullfile(pathelp,'uvmat_doc','uvmat_doc.html');
895if isempty(dir(helpfile)), msgbox_uvmat('ERROR','Please put the help file uvmat_doc.html in the sub-directory /uvmat_doc of the UVMAT package')
896else
897    addpath (fullfile(pathelp,'uvmat_doc'))
898    web([helpfile '#set_object'])
899end
900
901
902
Note: See TracBrowser for help on using the repository browser.