@@ -20,6 +20,7 @@ import { cache } from 'lit/directives/cache.js'
2020import { AuthController } from '../../auth/auth.controller.js'
2121import { getTimeAveragedMapNotebook } from './notebooks/time-averaged-map-notebook.js'
2222import { getTimeSeriesNotebook } from './notebooks/time-series-notebook.js'
23+ import { nothing } from 'lit'
2324
2425/**
2526 * @summary Short summary of the component's intended use.
@@ -55,6 +56,8 @@ export default class TerraPlotToolbar extends TerraElement {
5556 @property ( ) dataType : DataType
5657 @property ( { type : Boolean , attribute : 'show-location' } ) showLocation : boolean =
5758 true
59+ @property ( { type : String } ) colormap = 'viridis' // default colormap
60+ @property ( { type : Number } ) opacity = 1
5861
5962 @state ( )
6063 activeMenuItem : MenuNames = null
@@ -66,6 +69,52 @@ export default class TerraPlotToolbar extends TerraElement {
6669 locationMapValue : any = [ ]
6770
6871 #tooltipTimeout: number | null = null
72+ @state ( ) colormaps = [
73+ 'jet' ,
74+ 'hsv' ,
75+ 'hot' ,
76+ 'cool' ,
77+ 'spring' ,
78+ 'summer' ,
79+ 'autumn' ,
80+ 'winter' ,
81+ 'bone' ,
82+ 'copper' ,
83+ 'greys' ,
84+ 'YIGnBu' ,
85+ 'greens' ,
86+ 'YIOrRd' ,
87+ 'bluered' ,
88+ 'RdBu' ,
89+ 'picnic' ,
90+ 'rainbow' ,
91+ 'portland' ,
92+ 'blackbody' ,
93+ 'earth' ,
94+ 'electric' ,
95+ 'viridis' ,
96+ 'inferno' ,
97+ 'magma' ,
98+ 'plasma' ,
99+ 'warm' ,
100+ 'cool' ,
101+ 'bathymetry' ,
102+ 'cdom' ,
103+ 'chlorophyll' ,
104+ 'density' ,
105+ 'fressurface-blue' ,
106+ 'freesurface-red' ,
107+ 'oxygen' ,
108+ 'par' ,
109+ 'phase' ,
110+ 'salinity' ,
111+ 'temperature' ,
112+ 'turbidity' ,
113+ 'velocity-blue' ,
114+ 'velocity-green' ,
115+ 'cubhelix' ,
116+ ]
117+ @state ( ) colorMapName = 'density'
69118
70119 @query ( '#menu' ) menu : HTMLMenuElement
71120
@@ -79,7 +128,6 @@ export default class TerraPlotToolbar extends TerraElement {
79128
80129 this . menu . focus ( )
81130 }
82-
83131 closeMenu ( ) {
84132 this . activeMenuItem = null
85133 }
@@ -250,6 +298,28 @@ export default class TerraPlotToolbar extends TerraElement {
250298 font-size ="1.5em "
251299 > </ terra-icon >
252300 </ terra-button >
301+
302+ ${ this . dataType == 'geotiff'
303+ ? html `
304+ < terra-button
305+ circle
306+ outline
307+ aria-expanded =${ this . activeMenuItem ===
308+ 'GeoTIFF' }
309+ aria-controls ="menu"
310+ aria-haspopup="true"
311+ class="toggle"
312+ @mouseenter=${ this . #handleActiveMenuItem}
313+ data-menu-name="GeoTIFF"
314+ >
315+ < terra-icon
316+ name ="outline-cog-8-tooth "
317+ library ="heroicons "
318+ font-size ="1.5em "
319+ > </ terra-icon >
320+ </ terra-button >
321+ `
322+ : nothing }
253323 </ div >
254324
255325 < menu
@@ -286,6 +356,13 @@ export default class TerraPlotToolbar extends TerraElement {
286356 >
287357 ${ this . #renderJupyterNotebookPanel( ) }
288358 </ li >
359+
360+ < li
361+ role ="menuitem "
362+ ?hidden =${ this . activeMenuItem !== 'GeoTIFF' }
363+ >
364+ ${ this . #renderGeotiffPanel( ) }
365+ </ li >
289366 </ menu >
290367
291368 ${ this . showLocationTooltip
@@ -317,12 +394,79 @@ export default class TerraPlotToolbar extends TerraElement {
317394
318395 #handleMenuLeave( event : MouseEvent ) {
319396 // Only close if we're not moving to another element within the component
397+ // If the GeoTIFF menu is in use, it will only close if you hover outside of the time average map component
320398 const relatedTarget = event . relatedTarget as HTMLElement
399+
321400 if ( ! this . contains ( relatedTarget ) ) {
322401 this . activeMenuItem = null
323402 }
324403 }
325404
405+ #onShowOpacityChange = ( e : Event ) => {
406+ this . opacity = parseFloat ( ( e . target as HTMLInputElement ) . value )
407+ this . dispatchEvent (
408+ new CustomEvent ( 'show-opacity-value' , {
409+ detail : this . opacity ,
410+ bubbles : true ,
411+ composed : true ,
412+ } )
413+ )
414+ }
415+
416+ #onColorMapChange = ( e : Event ) => {
417+ this . colorMapName = ( e . target as HTMLInputElement ) . value
418+ this . dispatchEvent (
419+ new CustomEvent ( 'show-color-map' , {
420+ detail : this . colorMapName ,
421+ bubbles : true ,
422+ composed : true ,
423+ } )
424+ )
425+ }
426+
427+ #renderGeotiffPanel( ) {
428+ return html `
429+ < h3 class ="sr-only "> GeoTIFF Settings</ h3 >
430+
431+ ${ this . dataType === 'geotiff'
432+ ? html `
433+ < p > Select opacity and apply colormaps</ p >
434+
435+ < label >
436+ Layer opacity
437+ < input
438+ type ="range "
439+ min ="0 "
440+ max ="1 "
441+ step ="0.01 "
442+ .value =${ String ( this . opacity ) }
443+ @change =${ this . #onShowOpacityChange}
444+ />
445+ < span id ="opacity-output "> ${ this . opacity . toFixed ( 2 ) } </ span >
446+ </ label >
447+
448+ < label >
449+ ColorMap:
450+ < select
451+ id ="colormap-select "
452+ @change =${ this . #onColorMapChange}
453+ >
454+ ${ this . colormaps . map (
455+ cm =>
456+ html ` < option
457+ value ="${ cm } "
458+ ?selected =${ cm === this . colorMapName }
459+ >
460+ ${ cm }
461+ </ option > `
462+ ) }
463+ </ select >
464+ </ label >
465+ `
466+ : nothing }
467+ `
468+ }
469+
326470 #renderInfoPanel( ) {
327471 return html `
328472 < h3 class ="sr-only "> Information</ h3 >
0 commit comments