Skip to content

Commit

Permalink
fix(ColorMaps): Allow user to specify custom color maps
Browse files Browse the repository at this point in the history
Need to add `?serverColorMaps` to the URL to force the client to fetch the actual Presets instead of
using a local version of it.
  • Loading branch information
jourdain committed May 30, 2018
1 parent 7210cd9 commit 197acaf
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
12 changes: 12 additions & 0 deletions bin/pvw-visualizer-cli.js
Expand Up @@ -37,6 +37,9 @@ program
.option('--proxies [proxyFile]', 'Path to a file with json text containing filters to load')
.option('--no-auto-readers', 'If provided, disables ability to use non-configured readers\n')

.option('--no-built-in-palette', 'If provided, disables built-in color maps')
.option('--color-palette-file [colorMap.json]', 'File to load to define a set of color map\n')

.option('--viewport [1x2560x1440]', 'Configure viewport {scale}x{maxWidth}x{maxHeight}')
.option('--settings-lod-threshold [102400]', 'LOD Threshold in Megabytes\n')

Expand Down Expand Up @@ -145,6 +148,15 @@ if (pvPythonExecs.length < 1) {
cmdLine.push(program.virtualEnv);
}

if (!program.builtInPalette) {
cmdLine.push('--no-built-in-palette');
}

if (program.colorPaletteFile) {
cmdLine.push('--color-palette-file');
cmdLine.push(program.colorPaletteFile);
}

console.log(
'\n==============================================================================='
);
Expand Down
14 changes: 7 additions & 7 deletions dist/Visualizer.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion server/pvw-visualizer.py
Expand Up @@ -139,6 +139,7 @@ def add_arguments(parser):
parser.add_argument("--data", default=os.getcwd(), help="path to data directory to list, or else multiple directories given as 'name1=path1|name2=path2|...'", dest="path")
parser.add_argument("--load-file", default=None, help="File to load if any based on data-dir base path", dest="file")
parser.add_argument("--color-palette-file", default=None, help="File to load to define a set of color map", dest="palettes")
parser.add_argument("--no-built-in-palette", help="If provided, disables built-in color maps", action="store_true", dest="hide_built_in_color_maps")
parser.add_argument("--ds-host", default=None, help="Hostname to connect to for DataServer", dest="dsHost")
parser.add_argument("--ds-port", default=11111, type=int, help="Port number to connect to for DataServer", dest="dsPort")
parser.add_argument("--rs-host", default=None, help="Hostname to connect to for RenderServer", dest="rsHost")
Expand Down Expand Up @@ -174,6 +175,7 @@ def configure(args):
_VisualizerServer.viewportMaxHeight = args.viewportMaxHeight
_VisualizerServer.settingsLODThreshold = args.settingsLODThreshold
_VisualizerServer.allReaders = not args.no_auto_readers
_VisualizerServer.showBuiltin = not args.hide_built_in_color_maps

# If no save directory is provided, default it to the data directory
if args.saveDataDir == '':
Expand All @@ -190,7 +192,7 @@ def initialize(self):
self.registerVtkWebProtocol(pv_protocols.ParaViewWebStartupPluginLoader(_VisualizerServer.plugins))
self.registerVtkWebProtocol(pv_protocols.ParaViewWebFileListing(_VisualizerServer.dataDir, "Home", _VisualizerServer.excludeRegex, _VisualizerServer.groupRegex))
self.registerVtkWebProtocol(pv_protocols.ParaViewWebProxyManager(allowedProxiesFile=_VisualizerServer.proxies, baseDir=_VisualizerServer.dataDir, fileToLoad=_VisualizerServer.fileToLoad, allowUnconfiguredReaders=_VisualizerServer.allReaders))
self.registerVtkWebProtocol(pv_protocols.ParaViewWebColorManager(pathToColorMaps=_VisualizerServer.colorPalette))
self.registerVtkWebProtocol(pv_protocols.ParaViewWebColorManager(pathToColorMaps=_VisualizerServer.colorPalette, showBuiltin=_VisualizerServer.showBuiltin))
self.registerVtkWebProtocol(pv_protocols.ParaViewWebMouseHandler())
self.registerVtkWebProtocol(pv_protocols.ParaViewWebViewPort(_VisualizerServer.viewportScale, _VisualizerServer.viewportMaxWidth, _VisualizerServer.viewportMaxHeight))
self.registerVtkWebProtocol(pv_protocols.ParaViewWebPublishImageDelivery(decode=False))
Expand Down
5 changes: 4 additions & 1 deletion src/setup.js
@@ -1,9 +1,12 @@
import macro from 'vtk.js/Sources/macro';
import vtkURLExtract from 'vtk.js/Sources/Common/Core/URLExtract';

import { getActiveStore, dispatch, actions } from './redux';
import behaviorOnChange from './behavior';
import stateAccessor from './redux/selectors/stateAccessor';

const serverColorMaps = vtkURLExtract.extractURLParameters().serverColorMaps;

const resetProgress = macro.debounce(() => {
dispatch(actions.network.resetProgress());
}, 1000);
Expand Down Expand Up @@ -36,7 +39,7 @@ export default function setup(session) {

// Fetch heavy data after full initialization
setTimeout(() => {
dispatch(actions.colors.fetchColorMapImages());
dispatch(actions.colors.fetchColorMapImages(512, !serverColorMaps));
}, 2000);

// Attach default behavior
Expand Down

0 comments on commit 197acaf

Please sign in to comment.