Skip to content

Commit

Permalink
refactor(code): Adapt api to new data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigobasilio2022 committed Mar 20, 2024
1 parent 902434a commit 986c9b6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
4 changes: 2 additions & 2 deletions Examples/Geometry/AxesActor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '@kitware/vtk.js/favicon';
import '@kitware/vtk.js/Rendering/Profiles/Geometry';

import macro from '@kitware/vtk.js/macros';
import vtkAxesActor from 'vtk.js/Sources/Rendering/Core/AxesActor';
import vtkAxesActor from '@kitware/vtk.js/Rendering/Core/AxesActor';
import vtkFullScreenRenderWindow from '@kitware/vtk.js/Rendering/Misc/FullScreenRenderWindow';

import controlPanel from './controlPanel.html';
Expand All @@ -18,7 +18,7 @@ console.warn(
// ----------------------------------------------------------------------------

const fullScreenRenderer = vtkFullScreenRenderWindow.newInstance({
background: [0.9, 0.9, 0.9],
background: [0.2, 0.3, 0.4],
});
const renderer = fullScreenRenderer.getRenderer();
const renderWindow = fullScreenRenderer.getRenderWindow();
Expand Down
38 changes: 10 additions & 28 deletions Sources/Rendering/Core/AxesActor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,40 +123,22 @@ function vtkAxesActor(publicAPI, model) {
publicAPI.update();
const _debouncedUpdate = macro.debounce(publicAPI.update, 0);

publicAPI.setXAxisColor = (color) => {
model.xConfig.color = color;
_debouncedUpdate();
};

publicAPI.setYAxisColor = (color) => {
model.yConfig.color = color;
_debouncedUpdate();
};
publicAPI.setXAxisColor = (color) =>
publicAPI.setXConfig({ ...publicAPI.getXConfig(), color });

publicAPI.setZAxisColor = (color) => {
model.zConfig.color = color;
_debouncedUpdate();
};
publicAPI.setYAxisColor = (color) =>
publicAPI.setYConfig({ ...publicAPI.getYConfig(), color });

publicAPI.getXAxisColor = (color) =>
model.xConfig?.color || model.config?.color;
publicAPI.setZAxisColor = (color) =>
publicAPI.setZConfig({ ...publicAPI.getZConfig(), color });

publicAPI.getYAxisColor = (color) =>
model.yConfig?.color || model.config?.color;
publicAPI.getXAxisColor = () => model.getXConfig().color;

publicAPI.getZAxisColor = (color) =>
model.zConfig?.color || model.config?.color;
publicAPI.getYAxisColor = () => model.getYConfig().color;

const { setConfig } = publicAPI;

publicAPI.setConfig = (c) => {
if (setConfig(c)) {
_debouncedUpdate();
return true;
}
return false;
};
publicAPI.getZAxisColor = () => model.getZConfig().color;

model._onConfigChanged = _debouncedUpdate;
model._onXConfigChanged = _debouncedUpdate;
model._onYConfigChanged = _debouncedUpdate;
model._onZConfigChanged = _debouncedUpdate;
Expand Down

0 comments on commit 986c9b6

Please sign in to comment.