Changeset 429 for trunk/src/mouse_down.m


Ignore:
Timestamp:
May 22, 2012, 1:07:40 AM (12 years ago)
Author:
sommeria
Message:

improvements in object drawing and projection on points

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/mouse_down.m

    r427 r429  
    2323
    2424function xy=mouse_down(hObject,eventdata)
    25 
    2625AxeData=[];%default
    2726FigData=get(hObject,'UserData');
     
    5756    test_create=0;
    5857    hset_object=findobj(allchild(0),'tag','set_object');
     58
    5959    if ~isempty(hset_object)
    6060        hPLOT=findobj(hset_object,'tag','PLOT');
    61         test_create=strcmp(get(hPLOT,'enable'),'on') &&~test_edit;
    62     end
    63     %         test_create=~isempty(hset_object)&&~test_edit;
     61        test_create=strcmp(get(hPLOT,'enable'),'on') &&~test_edit;% create new object if set_object is in mode enable and uvmat not in mode 'edit_object'
     62    end
    6463   
    6564    test_cal=isequal(get(hhuvmat.MenuCalib,'checked'),'on');% test for calibration
     
    304303end
    305304
    306 %%  create new projection  object
    307 if  test_create && ~isempty(xy) && ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
     305%%  create projection  object
     306if  test_create && ~isempty(xy) %&& ~(isfield(AxeData,'Drawing')&& isequal(AxeData.Drawing,'create'))
    308307    hset_object=findobj(allchild(0),'tag','set_object');
    309308    % activate this option if the GUI set_object is opened
    310309    if ~isempty(hset_object)
    311         sethandles=guidata(hset_object);% handles of the elements in set_object
     310        sethandles=guidata(hset_object);% handles of the elements in the GUI set_object
    312311        ObjectData=read_GUI(hset_object); %read object parameters in the GUI set_object
    313         ObjectData.Coord=[]; %reset previous object coordinates
    314         ObjectData.Coord(1,1)=xy(1,1); % the object first coordinate is set by the mouse position
    315         ObjectData.Coord(1,2)=xy(1,2);
    316         if isfield(AxeData,'ObjectCoord') && size(AxeData.ObjectCoord,2)==3
    317             ObjectData.Coord(1,3)=AxeData.ObjectCoord(1,3); %generaliser au cas avec angle
    318         end
     312        IndexObj=length(UvData.Object);
     313        %initiate a new object
     314        if isempty(UvData.Object{IndexObj});
     315            ObjectData.Coord=[];
     316            ObjectNameNew=ObjectData.Name;
     317            if isempty(ObjectNameNew)
     318                ObjectNameNew=ObjectData.Type;
     319            end
     320            % add an index to the object name if the proposed name already exists
     321           
     322           
     323            vers=0;% index of the name
     324            ListObject=get(hhuvmat.ListObject,'String');
     325            detectname=1;
     326            while ~isempty(detectname)
     327                detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
     328                if detectname% if the object name already exists
     329                    indstr=regexp(ObjectNameNew,'\D');
     330                    if indstr(end)<length(ObjectNameNew) %object name ends by a number
     331                        vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
     332                        ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
     333                    else
     334                        vers=vers+1;
     335                        ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
     336                    end
     337                end
     338            end
     339            ObjectName=ObjectNameNew;
     340            set(sethandles.Name,'String',ObjectName)% display the default name in set_object
     341            ListObject{end}=ObjectName;
     342            set(hhuvmat.ListObject,'String',ListObject);%complement the object list
     343            set(hhuvmat.ListObject_1,'String',ListObject);%complement the object list
     344            set(hhuvmat.ListObject,'Value',IndexObj)
     345            set(hhuvmat.ViewObject,'Value',1)
     346        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
     353        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       
    319363        AxeData.CurrentObject=plot_object(ObjectData,[],haxes,'m');%draw the object and its handle becomes AxeData.CurrentObject
    320         if isfield(UvData,'Object')
    321             IndexObj=length(UvData.Object)+1;% add the object as index IndexObj on the list of the interface
    322         else
    323             IndexObj=2;% the first object is used for uvmat display or blank
    324         end
    325         UvData.Object{IndexObj}=ObjectData;
    326         ListObject=get(hhuvmat.ListObject,'String');
    327         UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject;
    328         ObjectNameNew=ObjectData.Name;
    329         if isempty(ObjectNameNew)
    330              ObjectNameNew=ObjectData.Type;
    331         end
    332         % add an index to the object name if the proposed name already exists
    333         vers=0;% index of the name
    334         detectname=1;
    335         while ~isempty(detectname)
    336             detectname=find(strcmp(ObjectNameNew,ListObject),1);%test the existence of the proposed name in the list
    337             if detectname% if the object name already exists
    338                 indstr=regexp(ObjectNameNew,'\D');
    339                 if indstr(end)<length(ObjectNameNew) %object name ends by a number
    340                     vers=str2double(ObjectNameNew(indstr(end)+1:end))+1;
    341                     ObjectNameNew=[ObjectNameNew(1:indstr(end)) num2str(vers)];
    342                 else
    343                     vers=vers+1;
    344                     ObjectNameNew=[ObjectNameNew(1:indstr(end)) '_' num2str(vers)];
    345                 end
    346             end
    347         end
    348         ObjectName=ObjectNameNew;
    349         set(sethandles.Name,'String',ObjectName)% display the default name in set_object
    350         set(hhuvmat.ListObject,'String',[ListObject;{ObjectName}]);%complement the object list
    351         set(hhuvmat.ListObject_1,'String',[ListObject;{ObjectName}]);%complement the object list
    352         set(hhuvmat.ListObject,'Value',IndexObj)
    353         set(hhuvmat.ViewObject,'Value',1)
     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
     369        UvData.Object{IndexObj}=ObjectData;     
     370        UvData.Object{IndexObj}.DisplayHandle_uvmat=AxeData.CurrentObject;     
    354371        UvData.Object{IndexObj}.DisplayHandle_view_field=AxeData.CurrentObject;
    355372        set(huvmat,'UserData',UvData)
     
    358375        set(AxeData.CurrentObject,'UserData',PlotData); %record the object index in the graph (memory used for mouse motion)
    359376        AxeData.Drawing='create';% flag for mouse motion
    360     end
    361 end
    362 
    363 % create calibration points if the GUI geometry_calib is opened, if the main axes axes3 of uvmat has ben selected
     377        %show object coordinates in the GUI set_object
     378        h_set_object=findobj(allchild(0),'Tag','set_object');
     379        hh_set_object=guidata(h_set_object);
     380        set(hh_set_object.Coord,'Data',ObjectData.Coord);
     381    end
     382end
     383
     384%% create calibration points if the GUI geometry_calib is opened, if the main axes axes3 of uvmat has ben selected
    364385if ~test_zoom && test_cal && ~isempty(haxes) && strcmp(get(haxes,'tag'),'axes3')
    365386    h_geometry_calib=findobj(allchild(0),'Name','geometry_calib'); %find the geomterty_calib GUI
     
    426447end
    427448
    428 % edit vectors
     449%% edit vectors
    429450if test_edit_vect && ~isempty(ivec)
    430451    %create the error flag FF if it does not exist
     
    445466    eval(['FigData.' tagaxes '=Field;'])%record the modified field in FigData
    446467    set(hcurrentfig,'UserData',FigData);
    447 end   
     468end 
    448469set(haxes,'UserData',AxeData);
    449470
Note: See TracChangeset for help on using the changeset viewer.