0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 function varargout = set_object(varargin)
0031
0032
0033
0034
0035 gui_Singleton = 1;
0036 gui_State = struct('gui_Name', mfilename, ...
0037 'gui_Singleton', gui_Singleton, ...
0038 'gui_OpeningFcn', @set_object_OpeningFcn, ...
0039 'gui_OutputFcn', @set_object_OutputFcn, ...
0040 'gui_LayoutFcn', [] , ...
0041 'gui_Callback', []);
0042 if nargin & isstr(varargin{1})
0043 gui_State.gui_Callback = str2func(varargin{1});
0044 end
0045
0046 if nargout
0047 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0048 else
0049 gui_mainfcn(gui_State, varargin{:});
0050 end
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068 function set_object_OpeningFcn(hObject, eventdata, handles, data, PlotHandles,ZBounds)
0069
0070
0071 handles.output = hObject;
0072
0073
0074 guidata(hObject, handles);
0075
0076
0077 if ~exist('ZBound','var')
0078 ZBound=0;
0079 end
0080 set(hObject,'KeyPressFcn',{'keyboard_callback',handles})
0081 set(handles.MenuCoord,'ListboxTop',1)
0082 if ~exist('PlotHandles','var')
0083 PlotHandles=[];
0084 end
0085 desable_open=0;
0086 desable_plot=0;
0087 SetData.PlotHandles=PlotHandles;
0088 if exist('data','var') & isfield(data,'ParentButton')
0089 SetData.ParentButton=data.ParentButton;
0090 set(hObject,'DeleteFcn',{@closefcn,SetData.ParentButton})
0091 end
0092 set(hObject,'UserData',SetData)
0093
0094
0095 if exist('data','var')
0096 if isfield(data,'desable_open')
0097 desable_open=data.desable_open;
0098 end
0099 if isfield(data,'desable_plot')
0100 desable_plot=data.desable_plot;
0101 end
0102 if ~isfield(data,'NbDim')|~isequal(data.NbDim,3)
0103 set(handles.ZObject,'Visible','off')
0104 set(handles.z_slider,'Visible','off')
0105 else
0106 set(handles.ZObject,'Visible','on')
0107 set(handles.z_slider,'Visible','on')
0108 if isfield(data,'Coord') && size(data.Coord,2)==3
0109 set(handles.ZObject,'String',num2str(data.Coord(1,3),4))
0110 end
0111 end
0112 if isfield(data,'ProjMode') && isfield(data,'Style')
0113 data.TITLE=set_title(data.Style,data.ProjMode);
0114 end
0115 if isfield(data,'TITLE')
0116 menutitle=get(handles.TITLE,'String');
0117 for iline=1:length(menutitle)
0118 strmenu=menutitle{iline};
0119 if isequal(data.TITLE,strmenu)
0120 set(handles.TITLE,'Value',iline)
0121 break
0122 end
0123 end
0124 TITLE_Callback(hObject, eventdata, handles)
0125 end
0126 if isfield(data,'fixedtitle')&isequal(data.fixedtitle,1)
0127 set(handles.TITLE,'enable','off')
0128 end
0129 if isfield(data,'Style')
0130 menu=get(handles.ObjectStyle,'String');
0131 for iline=1:length(menu)
0132 if isequal(menu{iline},data.Style)
0133 set(handles.ObjectStyle,'Value',iline)
0134 break
0135 end
0136 end
0137 end
0138 if isfield(data,'ProjMode')
0139 menu=get(handles.ProjMode,'String');
0140 for iline=1:length(menu)
0141 if isequal(menu{iline},data.ProjMode)
0142 set(handles.ProjMode,'Value',iline)
0143 break
0144 end
0145 end
0146 end
0147 if isfield(data,'Coord') & size(data.Coord,2)>=2
0148 sizcoord=size(data.Coord);
0149 for i=1:sizcoord(1)
0150 XObject{i}=num2str(data.Coord(i,1),4);
0151 YObject{i}=num2str(data.Coord(i,2),4);
0152 end
0153 set(handles.XObject,'String',XObject)
0154 set(handles.YObject,'String',YObject)
0155
0156
0157 if sizcoord(2)>3
0158 for i=1:sizcoord(1)
0159 ZObject{i}=num2str(data.Coord(i,3),4);
0160 end
0161 set(handles.ZObject,'String',ZObject)
0162 end
0163 end
0164 if isfield(data,'DX')
0165 set(handles.DX,'String',num2str(data.DX,3))
0166 end
0167 if isfield(data,'DY')
0168 set(handles.DY,'String',num2str(data.DY,3))
0169 end
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183 if isfield(data,'RangeZ') && length(ZBounds) >= 2
0184 set(handles.ZMax,'String',num2str(max(data.RangeZ),3))
0185 DZ=max(data.RangeZ);
0186 if ZBounds(2)~=ZBounds(1)
0187 rel_step(1)=min(DZ/(ZBounds(2)-ZBounds(1)),0.2);
0188 rel_step(2)=0.1;
0189 set(handles.z_slider,'Visible','on')
0190 set(handles.z_slider,'Min',ZBounds(1))
0191 set(handles.z_slider,'Max',ZBounds(2))
0192 set(handles.z_slider,'SliderStep',rel_step)
0193 set(handles.z_slider,'Value',(ZBounds(1)+ZBounds(2))/2)
0194 end
0195 end
0196 if isfield(data,'RangeX')
0197 set(handles.XMax,'String',num2str(max(data.RangeX),3))
0198 set(handles.XMin,'String',num2str(min(data.RangeX),3))
0199 end
0200 if isfield(data,'RangeY')
0201 set(handles.YMax,'String',num2str(max(data.RangeY),3))
0202 set(handles.YMin,'String',num2str(min(data.RangeY),3))
0203 end
0204 if isfield(data,'RangeZ')
0205 set(handles.ZMax,'String',num2str(max(data.RangeZ),3))
0206 set(handles.ZMin,'String',num2str(min(data.RangeZ),3))
0207 end
0208 if isfield(data,'Phi')
0209 set(handles.Phi,'String',num2str(data.Phi,3))
0210 end
0211 if isfield(data,'Theta')
0212 set(handles.Theta,'String',num2str(data.Theta,3))
0213 end
0214 if isfield(data,'Psi')
0215 set(handles.Psi,'String',num2str(data.Psi,3))
0216 end
0217 if isfield(data,'DZ')
0218 set(handles.DZ,'String',num2str(data.DZ,3))
0219 end
0220 if isfield(data,'CoordType')
0221 if isequal(data.CoordType,'phys')
0222 set(handles.MenuCoord,'Value',1)
0223 elseif isequal(data.CoordType,'px')
0224 set(handles.MenuCoord,'Value',2)
0225 end
0226 end
0227 end
0228 if desable_open
0229 set(handles.OPEN,'Visible','off')
0230 else
0231 set(handles.OPEN,'Visible','on')
0232 end
0233 if desable_plot
0234 set(handles.PLOT,'Visible','off')
0235 else
0236 set(handles.PLOT,'Visible','on')
0237 end
0238
0239
0240
0241 function varargout = set_object_OutputFcn(hObject, eventdata, handles)
0242
0243
0244
0245
0246
0247
0248 varargout{1} = handles.output;
0249 varargout{2}=handles;
0250
0251
0252
0253 function ObjectStyle_Callback(hObject, eventdata, handles)
0254 style_prev=get(handles.ObjectStyle,'UserData');
0255 str=get(handles.ObjectStyle,'String');
0256 val=get(handles.ObjectStyle,'Value');
0257
0258
0259 Xcolumn=get(handles.XObject,'String');
0260 Ycolumn=get(handles.YObject,'String');
0261 if ischar(Xcolumn)
0262 sizchar=size(Xcolumn);
0263 for icol=1:sizchar(1)
0264 Xcolumn_cell{icol}=Xcolumn(icol,:);
0265 end
0266 Xcolumn=Xcolumn_cell;
0267 end
0268 if ischar(Ycolumn)
0269 sizchar=size(Ycolumn);
0270 for icol=1:sizchar(1)
0271 Ycolumn_cell{icol}=Ycolumn(icol,:);
0272 end
0273 Ycolumn=Ycolumn_cell;
0274 end
0275 Zcolumn={};
0276 z_new={};
0277 if isequal(get(handles.ZObject,'Visible'),'on')
0278 data.NbDim=3;
0279 Zcolumn=get(handles.ZObject,'String');
0280 if ischar(Zcolumn)
0281 Zcolumn={Zcolumn};
0282 end
0283 end
0284 x_new{1}=Xcolumn{1};
0285 y_new{1}=Ycolumn{1};
0286 if ~isempty(Zcolumn)
0287 z_new{1}=Zcolumn{1};
0288 end
0289 if isequal(str{val},'line')
0290 if isequal(style_prev,'rectangle')|isequal(style_prev,'ellipse')
0291 XMax=get(handles.XMax,'String');
0292 YMax=get(handles.YMax,'String');
0293 x_new{2}=num2str(XMax,4);
0294 y_new{2}=num2str(YMax,4);
0295 set(handles.XObject,'String',x_new)
0296 set(handles.YObject,'String',y_new)
0297 set(handles.ZObject,'String',z_new)
0298 end
0299 elseif isequal(str{val},'polyline')
0300 elseif isequal(str{val},'rectangle')| isequal(str{val},'ellipse')
0301 set(handles.XObject,'String',x_new)
0302 set(handles.YObject,'String',y_new)
0303 set(handles.ZObject,'String',z_new)
0304 end
0305
0306
0307
0308
0309 ProjMode_Callback(hObject, eventdata, handles)
0310
0311 str=get(handles.ObjectStyle,'String');
0312 val=get(handles.ObjectStyle,'Value');
0313 set(handles.ObjectStyle,'UserData',str{val})
0314
0315
0316 function xObject_Callback(hObject, eventdata, handles)
0317
0318
0319 function yObject_Callback(hObject, eventdata, handles)
0320
0321
0322
0323 function zObject_Callback(hObject, eventdata, handles)
0324
0325
0326
0327
0328 function ProjMode_Callback(hObject, eventdata, handles)
0329 menu=get(handles.ProjMode,'String');
0330 value=get(handles.ProjMode,'Value');
0331 ProjMode=menu{value};
0332 menu=get(handles.ObjectStyle,'String');
0333 value=get(handles.ObjectStyle,'Value');
0334 ObjectStyle=menu{value};
0335 test3D=isequal(get(handles.ZObject,'Visible'),'on');
0336 if isequal(ObjectStyle,'plane')|isequal(ObjectStyle,'volume')
0337 set(handles.Phi,'Visible','on')
0338 if test3D
0339 set(handles.Theta,'Visible','on')
0340 set(handles.Psi,'Visible','on')
0341 end
0342 set(handles.XMin,'Visible','on')
0343 set(handles.XMax,'Visible','on')
0344 set(handles.YMin,'Visible','on')
0345 set(handles.YMax,'Visible','on')
0346 if test3D
0347 set(handles.Theta,'Visible','on')
0348 set(handles.Psi,'Visible','on')
0349 set(handles.ZMin,'Visible','on')
0350 set(handles.ZMax,'Visible','on')
0351 end
0352 else
0353 set(handles.Phi,'Visible','off')
0354 set(handles.Theta,'Visible','off')
0355 set(handles.Psi,'Visible','off')
0356 set(handles.XMin,'Visible','off')
0357 set(handles.XMax,'Visible','off')
0358 set(handles.YMin,'Visible','off')
0359 if isequal(ProjMode,'interp')
0360 set(handles.YMax,'Visible','off')
0361 else
0362 set(handles.YMax,'Visible','on')
0363 end
0364 if isequal(ObjectStyle,'rectangle')|isequal(ObjectStyle,'ellipse')
0365 set(handles.XMax,'Visible','on')
0366 else
0367 set(handles.XMax,'Visible','off')
0368 end
0369 set(handles.ZMin,'Visible','off')
0370 set(handles.ZMax,'Visible','off')
0371 end
0372 TITLE_list=get(handles.TITLE,'String');
0373 val=get(handles.TITLE,'Value');
0374 TITLE=TITLE_list{val};
0375 switch TITLE
0376 case {'POINTS','PATCH','MASK'}
0377 set(handles.DX,'Visible','off')
0378 set(handles.DY,'Visible','off')
0379 set(handles.DZ,'Visible','off')
0380 case {'LINE'}
0381 if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
0382 set(handles.DX,'Visible','on')
0383 else
0384 set(handles.DX,'Visible','off')
0385 end
0386 case {'PLANE'}
0387 if isequal(ProjMode,'interp')|| isequal(ProjMode,'filter')
0388 set(handles.DX,'Visible','on')
0389 set(handles.DY,'Visible','on')
0390 else
0391 set(handles.DX,'Visible','off')
0392 set(handles.DY,'Visible','off')
0393 end
0394 case {'VOLUME'}
0395 if isequal(ProjMode,'interp')
0396 set(handles.DX,'Visible','on')
0397 set(handles.DY,'Visible','on')
0398 set(handles.DZ,'Visible','on')
0399 else
0400 set(handles.DX,'Visible','off')
0401 set(handles.DY,'Visible','off')
0402 set(handles.DZ,'Visible','off')
0403 end
0404 end
0405
0406
0407
0408 function TITLE_Callback(hObject, eventdata, handles)
0409
0410 hsetobject=get(handles.TITLE,'parent');
0411 SetData=get(hsetobject,'UserData');
0412
0413 menu=get(handles.TITLE,'String');
0414 value=get(handles.TITLE,'Value');
0415 titl=menu{value};
0416 if isequal(titl,'POINTS');
0417 menu_style={'points'};
0418 menu_proj={'projection';'interp';'filter';'none'};
0419 elseif isequal(titl,'LINE')
0420 menu_style={'line';'polyline';'rectangle';'polygon';'ellipse'};
0421 menu_proj={'projection';'interp';'filter';'none'};
0422 elseif isequal(titl,'PATCH')
0423 menu_style={'rectangle';'polygon';'ellipse'};
0424 menu_proj={'inside';'outside'};
0425 elseif isequal(titl,'MASK')
0426 menu_style={'polygon'};
0427 menu_proj={'mask_inside';'mask_outside'};
0428 elseif isequal(titl,'PLANE')
0429 menu_style={'plane'};
0430 menu_proj={'projection';'interp';'filter';'none'};
0431 elseif isequal(titl,'VOLUME')
0432 menu_style={'volume'};
0433 menu_proj={'none'};
0434
0435 end
0436 old_menu=get(handles.ObjectStyle,'String');
0437 value=get(handles.ObjectStyle,'Value');
0438 old_style=old_menu{value};
0439 teststyle=0;
0440 for iline=1:length(menu_style)
0441 if isequal(menu_style{iline},old_style)
0442 styleval=iline;
0443 teststyle=1;
0444 break
0445 end
0446 end
0447 if ~teststyle
0448 new_style=[];
0449 switch old_style
0450 case 'polyline'
0451 new_style='polygon';
0452 case 'polygon'
0453 new_style='polyline';
0454 end
0455 if ~isempty(new_style)
0456 for iline=1:length(menu_style)
0457 if isequal(menu_style{iline},new_style)
0458 styleval=iline;
0459 teststyle=1;
0460 break
0461 end
0462 end
0463 end
0464 end
0465 if ~teststyle
0466 styleval=1;
0467 end
0468 set(handles.ObjectStyle,'String',menu_style)
0469 set(handles.ObjectStyle,'Value',styleval)
0470 set(handles.ProjMode,'String',menu_proj)
0471 set(handles.ProjMode,'Value',1)
0472 ObjectStyle_Callback(hObject, eventdata, handles)
0473
0474
0475 function Phi_Callback(hObject, eventdata, handles)
0476 update_slider(hObject, eventdata,handles)
0477
0478
0479 function Theta_Callback(hObject, eventdata, handles)
0480 update_slider(hObject, eventdata,handles)
0481
0482 function update_slider(hObject, eventdata,handles)
0483
0484 Phi=(pi/180)*str2num(get(handles.Phi,'String'));
0485 Theta=(pi/180)*str2num(get(handles.Theta,'String'));
0486
0487
0488 NormVec_X=-sin(Phi)*sin(Theta);
0489 NormVec_Y=cos(Phi)*sin(Theta);
0490 NormVec_Z=cos(Theta);
0491 huvmat=findobj('Tag','uvmat');
0492 UvData=get(huvmat,'UserData');
0493 if isfield(UvData,'X') & isfield(UvData,'Y') & isfield(UvData,'Z')
0494 Z=NormVec_X *(UvData.X)+NormVec_Y *(UvData.Y)+NormVec_Z *(UvData.Z);
0495 set(handles.z_slider,'Min',min(Z))
0496 set(handles.z_slider,'Max',max(Z))
0497 ZMax_Callback(hObject, eventdata, handles)
0498 end
0499
0500 function DX_Callback(hObject, eventdata, handles)
0501
0502
0503 function DY_Callback(hObject, eventdata, handles)
0504
0505
0506 function DZ_Callback(hObject, eventdata, handles)
0507
0508
0509
0510
0511
0512 function OPEN_Callback(hObject, eventdata, handles)
0513
0514 oldfile=' ';
0515 huvmat=findobj('Tag','uvmat');
0516
0517
0518
0519 hchild=get(huvmat,'Children');
0520 hrootpath=findobj(hchild,'Tag','RootPath');
0521 if ~isempty(hrootpath)
0522 oldfile=get(hrootpath,'String');
0523 if iscell(oldfile)
0524 oldfile=oldfile{1};
0525 end
0526 end
0527
0528 [FileName, PathName, filterindex] = uigetfile( ...
0529 {'*.xml;*.mat', ' (*.xml,*.mat)';
0530 '*.xml', '.xml files '; ...
0531 '*.mat', '.mat matlab files '}, ...
0532 'Pick a file',oldfile);
0533 fileinput=[PathName FileName];
0534 testblank=findstr(fileinput,' ');
0535 if ~isempty(testblank)
0536 errordlg('forbidden input file name: contain blanks')
0537 return
0538 end
0539 sizf=size(fileinput);
0540 if (~ischar(fileinput)|~isequal(sizf(1),1)),return;end
0541
0542
0543 t=xmltree(fileinput);
0544 s=convert(t);
0545 if ~isfield(s,'Style')
0546 s.Style='points';
0547 end
0548 if ~isfield(s,'ProjMode')
0549 s.ProjMode='none';
0550 end
0551
0552 title=set_title(s.Style,s.ProjMode);
0553 if ~isempty(huvmat)
0554 hhuvmat=guidata(huvmat);
0555
0556
0557
0558
0559
0560
0561
0562
0563
0564
0565
0566
0567
0568
0569 end
0570 menu=get(handles.TITLE,'String');
0571 for iline=1:length(menu)
0572 if isequal(menu{iline},title)
0573 set(handles.TITLE,'Value',iline)
0574 break
0575 end
0576 end
0577 TITLE_Callback(hObject, eventdata, handles)
0578 teststyle=0;
0579
0580 menu=get(handles.ObjectStyle,'String');
0581 for iline=1:length(menu)
0582 if isequal(menu{iline},s.Style)
0583 set(handles.ObjectStyle,'Value',iline)
0584 teststyle=1;
0585 break
0586 end
0587 end
0588 testmode=0;
0589 menu=get(handles.ProjMode,'String');
0590 for iline=1:length(menu)
0591 if isequal(menu{iline},s.ProjMode)
0592 set(handles.ProjMode,'Value',iline)
0593 testmode=1;
0594 break
0595 end
0596 end
0597
0598 ProjMode_Callback(hObject, eventdata, handles);
0599 if isfield(s,'CoordType')
0600 if isequal(s.CoordType,'phys')
0601 set(handles.MenuCoord,'Value',1)
0602 elseif isequal(s.CoordType,'px')
0603 set(handles.MenuCoord,'Value',2)
0604 else
0605 warndlg('unknown CoordType (px or phys) in set_object.m')
0606 end
0607 end
0608 if isfield(s,'XMax')
0609 set(handles.XMax,'String',s.XMax)
0610 end
0611 if isfield(s,'XMin')
0612 set(handles.XMin,'String',s.XMin)
0613 end
0614 if isfield(s,'YMax')
0615 set(handles.YMax,'String',s.YMax)
0616 end
0617 if isfield(s,'YMin')
0618 set(handles.YMin,'String',s.YMin)
0619 end
0620 Range=0;
0621 if isfield(s,'Range')
0622 if ischar(s.Range)
0623 Range=str2num(s.Range);
0624 else
0625 Range(1,:)=str2num(s.Range{1});
0626 Range(2,:)=str2num(s.Range{2});
0627 end
0628 end
0629 if size(Range,2)>=3
0630 if size(Range,1)>=2
0631 set(handles.ZMin,'String',num2str(Range(2,3),3))
0632 end
0633 if size(Range,1)>=2
0634 set(handles.ZMax,'String',num2str(Range(1,3),3))
0635 end
0636 end
0637 if size(Range,2)>=2
0638 if size(Range,1)>=2
0639 set(handles.YMin,'String',num2str(Range(2,2),3))
0640 end
0641 if size(Range,1)>=2
0642 set(handles.YMax,'String',num2str(Range(1,2),3))
0643 end
0644 end
0645 if size(Range,2)>=1
0646 if size(Range,1)>=2
0647 set(handles.XMin,'String',num2str(Range(2,1),3))
0648 end
0649 if size(Range,1)>=2
0650 set(handles.XMax,'String',num2str(Range(1,1),3))
0651 end
0652 end
0653 if isfield(s,'RangeX') & ischar(s.RangeX)
0654 RangeX=str2num(s.RangeX);
0655 set(handles.XMax,'String',num2str(max(RangeX),3))
0656 set(handles.XMin,'String',num2str(min(RangeX),3))
0657 end
0658
0659 if isfield(s,'RangeY')
0660 if ischar(s.RangeY)
0661 RangeY=str2num(s.RangeY);
0662 set(handles.YMax,'String',num2str(max(RangeY),3))
0663 set(handles.YMin,'String',num2str(min(RangeY),3))
0664 end
0665 end
0666 if isfield(s,'RangeZ')
0667 if ischar(s.RangeZ)
0668 RangeZ=str2num(s.RangeZ);
0669 set(handles.ZMax,'String',num2str(max(RangeZ),3))
0670 set(handles.ZMin,'String',num2str(min(RangeZ),3))
0671 end
0672 end
0673 if isfield(s,'Phi')
0674 set(handles.Phi,'String',s.Phi)
0675 end
0676 if isfield(s,'Theta')
0677 set(handles.Theta,'String',s.Theta)
0678 end
0679 if isfield(s,'Psi')
0680 set(handles.Psi,'String',s.Psi)
0681 end
0682
0683 if isfield(s,'DX')
0684 set(handles.DX,'String',s.DX)
0685 end
0686 if isfield(s,'DY')
0687 set(handles.DY,'String',s.DY)
0688 end
0689 if ~isfield(s,'Coord')
0690 XObject='0';
0691 YObject='0';
0692 elseif ischar(s.Coord)
0693 line=str2num(s.Coord);
0694 XObject=num2str(line(1),4);
0695 YObject=num2str(line(2),4);
0696 else
0697 for i=1:length(s.Coord)
0698 line=str2num(s.Coord{i});
0699 XObject{i}=num2str(line(1),4);
0700 YObject{i}=num2str(line(2),4);
0701 end
0702 end
0703 set(handles.XObject,'String',XObject)
0704 set(handles.YObject,'String',YObject)
0705
0706
0707
0708
0709 function closefcn(gcbo,eventdata,parent_button)
0710
0711 huvmat=findobj(allchild(0),'Name','uvmat');
0712 if ~isempty(huvmat)
0713 hhuvmat=guidata(huvmat);
0714 set(hhuvmat.create,'Value',0)
0715 set(hhuvmat.create,'BackgroundColor',[0 1 0])
0716
0717
0718
0719
0720
0721
0722
0723
0724 set(hhuvmat.edit,'Value',0)
0725 set(hhuvmat.edit,'BackgroundColor',[0.7 0.7 0.7])
0726 end
0727 hseries=findobj(allchild(0),'Name','series');
0728 if ~isempty(hseries)
0729 hhseries=guidata(hseries);
0730 set(hhseries.GetObject,'Value',0)
0731 set(hhseries.GetObject,'BackgroundColor',[0 1 0])
0732 end
0733
0734
0735
0736 function PLOT_Callback(hObject, eventdata, handles)
0737
0738 hsetobject=get(handles.PLOT,'parent');
0739 SetData=get(hsetobject,'UserData');
0740 huvmat=findobj('Name','uvmat');
0741 hlist_object=findobj(huvmat,'Tag','list_object');
0742 IndexObj=get(hlist_object,'Value');
0743 UvData=get(huvmat,'UserData');
0744 ObjectData=read_set_object(handles);
0745 ObjectData.HandlesDisplay=[];
0746 if length(UvData.Object) >= IndexObj && isfield(UvData.Object{IndexObj},'HandlesDisplay')
0747 hdisplay=UvData.Object{IndexObj}.HandlesDisplay;
0748 if isequal(UvData.Object{IndexObj}.Style, ObjectData.Style) && isequal(UvData.Object{IndexObj}.ProjMode, ObjectData.ProjMode)
0749 ObjectData.HandlesDisplay=UvData.Object{IndexObj}.HandlesDisplay;
0750 else
0751 for ih=1:length(hdisplay)
0752 PlotData=get(hdisplay(ih),'UserData');
0753 if isfield(PlotData,'SubObject') & ishandle(PlotData.SubObject)
0754 delete(PlotData.SubObject);
0755 end
0756 if isfield(PlotData,'DeformPoint') & ishandle(PlotData.DeformPoint)
0757 delete(PlotData.DeformPoint);
0758 end
0759 if ~isequal(hdisplay(ih),0)
0760 delete(hdisplay(ih));
0761 end
0762 end
0763 if isfield(ObjectData,'plotaxes') && ishandle(ObjectData.plotaxes)
0764 delete(ObjectData.plotaxes)
0765 end
0766 end
0767 end
0768
0769
0770 UvData.Object{IndexObj}=update_obj(UvData,IndexObj,ObjectData,SetData.PlotHandles);
0771
0772 set(huvmat,'UserData',UvData)
0773 list_str=get(hlist_object,'String');
0774 TITLE=set_title(ObjectData.Style,ObjectData.ProjMode);
0775 list_str{IndexObj}=[num2str(IndexObj) '-' TITLE];
0776 if isequal(length(list_str),IndexObj)
0777 list_str{IndexObj+1}='more...';
0778 end
0779 set(hlist_object,'String',list_str)
0780 set(hlist_object,'Value',IndexObj)
0781
0782
0783 hhuvmat=guidata(huvmat);
0784
0785
0786 set(hhuvmat.create,'Value',0)
0787 set(hhuvmat.create,'BackgroundColor',[0 1 0])
0788
0789
0790
0791
0792
0793
0794
0795
0796
0797 set(hhuvmat.edit,'Value',1)
0798 set(hhuvmat.edit,'BackgroundColor',[1 1 0]);
0799 set(hhuvmat.edit,'Value',1);
0800 UvData.MouseAction='edit_object';
0801 set(huvmat,'UserData',UvData)
0802
0803
0804 function MenuCoord_Callback(hObject, eventdata, handles)
0805
0806
0807 function YMin_Callback(hObject, eventdata, handles)
0808
0809
0810 function ZMin_Callback(hObject, eventdata, handles)
0811
0812
0813 function ZMax_Callback(hObject, eventdata, handles)
0814 DZ=str2num(get(handles.ZMax,'String'));
0815 ZMin=get(handles.z_slider,'Min');
0816 ZMax=get(handles.z_slider,'Max');
0817 if ~isequal(ZMax-ZMin,0)
0818 rel_step(1)=DZ/(ZMax-ZMin);
0819 rel_step(2)=0.2;
0820 set(handles.z_slider,'SliderStep',rel_step)
0821 end
0822
0823 function YMax_Callback(hObject, eventdata, handles)
0824
0825
0826 function XMin_Callback(hObject, eventdata, handles)
0827
0828
0829 function XMax_Callback(hObject, eventdata, handles)
0830
0831
0832
0833 function SAVE_Callback(hObject, eventdata, handles)
0834
0835 Object=read_set_object(handles);
0836 huvmat=findobj('Tag','uvmat');
0837
0838 if isempty(huvmat)
0839 huvmat=findobj(allchild(0),'Name','series');
0840 end
0841 hchild=get(huvmat,'Children');
0842 hrootpath=findobj(hchild,'Tag','RootPath');
0843 if isempty(hrootpath)
0844 RootPath='';
0845 else
0846 RootPath=get(hrootpath,'String');
0847 if iscell(RootPath)
0848 RootPath=RootPath{1};
0849 end
0850 end
0851 title={'object name'};
0852 dir_save=uigetdir(RootPath);
0853 def={fullfile(dir_save,['Object' Object.CoordType '.xml'])};
0854 options.Resize='on';
0855 displ_txt='save object as an .xml file';
0856 menu=get(handles.ProjMode,'String');
0857 value=get(handles.ProjMode,'Value');
0858 ProjMode=menu{value};
0859 if strcmp(ProjMode,'mask_inside')||strcmp(ProjMode,'mask_outside')
0860 displ_txt='save mask contour as an .xml file: to create a mask image, use save_mask on the GUI uvmat (lower right)';
0861 end
0862 answer=msgbox_uvmat('INPUT_TXT','save object as an .xml file',def);
0863
0864 if ~isempty(answer)
0865 t=struct2xml(Object);
0866 save(t,answer{1})
0867 end
0868 msgbox_uvmat('CONFIRMATION',[answer{1} ' saved'])
0869
0870
0871 function z_slider_Callback(hObject, eventdata, handles)
0872
0873
0874 Z_value=get(handles.z_slider,'Value');
0875
0876
0877 Phi=(pi/180)*str2num(get(handles.Phi,'String'));
0878 Theta=(pi/180)*str2num(get(handles.Theta,'String'));
0879
0880
0881 NormVec_X=-sin(Phi)*sin(Theta);
0882 NormVec_Y=cos(Phi)*sin(Theta);
0883 NormVec_Z=cos(Theta);
0884
0885
0886 set(handles.XObject,'String',num2str(NormVec_X*Z_value,4))
0887 set(handles.YObject,'String',num2str(NormVec_Y*Z_value,4))
0888 set(handles.ZObject,'String',num2str(NormVec_Z*Z_value,4))
0889 PLOT_Callback(hObject, eventdata, handles)
0890
0891
0892
0893 function XObject_Callback(hObject, eventdata, handles)
0894
0895
0896 function YObject_Callback(hObject, eventdata, handles)
0897
0898
0899
0900
0901 function ZObject_Callback(hObject, eventdata, handles)
0902
0903
0904
0905 function HELP_Callback(hObject, eventdata, handles)
0906 path_to_uvmat=which ('uvmat');
0907 pathelp=fileparts(path_to_uvmat);
0908 helpfile=fullfile(pathelp,'UVMAT_DOC','uvmat_doc.html');
0909 if isempty(dir(helpfile)), errordlg('Please put the help file uvmat_doc.html in the directory UVMAT/UVMAT_DOC')
0910 else
0911 web([helpfile '#set_object'])
0912 end
0913
0914
0915
0916