patchfacefcn(hPatch, hit, callbackFun, selection)
patchfacefcn(hPatch, hit, callbackFun, selection, dLim)
patchfacefcn(hPatch, hit, callbackFun, selection) finds the index of the
face in a patch object which was clicked on by the mouse. The function
should be used as a callback function for the
ButtonDownFcn event of
the patch object and it will call a user defined function with the same
arguments as the
ButtonDownFcn call, plus adding an extra argument, the
face index. Thus the user defined callback function needs to have the
The function can detect if the mouse click was on a face or on an edge of the patch object.
patchfacefcn(hPatch, hit, callbackFun, selection, dLim) adds optional
control on the selectivity whether the click was on a face of a patch
The color of any face of the red triangulated icosahedron will be changed from red to green if clicked on with the mouse.
mesh = swplot.icomesh(1) V = mesh.X F = mesh.Triangulation hPatch = patch('Faces',F,'Vertices',V,'FaceColor','r','EdgeColor','none') axis equal axis off box on view(3) camlight('right') hPatch.FaceColor = 'flat' hPatch.FaceVertexCData = repmat([1 0 0],[size(F,1) 1]) fun = @(hPatch,hif,face)set(hPatch,'FaceVertexCData',[hPatch.FaceVertexCData(1:(face-1),:); [0 1 0]; hPatch.FaceVertexCData((face+1):end,:)]) hPatch.ButtonDownFcn = @(hPatch,hit)swplot.patchfacefcn(hPatch,hit,fun,'face')
- Handle of the patch object.
- Hit object that contains the point where the object was hit.
- User function that will be called in case of a click event
hPatchobject. It should have the following header:
faceIndexcontains the index of the face that was clicked on, it can contain a single index or more depending on the selection type.
- String, that defines three diferent selection criteria when the
callbackfun()function will be called:
callbackFun()will be triggered if a face was clicked (
callbackfun()will be triggered if an edge is clicked (
callbackfun()will be triggered for both faces and edges.
- Upper limit of the absolute value of the determinant that determines whether a point is on a plane spanned by the two edges of a triangle. Default value is (tested).