All files / Sources/Rendering/Core/Property2D index.js

71.42% Statements 15/21
0% Branches 0/1
25% Functions 2/8
71.42% Lines 15/21

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          1x               9x   9x   9x     9x   9x   9x   9x             1x                       9x     9x 9x             9x     9x         1x          
import macro from 'vtk.js/Sources/macros';
import Constants from 'vtk.js/Sources/Rendering/Core/Property2D/Constants';
 
import { Representation } from 'vtk.js/Sources/Rendering/Core/Property/Constants';
 
const { DisplayLocation } = Constants;
 
// ----------------------------------------------------------------------------
// vtkProperty2D methods
// ----------------------------------------------------------------------------
 
function vtkProperty2D(publicAPI, model) {
  // Set our className
  model.classHierarchy.push('vtkProperty2D');
 
  publicAPI.setDisplayLocationToBackground = () =>
    publicAPI.setDisplayLocation(DisplayLocation.BACKGROUND);
  publicAPI.setDisplayLocationToForeground = () =>
    publicAPI.setDisplayLocation(DisplayLocation.FOREGROUND);
 
  publicAPI.setRepresentationToWireframe = () =>
    publicAPI.setRepresentation(Representation.WIREFRAME);
  publicAPI.setRepresentationToSurface = () =>
    publicAPI.setRepresentation(Representation.SURFACE);
  publicAPI.setRepresentationToPoints = () =>
    publicAPI.setRepresentation(Representation.POINTS);
  publicAPI.getRepresentationAsString = () =>
    macro.enumToString(Representation, model.representation);
}
 
// ----------------------------------------------------------------------------
// Object factory
// ----------------------------------------------------------------------------
const DEFAULT_VALUES = {
  color: [1, 1, 1],
  opacity: 1,
  pointSize: 1,
  lineWidth: 1,
  representation: Representation.SURFACE,
  displayLocation: DisplayLocation.FOREGROUND,
};
 
// ----------------------------------------------------------------------------
 
export function extend(publicAPI, model, initialValues = {}) {
  Object.assign(model, DEFAULT_VALUES, initialValues);
 
  // Build VTK API
  macro.obj(publicAPI, model);
  macro.setGet(publicAPI, model, [
    'opacity',
    'lineWidth',
    'pointSize',
    'displayLocation',
    'representation',
  ]);
  macro.setGetArray(publicAPI, model, ['color'], 3);
 
  // Object methods
  vtkProperty2D(publicAPI, model);
}
 
// ----------------------------------------------------------------------------
 
export const newInstance = macro.newInstance(extend, 'vtkProperty2D');
 
// ----------------------------------------------------------------------------
 
export default { newInstance, extend, ...Constants };