function handles = GUIPlotMesh( handles )
% This must not be called while the simulation is running.

    if ~isempty( handles.mesh )
        wasBusy = setGFtboxBusy( handles, true );
      % fprintf( 1, 'GUIPlotMesh\n' );
        handles = processPendingData( handles );
%         if testAndClear( handles.plotFlag )
%             handles.mesh = getPlotOptionsFromDialog( handles.mesh, handles );
%         end
% 
%         handles.mesh = leaf_plot( handles.mesh );
        
        if isfield( handles.mesh, 'plothandles' ) && ~isempty( handles.mesh.plothandles )
            if isfield( handles.mesh.plothandles, 'meshhandles' ) && all(ishandle(handles.mesh.plothandles.meshhandles))
                set( handles.mesh.plothandles.meshhandles, 'ButtonDownFcn', {@doMeshClick} );
            end
            if isfield( handles.mesh.plothandles, 'vxhandles' )
                for i=1:length(handles.mesh.plothandles.vxhandles)
                    h = handles.mesh.plothandles.vxhandles(i);
                    if ishandle(h)
                        set( h, 'ButtonDownFcn', {@doVxClick} );
                    end
                end
            end
            if isfield( handles.mesh.plothandles, 'secondlayerhandle' ) ...
                    && ~isempty( handles.mesh.plothandles.secondlayerhandle ) ...
                    && all( ishandle( handles.mesh.plothandles.secondlayerhandle(:) ) )
                set( handles.mesh.plothandles.secondlayerhandle, 'ButtonDownFcn', {@doSecondLayerClick} );
            end
        end

        if handles.boingNeeded==2
            boing();
            handles.boingNeeded = 0;
        end
        setGFtboxBusy( handles, wasBusy );
    end
end
