Changeset 681


Ignore:
Timestamp:
Sep 2, 2013, 2:42:52 PM (11 years ago)
Author:
sommeria
Message:

mouse action improved for translations, use of magenta color to indicate that REFRESH is needed

Location:
trunk/src
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/keyboard_callback.m

    r625 r681  
    44cur_axes=get(hObject,'CurrentAxes');%current plotting axes of the figure with handle hObject
    55xx=double(get(hObject,'CurrentCharacter')); %get the keyboard character
     6if ~isempty(xx)
    67switch xx
    78    case {29,28,30,31}    %arrows for displacement
     
    4445            end
    4546        end
    46     case {8, 127} %if the delete or suppr key is pressed, delete the current object
    47         currentobject=gco;
    48         huvmat=findobj(allchild(0),'tag','uvmat');
    49         hlist_object=findobj(huvmat,'Tag','list_object_1');
    50         ObjIndex=get(hlist_object,'Value');
    51         if ObjIndex>1
    52             delete_object(ObjIndex)
    53         end
    54         if ishandle(currentobject)
    55             tag=get(currentobject,'Tag');%tag of the current selected object
    56             if isequal(tag,'proj_object')
    57                 delete_object(currentobject)
    58             end
    59         end
     47%     case {8, 127} %if the delete or suppr key is pressed, delete the current object
     48%         currentobject=gco;
     49%         huvmat=findobj(allchild(0),'tag','uvmat');
     50%         hlist_object=findobj(huvmat,'Tag','list_object_1');
     51%         ObjIndex=get(hlist_object,'Value');
     52%         if ObjIndex>1
     53%             delete_object(ObjIndex)
     54%         end
     55%         if ishandle(currentobject)
     56%             tag=get(currentobject,'Tag');%tag of the current selected object
     57%             if isequal(tag,'proj_object')
     58%                 delete_object(currentobject)
     59%             end
     60%         end
    6061    case 112%  key 'p'
    6162        uvmat('runplus_Callback',hObject,eventdata,handleshaxes)
    6263    case 109%  key 'm'
    6364        uvmat('runmin_Callback',hObject,eventdata,handleshaxes)
     65    otherwise
     66        set(handleshaxes.run0,'BackgroundColor',[1 0 1])%indicat that Run must be activated (todo: rplace by REFRESH)
    6467end
    65 
     68end
  • trunk/src/mouse_down.m

    r680 r681  
    5959    UvData=get(huvmat,'UserData');
    6060    test_ruler=isequal(get(hhuvmat.MenuRuler,'checked'),'on');%test for ruler  action, second priority;
    61     test_edit=get(hhuvmat.CheckEditObject,'Value')&& (isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint'));%test for object editing, third priority
     61    test_edit=get(hhuvmat.CheckEditObject,'Value');%&& (isequal(obj_tag,'proj_object')||isequal(obj_tag,'DeformPoint'));%test for object editing, third priority
    6262    hset_object=findobj(allchild(0),'Name','set_object');
    6363    if ~isempty(hset_object)
     
    9797ind_object=find(check_pos(:,1) & check_pos(:,2),1);% select the index of the (first) object under the mouse
    9898hchild=hchildren(ind_object);% corresponding object handle
     99htype='';
    99100if ~isempty(hchild)
    100101    htype=get(hchild,'Type');%type of object child of the current figure
     
    105106            xy=get(hchild,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    106107            AxeData=get(hchild,'UserData');% data attached to the axis
    107 %             if isfield(AxeData,'ObjectCoord') && size(AxeData.ProjObjectCoord,2)==3
    108 %                 xy(1,3)=AxeData.ProjObjectCoord(1,3); % z coordinate of the mouse: to generalise ...
    109 %             else
    110 %                 xy(1,3)=0; % z coordinate set to 0 by default
    111 %             end
     108            AxeData.Enable='on';% unable current axes for mouse up action
    112109            AxeData.CurrentOrigin=xy(1,1:2);% The current point set by the mouse becomes the current origin
    113110           
     
    135132                end
    136133            end
    137             %break% leave the loop once an axes has been selected
    138            
     134            set(hchild,'UserData',AxeData)
    139135            %if the mouse is over a uicontrol, with right mouse button activated, duplicate the display in an editable  zoom window
    140136        case 'uicontrol'
     
    153149                hhchildren=get(hchild,'Children');%handles of all objects in the selected panel
    154150                check_visible=strcmp(get(hhchildren,'Visible'),'on');%=1 if visible='on', =0 otherwise
    155                 hhchildren=hhchildren(check_visible); %keep only the visible children
    156                
     151                hhchildren=hhchildren(check_visible); %keep only the visible children               
    157152                PosChildren=get(hhchildren,'Position');
    158153                PosLength=cellfun('length',PosChildren);
     
    171166                    end
    172167                end
    173             end
    174             %   return %leave the function once a uicontrol has been selected
    175     end
    176 end
    177 
     168            end           
     169    end
     170end
     171    if ~strcmp(htype,'axes')
     172        currentaxes=get(hObject,'CurrentAxes');
     173        if ~isempty(currentaxes)
     174        AxeData=get(currentaxes,'UserData');% data attached to the axis
     175        AxeData.Enable='off';% desactivate current axes for mouse up action
     176        set(currentaxes,'UserData',AxeData);
     177        end
     178    end
     179   
    178180%% zoom has first priority, stop here
    179181if CheckZoom
     
    236238%% selection of an existing projection object (third priority)
    237239if  test_edit
     240    testdeform=0;
    238241    if ~(isfield(AxeData,'Drawing') && isequal(AxeData.Drawing,'create'))
    239242        userdata=get(hcurrentobject,'UserData');
     
    293296            set_object(UvData.ProjObject{IndexObj})
    294297            axes(hchild);%set back the current axes haxes
    295             testdeform=0;
    296298            set(gcbo,'Pointer','circle');
    297299            AxeData.Drawing='deform';
     
    307309               end
    308310            end
    309             if testdeform==0
     311%             if testdeform==0
     312%                 AxeData.Drawing='translate';
     313%                 set(AxeData.CurrentObject,'Selected','on')
     314%                 set(gcbo,'Pointer','fleur');
     315%             end
     316        else
     317            if strcmp(get(hCurrentGUI,'tag'),'uvmat') %if the uvmat graph has been selected, object projection is on the other frame view_field
     318               IndexObj=get(hhuvmat.ListObject,'Value');
     319               AxeData.CurrentObject=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
     320            else
     321                IndexObj=get(hhuvmat.ListObject_1,'Value');
     322                AxeData.CurrentObject=UvData.ProjObject{IndexObj}.DisplayHandle.view_field;
     323            end   
     324            ObjectData=get(AxeData.CurrentObject,'UserData');
     325            ObjectData.IndexObj=IndexObj;
     326            set(AxeData.CurrentObject,'UserData',ObjectData)
     327        end
     328        if testdeform==0
    310329                AxeData.Drawing='translate';
    311330                set(AxeData.CurrentObject,'Selected','on')
    312331                set(gcbo,'Pointer','fleur');
    313             end
    314332        end
    315333    end
  • trunk/src/mouse_motion.m

    r664 r681  
    4949test_zoom_draw=0;
    5050test_object=0; %test for object editing or creation
    51 test_edit_object=0;% edit test for mouse shap: an arrow
     51test_edit_object=0;% edit test for mouse shape: an arrow
    5252test_ruler=0;%test for active ruler
    5353test_transform=0;
     
    357357        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
    358358        pointershape='crosshair';
    359     elseif isequal(AxeData.Drawing,'translate')
     359    elseif test_edit_object && isequal(AxeData.Drawing,'translate')
    360360        DX=xy(1,1)-XYData(1);%translation from initial position
    361361        DY=xy(1,2)-XYData(2);
     
    364364        plot_object(ObjectData,ProjObject,AxeData.CurrentObject,'m');
    365365        pointershape='fleur';
    366     elseif isequal(AxeData.Drawing,'deform')
     366    elseif test_edit_object && isequal(AxeData.Drawing,'deform')
    367367        ind_move=AxeData.CurrentIndex;
    368368        ObjectData.Coord(ind_move,1)=xy(1,1);
  • trunk/src/mouse_up.m

    r660 r681  
    5151end
    5252test_drawing=0;%default, =1 to allow drawing by further mouse action
     53if ~(isfield(AxeData,'Enable')&& strcmp(AxeData.Enable,'on'))
     54    return
     55end
    5356xy=get(gca,'CurrentPoint');%xy(1,1),xy(1,2): current x,y positions in axes coordinates
    5457
     
    7477        ObjectData.Coord(:,1)=ObjectData.Coord(:,1)+DX;
    7578        ObjectData.Coord(:,2)=ObjectData.Coord(:,2)+DY;
    76        
     79        set(hh_set_object.Coord,'Data',ObjectData.Coord);
    7780        %ending object deformation
    7881    elseif isequal(AxeData.Drawing,'deform')
     
    8083        ObjectData.Coord(ind_move,1)=xy(1,1);
    8184        ObjectData.Coord(ind_move,2)=xy(1,2);
    82        
     85        set(hh_set_object.Coord,'Data',ObjectData.Coord);
    8386        %creating object
    8487    else
     
    160163                        drawnow
    161164                        set(hview_field,'UserData',ViewFieldData);% restore the previously stored GUI position after GUI resizing
    162                     else
     165                    elseif isfield(ViewFieldData,'GUISize')
    163166                        set(hview_field,'Position',ViewFieldData.GUISize)
    164167                    end
  • trunk/src/plot_object.m

    r680 r681  
    394394    end
    395395    if test_patch
     396        if isfield(PlotData,'SubObject')
    396397        for iobj=1:length(PlotData.SubObject)
    397398            if ~ishandle(PlotData.SubObject(iobj))
     
    408409                end
    409410            end
    410         end     
     411        end
     412        end
    411413    else% no patch image requested, erase existing ones
    412414        if isfield(PlotData,'SubObject')
  • trunk/src/read_field.m

    r675 r681  
    7171        Role={};
    7272        ProjModeRequest={};
     73        checkU=0;
     74        checkV=0;
    7375        for ilist=1:numel(InputField)
    7476            r=regexp(InputField{ilist},'(?<Operator>(^vec|^norm))\((?<UName>.+),(?<VName>.+)\)$','names');
     77            Operator='';
    7578            if isempty(r)%  no operator used
    76                 ListVar=[ListVar InputField(ilist)];
     79                if isempty(find(strcmp(InputField{ilist},ListVar)))
     80                ListVar=[ListVar InputField(ilist)];%append the variable name if not already in the list
     81                end
    7782                if check_colorvar(ilist)
    7883                    Role{numel(ListVar)}='ancillary';% not projected with interpolation
     
    8388                end
    8489            else  % an operator 'vec' or 'norm' is used
     90                Operator=r.Operator;
    8591                if ~check_colorvar(ilist) && strcmp(r.Operator,'norm')
    8692                    ProjModeRequestVar='interp_lin';%scalar field (requires interpolation for plot)
     
    94100                    Role=[Role {'vector_x'}];
    95101                    ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}];
     102                else
     103                    checkU=1;
    96104                end
    97105                if isempty(ind_var_V)
     
    99107                    Role=[Role {'vector_y'}];
    100108                    ProjModeRequest=[ProjModeRequest {ProjModeRequestVar}];
     109                else
     110                    checkV=1;
    101111                end
    102112            end
     
    125135            Field.VarAttribute{ivar+2}.ProjModeRequest=ProjModeRequest{ivar};
    126136        end
    127 
     137        if strcmp(Operator,'norm')
     138             NormName='norm';
     139            if ~isempty(strcmp(ListVar,'norm'))
     140                NormName='norm_1';
     141            end
     142            Field.ListVarName=[Field.ListVarName {NormName}];
     143            ilist=numel(Field.ListVarName);
     144            Field.VarDimName{ilist}=Field.VarDimName{ind_var_U};
     145            Field.VarDimName{ilist}.Role='scalar';
     146            Field.(NormName)=Field.(r.UName).*Field.(r.UName)+Field.(r.VName).*Field.(r.VName);
     147            Field.(NormName)=sqrt(Field.(NormName));
     148            if ~checkU && ~checkV
     149                Field.ListVarName([ind_var_U ind_var_V])=[];
     150                Field.VarDimName([ind_var_U ind_var_V])=[];
     151                Field.VarAttribute([ind_var_U ind_var_V])=[];
     152            elseif ~checkU
     153                Field.ListVarName(ind_var_U)=[];
     154                Field.VarDimName(ind_var_U)=[];
     155                Field.VarAttribute(ind_var_U )=[];
     156            elseif ~checkV
     157                                Field.ListVarName(ind_var_V)=[];
     158                Field.VarDimName(ind_var_V)=[];
     159                Field.VarAttribute(ind_var_V )=[];
     160            end
     161        end
    128162    case 'video'
    129163        if strcmp(class(ParamIn),'VideoReader')
  • trunk/src/set_object.m

    r680 r681  
    3636function varargout = set_object(varargin)
    3737
    38 % Last Modified by GUIDE v2.5 28-Aug-2013 20:41:02
     38% Last Modified by GUIDE v2.5 02-Sep-2013 11:39:56
    3939
    4040% Begin initialization code - DO NOT REFRESH
     
    9393    ZBounds=0; %default
    9494end
    95 set(handles.Coord,'KeyPressFcn',{@key_press_fcn,handles})%set keyboard action function (allow action on uvmat when set_object is in front)
    9695set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
    9796set(hObject,'DeleteFcn',{@closefcn})
     
    116115    end
    117116    Type_Callback(hObject, eventdata, handles)% update the GUI set_object depending on the object type   
    118 
     117    set(handles.REFRESH,'BackgroundColor',[1 0 0])
    119118    if isfield(data,'RangeZ') && length(ZBounds) >= 2
    120119        set(handles.num_RangeZ_2,'String',num2str(max(data.RangeZ),3))
     
    219218function Type_Callback(hObject, eventdata, handles)
    220219%------------------------------------------------------------------------
    221 %style_prev=get(handles.Type,'UserData');%previous object style
     220
    222221ListType=get(handles.Type,'String');
    223222Type=ListType{get(handles.Type,'Value')};
     
    271270% --- Executes on selection change in ProjMode.
    272271%------------------------------------------------------------------------
    273 
    274272function ProjMode_Callback(hObject, eventdata, handles)
     273
     274set(handles.REFRESH,'BackgroundColor',[1 0 1])
    275275menu=get(handles.ProjMode,'String');
    276276value=get(handles.ProjMode,'Value');
     
    419419function REFRESH_Callback(hObject, eventdata, handles)
    420420
    421 set(handles.REFRESH,'BackgroundColor',[1 1 0])
     421set(handles.REFRESH,'BackgroundColor',[1 1 0])% indicate activation of REFRESH
    422422drawnow
    423423
     
    588588set(hhuvmat.CheckEditObject,'Value',1) % set uvmat to object edit mode to allow further object update
    589589set(hhuvmat.CheckViewField,'Value',1)
     590
    590591set(handles.REFRESH,'BackgroundColor',[1 0 0])
     592%set(handles.Coord,'BackgroundColor',[1 1 1])
     593set(handles.num_RangeY_2,'BackgroundColor',[1 1 1])
     594
    591595%------------------------------------------------------------------------
    592596% --- Executes on button press in MenuCoord.
     
    617621
    618622function num_RangeX_2_Callback(hObject, eventdata, handles)
     623
    619624%------------------------------------------------------------------------
    620625%------------------------------------------------------------------------
     
    720725function Coord_CellEditCallback(hObject, eventdata, handles)
    721726%------------------------------------------------------------------------
     727%set(handles.Coord,'BackgroundColor',[1 1 0])
    722728% ListType=get(handles.Type,'String');
    723729% Type=ListType{get(handles.Type,'Value')};
     
    744750end
    745751
    746 %------------------------------------------------------------------------
    747 % --- 'key_press_fcn:' function activated when a key is pressed on the keyboard
    748 %------------------------------------------------------------------------
    749 function key_press_fcn(hObject,eventdata,handles)
    750 
     752
     753function num_Angle_3_Callback(hObject, eventdata, handles)
     754
     755%------------------------------------------------------------------------
     756% --- Executes on key press with selection of a uicontrol
     757%------------------------------------------------------------------------
     758function KeyPressFcn(hObject, eventdata, handles)
     759set(handles.REFRESH,'BackgroundColor',[1 0 1])% se REFRESH to magenta color, indicates that refresh needs to be done
     760
     761%------------------------------------------------------------------------
     762% --- Executes on key press with focus on Coord and none of its controls.
     763%------------------------------------------------------------------------
     764function Coord_KeyPressFcn(hObject, eventdata, handles)
     765
     766set(handles.REFRESH,'BackgroundColor',[1 0 1])
    751767xx=double(get(handles.set_object,'CurrentCharacter')); %get the keyboard character
    752768if ismember(xx,[127 31])% delete, or downward
     
    763779end
    764780
    765 function num_Angle_3_Callback(hObject, eventdata, handles)
    766 % hObject    handle to num_Angle_3 (see GCBO)
    767 % eventdata  reserved - to be defined in a future version of MATLAB
    768 % handles    structure with handles and user data (see GUIDATA)
    769 
    770 % Hints: get(hObject,'String') returns contents of num_Angle_3 as text
    771 %        str2double(get(hObject,'String')) returns contents of num_Angle_3 as a double
     781
     782
  • trunk/src/uvmat.m

    r680 r681  
    204204
    205205%% set functions for the mouse and keyboard
    206 set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
     206set(hObject,'WindowKeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
    207207set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
    208208set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
     
    17691769    errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2);
    17701770end
    1771 
    1772 %% refresh plots
    1773 % errormsg=refresh_field(handles,filename,filename_1,i1,i2,j1,j2,i1_1,i2_1,j1_1,j2_1);
     1771set(handles.run0,'BackgroundColor',[1 0 0])
    17741772
    17751773%% update the index counters if the index move is successfull
     
    18221820else
    18231821    set(handles.movie_pair,'BusyAction','queue')
     1822    set(handles.run0,'BackgroundColor',[1 0 0])
    18241823end
    18251824
     
    19871986    set(handles.j2,'BackgroundColor',[1 1 1])
    19881987    set(handles.FileIndex,'BackgroundColor',[1 1 1])
    1989     set(handles.FileIndex_1,'BackgroundColor',[1 1 1])   
     1988    set(handles.FileIndex_1,'BackgroundColor',[1 1 1]) 
     1989    set(handles.run0,'BackgroundColor',[1 0 0])
    19901990end   
    1991 set(handles.run0,'BackgroundColor',[1 0 0])
    1992 
    19931991
    19941992%------------------------------------------------------------------------
     
    27022700end
    27032701ResizeFcn(handles.uvmat,[],handles)
     2702%set(handles.uvmat,'CurrentAxes',handles.PlotAxes)% make the main axis current (usefull for key board callback)
    27042703
    27052704%------------------------------------------------------------------------
     
    40214020[tild,PlotParamOut]= plot_field(AxeData,handles.PlotAxes,PlotParam);
    40224021errormsg=fill_GUI(PlotParamOut,handles.uvmat);
    4023 %write_plot_param(handles,PlotParamOut); %update the auto plot parameters
     4022RUNColor=get(handles.run0,'BackgroundColor');%
     4023if isequal(RUNColor,[1 0 1])% suppress magenta color (indicate that plot is  updated)
     4024    set(handles.run0,'BackgroundColor',[1 0 0]);
     4025end
    40244026
    40254027%------------------------------------------------------------------------
     
    43344336if  ~isempty(UvData) && isfield(UvData, 'ProjObject') && length(UvData.ProjObject)>=IndexObj
    43354337    if isfield(UvData.ProjObject{IndexObj},'DisplayHandle') && isfield(UvData.ProjObject{IndexObj}.DisplayHandle,'uvmat')
    4336         hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;
     4338        hdisplay=UvData.ProjObject{IndexObj}.DisplayHandle.uvmat;%handle of the object graphic representation in uvmat
    43374339        for iview=1:length(hdisplay)
    43384340            if ishandle(hdisplay(iview)) && ~isequal(hdisplay(iview),0)
    43394341                ObjectData=get(hdisplay(iview),'UserData');
    43404342                if isfield(ObjectData,'SubObject') & ishandle(ObjectData.SubObject)
    4341                     delete(ObjectData.SubObject);
     4343                    delete(ObjectData.SubObject);% delete the graphic 'sub-objects (e.g. projection bounds)
    43424344                end
    4343                 if isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
    4344                     delete(ObjectData.DeformPoint);
    4345                 end
    4346                 delete(hdisplay(iview))
     4345                check_suppress= isfield(ObjectData,'DeformPoint') & ishandle(ObjectData.DeformPoint)
     4346                delete(ObjectData.DeformPoint(check_suppress));% delete the graphic deformation points
     4347                delete(hdisplay(iview))% delete the main graphic representation of the object
    43474348            end
    43484349            ishandle(hdisplay(iview))
  • trunk/src/view_field.m

    r650 r681  
    6565
    6666%functions for the mouse and keyboard
    67 set(hObject,'KeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
     67set(hObject,'WindowKeyPressFcn',{'keyboard_callback',handles})%set keyboard action function
    6868set(hObject,'WindowButtonMotionFcn',{'mouse_motion',handles})%set mouse action functio
    6969set(hObject,'WindowButtonDownFcn',{'mouse_down'})%set mouse click action function
Note: See TracChangeset for help on using the changeset viewer.