Callback function for selecting triangular faces of patch objects

버전 1.0.0.0 (3.13 KB) 작성자: Sandor Toth
The function can find the index of the face in a triangular patch object which was clicked on
다운로드 수: 273
업데이트 날짜: 2017/1/11

라이선스 보기

The function can find 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 patch object and it will call a user defined function with the same arguments as the ButtonDownFcn call, but adding an extra argument, the face index. Thus the user defined
callback function will have the following header:
callbackfun(obj,hit,faceIndex)
The function can detect if the mouse click was on a face or on an edge of the patch object.
Input:
obj The patch object that calls the function.
hit Hit object that contains the point where the object was hit.
callbackfun User function that will be called in case of a click event on obj. It should have the following header:
callbackfun(obj,hit,faceIndex)
where face Index contains the index of the face that was clicked on, it can contain a single index or two depending on the selection type.
selection String defines three diferent selection criteria when the callbackfun() function will be called:
'face' The callbackfun() will be triggered if a face was clicked (numel(faceIndex)==1).
'edge' The callbackfun() will be triggered if an edge is clicked (numel(faceIndex)==2).
'all' The callbackfun() will be triggered for both faces and edges.
Example:
The color of any face of the red triangulated icosahedron will be
changed to green if clicked on.
mesh = icomesh(1);
V = mesh.Points;
F = mesh.ConnectivityList;
hPatch = patch('Faces',F,'Vertices',V,'FaceColor','r','EdgeColor','none');
axis equal
box on
view(3)
camlight('right')
hPatch.FaceColor = 'flat';
hPatch.FaceVertexCData = repmat([1 0 0],[size(F,1) 1]);
fun = @(obj,hif,face)set(obj,'FaceVertexCData',[obj.FaceVertexCData(1:(face-1),:); [0 1 0]; obj.FaceVertexCData((face+1):end,:)]);
hPatch.ButtonDownFcn = @(obj,hit)patchfacefcn(obj,hit,fun,'face');

인용 양식

Sandor Toth (2024). Callback function for selecting triangular faces of patch objects (https://www.mathworks.com/matlabcentral/fileexchange/61078-callback-function-for-selecting-triangular-faces-of-patch-objects), MATLAB Central File Exchange. 검색됨 .

MATLAB 릴리스 호환 정보
개발 환경: R2016b
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
버전 게시됨 릴리스 정보
1.0.0.0

Added graphics.
Updated description.