Skip to content

Commit 36c632a

Browse files
authored
Merge pull request #71 from napakalas/issue-#68
Adjust nerve cuff behavior for active and selected states
2 parents 9a91b44 + b5f281c commit 36c632a

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

src/layers/styling.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ export interface StylingOptions extends StyleLayerOptions
7070

7171
const COLOUR_ACTIVE = 'blue'
7272
const COLOUR_ANNOTATED = '#C8F'
73-
const COLOUR_SELECTED = '#0F0'
73+
const COLOUR_SELECTED = '#8EF35D'
7474
const COLOUR_HIDDEN = '#D8D8D8'
7575

7676
const CENTRELINE_ACTIVE = '#888'
7777
const CENTRELINE_COLOUR = '#8FF'
7878

7979
const FEATURE_SELECTED_BORDER = 'black'
8080

81-
const NERVE_ACTIVE = '#222'
82-
const NERVE_SELECTED = 'red'
81+
const NERVE_ACTIVE = 'blue'
82+
const NERVE_SELECTED = 'black'
8383

8484
//==============================================================================
8585

@@ -356,7 +356,7 @@ export class FeatureFillLayer extends VectorStyleLayer
356356
'fill-opacity': [
357357
'case',
358358
['boolean', ['feature-state', 'hidden'], false], 0.01,
359-
['boolean', ['feature-state', 'selected'], false], 0.2,
359+
['boolean', ['feature-state', 'selected'], false], 1.0,
360360
['has', 'opacity'], ['get', 'opacity'],
361361
['has', 'colour'], 1.0,
362362
['==', ['get', 'kind'], 'proxy'], 1.0,
@@ -992,42 +992,42 @@ export class FeatureNerveLayer extends VectorStyleLayer
992992
]
993993
}
994994

995+
paintStyle(options: StylingOptions, changes=false) {
996+
const dimmed = options.dimmed || false
997+
const paintStyle: PaintSpecification = {
998+
'line-color': [
999+
'case',
1000+
['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
1001+
['boolean', ['feature-state', 'active'], false], NERVE_ACTIVE,
1002+
['boolean', ['feature-state', 'selected'], false], NERVE_SELECTED,
1003+
'#888'
1004+
],
1005+
'line-opacity': [
1006+
'case',
1007+
['boolean', ['feature-state', 'hidden'], false], 0.3,
1008+
['boolean', ['get', 'invisible'], false], 0.001,
1009+
['boolean', ['feature-state', 'active'], false], 0.9,
1010+
['boolean', ['feature-state', 'selected'], false], 0.9,
1011+
dimmed ? 0.05 : 0.9
1012+
],
1013+
'line-dasharray': [2, 2],
1014+
'line-width': [
1015+
'case',
1016+
['boolean', ['feature-state', 'selected'], false], 1.5,
1017+
['boolean', ['feature-state', 'active'], false], 1.5,
1018+
dimmed ? 0.2 : 1.5
1019+
]
1020+
}
1021+
return super.changedPaintStyle(paintStyle, changes)
1022+
}
1023+
9951024
style(layer: FlatMapLayer, options: StylingOptions): LineLayerSpecification
9961025
{
9971026
return {
9981027
...super.style(layer, options),
9991028
'type': 'line',
10001029
'filter': this.defaultFilter(),
1001-
'paint': {
1002-
'line-color': [
1003-
'case',
1004-
['boolean', ['feature-state', 'hidden'], false], COLOUR_HIDDEN,
1005-
['boolean', ['feature-state', 'selected'], false], NERVE_SELECTED,
1006-
['boolean', ['feature-state', 'active'], false], NERVE_ACTIVE,
1007-
'#888'
1008-
],
1009-
'line-opacity': [
1010-
'case',
1011-
['boolean', ['feature-state', 'hidden'], false], 0.3,
1012-
['boolean', ['get', 'invisible'], false], 0.001,
1013-
['boolean', ['feature-state', 'active'], false], 0.9,
1014-
['boolean', ['feature-state', 'selected'], false], 0.9,
1015-
0.9
1016-
],
1017-
'line-dasharray': [2, 1],
1018-
'line-width': [
1019-
'let', 'width', ['case',
1020-
['boolean', ['feature-state', 'active'], false], 0.8,
1021-
['boolean', ['feature-state', 'selected'], false], 1.2,
1022-
0.6],
1023-
[ 'interpolate',
1024-
['exponential', 2],
1025-
['zoom'],
1026-
2, ["*", ['var', 'width'], ["^", 2, -1]],
1027-
10, ["*", ['var', 'width'], ["^", 2, 6]]
1028-
]
1029-
]
1030-
}
1030+
'paint': this.paintStyle(options) as LinePaintSpecification
10311031
}
10321032
}
10331033
}
@@ -1125,7 +1125,7 @@ export class NervePolygonFill extends VectorStyleLayer
11251125
'fill-opacity': [
11261126
'case',
11271127
['boolean', ['feature-state', 'hidden'], false], 0.01,
1128-
['boolean', ['feature-state', 'selected'], false], 0.2,
1128+
['boolean', ['feature-state', 'selected'], false], 1,
11291129
['has', 'opacity'], ['get', 'opacity'],
11301130
['has', 'colour'], 1.0,
11311131
['==', ['get', 'kind'], 'proxy'], 1.0,
@@ -1137,7 +1137,7 @@ export class NervePolygonFill extends VectorStyleLayer
11371137
['==', ['get', 'type'], 'arrow'],
11381138
['==', ['get', 'type'], 'junction']
11391139
], dimmed ? 0.1 : 0.5,
1140-
0.5
1140+
dimmed ? 0.2 : 0.5
11411141
]
11421142
}
11431143
return super.changedPaintStyle(paintStyle, changes)

0 commit comments

Comments
 (0)