Changeset 61 for trunk/src/view_field.m
- Timestamp:
- Mar 24, 2010, 12:51:51 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/view_field.m
r60 r61 70 70 % set the position of colorbar and ancillary GUIs: 71 71 set(hObject,'Units','Normalized') 72 movegui(hObject,'center')73 UvData.PosColorbar=[0.805 0.022 0.019 0.445];74 UvData.SetObjectOrigin=[-0.05 -0.03]; %position for set_object75 UvData.SetObjectSize=[0.3 0.7];76 UvData.CalOrigin=[0.95 -0.03];%position for geometry_calib (TO IMPROVE)77 UvData.CalSize=[0.28 1];78 72 handles_mouse=handles; 79 73 huvmat=findobj(allchild(0),'Name','uvmat'); 80 74 hhuvmat=guidata(huvmat); 81 handles_mouse.create=hhuvmat.create; 75 set(hhuvmat.list_object_2,'Visible','on') 76 % handles_mouse.create=hhuvmat.create; 82 77 handles_mouse.edit=hhuvmat.edit; 78 pos_uvmat=get(huvmat,'Position'); 79 pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2; 80 pos_view_field(2)=pos_uvmat(2)-pos_uvmat(3)/4; 81 pos_view_field(3:4)=pos_uvmat(3:4); 82 set(hObject,'Position',pos_view_field) 83 84 83 85 84 86 %functions for the mouse and keyboard … … 87 89 set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function 88 90 set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse}) 89 91 % set(hObject,'CloseRequestFcn ',{'close_fcn'}) 90 92 91 93 [PlotType,PlotParamOut,haxes]= plot_field(Field,handles.axes3)%,PlotParam,KeepLim,PosColorbar) … … 94 96 function varargout = view_field_OutputFcn(hObject, eventdata, handles) 95 97 varargout{1} = handles.output;% the only output argument is the handle to the GUI figure 98 96 99 97 100 %------------------------------------------------------------------- … … 1988 1991 end 1989 1992 1990 %------------------------------------------------1991 function create_Callback(hObject,eventdata,handles)1992 %------------------------------------------------1993 if ishandle(handles.VIEW_FIELD_title)1994 delete(handles.VIEW_FIELD_title)1995 end1996 huvmat=get(handles.create,'parent');1997 UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface (handles huvmat)1998 if isequal(get(handles.create,'Value'),1)1999 set(handles.zoom,'Value',0)2000 zoom_Callback(hObject, eventdata, handles)2001 set(handles.create,'BackgroundColor',[1 1 0]) %visualise in yellow2002 set(handles.edit_vect,'Value',0)2003 edit_vect_Callback(hObject, eventdata, handles)2004 set(handles.edit,'Value',0)2005 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2006 list_object=get(handles.list_object,'String');2007 if ~isempty(list_object)2008 set(handles.list_object,'Value',length(list_object))2009 end2010 MouseAction='create_object';2011 hset_object=findobj(allchild(0),'Name','set_object');2012 uistack(hset_object,'top')2013 else2014 set(handles.create,'BackgroundColor',[0 1 0])2015 set(handles.edit,'Value',1)2016 set(handles.edit,'BackgroundColor',[1 1 0])2017 MouseAction='none';2018 end2019 2020 UvData.MouseAction=MouseAction;2021 set(huvmat,'UserData',UvData);2022 2023 %------------------------------------------------2024 function POINTS_Callback(hObject,eventdata,handles)2025 %------------------------------------------------2026 if ishandle(handles.VIEW_FIELD_title)2027 delete(handles.VIEW_FIELD_title)2028 end2029 huvmat=get(handles.create,'parent');2030 UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface (handles huvmat)2031 if isequal(get(handles.create,'Value'),1)2032 set(handles.zoom,'Value',0)2033 zoom_Callback(hObject, eventdata, handles)2034 set(handles.edit_vect,'Value',0)2035 edit_vect_Callback(hObject, eventdata, handles)2036 set(handles.edit,'Value',0)2037 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2038 %set(handles.grid,'Value',0)2039 %set(handles.grid,'BackgroundColor',[0 1 0])2040 % initiate set_object GUI2041 data.TITLE='POINTS';2042 if isfield(UvData,'CoordType')2043 data.CoordType=UvData.CoordType;2044 end2045 if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)2046 data.RangeY=UvData.Mesh;2047 elseif isfield(UvData,'AX')&isfield(UvData,'AY')& isfield(UvData,'A')%only image2048 np=size(UvData.Field.A);2049 meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);2050 meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);2051 data.RangeY=max(meshx,meshy);2052 data.DX=max(meshx,meshy);2053 end2054 data.Coord=[0 0 0]; %default2055 data.ParentButton=handles.create;2056 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters2057 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface2058 if isfield(UvData,'SetObjectOrigin')2059 pos_view_field=get(huvmat,'Position');2060 pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);2061 pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4);2062 set(hset_object,'Position',pos_set_object)2063 end2064 %set(hset_object,'Position',[pos_view_field(1) pos_view_field(2)-0.05*pos_view_field(4) 0.2*pos_view_field(3) 0.5*pos_view_field(4)]);2065 list_object=get(handles.list_object,'String');2066 if ~isempty(list_object)2067 set(handles.list_object,'Value',length(list_object))2068 end2069 MouseAction='create_object';2070 %UvData.ZoomOn=0;2071 else2072 set(handles.create,'BackgroundColor',[0 1 0])2073 set(handles.edit,'Value',1)2074 set(handles.edit,'BackgroundColor',[1 1 0])2075 MouseAction='none';2076 end2077 2078 UvData.MouseAction=MouseAction;2079 set(huvmat,'UserData',UvData);2080 2081 %-----------------------------------------------------------2082 function LINE_Callback(hObject, eventdata, handles)2083 %-------------------------------------------------2084 if ishandle(handles.VIEW_FIELD_title)2085 delete(handles.VIEW_FIELD_title)2086 end2087 % handles.view_field2088 huvmat=get(handles.create,'parent');2089 UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface2090 set(handles.zoom,'Value',0)2091 zoom_Callback(hObject, eventdata, handles)2092 set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])2093 set(handles.edit_vect,'Value',0)2094 edit_vect_Callback(hObject, eventdata, handles)2095 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2096 set(handles.edit,'Value',0)2097 set(handles.list_object,'Value',1);2098 edit_vect_Callback(hObject, eventdata, handles)2099 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2100 set(handles.cal,'Value',0)2101 set(handles.cal,'BackgroundColor',[0 1 0])2102 % initiate the set_object GUI2103 data.TITLE='LINE';2104 if isfield(UvData,'CoordType')2105 data.CoordType=UvData.CoordType;2106 end2107 if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)2108 data.RangeX=UvData.Mesh;2109 data.RangeY=UvData.Mesh;2110 data.DX=UvData.Mesh;2111 data.DY=UvData.Mesh;2112 elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image2113 np=size(UvData.Field.A);2114 meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);2115 meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);2116 data.RangeY=max(meshx,meshy);2117 data.RangeX=max(meshx,meshy);2118 data.DX=max(meshx,meshy);2119 end2120 if isfield(data,'DX')2121 data.Coord=[[0 0 0];[data.DX 0 0]]; %default2122 else2123 data.Coord=[[0 0 0];[1 0 0]]; %default2124 end2125 data.ParentButton=handles.create;2126 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters2127 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,2128 % associate the set_edit interface handle to the plotting axes2129 pos_view_field=get(huvmat,'Position');2130 if isfield(UvData,'SetObjectOrigin')2131 pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);2132 pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4);2133 set(hset_object,'Position',pos_set_object)2134 end2135 list_object=get(handles.list_object,'String');2136 if ~isempty(list_object)2137 set(handles.list_object,'Value',length(list_object))2138 end2139 MouseAction='create_object';2140 UvData.MouseAction=MouseAction;2141 set(huvmat,'UserData',UvData)2142 2143 %-----------------------------------------------------------2144 function PATCH_Callback(hObject, eventdata, handles)2145 %-----------------------------------------------------------2146 if ishandle(handles.VIEW_FIELD_title)2147 delete(handles.VIEW_FIELD_title)2148 end2149 huvmat=get(handles.create,'parent');2150 UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface2151 % if isequal(get(handles.PATCH,'Value'),1)2152 set(handles.zoom,'Value',0)2153 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])2154 % set(handles.create,'Value',0)%suppress the other options if LINE is chosen2155 % set(handles.create,'BackgroundColor',[0 1 0])2156 % set(handles.LINE,'Value',0)2157 % set(handles.LINE,'BackgroundColor',[0 1 0])2158 % set(handles.PATCH,'Value',1)2159 % set(handles.PATCH,'BackgroundColor',[1 1 0])2160 % set(handles.PLANE,'Value',0)2161 % set(handles.PLANE,'BackgroundColor',[0 1 0])%put activated buttons to yellow2162 % set(handles.VOLUME,'Value',0)2163 % set(handles.VOLUME,'BackgroundColor',[0 1 0])2164 %set(handles.makemask,'Value',0)2165 %makemask_Callback(hObject, eventdata, handles)2166 set(handles.edit_vect,'Value',0)2167 edit_vect_Callback(hObject, eventdata, handles)2168 set(handles.edit,'Value',0)2169 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2170 set(handles.edit_vect,'Value',0)2171 edit_vect_Callback(hObject, eventdata, handles)2172 set(handles.cal,'Value',0)2173 set(handles.cal,'BackgroundColor',[0 1 0])2174 %set(handles.grid,'Value',0)2175 %set(handles.grid,'BackgroundColor',[0 1 0])2176 %initiate set_object GUI2177 data.TITLE='PATCH';2178 if isfield(UvData,'CoordType')2179 data.CoordType=UvData.CoordType;2180 end2181 if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)2182 data.YMax=UvData.Mesh;2183 elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image2184 np=size(UvData.Field.A);2185 meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);2186 meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);2187 data.YMax=max(meshx,meshy);2188 data.DX=max(meshx,meshy);2189 end2190 data.Coord=[0 0 0]; %default2191 data.ParentButton=handles.create;2192 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters2193 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface2194 pos_view_field=get(huvmat,'Position');2195 if isfield(UvData,'SetObjectOrigin')2196 pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);2197 pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4);2198 set(hset_object,'Position',pos_set_object)2199 end2200 list_object=get(handles.list_object,'String');2201 if ~isempty(list_object)2202 set(handles.list_object,'Value',length(list_object))2203 end2204 UvData.MouseAction='create_object';2205 set(huvmat,'UserData',UvData);2206 %-------------------------------------------------------2207 function PLANE_Callback(hObject, eventdata, handles)2208 %-------------------------------------------------------2209 if ishandle(handles.VIEW_FIELD_title)2210 delete(handles.VIEW_FIELD_title)2211 end2212 huvmat=get(handles.create,'parent');2213 UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface2214 set(handles.zoom,'Value',0)2215 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])2216 set(handles.edit_vect,'Value',0)2217 edit_vect_Callback(hObject, eventdata, handles)2218 set(handles.edit,'Value',0)2219 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2220 set(handles.cal,'Value',0)2221 set(handles.cal,'BackgroundColor',[0 1 0])2222 %set(handles.grid,'Value',0)2223 %set(handles.grid,'BackgroundColor',[0 1 0])2224 %initiate set_object GUI2225 data.TITLE='PLANE';2226 if isfield(UvData,'CoordType')2227 data.CoordType=UvData.CoordType;2228 end2229 %Si 3D data.nbdim=3;2230 %Si 2D2231 if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)2232 data.ZMax=UvData.Mesh;2233 data.DX=UvData.Mesh;2234 data.DY=UvData.Mesh;2235 elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image2236 np=size(UvData.Field.A);2237 meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/(np(2)-1);2238 meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/(np(1)-1);2239 data.DX=max(meshx,meshy);2240 end2241 if isfield(UvData,'DX')2242 data.DX=UvData.DX;2243 end2244 if isfield(UvData,'DY')2245 data.DY=UvData.DY;2246 elseif isfield(UvData,'Mesh')2247 data.DY=UvData.Mesh;2248 end2249 if isfield(UvData.Field,'X')& isfield(UvData.Field,'Y')2250 data.Coord=[0 0 0];2251 data.Style='plane';2252 data.Phi=0;2253 data.IndexObj=1; %act on the first reference plane by default2254 haxes= handles.axes3;%GENERALISER2255 plot_object(data,[],haxes,'m'); %plot the axes of the default plane2256 end2257 data.ParentButton=handles.create;2258 PlotHandles=get_plot_handles(handles);%get the handles of the graphic objects setting the plotting parameters2259 ZBounds=0; % default2260 if isfield(UvData,'ZMin') && isfield(UvData,'ZMax')2261 ZBounds(1)=UvData.ZMin; %minimum for the Z slider2262 ZBounds(2)=UvData.ZMax;%maximum for the Z slider2263 end2264 [hset_object,UvData.sethandles]=set_object(data,PlotHandles,ZBounds);% call the set_object interface with action on haxes,2265 if isfield(UvData,'SetObjectOrigin')2266 pos_view_field=get(huvmat,'Position');2267 pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);2268 pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4);2269 set(hset_object,'Position',pos_set_object)2270 end2271 list_object=get(handles.list_object,'String');2272 nbobject=length(list_object);2273 set(handles.list_object,'Value',nbobject)2274 UvData.MouseAction='create_object';2275 set(huvmat,'UserData',UvData)2276 2277 %-------------------------------------------------------2278 % --- Executes on button press in MENUVOLUME.2279 %-------------------------------------------------------2280 function VOLUME_Callback(hObject, eventdata, handles)2281 %errordlg('command VOL not implemented yet')2282 if ishandle(handles.VIEW_FIELD_title)2283 delete(handles.VIEW_FIELD_title)2284 end2285 huvmat=get(handles.create,'parent');2286 UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface2287 if isequal(get(handles.VOLUME,'Value'),1)2288 set(handles.zoom,'Value',0)2289 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])2290 set(handles.edit_vect,'Value',0)2291 edit_vect_Callback(hObject, eventdata, handles)2292 set(handles.edit,'Value',0)2293 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2294 set(handles.cal,'Value',0)2295 set(handles.cal,'BackgroundColor',[0 1 0])2296 set(handles.edit_vect,'Value',0)2297 edit_vect_Callback(hObject, eventdata, handles)2298 %initiate set_object GUI2299 data.TITLE='VOLUME';2300 if isfield(UvData,'CoordType')2301 data.CoordType=UvData.CoordType;2302 end2303 if isfield(UvData,'Mesh')&~isempty(UvData.Mesh)2304 data.RangeY=UvData.Mesh;2305 data.RangeX=UvData.Mesh;2306 data.DX=UvData.Mesh;2307 data.DY=UvData.Mesh;2308 elseif isfield(UvData.Field,'AX')&isfield(UvData.Field,'AY')& isfield(UvData.Field,'A')%only image2309 np=size(UvData.Field.A);2310 meshx=(UvData.Field.AX(end)-UvData.Field.AX(1))/np(2);2311 meshy=abs(UvData.Field.AY(end)-UvData.Field.AY(1))/np(1);2312 data.RangeY=max(meshx,meshy);2313 data.RangeX=max(meshx,meshy);2314 data.DX=max(meshx,meshy);2315 end2316 data.ParentButton=handles.VOLUME;2317 PlotHandles=get_plot_handles(handles);%get the handles of the interface elements setting the plotting parameters2318 [hset_object,UvData.sethandles]=set_object(data,PlotHandles);% call the set_object interface with action on haxes,2319 % associate the set_edit interface handle to the plotting axes2320 if isfield(UvData,'SetObjectOrigin')2321 pos_view_field=get(huvmat,'Position');2322 pos_set_object(1:2)=UvData.SetObjectOrigin + pos_view_field(1:2);2323 pos_set_object(3:4)=UvData.SetObjectSize .* pos_view_field(3:4);2324 set(hset_object,'Position',pos_set_object)2325 end2326 UvData.MouseAction='create_object';2327 else2328 set(handles.VOLUME,'BackgroundColor',[0 1 0])2329 UvData.MouseAction='none';2330 end2331 set(huvmat,'UserData',UvData)2332 2333 %-------------------------------------------------------2334 function edit_vect_Callback(hObject, eventdata, handles)2335 %-------------------------------------------------------2336 2337 UvData=get(handles.view_field,'UserData');%read UvData properties stored on the view_field interface2338 if isequal(get(handles.edit_vect,'Value'),1)2339 test_civ2=isequal(get(handles.civ2,'BackgroundColor'),[1 1 0]);2340 test_civ1=isequal(get(handles.civ1,'BackgroundColor'),[1 1 0]);2341 if ~test_civ2 && ~test_civ12342 msgbox_view_field('ERROR','manual correction only possible for CIV1 or CIV2 velocity fields')2343 end2344 set(handles.record,'Visible','on')2345 set(handles.edit_vect,'BackgroundColor',[1 1 0])2346 set(handles.edit,'Value',0)2347 set(handles.create,'Value',0)2348 set(handles.create,'BackgroundColor',[0 1 0])2349 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2350 set(gcf,'Pointer','arrow')2351 UvData.MouseAction='edit_vect';2352 else2353 set(handles.record,'Visible','off')2354 set(handles.edit_vect,'BackgroundColor',[0.7 0.7 0.7])2355 UvData.MouseAction='none';2356 end2357 set(handles.view_field,'UserData',UvData)2358 2359 %----------------------------------------------2360 function save_mask_Callback(hObject, eventdata, handles)2361 %-----------------------------------------------------------------------2362 huvmat=get(handles.save_mask,'parent');2363 UvData=get(huvmat,'UserData');2364 2365 hpatch=findobj(huvmat,'Type','patch');2366 flag=1;2367 npx=size(UvData.Field.A,2);2368 npy=size(UvData.Field.A,1);2369 xi=[0.5:npx-0.5];2370 yi=[0.5:npy-0.5];2371 [Xi,Yi]=meshgrid(xi,yi);2372 if isfield(UvData,'Object')2373 for iobj=1:length(UvData.Object)2374 ObjectData=UvData.Object{iobj};2375 if isfield(ObjectData,'ProjMode') &&(isequal(ObjectData.ProjMode,'mask_inside')||isequal(ObjectData.ProjMode,'mask_outside'));2376 flagobj=1;2377 testphys=0; %coordinates in pixels by default2378 if isfield(ObjectData,'CoordType') && isequal(ObjectData.CoordType,'phys')2379 if isfield(UvData,'XmlData')&& isfield(UvData.XmlData,'GeometryCalib')2380 Calib=UvData.XmlData.GeometryCalib;2381 testphys=1;2382 end2383 end2384 if isfield(ObjectData,'Coord')& isfield(ObjectData,'Style')2385 if isequal(ObjectData.Style,'polygon')2386 X=ObjectData.Coord(:,1);2387 Y=ObjectData.Coord(:,2);2388 if testphys2389 [X,Y]=px_XYZ(Calib,X,Y,0);% to generalise with 3D cases2390 end2391 flagobj=~inpolygon(Xi,Yi,X,Y);%=0 inside the polygon, 1 outside2392 elseif isequal(ObjectData.Style,'ellipse')2393 if testphys2394 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys2395 end2396 RangeX=max(ObjectData.RangeX);2397 RangeY=max(ObjectData.RangeY);2398 X2Max=RangeX*RangeX;2399 Y2Max=RangeY*RangeY;2400 distX=(Xi-ObjectData.Coord(1,1));2401 distY=(Yi-ObjectData.Coord(1,2));2402 flagobj=(distX.*distX/X2Max+distY.*distY/Y2Max)>1;2403 elseif isequal(ObjectData.Style,'rectangle')2404 if testphys2405 %[X,Y]=px_XYZ(Calib,X,Y,0);% TODO:create a polygon boundary and transform to phys2406 end2407 distX=abs(Xi-ObjectData.Coord(1,1));2408 distY=abs(Yi-ObjectData.Coord(1,2));2409 flagobj=distX>max(ObjectData.RangeX) | distY>max(ObjectData.RangeY);2410 end2411 if isequal(ObjectData.ProjMode,'mask_outside')2412 flagobj=~flagobj;2413 end2414 flag=flag & flagobj;2415 end2416 end2417 end2418 end2419 % flag=~flag;2420 %mask name2421 RootPath=get(handles.RootPath,'String');2422 RootFile=get(handles.RootFile,'String');2423 if ~isempty(RootFile)&(isequal(RootFile(1),'/')| isequal(RootFile(1),'\'))2424 RootFile(1)=[];2425 end2426 filebase=fullfile(RootPath,RootFile);2427 list=get(handles.masklevel,'String');2428 masknumber=num2str(length(list));2429 maskindex=get(handles.masklevel,'Value');2430 mask_name=name_generator([filebase '_' masknumber 'mask'],maskindex,1,'.png','_i');2431 imflag=uint8(255*(0.392+0.608*flag));% =100 for flag=0 (vectors not computed when 20<imflag<200)2432 imflag=flipdim(imflag,1);2433 % imflag=uint8(255*flag);% =0 for flag=0 (vectors=0 when 20<imflag<200)2434 msgbox_view_field('CONFIRMATION',[mask_name ' saved'])2435 imwrite(imflag,mask_name,'BitDepth',8);2436 2437 %display the mask2438 %update_mask(handles,num_i1,num_j1)2439 figure;2440 vec=linspace(0,1,256);%define a linear greyscale colormap2441 map=[vec' vec' vec'];2442 colormap(map)2443 2444 image(imflag);2445 1993 2446 1994 %------------------------------------------------------------------- … … 2608 2156 % set(handles.vec_col_bar,'Cdata',A) 2609 2157 2610 %--------------------------------------------------------2611 % --- Executes on button press in cal.2612 function cal_Callback(hObject, eventdata, handles)2613 2614 huvmat=get(handles.cal,'parent');%handles of the view_field interface2615 UvData=get(huvmat,'UserData');%read UvData properties stored on the view_field interface2616 %reinitialize the edit interface associated with view_field2617 value=get(handles.cal,'Value');2618 if value2619 set(handles.cal,'BackgroundColor',[1 1 0])2620 %suppress the other options if MENULINE is chosen2621 set(handles.zoom,'Value',0)2622 set(handles.zoom,'BackgroundColor',[0.7 0.7 0.7])2623 set(handles.create,'Value',0)2624 set(handles.create,'BackgroundColor',[0 1 0])2625 set(handles.create,'enable','off')2626 set(handles.edit_vect,'Value',0)2627 set(handles.edit_vect,'enable','off')2628 edit_vect_Callback(hObject, eventdata, handles)2629 set(handles.edit,'Value',0)2630 set(handles.edit,'BackgroundColor',[0.7 0.7 0.7])2631 set(handles.edit,'enable','off')2632 set(handles.list_object,'Value',1)2633 % initiate display of GUI geometry_calib2634 data=[]; %default2635 if isfield(UvData,'CoordType')2636 data.CoordType=UvData.CoordType;2637 end2638 %data.ParentButton=handles.cal; % transmit the handles of the calling button to the GUI geometry_calib2639 pos=get(huvmat,'Position');2640 pos(1)=pos(1)+pos(3)-0.311+0.04; %0.311= width of the geometry_calib interface (units relative to the srcreen)2641 pos(2)=pos(2)-0.02;2642 [FileName,RootPath,FileBase,FileIndices,FileExt,SubDir]=read_file_boxes(handles);2643 % [filebase,num_i1,num_j1,num_i2,num_j2,Ext,NomType,SubDir]=read_input_file(handles);2644 % [inputfile,idetect]=name_generator(filebase,num_i1,num_j1,Ext,NomType,1,num_i2,num_j2,SubDir);2645 [UvData.hset_object,UvData.sethandles]=geometry_calib(handles,pos,FileName);% call the set_object interface2646 pos_view_field=get(huvmat,'Position');2647 %pos_cal(1:2)=UvData.CalOrigin + pos_view_field(1:2);2648 if isfield(UvData,'CalOrigin')2649 pos_cal(1)=pos_view_field(1)+UvData.CalOrigin(1)*pos_view_field(3);2650 pos_cal(2)=pos_view_field(2)+UvData.CalOrigin(2)*pos_view_field(4);2651 pos_cal(3:4)=UvData.CalSize .* pos_view_field(3:4);2652 set(UvData.hset_object,'Position',pos_cal)2653 end2654 UvData.MouseAction='calib';2655 else2656 UvData.MouseAction='none';2657 hgeometry_calib=findobj(allchild(0),'Name','geometry_calib');2658 % if ~isempty(hgeometry_calib)2659 % answer=questdlg('close the GUI geometry-calib?');2660 % if isequal(answer,'Yes')2661 % delete(hgeometry_calib)2662 % set(handles.cal,'BackgroundColor',[0 1 0])2663 % else2664 % set(handles.cal,'Value',1)% keep the calibration function active2665 % end2666 % end2667 set(handles.edit_vect,'enable','on')2668 set(handles.edit,'enable','on')2669 set(handles.create,'enable','on')2670 % set(handles.LINE,'enable','on')2671 % set(handles.PATCH,'enable','on')2672 % set(handles.PLANE,'enable','on')2673 % set(handles.VOLUME,'enable','on')2674 %set(handles.makemask,'enable','on')2675 hh=findobj(handles.axes3,'Tag','calib_points');2676 if ~isempty(hh)2677 delete(hh)2678 end2679 hhh=findobj(handles.axes3,'Tag','calib_marker');2680 if ~isempty(hhh)2681 delete(hhh)2682 end2683 end2684 set(huvmat,'UserData',UvData);2685 2686 %-------------------------------------------------------------2687 % --- Executes on selection change in transform_fct.2688 function transform_fct_Callback(hObject, eventdata, handles)2689 %-------------------------------------------------------------2690 global nb_builtin2691 2692 huvmat=get(handles.transform_fct,'parent');2693 menu=get(handles.transform_fct,'String');2694 ind_coord=get(handles.transform_fct,'Value');2695 coord_option=menu{ind_coord};2696 list_transform=get(handles.transform_fct,'UserData');2697 ff=functions(list_transform{end});2698 if isequal(coord_option,'more...');2699 coord_fct='';2700 2701 % if exist(profil_perso,'file')2702 % h=load (profil_perso);2703 % if isfield(h,'transform_fct')2704 % transform_fct=h.transform_fct;2705 % end2706 % end2707 prompt = {'Enter the name of the transform function'};2708 dlg_title = 'user defined transform';2709 num_lines= 1;2710 [FileName, PathName, filterindex] = uigetfile( ...2711 {'*.m', ' (*.m)';2712 '*.m', '.m files '; ...2713 '*.*', 'All Files (*.*)'}, ...2714 'Pick a file', ff.file);2715 if isequal(PathName(end),'/')||isequal(PathName(end),'\')2716 PathName(end)=[];2717 end2718 transform_selected =fullfile(PathName,FileName);2719 if ~exist(transform_selected,'file')2720 % msgbox_view_field('ERROR',['procesing fct ' transform_selected ' not found'])2721 return2722 end2723 [ppp,transform,ext_fct]=fileparts(FileName);% removes extension .m2724 if ~isequal(ext_fct,'.m')2725 msgbox_view_field('ERROR','a Matlab function .m must be introduced');2726 return2727 end2728 menu=update_menu(handles.transform_fct,transform);%add the selected fct to the menu2729 ind_coord=get(handles.transform_fct,'Value');2730 addpath(PathName)2731 list_transform{ind_coord}=str2func(transform);% create the function handle corresponding to the newly seleced function2732 set(handles.transform_fct,'UserData',list_transform)2733 rmpath(PathName)2734 % save the new menu in the personal file 'view_field_perso.mat'2735 dir_perso=prefdir;%personal Matalb directory2736 profil_perso=fullfile(dir_perso,'view_field_perso.mat');2737 if exist(profil_perso,'file')2738 for ilist=nb_builtin+1:numel(list_transform)2739 ff=functions(list_transform{ilist});2740 transform_fct{ilist-nb_builtin}=ff.file;2741 end2742 save (profil_perso,'transform_fct','-append'); %store the root name for future opening of view_field2743 end2744 end2745 2746 %check the current path to the selected function2747 if isa(list_transform{ind_coord},'function_handle')2748 func=functions(list_transform{ind_coord});2749 set(handles.path_transform,'String',fileparts(func.file)); %show the path to the senlected function2750 else2751 set(handles.path_transform,'String','')2752 end2753 %CurrentPath=fileparts(which(coord_option));2754 % if ~isequal(PathName,CurrentPath)2755 % addpath(PathName)2756 % errormsg=check_functions;2757 % msgbox_view_field('WARNING',[['path ' PathName ' added to the current Matlab pathes'];errormsg])2758 % end2759 %set(handles.path_transform,'String',fullfile(PathName,' ')); %show the path to the senlected function2760 set(handles.FixedLimits,'Value',0)2761 set(handles.FixedLimits,'BackgroundColor',[0.7 0.7 0.7])2762 2763 UvData=get(huvmat,'UserData');2764 2765 %delete drawn objects2766 hother=findobj('Tag','proj_object');%find all the proj objects2767 for iobj=1:length(hother)2768 delete_object(hother(iobj))2769 end2770 hother=findobj('Tag','DeformPoint');%find all the proj objects2771 for iobj=1:length(hother)2772 delete_object(hother(iobj))2773 end2774 hh=findobj('Tag','calib_points');2775 if ~isempty(hh)2776 delete(hh)2777 end2778 hhh=findobj('Tag','calib_marker');2779 if ~isempty(hhh)2780 delete(hhh)2781 end2782 if isfield(UvData,'Object')2783 nbobject=length(UvData.Object);2784 UvData.Object([2:nbobject])=[];2785 end2786 2787 %delete mask if it is displayed2788 if isequal(get(handles.mask_test,'Value'),1)%if the mask option is on2789 UvData=rmfield(UvData,'MaskName'); %will impose mask refresh2790 end2791 set(huvmat,'UserData',UvData)2792 run0_Callback(hObject, eventdata, handles)2793 2794 %--------------------------------------------2795 function histo1_menu_Callback(hObject, eventdata, handles)2796 %--------------------------------------------2797 %plot first histo2798 huvmat=get(handles.histo1_menu,'parent');2799 histo_menu=get(handles.histo1_menu,'String');2800 histo_value=get(handles.histo1_menu,'Value');2801 FieldName=histo_menu{histo_value};2802 UvData=get(huvmat,'UserData');2803 update_histo(handles.histo_u,huvmat,FieldName)2804 2805 %----------------------------------------------2806 function histo2_menu_Callback(hObject, eventdata, handles)2807 %----------------------------------------------2808 %plot second histo2809 huvmat=get(handles.histo2_menu,'parent');2810 histo_menu=get(handles.histo2_menu,'String');2811 histo_value=get(handles.histo2_menu,'Value');2812 FieldName=histo_menu{histo_value};2813 UvData=get(huvmat,'UserData');2814 update_histo(handles.histo_v,huvmat,FieldName)2815 2816 2817 %--------------------------------------------2818 %read the field .Fieldname stored in UvData and plot its histogram2819 function update_histo(haxes,huvmat,FieldName)2820 UvData=get(huvmat,'UserData');2821 2822 if ~isfield(UvData.Field,FieldName)2823 msgbox_view_field('ERROR',['no field ' FieldName ' for histogram'])2824 return2825 end2826 Field=UvData.Field;2827 FieldHisto=eval(['Field.' FieldName]);2828 if isfield(Field,'FF') & ~isempty(Field.FF) & isequal(size(Field.FF),size(FieldHisto))2829 indsel=find(Field.FF==0);%find values marked as false2830 if ~isempty(indsel)2831 FieldHisto=FieldHisto(indsel);2832 end2833 end2834 if isempty(Field)2835 msgbox_view_field('ERROR',['empty field ' FieldName])2836 else2837 nxy=size(FieldHisto);2838 Amin=double(min(min(min(FieldHisto))));%min of image2839 Amax=double(max(max(max(FieldHisto))));%max of image2840 if isequal(Amin,Amax)2841 Histo.Txt=['uniform field =' num2str(Amin)];2842 else2843 Histo.ListVarName={FieldName,'histo'};2844 if numel(nxy)==22845 Histo.VarDimName={FieldName,FieldName}; %dimensions for the histogram2846 else %color images2847 Histo.VarDimName={FieldName,{FieldName,'rgb'}}; %dimensions for the histogram2848 end2849 %unit2850 units=[]; %default2851 for ivar=1:numel(Field.ListVarName)2852 if strcmp(Field.ListVarName{ivar},FieldName)2853 if isfield(Field,'VarAttribute') && numel(Field.VarAttribute)>=ivar && isfield(Field.VarAttribute{ivar},'units')2854 units=Field.VarAttribute{ivar}.units;2855 break2856 end2857 end2858 end2859 if ~isempty(units)2860 Histo.VarAttribute{1}.units=units;2861 end2862 eval(['Histo.' FieldName '=linspace(Amin,Amax,50);'])%absissa values for histo2863 for col=1:size(FieldHisto,3)2864 B=FieldHisto(:,:,col);2865 C=reshape(double(B),1,nxy(1)*nxy(2));% reshape in a vector2866 eval(['Histo.histo(:,col)=hist(C, Histo.' FieldName ');']); %calculate histogram2867 end2868 set(haxes,'XLimMode','auto')%reset auto mode (after zoom effect)2869 set(haxes,'YLimMode','auto')2870 plot_field(Histo,haxes);2871 end2872 end2873 2874 2875 2158 2876 2159 %------------------------------------------------ … … 3083 2366 3084 2367 3085 function edit84_Callback(hObject, eventdata, handles)3086 % hObject handle to edit84(see GCBO)2368 function npx_Callback(hObject, eventdata, handles) 2369 % hObject handle to npx (see GCBO) 3087 2370 % eventdata reserved - to be defined in a future version of MATLAB 3088 2371 % handles structure with handles and user data (see GUIDATA) 3089 2372 3090 % Hints: get(hObject,'String') returns contents of edit84as text3091 % str2double(get(hObject,'String')) returns contents of edit84as a double2373 % Hints: get(hObject,'String') returns contents of npx as text 2374 % str2double(get(hObject,'String')) returns contents of npx as a double 3092 2375 3093 2376 3094 2377 % --- Executes during object creation, after setting all properties. 3095 function edit84_CreateFcn(hObject, eventdata, handles)3096 % hObject handle to edit84(see GCBO)2378 function npx_CreateFcn(hObject, eventdata, handles) 2379 % hObject handle to npx (see GCBO) 3097 2380 % eventdata reserved - to be defined in a future version of MATLAB 3098 2381 % handles empty - handles not created until after all CreateFcns called … … 3106 2389 3107 2390 3108 function edit85_Callback(hObject, eventdata, handles)3109 % hObject handle to edit85(see GCBO)2391 function npy_Callback(hObject, eventdata, handles) 2392 % hObject handle to npy (see GCBO) 3110 2393 % eventdata reserved - to be defined in a future version of MATLAB 3111 2394 % handles structure with handles and user data (see GUIDATA) 3112 2395 3113 % Hints: get(hObject,'String') returns contents of edit85as text3114 % str2double(get(hObject,'String')) returns contents of edit85as a double2396 % Hints: get(hObject,'String') returns contents of npy as text 2397 % str2double(get(hObject,'String')) returns contents of npy as a double 3115 2398 3116 2399 3117 2400 % --- Executes during object creation, after setting all properties. 3118 function edit85_CreateFcn(hObject, eventdata, handles)3119 % hObject handle to edit85(see GCBO)2401 function npy_CreateFcn(hObject, eventdata, handles) 2402 % hObject handle to npy (see GCBO) 3120 2403 % eventdata reserved - to be defined in a future version of MATLAB 3121 2404 % handles empty - handles not created until after all CreateFcns called … … 3130 2413 3131 2414 function edit86_Callback(hObject, eventdata, handles) 3132 % hObject handle to edit86(see GCBO)2415 % hObject handle to MaxA (see GCBO) 3133 2416 % eventdata reserved - to be defined in a future version of MATLAB 3134 2417 % handles structure with handles and user data (see GUIDATA) 3135 2418 3136 % Hints: get(hObject,'String') returns contents of edit86as text3137 % str2double(get(hObject,'String')) returns contents of edit86as a double2419 % Hints: get(hObject,'String') returns contents of MaxA as text 2420 % str2double(get(hObject,'String')) returns contents of MaxA as a double 3138 2421 3139 2422 3140 2423 % --- Executes during object creation, after setting all properties. 3141 function edit86_CreateFcn(hObject, eventdata, handles)3142 % hObject handle to edit86(see GCBO)2424 function MaxA_CreateFcn(hObject, eventdata, handles) 2425 % hObject handle to MaxA (see GCBO) 3143 2426 % eventdata reserved - to be defined in a future version of MATLAB 3144 2427 % handles empty - handles not created until after all CreateFcns called … … 3153 2436 3154 2437 function edit87_Callback(hObject, eventdata, handles) 3155 % hObject handle to edit87(see GCBO)2438 % hObject handle to MinA (see GCBO) 3156 2439 % eventdata reserved - to be defined in a future version of MATLAB 3157 2440 % handles structure with handles and user data (see GUIDATA) 3158 2441 3159 % Hints: get(hObject,'String') returns contents of edit87as text3160 % str2double(get(hObject,'String')) returns contents of edit87as a double2442 % Hints: get(hObject,'String') returns contents of MinA as text 2443 % str2double(get(hObject,'String')) returns contents of MinA as a double 3161 2444 3162 2445 3163 2446 % --- Executes during object creation, after setting all properties. 3164 function edit87_CreateFcn(hObject, eventdata, handles)3165 % hObject handle to edit87(see GCBO)2447 function MinA_CreateFcn(hObject, eventdata, handles) 2448 % hObject handle to MinA (see GCBO) 3166 2449 % eventdata reserved - to be defined in a future version of MATLAB 3167 2450 % handles empty - handles not created until after all CreateFcns called … … 3174 2457 3175 2458 3176 % --- Executes on button press in checkbox39.3177 function checkbox39_Callback(hObject, eventdata, handles)3178 % hObject handle to checkbox39(see GCBO)2459 % --- Executes on button press in auto_sclar. 2460 function auto_sclar_Callback(hObject, eventdata, handles) 2461 % hObject handle to auto_sclar (see GCBO) 3179 2462 % eventdata reserved - to be defined in a future version of MATLAB 3180 2463 % handles structure with handles and user data (see GUIDATA) 3181 2464 3182 % Hint: get(hObject,'Value') returns toggle state of checkbox392465 % Hint: get(hObject,'Value') returns toggle state of auto_sclar 3183 2466 3184 2467 3185 2468 3186 2469 function edit88_Callback(hObject, eventdata, handles) 3187 % hObject handle to edit88(see GCBO)2470 % hObject handle to IncrA (see GCBO) 3188 2471 % eventdata reserved - to be defined in a future version of MATLAB 3189 2472 % handles structure with handles and user data (see GUIDATA) 3190 2473 3191 % Hints: get(hObject,'String') returns contents of edit88as text3192 % str2double(get(hObject,'String')) returns contents of edit88as a double2474 % Hints: get(hObject,'String') returns contents of IncrA as text 2475 % str2double(get(hObject,'String')) returns contents of IncrA as a double 3193 2476 3194 2477 3195 2478 % --- Executes during object creation, after setting all properties. 3196 function edit88_CreateFcn(hObject, eventdata, handles)3197 % hObject handle to edit88(see GCBO)2479 function IncrA_CreateFcn(hObject, eventdata, handles) 2480 % hObject handle to IncrA (see GCBO) 3198 2481 % eventdata reserved - to be defined in a future version of MATLAB 3199 2482 % handles empty - handles not created until after all CreateFcns called … … 3206 2489 3207 2490 3208 % --- Executes on button press in checkbox40.2491 % --- Executes on button press in AutoScal. 3209 2492 function checkbox40_Callback(hObject, eventdata, handles) 3210 % hObject handle to checkbox40(see GCBO)2493 % hObject handle to AutoScal (see GCBO) 3211 2494 % eventdata reserved - to be defined in a future version of MATLAB 3212 2495 % handles structure with handles and user data (see GUIDATA) 3213 2496 3214 % Hint: get(hObject,'Value') returns toggle state of checkbox402497 % Hint: get(hObject,'Value') returns toggle state of AutoScal 3215 2498 3216 2499 … … 3240 2523 3241 2524 function edit83_Callback(hObject, eventdata, handles) 3242 % hObject handle to edit83(see GCBO)2525 % hObject handle to min_vec (see GCBO) 3243 2526 % eventdata reserved - to be defined in a future version of MATLAB 3244 2527 % handles structure with handles and user data (see GUIDATA) 3245 2528 3246 % Hints: get(hObject,'String') returns contents of edit83as text3247 % str2double(get(hObject,'String')) returns contents of edit83as a double2529 % Hints: get(hObject,'String') returns contents of min_vec as text 2530 % str2double(get(hObject,'String')) returns contents of min_vec as a double 3248 2531 3249 2532 3250 2533 % --- Executes during object creation, after setting all properties. 3251 function edit83_CreateFcn(hObject, eventdata, handles)3252 % hObject handle to edit83(see GCBO)2534 function min_vec_CreateFcn(hObject, eventdata, handles) 2535 % hObject handle to min_vec (see GCBO) 3253 2536 % eventdata reserved - to be defined in a future version of MATLAB 3254 2537 % handles empty - handles not created until after all CreateFcns called … … 3305 2588 3306 2589 3307 % --- Executes on button press in checkbox41.2590 % --- Executes on button press in AutoVecColor. 3308 2591 function checkbox41_Callback(hObject, eventdata, handles) 3309 % hObject handle to checkbox41(see GCBO)2592 % hObject handle to AutoVecColor (see GCBO) 3310 2593 % eventdata reserved - to be defined in a future version of MATLAB 3311 2594 % handles structure with handles and user data (see GUIDATA) 3312 2595 3313 % Hint: get(hObject,'Value') returns toggle state of checkbox412596 % Hint: get(hObject,'Value') returns toggle state of AutoVecColor 3314 2597 3315 2598 3316 2599 3317 2600 function edit89_Callback(hObject, eventdata, handles) 3318 % hObject handle to edit89(see GCBO)2601 % hObject handle to max_vec (see GCBO) 3319 2602 % eventdata reserved - to be defined in a future version of MATLAB 3320 2603 % handles structure with handles and user data (see GUIDATA) 3321 2604 3322 % Hints: get(hObject,'String') returns contents of edit89as text3323 % str2double(get(hObject,'String')) returns contents of edit89as a double2605 % Hints: get(hObject,'String') returns contents of max_vec as text 2606 % str2double(get(hObject,'String')) returns contents of max_vec as a double 3324 2607 3325 2608 3326 2609 % --- Executes during object creation, after setting all properties. 3327 function edit89_CreateFcn(hObject, eventdata, handles)3328 % hObject handle to edit89(see GCBO)2610 function max_vec_CreateFcn(hObject, eventdata, handles) 2611 % hObject handle to max_vec (see GCBO) 3329 2612 % eventdata reserved - to be defined in a future version of MATLAB 3330 2613 % handles empty - handles not created until after all CreateFcns called … … 3360 2643 3361 2644 3362 % --- Executes on button press in pushbutton35.2645 % --- Executes on button press in vec_col_bar. 3363 2646 function pushbutton35_Callback(hObject, eventdata, handles) 3364 % hObject handle to pushbutton35(see GCBO)2647 % hObject handle to vec_col_bar (see GCBO) 3365 2648 % eventdata reserved - to be defined in a future version of MATLAB 3366 2649 % handles structure with handles and user data (see GUIDATA) 3367 2650 3368 2651 2652 function close_fcn(hObject, eventdata, handles) 2653 huvmat=findobj(allchild(0),'Name','uvmat'); 2654 hhuvmat=guidata(huvmat); 2655 set(hhuvmat.list_object_2,'Visible','off')
Note: See TracChangeset
for help on using the changeset viewer.