diff --git a/CHANGELOG.md b/CHANGELOG.md index 1841f067a2..d39e8cf236 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,7 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed -- `plot`: speed optimization: `tic();plot(rand(300,300), rand(300,300));toc()` +- `plot`, `plot3` : speed optimization: `tic();plot(rand(300,300), rand(300,300));toc()` - fmtlib 11.1.3 ## 1.12.0 (2025-02-16) diff --git a/modules/graphics/examples/cube/demo_cube.m b/modules/graphics/examples/cube/demo_cube.m new file mode 100644 index 0000000000..f5eb86014e --- /dev/null +++ b/modules/graphics/examples/cube/demo_cube.m @@ -0,0 +1,62 @@ +%============================================================================= +% Copyright (c) 2016-present Allan CORNET (Nelson) +%============================================================================= +% This file is part of the Nelson. +%============================================================================= +% LICENCE_BLOCK_BEGIN +% SPDX-License-Identifier: LGPL-3.0-or-later +% LICENCE_BLOCK_END +%============================================================================= +% Define cube vertices +vertices = [ + -1 -1 -1; + -1 -1 1; + -1 1 -1; + -1 1 1; + 1 -1 -1; + 1 -1 1; + 1 1 -1; + 1 1 1 +]; + +% Define cube edges +edges = [ + 1 2; 1 3; 1 5; + 2 4; 2 6; + 3 4; 3 7; + 4 8; + 5 6; 5 7; + 6 8; + 7 8 +]; + +% Generate random lines inside the cube +numLines = 1000; % Increased number of lines +randLines = -1 + 2 * rand(numLines, 6); % Random points in range [-1,1] +colors = rand(numLines, 3); % Generate random colors + +% Create figure +f = figure('Visible', 'off'); +axis equal; +axis off +grid on; +view(3); +hold on; + +% Plot cube edges +for i = 1:size(edges, 1) + plot3(vertices(edges(i, :), 1), vertices(edges(i, :), 2), vertices(edges(i, :), 3), 'k', 'LineWidth', 1); +end + +% Plot random lines inside the cube with multiple colors +plot3([randLines(:,1), randLines(:,4)]', ... + [randLines(:,2), randLines(:,5)]', ... + [randLines(:,3), randLines(:,6)]', 'LineWidth', 0.5); +f.Visible = 'on'; + +% Rotate the cube +for angle = 1:3600 + if (isgraphics(f)) + view(angle, 30); + end +end diff --git a/modules/graphics/functions/plot.m b/modules/graphics/functions/plot.m index 88b301fd7c..12c7503297 100644 --- a/modules/graphics/functions/plot.m +++ b/modules/graphics/functions/plot.m @@ -90,7 +90,9 @@ end end axes(saveca); - h.Visible='on'; + if isempty(find(strcmp(propertiesList, 'Visible'))) + h.Visible = 'on'; + end if (nargout > 0) varargout{1} = h; end diff --git a/modules/graphics/functions/plot3.m b/modules/graphics/functions/plot3.m index 8e63002510..0f99aaeeff 100644 --- a/modules/graphics/functions/plot3.m +++ b/modules/graphics/functions/plot3.m @@ -71,6 +71,9 @@ view(3); end axes(backupCurrentAxis); + if isempty(find(strcmp(propertiesList, 'Visible'))) + h.Visible = 'on'; + end if (nargout > 0) varargout{1} = h; end @@ -131,6 +134,6 @@ if (~any(strcmp(lineProperties, 'LineStyle'))) lineProperties = [lineProperties, {'LineStyle', lineStyle}]; end - hl = __line__('Parent', go, 'XData', x, 'YData', y, 'ZData', z, 'Color', color, lineProperties{:}); + hl = __line__('Parent', go, 'XData', x, 'YData', y, 'ZData', z, 'Color', color, 'Visible', 'off', lineProperties{:}); end %============================================================================= diff --git a/modules/graphics/tests/test_examples.m b/modules/graphics/tests/test_examples.m index 13a5ea54d3..771f3b9a1b 100644 --- a/modules/graphics/tests/test_examples.m +++ b/modules/graphics/tests/test_examples.m @@ -14,4 +14,5 @@ run([examples_directory, 'nefertiti-mask/nefertiti_mask.m']); run([examples_directory, 'stanford-bunny/stanford_bunny.m']); run([examples_directory, 'movie/demo_movie.m']); +run([examples_directory, 'cube/demo_cube.m']); %============================================================================= \ No newline at end of file diff --git a/modules/gui/src/cpp/MainGuiObject.cpp b/modules/gui/src/cpp/MainGuiObject.cpp index 454ee29711..01ebb6bc86 100644 --- a/modules/gui/src/cpp/MainGuiObject.cpp +++ b/modules/gui/src/cpp/MainGuiObject.cpp @@ -135,7 +135,7 @@ DestroyMainGuiObject(void* term) delete nlsTerm; nlsTerm = nullptr; } - NelSonQtApp->deleteLater(); + delete NelSonQtApp; NelSonQtApp = nullptr; } DestroyConsole();