Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
div.uncertainty *= uncertScale;
});
// console.log('DBG partitionSelection', JSON.stringify(partitionSelection, 2));
// Construct a partition annotation:
let partitionAnnotation = null;
if (def.annotation && !model.provider.shouldCreateNewAnnotation()) {
// don't send a new selection unless it's changed.
const saveGen = partitionSelection.generation;
partitionSelection.generation = def.annotation.selection.generation;
const changeSet = { score: def.regions };
if (!deepEquals(partitionSelection, def.annotation.selection)) {
partitionSelection.generation = saveGen;
changeSet.selection = partitionSelection;
}
partitionAnnotation = AnnotationBuilder.update(def.annotation, {
selection: partitionSelection,
score: def.regions,
});
} else {
partitionAnnotation = AnnotationBuilder.annotation(
partitionSelection,
def.regions,
1,
''
);
}
AnnotationBuilder.updateReadOnlyFlag(
partitionAnnotation,
model.readOnlyFields
);
return partitionAnnotation;
import GenericViewer from 'paraviewweb/src/React/Viewers/ImageBuilderViewer';
import QueryDataModel from 'paraviewweb/src/IO/Core/QueryDataModel';
import LookupTableManager from 'paraviewweb/src/Common/Core/LookupTableManager';
import ImageQueryDataModelViewer from 'arctic-viewer/lib/types/ImageQueryDataModel';
import SortedCompositeViewer from 'arctic-viewer/lib/types/SortedComposite';
// Resource images -----------------------------------------------------------
import link from './tomvizLink.png';
// Global variables -----------------------------------------------------------
const iOS = /iPad|iPhone|iPod/.test(window.navigator.platform);
const lookupTableManager = new LookupTableManager();
const dataViewers = [
ImageQueryDataModelViewer,
SortedCompositeViewer,
];
// Add class to body if iOS device --------------------------------------------
if (iOS) {
document.querySelector('body').classList.add('is-ios-device');
}
// ----------------------------------------------------------------------------
function viewerBuilder(basepath, data, config, callback) {
var foundViewer = false;
var viewerCount = dataViewers.length;
function dividersToPartition(def, scores) {
if (!def.regions || !def.dividers || !scores) return null;
if (def.regions.length !== def.dividers.length + 1) return null;
const uncertScale = getUncertScale(def);
const partitionSelection = SelectionBuilder.partition(
def.name,
def.dividers
);
partitionSelection.partition.dividers.forEach((div, index) => {
div.uncertainty *= uncertScale;
});
// console.log('DBG partitionSelection', JSON.stringify(partitionSelection, 2));
// Construct a partition annotation:
let partitionAnnotation = null;
if (def.annotation && !model.provider.shouldCreateNewAnnotation()) {
// don't send a new selection unless it's changed.
const saveGen = partitionSelection.generation;
partitionSelection.generation = def.annotation.selection.generation;
const changeSet = { score: def.regions };
if (!deepEquals(partitionSelection, def.annotation.selection)) {
function sendScores(def, passive = false) {
const scoreData = dividersToPartition(def, model.scores);
if (scoreData === null) {
console.error('Cannot translate scores to send to provider');
return;
}
if (model.provider.isA('SelectionProvider')) {
if (!scoreData.name) {
AnnotationBuilder.setDefaultName(scoreData);
if (model.provider.isA('AnnotationStoreProvider')) {
scoreData.name = model.provider.getNextStoredAnnotationName(
scoreData.name
);
}
}
if (!passive) {
model.provider.setAnnotation(scoreData);
} else if (
model.provider.isA('AnnotationStoreProvider') &&
model.provider.getStoredAnnotation(scoreData.id)
) {
// Passive means we don't want to set the active annotation, but if there is
// a stored annotation matching these score dividers, we still need to update
// that stored annotation
model.provider.updateStoredAnnotations({
// ----------------------------------------------------------------------------
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
CompositeClosureHelper.destroy(publicAPI, model);
CompositeClosureHelper.isA(publicAPI, model, 'HistogramBinHoverProvider');
CompositeClosureHelper.event(publicAPI, model, 'HoverBinChange');
histogramBinHoverProvider(publicAPI, model);
}
// ----------------------------------------------------------------------------
export const newInstance = CompositeClosureHelper.newInstance(extend);
// ----------------------------------------------------------------------------
export default { newInstance, extend };
const histogramSelectorContainer = document.createElement('div');
histogramSelectorContainer.style.position = 'relative';
histogramSelectorContainer.style.width = '58%';
histogramSelectorContainer.style.height = defaultHeight;
histogramSelectorContainer.style.float = 'left';
bodyElt.appendChild(histogramSelectorContainer);
const fieldSelectorContainer = document.createElement('div');
fieldSelectorContainer.style.position = 'relative';
fieldSelectorContainer.style.width = '42%';
fieldSelectorContainer.style.height = defaultHeight;
fieldSelectorContainer.style.float = 'left';
fieldSelectorContainer.style['font-size'] = '10pt';
bodyElt.appendChild(fieldSelectorContainer);
const provider = CompositeClosureHelper.newInstance(
(publicAPI, model, initialValues = {}) => {
Object.assign(model, initialValues);
FieldProvider.extend(publicAPI, model, initialValues);
Histogram1DProvider.extend(publicAPI, model, initialValues);
HistogramBinHoverProvider.extend(publicAPI, model);
LegendProvider.extend(publicAPI, model, initialValues);
ScoresProvider.extend(publicAPI, model, initialValues);
SelectionProvider.extend(publicAPI, model, initialValues);
}
)(dataModel);
// set provider behaviors
provider.setFieldsSorted(true);
provider.getFieldNames().forEach((name) => {
provider.addLegendEntry(name);
});
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
CompositeClosureHelper.destroy(publicAPI, model);
CompositeClosureHelper.isA(publicAPI, model, PROVIDER_NAME);
CompositeClosureHelper.event(publicAPI, model, 'StoreAnnotationChange');
CompositeClosureHelper.set(publicAPI, model, ['defaultEmptyAnnotationName']);
CompositeClosureHelper.get(publicAPI, model, ['defaultEmptyAnnotationName']);
annotationStoreProvider(publicAPI, model);
}
// ----------------------------------------------------------------------------
export const newInstance = CompositeClosureHelper.newInstance(extend);
// ----------------------------------------------------------------------------
export default { newInstance, extend };
CompositeClosureHelper.isA(publicAPI, model, 'SelectionProvider');
CompositeClosureHelper.get(publicAPI, model, ['selection', 'annotation']);
CompositeClosureHelper.event(publicAPI, model, 'selectionChange');
CompositeClosureHelper.event(publicAPI, model, 'annotationChange');
CompositeClosureHelper.event(
publicAPI,
model,
'dataSelectionSubscriptionChange'
);
selectionProvider(publicAPI, model);
}
// ----------------------------------------------------------------------------
export const newInstance = CompositeClosureHelper.newInstance(extend);
// ----------------------------------------------------------------------------
export default { newInstance, extend };
};
// ----------------------------------------------------------------------------
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
CompositeClosureHelper.destroy(publicAPI, model);
CompositeClosureHelper.isA(publicAPI, model, 'LegendProvider');
legendProvider(publicAPI, model);
}
// ----------------------------------------------------------------------------
export const newInstance = CompositeClosureHelper.newInstance(extend);
// ----------------------------------------------------------------------------
export default Object.assign({ newInstance, extend }, STATIC);
// ----------------------------------------------------------------------------
export function extend(publicAPI, model, initialValues = {}) {
Object.assign(model, DEFAULT_VALUES, initialValues);
CompositeClosureHelper.destroy(publicAPI, model);
CompositeClosureHelper.isA(publicAPI, model, 'ScoresProvider');
CompositeClosureHelper.event(publicAPI, model, 'scoresChange', false);
CompositeClosureHelper.get(publicAPI, model, ['scores']);
scoresProvider(publicAPI, model);
}
// ----------------------------------------------------------------------------
export const newInstance = CompositeClosureHelper.newInstance(extend);
// ----------------------------------------------------------------------------
export default { newInstance, extend };