필터 지우기
필터 지우기

how to select patch surface in gui

조회 수: 7 (최근 30일)
Xiwen
Xiwen 2024년 4월 8일
댓글: Xiwen 2024년 4월 16일
Hi all,
I am looking for a method to select the patch surface in a 3D plot. In figure GUI, I can only select the node and get nodal position information through updateFun. The datacursormode.target has the patch data stored in there. Is there a way to change the cursor selection method from node to surface in a 3D mesh? Thanks in advance!

답변 (1개)

Ramtej
Ramtej 2024년 4월 16일
Hi,
MATLAB's data cursor mode primarily focuses on points (nodes) rather than entire surfaces. However, you can leverage "ButtonDownFcn"of the plotting function to extract and display information related to the surface (patch) under the clicked point, rather than just the nodal information.
Below code demonstrates how to identify when a patch object is selected when you left click anywhere on the surface and toggles the marker (of vertices) and linewidth property of patch to distinguish it visually.
You can extend the functionality within the "myCustomUpdateFcn" function to include more specific information about the patch.
x1 = [0 0 1 1];
y1 = [3 3 2 2];
z1 = [0 3 2 1];
c1 = [0 0.447 0.741];
x2 = [2 2 3 3];
y2 = [1 1 0 0];
z2 = [1 2 3 0];
c2 = [0.850 0.325 0.098];
fill3(x1,y1,z1,c1,x2,y2,z2,c2, "ButtonDownFcn",@myCustomFcn);
% Define the custom update function
function myCustomFcn(~,event_obj)
target = event_obj.Source;
% Check if the target is a patch
if isa(target, 'matlab.graphics.primitive.Patch')
if target.Marker == "none"
target.Marker = 'o';
target.LineWidth = 3;
else
target.Marker = "none";
target.LineWidth = 0.5
end
% Now target is your selected patch
% Add your own code to modify patch
end
end
If you are trying to modify patch properties, refer the below documentaton for changing patch appearance and behavior.
  댓글 수: 1
Xiwen
Xiwen 2024년 4월 16일
Hi using this method, I select the whole patch. My patch has many faces in it. I am more interested to select the individual face inside a patch.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Polygons에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by