-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Markus Leuthold
committed
Sep 14, 2023
1 parent
df9b09b
commit 46ac5df
Showing
5 changed files
with
54 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
hGrid = uigridlayout([1 2]); | ||
hGrid.Parent.Name = "Orbit3d for multiple axes (Press h for help)"; | ||
|
||
hAxes1 = uiaxes("Parent", hGrid); | ||
hAxes2 = uiaxes("Parent", hGrid); | ||
|
||
gfx.orbit3d(hAxes1); | ||
gfx.orbit3d(hAxes2); | ||
|
||
mesh = load('trimesh3d'); | ||
|
||
hPatch1 = patch("parent", hAxes1, "Vertices", [mesh.x mesh.y mesh.z], "Faces", mesh.tri, "FaceColor", "y"); | ||
hPatch2 = patch("parent", hAxes2, "Vertices", [mesh.x mesh.y mesh.z], "Faces", mesh.tri, "FaceColor", "r"); | ||
|
||
% right click on first axes changes mesh color | ||
gfx.FigureEventDispatcher.addAxesEvent(... | ||
"WindowMousePress", @(~,~)set(hPatch1, 'FaceColor', rand(1, 3)), ... | ||
hAxes1, @(f,~)f.SelectionType == "alt"); | ||
|
||
% pressing v toggles hAxes1 visibility, no matter what is the current object | ||
gfx.FigureEventDispatcher.addFigureEvent(... | ||
"KeyPress", @(~,ev)toggleAxesVisibility(hAxes1, ev.Key), hGrid.Parent); | ||
|
||
function toggleAxesVisibility(hAxes, key) | ||
if isequal(key, 'v') | ||
hAxes.Visible = ~ hAxes.Visible; | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
mesh = load('trimesh3d'); | ||
|
||
%% equivalent to cla(): create a new figure with a new axes if no figure exists yet | ||
gfx.clearOrNewUiAxes3d | ||
gfx.clearUiAxes3d; | ||
patch("Vertices", [mesh.x mesh.y mesh.z], "Faces", mesh.tri, "FaceColor", "y"); | ||
|
||
%% equivalent to figure(): always create a new figure | ||
gfx.newUiAxes3d; | ||
gfx.newUiFigure3d; | ||
patch("Vertices", [mesh.x mesh.y mesh.z], "Faces", mesh.tri, "FaceColor", "r"); | ||
|
||
%% equivalent to cla(): clear the red mesh of the current figure and plot a new blue one | ||
gfx.clearOrNewUiAxes3d; | ||
gfx.clearUiAxes3d; | ||
patch("Vertices", [mesh.x mesh.y mesh.z], "Faces", mesh.tri, "FaceColor", "b"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters