All files / Sources/Rendering/SceneGraph/ViewNodeFactory index.js

95.83% Statements 23/24
81.81% Branches 9/11
100% Functions 3/3
95.83% Lines 23/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69                205x 1x       205x   205x 2394x       2394x 2394x 2394x 2394x 2394x 3149x 2230x   919x       2394x 164x   2230x 2230x 2230x               1x             205x     205x     205x         1x          
import macro from 'vtk.js/Sources/macros';
 
// ----------------------------------------------------------------------------
// vtkViewNodeFactory methods
// ----------------------------------------------------------------------------
 
function vtkViewNodeFactory(publicAPI, model) {
  // Make sure our overrides is just for our instance not shared with everyone...
  if (!model.overrides) {
    model.overrides = {};
  }
 
  // Set our className
  model.classHierarchy.push('vtkViewNodeFactory');
 
  publicAPI.createNode = (dataObject) => {
    Iif (dataObject.isDeleted()) {
      return null;
    }
 
    let cpt = 0;
    let className = dataObject.getClassName(cpt++);
    let isObject = false;
    const keys = Object.keys(model.overrides);
    while (className && !isObject) {
      if (keys.indexOf(className) !== -1) {
        isObject = true;
      } else {
        className = dataObject.getClassName(cpt++);
      }
    }
 
    if (!isObject) {
      return null;
    }
    const vn = model.overrides[className]();
    vn.setMyFactory(publicAPI);
    return vn;
  };
}
 
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
 
const DEFAULT_VALUES = {
  // overrides: {},
};
 
// ----------------------------------------------------------------------------
 
export function extend(publicAPI, model, initialValues = {}) {
  Object.assign(model, DEFAULT_VALUES, initialValues);
 
  // Build VTK API
  macro.obj(publicAPI, model);
 
  // Object methods
  vtkViewNodeFactory(publicAPI, model);
}
 
// ----------------------------------------------------------------------------
 
export const newInstance = macro.newInstance(extend, 'vtkViewNodeFactory');
 
// ----------------------------------------------------------------------------
 
export default { newInstance, extend };