CollapsibleControlFactory

Source

CompositeControl.js
import React from 'react';

import CollapsibleControlFactory from '.';
import CollapsibleWidget from '../../Widgets/CollapsibleWidget';
import CompositePipelineWidget from '../../Widgets/CompositePipelineWidget';

CollapsibleControlFactory.registerWidget(
'CompositeControl',
({ pipelineModel }) => (
<CollapsibleWidget title="Pipeline" key="CompositeControl_parent">
<CompositePipelineWidget key="CompositeControl" model={pipelineModel} />
</CollapsibleWidget>
)
);
EqualizerWidget.js
import React from 'react';

import CollapsibleControlFactory from '.';
import EqualizerWidget from '../../Widgets/EqualizerWidget';

CollapsibleControlFactory.registerWidget(
'EqualizerWidget',
({ levels, colors = ['#cccccc'], callback }) => (
<EqualizerWidget
key="Equalizer"
width={300}
height={120}
layers={levels}
onChange={callback}
colors={colors}
/>
)
);
FloatImageControl.js
import React from 'react';

import CollapsibleControlFactory from '.';
import FloatImageControl from '../FloatImageControl';

CollapsibleControlFactory.registerWidget('FloatImageControl', ({ model }) => (
<FloatImageControl key="FloatImageControl" model={model} />
));
LightPropertiesWidget.js
import React from 'react';

import CollapsibleControlFactory from '.';
import LightControl from '../LightControl';

CollapsibleControlFactory.registerWidget(
'LightPropertiesWidget',
({ light }) => <LightControl key="LightPropertiesWidget" light={light} />
);
LookupTableManagerWidget.js
import React from 'react';

import CollapsibleControlFactory from '.';
import LookupTableManagerControl from '../LookupTableManagerControl';

CollapsibleControlFactory.registerWidget(
'LookupTableManagerWidget',
({ lookupTableManager, activeField }) => {
let field = activeField;
if (!field) {
field = lookupTableManager.getActiveField();
}
return (
<LookupTableManagerControl
key="LookupTableManagerWidget"
field={field}
lookupTableManager={lookupTableManager}
/>
);
}
);
LookupTableWidget.js
import React from 'react';

import CollapsibleControlFactory from '.';
import CollapsibleWidget from '../../Widgets/CollapsibleWidget';
import LookupTableWidget from '../../Widgets/LookupTableWidget';

CollapsibleControlFactory.registerWidget(
'LookupTableWidget',
({ originalRange = [0, 1], lookupTable, lookupTableManager }) => (
<CollapsibleWidget title="LookupTable" key="LookupTableWidget_parent">
<LookupTableWidget
key="LookupTableWidget"
originalRange={originalRange}
lookupTable={lookupTable}
lookupTableManager={lookupTableManager}
/>
</CollapsibleWidget>
)
);
PixelOperatorControl.js
import React from 'react';

import CollapsibleControlFactory from '.';
import PixelOperatorControl from '../PixelOperatorControl';

CollapsibleControlFactory.registerWidget(
'PixelOperatorControl',
({ model }) => (
<PixelOperatorControl key="PixelOperatorControl" operator={model} />
)
);
PlotlyChartControl.js
import React from 'react';

import CollapsibleControlFactory from '.';
import PlotlyChartControl from '../PlotlyChartControl';

CollapsibleControlFactory.registerWidget('PlotlyChartControl', ({ model }) => (
<PlotlyChartControl key="PlotlyChartControl" model={model} />
));
ProbeControl.js
import React from 'react';

import CollapsibleControlFactory from '.';
import ProbeControl from '../ProbeControl';

CollapsibleControlFactory.registerWidget('ProbeControl', ({ model }) => (
<ProbeControl key="ProbeControl" imageBuilder={model} />
));
QueryDataModelWidget.js
import React from 'react';

import CollapsibleControlFactory from '.';
import QueryDataModelControl from '../QueryDataModelControl';

CollapsibleControlFactory.registerWidget(
'QueryDataModelWidget',
({ queryDataModel, handleExploration }) => (
<QueryDataModelControl
key="QueryDataModel"
handleExploration={!!handleExploration}
model={queryDataModel}
/>
)
);
TimeFloatImageControl.js
import React from 'react';

import CollapsibleControlFactory from '.';
import TimeFloatImageControl from '../TimeFloatImageControl';

CollapsibleControlFactory.registerWidget(
'TimeFloatImageControl',
({ model }) => (
<TimeFloatImageControl key="TimeFloatImageControl" model={model} />
)
);
VolumeControlWidget.js
import React from 'react';

import CollapsibleControlFactory from '.';
import VolumeControl from '../VolumeControl';

CollapsibleControlFactory.registerWidget(
'VolumeControlWidget',
({ lookupTable, equalizer, intensity, computation }) => (
<VolumeControl
key="VolumeControlWidget"
intensity={intensity}
computation={computation}
equalizer={equalizer}
lookupTable={lookupTable}
/>
)
);
index.js
const WidgetFactoryMapping = {};

function registerWidget(name, fn) {
WidgetFactoryMapping[name] = fn;
}

function createWidget(name, options) {
const fn = WidgetFactoryMapping[name];

if (fn) {
return fn(options);
}
return null;
}

function getWidgets(obj) {
if (!obj) {
return [];
}

const widgetDesc = obj.getControlWidgets();
const widgetList = [];

widgetDesc.forEach((desc) => {
const widget = createWidget(desc.name, desc);
if (widget) {
widgetList.push(widget);
} else {
console.error('Unable to create widget for name:', desc.name);
}
});

return widgetList;
}

export default {
createWidget,
getWidgets,
registerWidget,
};