Skip to content

Add Paraview colormaps #23

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ipygany/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# Copyright (c) Martin Renou.
# Distributed under the terms of the Modified BSD License.

from .colormaps import colormaps
from .ipygany import ( # noqa
PolyMesh, TetraMesh, PointCloud,
Scene,
Expand Down
135 changes: 135 additions & 0 deletions ipygany/colormaps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
from traitlets.utils.bunch import Bunch

colormaps = Bunch(
Cool_to_Warm='Cool to Warm',
Cool_to_Warm_Extended='Cool to Warm (Extended)',
Black_Body_Radiation='Black-Body Radiation',
X_Ray='X Ray',
Inferno='Inferno (matplotlib)',
Black_Blue_White='Black, Blue and White',
Blue_Orange='Blue Orange (divergent)',
Viridis='Viridis (matplotlib)',
Gray_Red='Gray and Red',
Linear_Green='Linear Green (Gr4L)',
Cold_Hot='Cold and Hot',
Blue_Green_Orange='Blue - Green - Orange',
Rainbow_Desaturated='Rainbow Desaturated',
Yellow_Gray_Blue='Yellow - Gray - Blue',
Rainbow_Uniform='Rainbow Uniform',
Jet='jet',
Warm_to_Cool='Warm to Cool',
Warm_to_Cool_Extended='Warm to Cool (Extended)',
Grayscale='Grayscale',
Black_Orange_White='Black, Orange and White',
Linear_YGB='Linear YGB 1211g',
Linear_Blue='Linear Blue (8_31f)',
Blue_to_Red_Rainbow='Blue to Red Rainbow',
Red_to_Blue_Rainbow='Red to Blue Rainbow',
Rainbow_Blended_White='Rainbow Blended White',
Rainbow_Blended_Grey='Rainbow Blended Grey',
Rainbow_Blended_Black='Rainbow Blended Black',
Blue_to_Yellow='Blue to Yellow',
Blot='blot',
CIELab_Blue_to_Red='CIELab Blue to Red',
Rainbow='rainbow',
ERDC_rainbow_bright='erdc_rainbow_bright',
ERDC_rainbow_dark='erdc_rainbow_dark',
NIC_CubicL='nic_CubicL',
NIC_CubicYF='nic_CubicYF',
Gist_earth='gist_earth',
TWOhot='2hot',
ERDC_red2yellow_BW='erdc_red2yellow_BW',
ERDC_marine2gold_BW='erdc_marine2gold_BW',
ERDC_blue2gold_BW='erdc_blue2gold_BW',
ERDC_sapphire2gold_BW='erdc_sapphire2gold_BW',
ERDC_red2purple_BW='erdc_red2purple_BW',
ERDC_purple2pink_BW='erdc_purple2pink_BW',
ERDC_pbj_lin='erdc_pbj_lin',
ERDC_blue2green_muted='erdc_blue2green_muted',
ERDC_blue2green_BW='erdc_blue2green_BW',
GREEN_WHITE_LINEAR='GREEN-WHITE_LINEAR',
ERDC_green2yellow_BW='erdc_green2yellow_BW',
Blue2cyan='blue2cyan',
ERDC_blue2cyan_BW='erdc_blue2cyan_BW',
ERDC_blue_BW='erdc_blue_BW',
BLUE_WHITE='BLUE-WHITE',
ERDC_purple_BW='erdc_purple_BW',
ERDC_magenta_BW='erdc_magenta_BW',
Magenta='magenta',
RED_PURPLE='RED-PURPLE',
ERDC_red_BW='erdc_red_BW',
RED_TEMPERATURE='RED_TEMPERATURE',
ERDC_orange_BW='erdc_orange_BW',
Heated_object='heated_object',
ERDC_gold_BW='erdc_gold_BW',
ERDC_brown_BW='erdc_brown_BW',
Copper_Matlab='copper_Matlab',
Pink_Matlab='pink_Matlab',
Bone_Matlab='bone_Matlab',
Gray_Matlab='gray_Matlab',
Purples='Purples',
Blues='Blues',
Greens='Greens',
PuBu='PuBu',
BuPu='BuPu',
BuGn='BuGn',
GnBu='GnBu',
GnBuPu='GnBuPu',
BuGnYl='BuGnYl',
PuRd='PuRd',
RdPu='RdPu',
Oranges='Oranges',
Reds='Reds',
RdOr='RdOr',
BrOrYl='BrOrYl',
RdOrYl='RdOrYl',
CIELab_blue2red='CIELab_blue2red',
Blue2yellow='blue2yellow',
ERDC_blue2gold='erdc_blue2gold',
ERDC_blue2yellow='erdc_blue2yellow',
ERDC_cyan2orange='erdc_cyan2orange',
ERDC_purple2green='erdc_purple2green',
ERDC_purple2green_dark='erdc_purple2green_dark',
Coolwarm='coolwarm',
BuRd='BuRd',
Spectral_lowBlue='Spectral_lowBlue',
GnRP='GnRP',
GYPi='GYPi',
GnYlRd='GnYlRd',
GBBr='GBBr',
PuOr='PuOr',
PRGn='PRGn',
PiYG='PiYG',
OrPu='OrPu',
BrBG='BrBG',
ERDC_divHi_purpleGreen='erdc_divHi_purpleGreen',
ERDC_divHi_purpleGreen_dim='erdc_divHi_purpleGreen_dim',
ERDC_divLow_icePeach='erdc_divLow_icePeach',
ERDC_divLow_purpleGreen='erdc_divLow_purpleGreen',
Haze_green='Haze_green',
Haze_lime='Haze_lime',
Haze='Haze',
Haze_cyan='Haze_cyan',
NIC_Edge='nic_Edge',
ERDC_iceFire_H='erdc_iceFire_H',
ERDC_iceFire_L='erdc_iceFire_L',
HSV='hsv',
Hue_L60='hue_L60',
GyRd='GyRd',
Muted_Blue_Green='Muted Blue-Green',
Green_Blue_Asymmetric_Divergent='Green-Blue Asymmetric Divergent (62Blbc)',
Asymmtrical_Earth_Tones='Asymmtrical Earth Tones (6_21b)',
Yellow_15='Yellow 15',
Magma='Magma (matplotlib)',
Plasma='Plasma (matplotlib)',
KAAMS_Step='KAAMS Step',
Spectrum_Step='Spectrum Step',
Warm_Step='Warm Step',
Cool_Step='Cool Step',
Blues_Step='Blues Step',
Wild_Flower_Step='Wild Flower Step',
Citrus_Step='Citrus Step',
Traffic_Lights_Step='Traffic Lights Step',
Traffic_Lights_For_Deuteranopes_Step='Traffic Lights For Deuteranopes Step',
Traffic_Lights_For_Deuteranopes_2_Step='Traffic Lights For Deuteranopes 2 Step'
)
6 changes: 5 additions & 1 deletion ipygany/ipygany.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import numpy as np

from traitlets import (
Bool, Dict, Unicode, List, Instance, CFloat, Tuple, TraitError, Union, default, validate
Bool, Dict, Enum, Unicode, List, Instance, CFloat, Tuple, TraitError, Union, default, validate
)
from traittypes import Array
from ipywidgets import (
Expand All @@ -18,6 +18,8 @@

from ._frontend import module_version, module_name

from .colormaps import colormaps

FLOAT32 = 'f'
UINT32 = 'I'

Expand Down Expand Up @@ -576,6 +578,8 @@ class IsoColor(Effect):
min = CFloat(0.).tag(sync=True)
max = CFloat(0.).tag(sync=True)

colormap = Enum(list(colormaps.keys()), allow_none=False, default_value=colormaps.Black_Body_Radiation).tag(sync=True)

@property
def input_dim(self):
"""Input dimension."""
Expand Down
7 changes: 6 additions & 1 deletion src/widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,21 +508,26 @@ class IsoColorModel extends EffectModel {
return this.get('max');
}

get colormap () : string {
return this.get('colormap');
}

get input () {
const input = this.get('input');

return typeof input == 'string' ? input : [input];
}

createBlock () {
return new IsoColor(this.parent.block, this.input, this.min, this.max);
return new IsoColor(this.parent.block, this.input, this.min, this.max, this.colormap);
}

initEventListeners () : void {
super.initEventListeners();

this.on('change:min', () => { this.block.min = this.min; });
this.on('change:max', () => { this.block.max = this.max; });
this.on('change:colormap', () => { this.block.colorMap = this.colormap; });
}

block: IsoColor;
Expand Down