Changeset 432


Ignore:
Timestamp:
May 25, 2012, 8:59:59 AM (12 years ago)
Author:
sommeria
Message:

system of projection object manipulation with uvmat improved.

Location:
trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/check_files.m

    r380 r432  
    108108    'translate_points.fig';...
    109109    'update_imadoc';...  %update the ImaDoc xml file
    110     'update_obj';... update the object representation graph and its projection field, record it in the uvmat interface
    111110    'update_waitbar';... update the waitbar display, used for ACTION functions in the GUI 'series'
    112111    'uvmat';...% master function for file scanning and visualisation of 2D fields
  • trunk/src/mouse_down.m

    r429 r432  
    311311        ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object
    312312        IndexObj=length(UvData.Object);
    313         %initiate a new object
    314         if isempty(UvData.Object{IndexObj});
     313        %initiate a new object (no data .Coord yet recorded)
     314        if ~isfield(UvData.Object{IndexObj},'Coord');
    315315            ObjectData.Coord=[];
    316316            ObjectNameNew=ObjectData.Name;
     
    318318                ObjectNameNew=ObjectData.Type;
    319319            end
    320             % add an index to the object name if the proposed name already exists
    321            
    322            
     320            % add an index to the object name if the proposed name already exists         
    323321            vers=0;% index of the name
    324322            ListObject=get(hhuvmat.ListObject,'String');
     
    345343            set(hhuvmat.ViewObject,'Value',1)
    346344        end
    347         % ObjectData.Coord=[]; %reset previous object coordinates
    348         %         ObjectData.Coord(1,1)=xy(1,1); % the object first coordinate is set by the mouse position
    349         %         ObjectData.Coord(1,2)=xy(1,2);
    350         %         if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3
    351         %             ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
    352         %         end
    353345        ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
    354         %                 if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3
    355         %                     xy(1,3)=AxeData.ObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
    356         %                 else
    357         %                     xy(1,3)=0; % z coordinate set to 0 by default
    358         %                 end
    359         %                 if ~isequal(ObjectData.Coord,xy(1,:))
    360         %                     ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];% append the coordinates marked by the mouse to the object
    361         %                 end
    362        
    363         AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
    364         %         if isfield(UvData,'Object')
    365         %             IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
    366         %         else
    367         %             IndexObj=2;% the first object is used for uvmat display or blank
    368         %         end
     346        hobject=UvData.Object{IndexObj}.DisplayHandle.(fig_tag);
     347        if isempty(hobject)
     348            hobject=haxes;
     349        end
     350        ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')};
     351        AxeData.CurrentObject=plot_object(ObjectData,ProjObject,hobject,'m');%draw the object and its handle becomes AxeData.CurrentObject
    369352        UvData.Object{IndexObj}=ObjectData;     
    370         UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject;     
    371         UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;
     353        UvData.Object{IndexObj}.DisplayHandle.(fig_tag)=AxeData.CurrentObject;% attribute the current plot object handle to the Object     
     354        %UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;
    372355        set(huvmat,'UserData',UvData)
    373356        PlotData=get(AxeData.CurrentObject,'UserData');
  • trunk/src/mouse_motion.m

    r413 r432  
    2929end
    3030FigData=get(hObject,'UserData');
    31 
    3231if ishandle(FigData)% case of a zoom plot, the handle of the parent rectangle is stored in UserData, its parent is the plotting axes of the rectangle
    33     currentfig=get(get(FigData,'parent'),'parent');
     32    CurrentFig=get(get(FigData,'parent'),'parent');
    3433else
    35     currentfig=hObject;%usual plot
    36 end
    37 hhcurrentfig=guidata(currentfig);
    38 test_zoom=get(hhcurrentfig.CheckZoom,'Value');%test for zoom activated on the current figure
     34    CurrentFig=hObject;%usual plot
     35end
     36hhCurrentFig=guidata(CurrentFig);%handles of the elements in the GUI containing the current figure (uvmat or view_field)
     37test_zoom=get(hhCurrentFig.CheckZoom,'Value');%test for zoom activated on the current figure
    3938test_draw=0;%test for mouse drawing of object, =0 by default
    4039test_object=0; %test for object editing or creation
     
    4241test_zoom_draw=0; % test for zoom drawing
    4342test_ruler=0;%test for active ruler
    44 % test_piv=0;% test for PIV correlation display
    4543huvmat=findobj(allchild(0),'tag','uvmat');%find the uvmat interface handle
    4644if ~isempty(huvmat)
    47     hhuvmat=guidata(huvmat);
     45    hhuvmat=guidata(huvmat);%handles of the elements in uvma
    4846    test_edit_object=get(hhuvmat.edit_object,'Value');
    4947    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');
     
    5957end
    6058
    61 %find the current axe 'haxes' and display the current mouse position or uicontrol tag
     59%find the current axe 'CurrentAxes' and display the current mouse position or uicontrol tag
    6260text_displ_1='';
    6361text_displ_2='';
     
    7472hchild=get(hObject,'Children');%handles of all objects in the current figure
    7573
    76 %% loop on all the objects in the current figure and detect whether the mouse is over a plot  axes
    77 haxes=[];
     74%% loop on all the objects in the current figure, detect whether the mouse is over a plot  axes
     75CurrentAxes=[];
    7876for ichild=1:length(hchild)
    7977    obj_pos=get(hchild(ichild),'Position');
     
    8583        %if the mouse is over an axis, look at the data
    8684        if strcmp(htype,'axes')
    87             haxes=hchild(ichild);
    88             xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    89             AxeData=get(haxes,'UserData');% data attached to the axis
     85            CurrentAxes=hchild(ichild);
     86            xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     87            AxeData=get(CurrentAxes,'UserData');% data attached to the axis
    9088            if isfield(AxeData,'Drawing')&& ~isempty(AxeData.Drawing)
    9189                test_draw=~isequal(AxeData.Drawing,'off');%=1 if mouse drawing of object is active
     
    9694                pointershape='crosshair';%set pointer with cross shape (default when mouse is over an axis)
    9795            end
    98             FigData=get(currentfig,'UserData');
    99             tagaxes=get(haxes,'tag');
     96            FigData=get(CurrentFig,'UserData');
     97            tagaxes=get(CurrentAxes,'tag');
    10098            if isfield(FigData,tagaxes)
    10199                eval(['Field=FigData.' tagaxes ';'])
     
    117115                                    (Y<(xy(1,2)+Field.Mesh/3) & Y>(xy(1,2)-Field.Mesh/3));%f
    118116                                ivec=find(flag_vec,1);% search the (first) selected vector index ivec
    119                                 hhh=findobj(haxes,'Tag','vector_marker');
     117                                hhh=findobj(CurrentAxes,'Tag','vector_marker');
    120118                                if ~isempty(ivec)
    121119                                    % mark the vectors with a circle in the absence of other operations
     
    123121                                        pointershape='arrow'; %mouse indicates  the detection of a vector
    124122                                        if isempty(hhh)
    125                                             set(0,'CurrentFigure',currentfig)
    126                                             set(currentfig,'CurrentAxes',haxes)
     123                                            set(0,'CurrentFigure',CurrentFig)
     124                                            set(CurrentFig,'CurrentAxes',CurrentAxes)
    127125                                            rectangle('Curvature',[1 1],...
    128126                                                'Position',[X(ivec)-Field.Mesh/2 Y(ivec)-Field.Mesh/2 Field.Mesh Field.Mesh],'EdgeColor','m',...
     
    226224                        shiftx=par.Shiftx;
    227225                        shifty=par.Shifty;     
    228                         hhh=findobj(haxes,'Tag','PIV_box_marker');
    229                         hhhh=findobj(haxes,'Tag','PIV_search_marker');
     226                        hhh=findobj(CurrentAxes,'Tag','PIV_box_marker');
     227                        hhhh=findobj(CurrentAxes,'Tag','PIV_search_marker');
    230228                        if isempty(hhh)
    231                             set(0,'CurrentFigure',currentfig)
    232                             set(currentfig,'CurrentAxes',haxes)
     229                            set(0,'CurrentFigure',CurrentFig)
     230                            set(CurrentFig,'CurrentAxes',CurrentAxes)
    233231                            rectangle('Curvature',[0 0],...
    234232                                'Position',[xround-ibx2 yround-iby2 2*ibx2 2*iby2],'EdgeColor','m',...
     
    264262                                   AxeData.TitleHandle=title(num2str(par.Grid));
    265263                                    colorbar
    266                                     set(haxes,'UserData',AxeData)
     264                                    set(CurrentAxes,'UserData',AxeData)
    267265                                    set(get(AxeData.CurrentCorrImage,'parent'),'YDir','normal')
    268266                                end
     
    301299            else
    302300                AxeData.CurrentRectZoom=rectangle('Position',rect,'LineStyle',':','Tag','rect_zoom');
    303                 set(haxes,'UserData',AxeData)
     301                set(CurrentAxes,'UserData',AxeData)
    304302            end
    305303        end
     
    311309%% create or modify an object
    312310if ~isempty(huvmat) && test_object
     311    UvData=get(huvmat,'UserData');
    313312    PlotData=get(AxeData.CurrentObject,'UserData');
    314     huvmat=findobj(allchild(0),'Name','uvmat');%find the uvmat interface handle
    315     if ~isempty(huvmat)
    316         UvData=get(huvmat,'UserData');
    317         if ~isfield(PlotData,'IndexObj')
    318              return
     313    if ~isfield(PlotData,'IndexObj')
     314        return
     315    end
     316    ObjectData=UvData.Object{PlotData.IndexObj};
     317    ProjObject=[];% object (plane) whose projection is represented on the current axes
     318    if isequal(hObject,huvmat)% if the mouse ifs over the GUI uvmat
     319        ProjObject=UvData.Object{get(hhuvmat.ListObject_1,'Value')};
     320    else
     321        ProjObject=UvData.Object{get(hhuvmat.ListObject,'Value')};
     322    end
     323    XYData=AxeData.CurrentOrigin;
     324    if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
     325        if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points')
     326            ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];
     327            % ObjectData.Coord(end,:)=xy(1,:);
     328        elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume')
     329            ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
     330            ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
     331            ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
     332            ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
     333        elseif isequal(ObjectData.Type,'plane') %case of 'plane'
     334            DX=(xy(1,1)-ObjectData.Coord(1,1));
     335            DY=(xy(1,2)-ObjectData.Coord(1,2));
     336            ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
     337            if isfield(ObjectData,'RangeX')
     338                XMax=sqrt(DX*DX+DY*DY);
     339                if XMax>max(ObjectData.RangeX)
     340                    ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
     341                end
     342            end
    319343        end
    320         ObjectData=UvData.Object{PlotData.IndexObj};
    321         XYData=AxeData.CurrentOrigin;
    322         if isequal(AxeData.Drawing,'create') && isfield(AxeData,'CurrentOrigin') && ~isempty(AxeData.CurrentOrigin)
    323            if strcmp(ObjectData.Type,'line')||strcmp(ObjectData.Type,'polyline')||strcmp(ObjectData.Type,'polygon')||strcmp(ObjectData.Type,'points')
    324               ObjectData.Coord=[ObjectData.Coord ;xy(1,1:2)];
    325              % ObjectData.Coord(end,:)=xy(1,:);
    326            elseif strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')||strcmp(ObjectData.Type,'volume')
    327               ObjectData.Coord(1,1)=(xy(1,1)+XYData(1))/2;%origin rectangle, x coordinate
    328               ObjectData.Coord(1,2)=(xy(1,2)+XYData(2))/2;
    329               ObjectData.RangeX=abs(xy(1,1)-XYData(1))/2;%rectangle width
    330               ObjectData.RangeY=abs(xy(1,2)-XYData(2))/2;%rectangle height
    331            elseif isequal(ObjectData.Type,'plane') %case of 'plane'
    332                 DX=(xy(1,1)-ObjectData.Coord(1,1));
    333                 DY=(xy(1,2)-ObjectData.Coord(1,2));
    334                 ObjectData.Phi=(angle(DX+i*DY))*180/pi;%rectangle widt
    335                 if isfield(ObjectData,'RangeX')
    336                     XMax=sqrt(DX*DX+DY*DY);
    337                     if XMax>max(ObjectData.RangeX)
    338                         ObjectData.RangeX=[min(ObjectData.RangeX) XMax];
    339                     end
    340                 end
    341            end
    342             plot_object(ObjectData,[],AxeData.CurrentObject,'m');
    343             pointershape='crosshair';
    344         elseif  isequal(AxeData.Drawing,'translate')
    345             DX=xy(1,1)-XYData(1);%translation from initial position
    346             DY=xy(1,2)-XYData(2);
    347             ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
    348             ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
    349             plot_object(ObjectData,[],AxeData.CurrentObject,'m');
    350             pointershape='fleur';
    351         elseif  isequal(AxeData.Drawing,'deform')
    352             ind_move=AxeData.CurrentIndex;
    353             ObjectData.Coord(ind_move,1)=xy(1,1);
    354             ObjectData.Coord(ind_move,2)=xy(1,2);
    355             plot_object(ObjectData,[],AxeData.CurrentObject,'m');
    356             pointershape='circle';
    357         end
    358     end
    359 end   
     344        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
     345        pointershape='crosshair';
     346    elseif  isequal(AxeData.Drawing,'translate')
     347        DX=xy(1,1)-XYData(1);%translation from initial position
     348        DY=xy(1,2)-XYData(2);
     349        ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
     350        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
     351        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
     352        pointershape='fleur';
     353    elseif  isequal(AxeData.Drawing,'deform')
     354        ind_move=AxeData.CurrentIndex;
     355        ObjectData.Coord(ind_move,1)=xy(1,1);
     356        ObjectData.Coord(ind_move,2)=xy(1,2);
     357        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
     358        pointershape='circle';
     359    end
     360end
    360361
    361362%% detect calibration points if the GUI geometry_calib is opened
     
    371372            XCoord=(data.Coord(:,4));
    372373            YCoord=(data.Coord(:,5));
    373             xy=get(haxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
     374            xy=get(CurrentAxes,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    374375            if ~isempty(xy)
    375                 xlim=get(haxes,'XLim');
     376                xlim=get(CurrentAxes,'XLim');
    376377                ind_range_x=abs((xlim(2)-xlim(1))/50);
    377                 ylim=get(haxes,'YLim');
     378                ylim=get(CurrentAxes,'YLim');
    378379                ind_range_y=abs((ylim(2)-ylim(1))/50);
    379380                ind_range=sqrt(ind_range_x*ind_range_y);
     
    414415
    415416%% update the mouse pointer
    416 set(currentfig,'Pointer',pointershape);
     417set(CurrentFig,'Pointer',pointershape);
  • trunk/src/mouse_up.m

    r429 r432  
    5959    PlotData=get(AxeData.CurrentObject,'UserData');%get data attached to the current projection object 
    6060    IndexObj=PlotData.IndexObj;
    61     ObjectData=UvData.Object{IndexObj};    
     61    ObjectData=UvData.Object{IndexObj};   
    6262%     ObjectData.enable_plot=1;
    6363    if strcmp(ObjectData.Type,'rectangle')||strcmp(ObjectData.Type,'ellipse')
     
    139139
    140140            %% update the object representation
    141             ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat;
    142             ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field;
    143             UvData.Object{IndexObj}=ObjectData;%update the current object properties
    144             hhuvmat=guidata(huvmat);
    145             IndexObj_1=get(hhuvmat.ListObject_1,'Value');
    146             IndexObj_2=get(hhuvmat.ListObject,'Value');
    147             UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
     141%             ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj}.DisplayHandle_uvmat;
     142%             ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj}.DisplayHandle_view_field;
     143%             UvData.Object{IndexObj}=ObjectData;%update the current object properties
     144%             hhuvmat=guidata(huvmat);
     145%             IndexObj_1=get(hhuvmat.ListObject_1,'Value');
     146%             IndexObj_2=get(hhuvmat.ListObject,'Value');
     147%             UvData.Object=update_obj(UvData,IndexObj_1,IndexObj_2);
    148148
    149149            %% plot the field projected on the object
     
    199199            set(hhuvmat.MenuEdit,'Enable','on');%
    200200        end
    201     else
     201    end   
    202202       AxeData.CurrentOrigin=[xy(1,1) xy(1,2)]; %the current point becomes the new current origin
    203203       test_drawing=1;%allow continuation of drawing object
    204204       UvData.Object{IndexObj}=ObjectData;
    205     end
     205%     end
    206206    hother=findobj('Tag','deformpoint');%find all the deformpoints
    207207    set(hother,'Color','b');%reset all the deformpoints in 'blue'
  • trunk/src/plot_object.m

    r397 r432  
    11%'plot_object': draws a projection object (points, line, plane...)
    22%-------------------------------------------------------------------
    3 % function [ObjectData_out,hh]=plot_object(ObjectData,hplot,col)
     3% function hh=plot_object(ObjectData,ProjObject,hplot,col)
    44%
    55%OUTPUT
     
    88%INPUT:
    99%
    10 % ObjectDataIn: structure representing the object properties:
     10% ObjectData: structure representing the object properties:
    1111%        .Type : style of projection object
    1212%        .Coord: set of coordinates defining the object position;
     
    3636%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    3737
    38 function [hh]=plot_object(ObjectDataIn,ProjObject,hplot,col)
     38function [hh]=plot_object(ObjectData,ProjObject,hplot,col)
     39
    3940%% default output
    4041hh=[];%default output
    41 if ~isfield(ObjectDataIn,'Type')|| isequal(ProjObject,ObjectDataIn)% object representation does not appear in its own projection plot
    42     return
    43 end
    44 if ~isfield(ProjObject,'Type')
    45     ObjectData=ObjectDataIn;
    46 elseif isequal(ProjObject.Type,'plane')
    47     ObjectData=ObjectDataIn;% TODO: modify take into account rotation of axis
    48 else
    49     return % object representation only  available in a plane
    50 end
    51 if ~isfield(ObjectData,'Type')||isempty(ObjectData.Type)||~ischar(ObjectData.Type)
    52     msgbox_uvmat('ERROR','undefined ObjectData.Type in plot_object.m')
    53     return
    54 end
    55 if ~isfield(ObjectData,'Type')||isempty(ObjectData.Type)||~ischar(ObjectData.Type)
    56     msgbox_uvmat('ERROR','undefined ObjectData.Type in plot_object.m')
    57     return
     42% object representation is canceled if the field is not projected on a plane or is the same as the represented object
     43if ~isfield(ObjectData,'Type')|| isequal(ProjObject,ObjectData)|| ~strcmp(ProjObject.Type,'plane')
     44    if ~isempty(hplot) && ishandle(hplot) && ~strcmp(get(hplot,'Type'),'axes')
     45        ObjectPlotData=get(hplot,'UserData');
     46        if isfield(ObjectPlotData,'SubObject') & ishandle(ObjectPlotData.SubObject)
     47            delete(ObjectPlotData.SubObject);
     48        end
     49        if isfield(ObjectPlotData,'DeformPoint') & ishandle(ObjectPlotData.DeformPoint)
     50            delete(ObjectPlotData.DeformPoint);
     51        end
     52        delete(hplot)
     53    end
     54    return
    5855end
    5956XMin=0;%default
     
    7471        haxes=hplot;
    7572        currentfig=get(hplot,'parent');
    76 %         set(0,'CurrentFigure',currentfig)
    77      
    78 %         set(currentfig,'CurrentAxes',haxes);
    7973    elseif isequal(get(hplot,'Type'),'figure')% hplot is the handle of a figure
    8074        set(0,'CurrentFigure',hplot);%set the input figure as the current one
     
    8276        haxes=haxes(1);
    8377        currentfig=hplot;
    84        % set(hplot,'CurrentAxes',haxes);%set the first found axis as the current one
    8578    else
    8679        currentfig=figure; %create new figure
     
    10396     ObjectData.Coord=[0 0 0];%default
    10497end
    105 % if ~isfield(ObjectData,'Phi')||isempty(ObjectData.Phi)
    106 %      ObjectData.Phi=0;%default
    107 % end
    108 % if ~isfield(ObjectData,'Range')
    109 %     ObjectData.Range(1,1)=0; %edfault
    110 % end
    111 % if size(ObjectData.Range,2)>=2
    112 %     YMax=ObjectData.Range(1,2);%default
    113 % end
    114 % if size(ObjectData.Range,2)>=2 & size(ObjectData.Range,1)>=2
    115 %     YMin=ObjectData.Range(2,2);
    116 % else
    117 %     YMin=0;
    118 % end
    11998if isfield(ObjectData,'RangeX') && ~isempty(ObjectData.RangeX)
    12099    XMax=max(ObjectData.RangeX);
  • trunk/src/set_object.m

    r429 r432  
    414414
    415415%------------------------------------------------------------------------
    416 % --- Executes on button press in PLOT: PLOT the defined object and its projected field
     416% --- Executes on button press in PLOT: refresh the current object , plot the object and its projected field
    417417function PLOT_Callback(hObject, eventdata, handles)
    418418
     
    430430ObjectName=ObjectData.Name;%name of the current object defined in set_object
    431431if isempty(ObjectName)
    432      ObjectName=ObjectData.Type;
    433 end
    434 
    435 %% read the object selection in the GUI uvmat
     432     ObjectName=ObjectData.Type;% name the object by the object type type by default
     433end
     434
     435%% read the current object selection in the GUI uvmat
    436436huvmat=findobj('tag','uvmat');%find the current uvmat GUI handle
    437437UvData=get(huvmat,'UserData');%Data associated to the GUI uvmat
    438438hhuvmat=guidata(huvmat);%handles of the objects children of the  GUI uvmat
    439 ListObject=get(hhuvmat.ListObject_1,'String');% list of objects displayed in uvmat
    440 IndexObj(1)=get(hhuvmat.ListObject_1,'Value');% index of the selected object for display in uvmat
    441 if get(hhuvmat.ViewObject,'Value') && get(hhuvmat.edit_object,'Value')
    442     IndexObj(2)=get(hhuvmat.ListObject,'Value');% index of the object, possibly selected for display in view_field
    443 end
     439ListObject=get(hhuvmat.ListObject,'String');% list of objects displayed in uvmat
     440IndexObj=get(hhuvmat.ListObject,'Value');% index of the selected object for display in uvmat
    444441if ~get(hhuvmat.edit_object,'Value') %new object is being created
    445442    detectname=1;
     
    461458    ObjectName=ObjectNameNew;
    462459    set(handles.Name,'String',ObjectName)% display the default name in set_object
    463     IndexObj(2)=numel(ListObject)+1;% append an object to the list in uvmat
     460    IndexObj=numel(ListObject)+1;% append an object to the list in uvmat
    464461    set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list
    465462    set(hhuvmat.ListObject_1,'String',[ListObject;{ObjectName}]);%complement the object list
    466     set(hhuvmat.ListObject,'Value',IndexObj(2))
     463    set(hhuvmat.ListObject,'Value',IndexObj)
    467464    set(hhuvmat.ViewObject,'Value',1)% indicate that the currently selected objected is viewed on set_object
    468     UvData.Object{IndexObj(2)}=[];%initiate a new object (empty yet)
    469 end
    470 
    471 %% naming the object
    472 % ListObject{IndexObj(end),1}=ObjectName;
    473 % set(hhuvmat.ListObject,'String',ListObject)
    474 % set(hhuvmat.ListObject_1,'String',ListObject)
    475 
    476 %% update the object plot
    477 if IndexObj(end)<=length(UvData.Object) && isfield(UvData.Object{IndexObj(end)},'DisplayHandle_uvmat')% save the previous object graph handles
    478     ObjectData.DisplayHandle_uvmat=UvData.Object{IndexObj(end)}.DisplayHandle_uvmat;
    479 else
    480     ObjectData.DisplayHandle_uvmat=hhuvmat.axes3;%there is no object handle, than the axes handles is used as input
    481 end
    482 if isfield(UvData.Object{IndexObj(end)},'DisplayHandle_view_field')% save the previous object graph handles
    483     ObjectData.DisplayHandle_view_field=UvData.Object{IndexObj(end)}.DisplayHandle_view_field;
    484 else
    485     ObjectData.DisplayHandle_view_field=[];
    486 end
    487 UvData.Object{IndexObj(end)}=ObjectData;%update the current object properties
    488 if numel(IndexObj)==2
    489     UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
    490 end
    491 set(huvmat,'UserData',UvData)
     465    UvData.Object{IndexObj}=[];%initiate a new object (empty yet)
     466    UvData.Object{IndexObj}.DisplayHandle.uvmat=hhuvmat.axes3; %axes taken as object display handle by defualt
     467end
    492468
    493469%% plot the field projected on the object
     470hview_field=[];%default
    494471if strcmp(ObjectData.ProjMode,'mask_inside')||strcmp(ObjectData.ProjMode,'mask_outside')||strcmp(ObjectData.ProjMode,'none')
    495472    PlotType='text';
     
    500477        return
    501478    end   
    502     if numel(IndexObj)==1   % if only one object is selected, the projection is in uvmat
     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
    503481        PlotType=plot_field(ProjData,hhuvmat.axes3,read_GUI(get(hhuvmat.axes3,'parent')));%update the current uvmat plot
    504482    else  % if a second object is selected, the projection is in view_field, and this second object is selected
     
    525503    end
    526504end
     505
     506%% 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
     511% end
     512% if isfield(UvData.Object{IndexObj},'DisplayHandle')% save the previous object graph handles
     513%     ObjectData.DisplayHandle.view_field=UvData.Object{IndexObj(end)}.DisplayHandle.view_field;
     514% else
     515%     ObjectData.DisplayHandle.view_field=[];
     516% end
     517% UvData.Object{IndexObj}=ObjectData;%update the current object properties
     518% if numel(IndexObj)==2
     519hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat;
     520if isempty(hobject)
     521    hobject=hhuvmat.axes3;
     522end
     523UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(ObjectData,[],hobject,'m');%draw the object in uvmat
     524if ~isempty(hview_field)
     525    if isfield(UvData.Object{IndexObj}.DisplayHandle,'view_field')
     526    hobject=UvData.Object{IndexObj}.DisplayHandle.view_field;
     527    end
     528    if isempty(hobject)
     529        hobject=haxes;
     530    end
     531    UvData.Object{IndexObj}.DisplayHandle.view_field=plot_object(ObjectData,[],hobject,'m');%draw the object in view_field
     532    %     UvData.Object=update_obj(UvData,IndexObj(1),IndexObj(2));
     533end
     534set(huvmat,'UserData',UvData)
    527535
    528536%% update the GUI uvmat
  • trunk/src/uvmat.m

    r429 r432  
    237237
    238238%% refresh projection plane
    239 UvData.Object{1}.ProjMode='projection';%main plotting plane
     239% UvData.Object{1}.ProjMode='projection';%main plotting plane
     240% UvData.Object{1}.DisplayHandle.uvmat=handles.axes3;
     241% UvData.Object{1}.DisplayHandle.view_field=[];
    240242set(handles.ListObject,'Value',1)% default: empty projection objectproj_field
    241243set(handles.ListObject,'String',{'plane'})
     
    25102512    UvData.Field.Mesh=ord;
    25112513end
    2512 
     2514        UvData.Object{1}.Type='plane';%main plotting plane
     2515        UvData.Object{1}.ProjMode='projection';%main plotting plane
     2516        UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
     2517        UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
    25132518
    25142519%% 3D case (menuvolume)
     
    25232528    if test_set_object% reinitiate the GUI set_object
    25242529        delete_object(1);% delete the current projection object in the list UvData.Object, delete its graphic representations and update the list displayed in handles.ListObject and 2
    2525         UvData.Object{1}.Type='plane';%main plotting plane
    2526         UvData.Object{1}.ProjMode='projection';%main plotting plane
    2527         UvData.Object{1}.DisplayHandle_uvmat=[]; %plane not visible in uvmat
     2530%         UvData.Object{1}.Type='plane';%main plotting plane
     2531%         UvData.Object{1}.ProjMode='projection';%main plotting plane
     2532%         UvData.Object{1}.DisplayHandle.uvmat=[]; %plane not visible in uvmat
     2533%         UvData.Object{1}.DisplayHandle.view_field=[]; %plane not visible in uvmat
    25282534        UvData.Object{1}.NbDim=NbDim;%test for 3D objects
    25292535        UvData.Object{1}.RangeZ=UvData.Field.Mesh;%main plotting plane
     
    39853991% --- Executes on selection change in ListObject_1.
    39863992function ListObject_1_Callback(hObject, eventdata, handles)
    3987 list_str=get(handles.ListObject_1,'String');
     3993list_str=get(handles.ListObject,'String');
    39883994UvData=get(handles.uvmat,'UserData');
    39893995ObjectData=UvData.Object{get(handles.ListObject_1,'Value')};
    39903996
    39913997%% update the projection plot on uvmat
    3992 ProjData= proj_field(UvData.Field,ObjectData);%project the current interface field on UvData.Object{IndexObj(1)}
    3993 plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));%read plotting parameters on the uvmat interfacPlotHandles);
    3994 Object_out=update_obj(UvData,get(handles.ListObject_1,'Value'),[]);
     3998ProjData= proj_field(UvData.Field,ObjectData);%project the current input field on object ObjectData
     3999plot_field(ProjData,handles.axes3,read_GUI(handles.uvmat));% plot the projected field;
     4000%replot all the objects within the new projected field
     4001for IndexObj=1:numel(list_str)
     4002    IndexObj
     4003        hobject=UvData.Object{IndexObj}.DisplayHandle.uvmat
     4004        if isempty(hobject) || ~ishandle(hobject)
     4005            hobject=handles.axes3
     4006        end
     4007        if isequal(IndexObj,get(handles.ListObject,'Value'))
     4008            objectcolor='m'; %paint in magenta the currently selected object in ListObject
     4009        else
     4010            objectcolor='b';
     4011        end
     4012        UvData.Object{IndexObj}.DisplayHandle.uvmat=plot_object(UvData.Object{IndexObj},ObjectData,hobject,objectcolor);%draw the object in uvmat     
     4013end
     4014set(handles.uvmat,'UserData',UvData)
    39954015
    39964016%% display the object parameters if the GUI set_object is already opened
     
    40054025    set(handles.ViewObject,'Value',1)% show that the selected object in ListObject_1 is currently visualised
    40064026end
     4027
    40074028%  desactivate the edit object mode
    40084029set(handles.edit_object,'Value',0)
     
    40594080
    40604081%% update the color of the graphic object representation: the selected object in magenta, others in blue
    4061 update_object_color(handles.axes3,hhview_field.axes3,UvData.Object{IndexObj(end)}.DisplayHandle_uvmat)
    4062 hview_field=findobj(allchild(0),'tag','view_field');
     4082update_object_color(handles.axes3,hhview_field.axes3,UvData.Object{IndexObj}.DisplayHandle.uvmat)
    40634083
    40644084%------------------------------------------------------------------------
     
    40874107    set(hother(iobj),'Selected','off')
    40884108end
    4089 if ~isempty(DisplayHandle)
     4109if ishandle(DisplayHandle)
    40904110    linetype=get(DisplayHandle,'Type');
    40914111    if isequal(linetype,'line')
     
    42574277    else
    42584278        Data=get(hview_field,'UserData');
    4259         set(hview_field,'Position',Data.GUISize)
     4279        set(hview_field,'Position',Data.GUISize)% restore the size of view_field for plots
    42604280    end
    42614281else
     
    45134533UvData=get(handles.uvmat,'UserData');
    45144534UvData.Object{IndexObj}=[]; %create a new empty object
     4535UvData.Object{IndexObj}.DisplayHandle.uvmat=handles.axes3; % axes for plot_object
     4536UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
    45154537data.Name=data.Type;% default name=type
    45164538data.Coord=[0 0]; %default
     
    45684590    set(handles.ListObject,'String',ListObject)
    45694591end
     4592UvData=get(handles.uvmat,'UserData');
     4593UvData.Object{IndexObj}=[]; %create a new empty object
     4594UvData.Object{IndexObj}.DisplayHandle.uvmat=[]; %no plot handle before plot_field operation
     4595UvData.Object{IndexObj}.DisplayHandle.view_field=[]; %no plot handle before plot_field operation
     4596set(handles.uvmat,'UserData',UvData)
    45704597set(handles.ListObject,'Value',length(ListObject))
    45714598hset_object=set_object(data);% call the set_object interface
     
    45744601set(handles.edit_object,'BackgroundColor',[0.7,0.7,0.7]) 
    45754602set(handles.delete_object,'Visible','on')
     4603
    45764604
    45774605%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  • trunk/src/view_field.m

    r429 r432  
    6464guidata(hObject, handles);
    6565
    66 dircur=pwd; %current working directory
    67 dir_opening=dircur;
    68 
    69 % set the position of colorbar and ancillary GUIs:
    70 set(hObject,'Units','Normalized')
    71 handles_mouse=handles;
    72 huvmat=findobj(allchild(0),'Name','uvmat');
    73 if ~isempty(huvmat)
    74     hhuvmat=guidata(huvmat);
    75     handles_mouse.edit=hhuvmat.edit_object;
    76     pos_view_field=get(hObject,'Position');
    77     pos_uvmat=get(huvmat,'Position');
    78     pos_view_field(1)=pos_uvmat(1)+pos_uvmat(3)/2;
    79     pos_view_field(2)=pos_uvmat(2)-pos_uvmat(3)/4;
    80 %      pos_view_field(3:4)=pos_uvmat(3:4);
    81     set(hObject,'Position',pos_view_field)
    82 end
    83 
    8466%functions for the mouse and keyboard
    85 set(hObject,'KeyPressFcn',{'keyboard_callback',handles_mouse})%set keyboard action function
    86 set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles_mouse})%set mouse action functio
     67set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
     68set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
    8769set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    88 set(hObject,'WindowButtonUpFcn',{'mouse_up',handles_mouse})
     70set(hObject,'WindowButtonUpFcn',{'mouse_up',handles})
    8971set(hObject,'DeleteFcn',{@closefcn})%
    9072set(hObject,'ResizeFcn',{@ResizeFcn,handles})%
     
    10385    write_plot_param(handles,PlotParamOut);% update the display of the plotting parameters
    10486end
     87
     88%put the GUI on the lower right of the sceen
     89pos_view_field=get(hObject,'Position');
     90ScreenSize=get(0,'ScreenSize');
     91pos_view_field(1)=ScreenSize(1)+ScreenSize(3)-pos_view_field(3);
     92pos_view_field(2)=ScreenSize(2);
     93set(hObject,'Position',pos_view_field)
    10594
    10695%------------------------------------------------------------------------
     
    827816
    828817
     818%
     819%
     820% % --- Executes when view_field is resized.
     821% function view_field_ResizeFcn(hObject, eventdata, handles)
     822% % hObject    handle to view_field (see GCBO)
     823% % eventdata  reserved - to be defined in a future version of MATLAB
     824% % handles    structure with handles and user data (see GUIDATA)
Note: See TracChangeset for help on using the changeset viewer.