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 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | 1x 1x 1x 51x 51x 389x 389x 1556x 142x 142x 1556x 97x 97x 389x 51x 16x 16x 16x 15x 15x 16x 16x 16x 16x 51x 170x 51x 9x 9x 9x 7x 7x 9x 9x 9x 9x 51x 164x 51x 2x 2x 2x 1x 1x 2x 51x 51x 51x 4x 4x 51x 8x 51x 51x 1x 51x 51x 51x 51x 51x 204x 51x 51x 51x 1x | import macro from 'vtk.js/Sources/macros'; import Constants from 'vtk.js/Sources/Rendering/Core/ImageProperty/Constants'; const { InterpolationType } = Constants; const { vtkErrorMacro } = macro; const VTK_MAX_VRCOMP = 4; // ---------------------------------------------------------------------------- // vtkImageProperty methods // ---------------------------------------------------------------------------- function vtkImageProperty(publicAPI, model) { // Set our className model.classHierarchy.push('vtkImageProperty'); publicAPI.getMTime = () => { let mTime = model.mtime; let time; for (let index = 0; index < VTK_MAX_VRCOMP; index++) { // Color MTimes if (model.componentData[index].rGBTransferFunction) { // time that RGB transfer function was last modified time = model.componentData[index].rGBTransferFunction.getMTime(); mTime = mTime > time ? mTime : time; } // Piecewise function MTimes if (model.componentData[index].piecewiseFunction) { // time that weighting function was last modified time = model.componentData[index].piecewiseFunction.getMTime(); mTime = mTime > time ? mTime : time; } } return mTime; }; // Set the color of a volume to an RGB transfer function publicAPI.setRGBTransferFunction = (index = 0, func = null) => { // backwards compatible call without the component index let idx = index; let transferFunc = func; if (!Number.isInteger(index)) { transferFunc = index; idx = 0; } if (model.componentData[idx].rGBTransferFunction !== transferFunc) { model.componentData[idx].rGBTransferFunction = transferFunc; publicAPI.modified(); return true; } return false; }; // Get the currently set RGB transfer function. publicAPI.getRGBTransferFunction = (idx = 0) => model.componentData[idx].rGBTransferFunction; // Set the piecewise function publicAPI.setPiecewiseFunction = (index = 0, func = null) => { let idx = index; let transferFunc = func; if (!Number.isInteger(index)) { transferFunc = index; idx = 0; } if (model.componentData[idx].piecewiseFunction !== transferFunc) { model.componentData[idx].piecewiseFunction = transferFunc; publicAPI.modified(); return true; } return false; }; // Get the component weighting function. publicAPI.getPiecewiseFunction = (idx = 0) => model.componentData[idx].piecewiseFunction; // Alias to set the piecewise function publicAPI.setScalarOpacity = (index = 0, func = null) => { // backwards compatible call without the component index let idx = index; let transferFunc = func; if (!Number.isInteger(index)) { transferFunc = index; idx = 0; } return publicAPI.setPiecewiseFunction(idx, transferFunc); }; // Alias to get the piecewise function (backwards compatibility) publicAPI.getScalarOpacity = (idx = 0) => publicAPI.getPiecewiseFunction(idx); publicAPI.setComponentWeight = (index = 0, value = 1) => { if (index < 0 || index >= VTK_MAX_VRCOMP) { vtkErrorMacro('Invalid index'); return false; } const val = Math.min(1, Math.max(0, value)); if (model.componentData[index].componentWeight !== val) { model.componentData[index].componentWeight = val; publicAPI.modified(); return true; } return false; }; publicAPI.getComponentWeight = (index = 0) => { Iif (index < 0 || index >= VTK_MAX_VRCOMP) { vtkErrorMacro('Invalid index'); return 0.0; } return model.componentData[index].componentWeight; }; publicAPI.setInterpolationTypeToNearest = () => publicAPI.setInterpolationType(InterpolationType.NEAREST); publicAPI.setInterpolationTypeToLinear = () => publicAPI.setInterpolationType(InterpolationType.LINEAR); publicAPI.getInterpolationTypeAsString = () => macro.enumToString(InterpolationType, model.interpolationType); } // ---------------------------------------------------------------------------- // Object factory // ---------------------------------------------------------------------------- const DEFAULT_VALUES = { independentComponents: false, interpolationType: InterpolationType.LINEAR, colorWindow: 255, colorLevel: 127.5, ambient: 1.0, diffuse: 0.0, opacity: 1.0, useLookupTableScalarRange: false, useLabelOutline: false, labelOutlineThickness: [1], labelOutlineOpacity: 1.0, }; // ---------------------------------------------------------------------------- export function extend(publicAPI, model, initialValues = {}) { Object.assign(model, DEFAULT_VALUES, initialValues); // Build VTK API macro.obj(publicAPI, model); if (!model.componentData) { model.componentData = []; for (let i = 0; i < VTK_MAX_VRCOMP; i++) { model.componentData.push({ rGBTransferFunction: null, piecewiseFunction: null, componentWeight: 1.0, }); } } macro.setGet(publicAPI, model, [ 'independentComponents', 'interpolationType', 'colorWindow', 'colorLevel', 'ambient', 'diffuse', 'opacity', 'useLookupTableScalarRange', 'useLabelOutline', 'labelOutlineOpacity', ]); macro.setGetArray(publicAPI, model, ['labelOutlineThickness']); // Object methods vtkImageProperty(publicAPI, model); } // ---------------------------------------------------------------------------- export const newInstance = macro.newInstance(extend, 'vtkImageProperty'); // ---------------------------------------------------------------------------- export default { newInstance, extend }; |