Changeset 445 for trunk/src/set_object.m
- Timestamp:
- Jun 8, 2012, 4:30:52 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/set_object.m
r432 r445 7 7 % hset_object: handle of the GUI figure 8 8 % 9 % INPUT: 9 % INPUT:u 10 10 % data: structure describing the object properties 11 11 % .Style=... … … 439 439 ListObject=get(hhuvmat.ListObject,'String');% list of objects displayed in uvmat 440 440 IndexObj=get(hhuvmat.ListObject,'Value');% index of the selected object for display in uvmat 441 if ~get(hhuvmat.edit_object,'Value') %new object is being created 442 detectname=1; 443 ObjectNameNew=ObjectName; 444 vers=0;% index of the name 445 while ~isempty(detectname) 446 detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list 447 if detectname% if the object name already exists 448 indstr=regexp(ObjectNameNew,'\D');%indices of non number characters 449 if indstr(end)<length(ObjectNameNew) %object name ends by a number 450 vers=str2double(ObjectNameNew(indstr(end)+1:end))+1; 451 ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)]; 452 else 453 vers=vers+1; 454 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; 455 end 456 end 457 end 458 ObjectName=ObjectNameNew; 459 set(handles.Name,'String',ObjectName)% display the default name in set_object 460 IndexObj=numel(ListObject)+1;% append an object to the list in uvmat 461 set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list 462 set(hhuvmat.ListObject_1,'String',[ListObject;{ObjectName}]);%complement the object list 463 set(hhuvmat.ListObject,'Value',IndexObj) 464 set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object 465 UvData.Object{IndexObj}=[];%initiate a new object (empty yet) 441 %set or modify(edit mode) the nameof the currently selected object 442 detectname=1; 443 ObjectNameNew=ObjectName; 444 vers=0;% index of the name 445 ListOther=ListObject; 446 ListOther(IndexObj)=[]; 447 while ~isempty(detectname) 448 detectname=find(strcmp(ObjectNameNew,ListOther),1);%test the existence of the proposed name in the list 449 if detectname% if the object name already exists 450 indstr=regexp(ObjectNameNew,'\D');%indices of non number characters 451 if indstr(end)<length(ObjectNameNew) %object name ends by a number 452 vers=str2double(ObjectNameNew(indstr(end)+1:end))+1; 453 ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)]; 454 else 455 vers=vers+1; 456 ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)]; 457 end 458 end 459 end 460 ObjectName=ObjectNameNew; 461 set(handles.Name,'String',ObjectName)% display the default name in set_object 462 ListObject{IndexObj}=ObjectName; 463 set(hhuvmat.ListObject,'String',ListObject);%complement the object list 464 set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object 465 check_handle=isfield(UvData.Object{IndexObj},'DisplayHandle') && isfield(UvData.Object{IndexObj}.DisplayHandle,'uvmat')... 466 && ~isempty(UvData.Object{IndexObj}.DisplayHandle.uvmat) && ishandle(UvData.Object{IndexObj}.DisplayHandle.uvmat); 467 if check_handle 468 obj_handle=UvData.Object{IndexObj}.DisplayHandle.uvmat; 469 end 470 UvData.Object{IndexObj}=ObjectData; 471 if check_handle 472 UvData.Object{IndexObj}.DisplayHandle.uvmat=obj_handle; %preserve the object plot handle if valid 473 else 466 474 UvData.Object{IndexObj}.DisplayHandle.uvmat=hhuvmat.axes3; %axes taken as object display handle by defualt 467 475 end 476 set(hhuvmat.edit_object,'Value',1)% set the current object to edit mode 477 % %IndexObj=numel(ListObject)+1;% append an object to the list in uvmat 478 % 479 % set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list 480 % set(hhuvmat.ListObject_1,'String',[ListObject;{ObjectName}]);%complement the object list 481 % set(hhuvmat.ListObject,'Value',IndexObj) 482 % set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object 483 % UvData.Object{IndexObj}=[];%initiate a new object (empty yet) 484 % UvData.Object{IndexObj}.DisplayHandle.uvmat=hhuvmat.axes3; %axes taken as object display handle by defualt 485 % end 468 486 469 487 %% plot the field projected on the object 470 488 hview_field=[];%default 489 IndexObj_1=get(hhuvmat.ListObject_1,'Value'); 471 490 if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none') 472 491 PlotType='text'; … … 477 496 return 478 497 end 479 IndexObj_1=get(hhuvmat.ListObject_1,'Value') 480 if isequal(IndexObj_1,IndexObj) % if only one object is selected, the projection is in uvmat 498 if isequal(IndexObj_1,IndexObj) % if the projection is in uvmat 481 499 PlotType=plot_field(ProjData,hhuvmat.axes3,read_GUI(get(hhuvmat.axes3,'parent')));%update the current uvmat plot 482 else % if a second object is selected, the projection is in view_field, and this second object is selected500 else % if the projection is in veiw_field 483 501 hview_field=findobj(allchild(0),'tag','view_field'); 484 502 if isempty(hview_field) … … 501 519 set(hview_field,'Position',Data.GUISize) 502 520 end 521 set(hhuvmat.ViewField,'Value',1)% indicate that the field projection on the current object is plotted in view_field 503 522 end 504 523 end 505 524 506 525 %% update the object plot 507 % if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle')% save the previous object graph handles 508 % ObjectData.DisplayHandle.uvmat=UvData.Object{IndexObj(end)}.DisplayHandle.uvmat; 509 % else 510 % ObjectData.DisplayHandle.uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input 526 hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat; 527 % if we are editing the object used for projection in uvmat 528 if isequal(IndexObj_1,IndexObj) 529 %update the representation of the current object for projection field represented in view_field 530 % UvData.Object{iobj}.DisplayHandle.view_field=... 531 % plot_object(UvData.Object{IndexObj},UvData.Object{IndexObj_1},UvData.Object{iobj}.DisplayHandle.uvmat,'m'); 532 % update the representation of all objects in uvmat 533 for iobj=1:numel(UvData.Object) 534 UvData.Object{iobj}.DisplayHandle.uvmat=... 535 plot_object(UvData.Object{iobj},UvData.Object{IndexObj_1},UvData.Object{iobj}.DisplayHandle.uvmat,'b'); 536 end 537 else % we are editing the object used for projection field represented in view_field 538 %update the representation of the current object in uvmat 539 UvData.Object{IndexObj}.DisplayHandle.uvmat=... 540 plot_object(UvData.Object{IndexObj},UvData.Object{IndexObj_1},UvData.Object{IndexObj}.DisplayHandle.uvmat,'m'); 541 %indicate the object index in the user data of the object plot (needed for further mouse editing) 542 ObjectInfo=get(UvData.Object{IndexObj}.DisplayHandle.uvmat,'UserData'); 543 ObjectInfo.IndexObj=IndexObj; 544 set(UvData.Object{IndexObj}.DisplayHandle.uvmat,'UserData',ObjectInfo) 545 % update the representation of all objects in view_field 546 for iobj=1:numel(UvData.Object) 547 if isfield(UvData.Object{iobj}.DisplayHandle,'view_field') 548 UvData.Object{iobj}.DisplayHandle.view_field=... 549 plot_object(UvData.Object{iobj},UvData.Object{iobj},UvData.Object{iobj}.DisplayHandle.view_field,'b'); 550 end 551 end 552 end 553 % UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(ObjectData,UvData.Object{IndexObj_1},hobject,'m');%draw the object in uvmat 554 % if ~isempty(hview_field) 555 % if isfield(UvData.Object{IndexObj}.DisplayHandle,'view_field') 556 % hobject=UvData.Object{IndexObj}.DisplayHandle.view_field; 557 % end 558 % if isempty(hobject) 559 % hobject=haxes; 560 % end 561 % %draw the object in view_field 562 % if ~isequal(IndexObj_1,IndexObj) % if the projection is in uvmat 563 % UvData.Object{IndexObj}.DisplayHandle.view_field=plot_object(ObjectData,UvData.Object{IndexObj},hobject,'m'); 564 % end 511 565 % end 512 % if isfield(UvData.Object{IndexObj},'DisplayHandle')% save the previous object graph handles513 % ObjectData.DisplayHandle.view_field=UvData.Object{IndexObj(end)}.DisplayHandle.view_field;514 % else515 % ObjectData.DisplayHandle.view_field=[];516 % end517 % UvData.Object{IndexObj}=ObjectData;%update the current object properties518 % if numel(IndexObj)==2519 hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;520 if isempty(hobject)521 hobject=hhuvmat.axes3;522 end523 UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(ObjectData,[],hobject,'m');%draw the object in uvmat524 if ~isempty(hview_field)525 if isfield(UvData.Object{IndexObj}.DisplayHandle,'view_field')526 hobject=UvData.Object{IndexObj}.DisplayHandle.view_field;527 end528 if isempty(hobject)529 hobject=haxes;530 end531 UvData.Object{IndexObj}.DisplayHandle.view_field=plot_object(ObjectData,[],hobject,'m');%draw the object in view_field532 % UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));533 end534 566 set(huvmat,'UserData',UvData) 535 567
Note: See TracChangeset
for help on using the changeset viewer.