forked from equinor/webviz
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7115e1b
commit 33e6d5e
Showing
17 changed files
with
227 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { defaultContinuousSequentialColorPalettes } from "@framework/utils/colorPalettes"; | ||
import { ColorScaleGradientType, ColorScaleType } from "@lib/utils/ColorScale"; | ||
import { ColorScale as ColorScaleImpl } from "@lib/utils/ColorScale"; | ||
|
||
import { LayerManagerTopic } from "./LayerManager"; | ||
import { ItemDelegate } from "./delegates/ItemDelegate"; | ||
import { Item } from "./interfaces"; | ||
|
||
export class ColorScale implements Item { | ||
private _itemDelegate: ItemDelegate; | ||
private _colorScale: ColorScaleImpl = new ColorScaleImpl({ | ||
colorPalette: defaultContinuousSequentialColorPalettes[0], | ||
gradientType: ColorScaleGradientType.Sequential, | ||
type: ColorScaleType.Continuous, | ||
steps: 10, | ||
}); | ||
private _areBoundariesUserDefined: boolean = false; | ||
|
||
constructor(name: string) { | ||
this._itemDelegate = new ItemDelegate(name); | ||
} | ||
|
||
getItemDelegate(): ItemDelegate { | ||
return this._itemDelegate; | ||
} | ||
|
||
getColorScale(): ColorScaleImpl { | ||
return this._colorScale; | ||
} | ||
|
||
setColorScale(colorScale: ColorScaleImpl): void { | ||
this._colorScale = colorScale; | ||
this.getItemDelegate().getLayerManager()?.publishTopic(LayerManagerTopic.SETTINGS_CHANGED); | ||
} | ||
|
||
getAreBoundariesUserDefined(): boolean { | ||
return this._areBoundariesUserDefined; | ||
} | ||
|
||
setAreBoundariesUserDefined(areBoundariesUserDefined: boolean): void { | ||
this._areBoundariesUserDefined = areBoundariesUserDefined; | ||
this.getItemDelegate().getLayerManager()?.publishTopic(LayerManagerTopic.LAYER_DATA_REVISION); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
frontend/src/modules/2DViewer/layers/components/ColorScaleComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React from "react"; | ||
|
||
import { SortableListItem } from "@lib/components/SortableList"; | ||
import { ColorScale as ColorScaleImpl } from "@lib/utils/ColorScale"; | ||
import { ColorScaleSelector } from "@modules/_shared/components/ColorScaleSelector/colorScaleSelector"; | ||
|
||
import { RemoveButtonComponent } from "./RemoveButtonComponent"; | ||
|
||
import { ColorScale } from "../ColorScale"; | ||
|
||
export type ColorScaleComponentProps = { | ||
colorScale: ColorScale; | ||
}; | ||
|
||
export function ColorScaleComponent(props: ColorScaleComponentProps): React.ReactNode { | ||
const workbenchSettings = props.colorScale.getItemDelegate().getLayerManager()?.getWorkbenchSettings(); | ||
|
||
function handleColorScaleChange(newColorScale: ColorScaleImpl, areBoundariesUserDefined: boolean): void { | ||
props.colorScale.setColorScale(newColorScale); | ||
props.colorScale.setAreBoundariesUserDefined(areBoundariesUserDefined); | ||
} | ||
|
||
function makeColorScaleSelector(): React.ReactNode { | ||
if (!workbenchSettings) { | ||
return "No layer manager set."; | ||
} | ||
|
||
return ( | ||
<ColorScaleSelector | ||
workbenchSettings={workbenchSettings} | ||
colorScale={props.colorScale.getColorScale()} | ||
onChange={handleColorScaleChange} | ||
areBoundariesUserDefined={props.colorScale.getAreBoundariesUserDefined()} | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<SortableListItem | ||
key={props.colorScale.getItemDelegate().getId()} | ||
id={props.colorScale.getItemDelegate().getId()} | ||
title={<span className="font-bold">Color scale</span>} | ||
endAdornment={<RemoveButtonComponent item={props.colorScale} />} | ||
> | ||
<div className="p-2">{makeColorScaleSelector()}</div> | ||
</SortableListItem> | ||
); | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions
4
frontend/src/modules/2DViewer/layers/components/SettingsGroupComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
frontend/src/modules/2DViewer/layers/components/ViewComponent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.