All files / Sources/Proxy/Representations/MoleculeRepresentationProxy index.js

92.59% Statements 25/27
0% Branches 0/1
40% Functions 2/5
100% Lines 25/25

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 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87                            1x     1x 1x 1x 1x 1x   1x     1x 1x 1x     1x 1x 1x 1x     1x 1x       1x 1x 1x             1x         1x     1x     1x 1x                             1x                
import macro from 'vtk.js/Sources/macros';
import vtkActor from 'vtk.js/Sources/Rendering/Core/Actor';
import vtkSphereMapper from 'vtk.js/Sources/Rendering/Core/SphereMapper';
import vtkStickMapper from 'vtk.js/Sources/Rendering/Core/StickMapper';
import vtkMoleculeToRepresentation from 'vtk.js/Sources/Filters/General/MoleculeToRepresentation';
 
import vtkAbstractRepresentationProxy from 'vtk.js/Sources/Proxy/Core/AbstractRepresentationProxy';
 
// ----------------------------------------------------------------------------
// vtkMoleculeRepresentationProxy methods
// ----------------------------------------------------------------------------
 
function vtkMoleculeRepresentationProxy(publicAPI, model) {
  // Set our className
  model.classHierarchy.push('vtkMoleculeRepresentationProxy');
 
  // Internals
  model.filter = vtkMoleculeToRepresentation.newInstance();
  model.sphereMapper = vtkSphereMapper.newInstance();
  model.stickMapper = vtkStickMapper.newInstance();
  model.sphereActor = vtkActor.newInstance();
  model.stickActor = vtkActor.newInstance();
 
  model.sourceDependencies.push(model.filter);
 
  // render sphere
  model.sphereMapper.setInputConnection(model.filter.getOutputPort(0));
  model.sphereMapper.setScaleArray(model.filter.getSphereScaleArrayName());
  model.sphereActor.setMapper(model.sphereMapper);
 
  // render sticks
  model.stickMapper.setInputConnection(model.filter.getOutputPort(1));
  model.stickMapper.setScaleArray('stickScales');
  model.stickMapper.setOrientationArray('orientation');
  model.stickActor.setMapper(model.stickMapper);
 
  // Add actors
  model.actors.push(model.sphereActor);
  model.actors.push(model.stickActor);
 
  // API ----------------------------------------------------------------------
 
  publicAPI.setColorBy = () => {};
  publicAPI.getColorBy = () => [];
  publicAPI.listDataArrays = () => [];
}
 
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
 
const DEFAULT_VALUES = {};
 
// ----------------------------------------------------------------------------
 
export function extend(publicAPI, model, initialValues = {}) {
  Object.assign(model, DEFAULT_VALUES, initialValues);
 
  // Object methods
  vtkAbstractRepresentationProxy.extend(publicAPI, model, initialValues);
 
  // Object specific methods
  vtkMoleculeRepresentationProxy(publicAPI, model);
  macro.proxyPropertyMapping(publicAPI, model, {
    tolerance: { modelKey: 'filter', property: 'tolerance' },
    atomicRadiusScaleFactor: {
      modelKey: 'filter',
      property: 'atomicRadiusScaleFactor',
    },
    bondRadius: { modelKey: 'filter', property: 'bondRadius' },
    deltaBondFactor: { modelKey: 'filter', property: 'deltaBondFactor' },
    radiusType: { modelKey: 'filter', property: 'radiusType' },
    hideElements: { modelKey: 'filter', property: 'hideElements' },
  });
}
 
// ----------------------------------------------------------------------------
 
export const newInstance = macro.newInstance(
  extend,
  'vtkMoleculeRepresentationProxy'
);
 
// ----------------------------------------------------------------------------
 
export default { newInstance, extend };