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
218376e
commit 3ca83ed
Showing
24 changed files
with
421 additions
and
169 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
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,22 @@ | ||
import { GroupDelegate } from "./delegates/GroupDelegate"; | ||
import { ItemDelegate } from "./delegates/ItemDelegate"; | ||
import { Group } from "./interfaces"; | ||
|
||
export class DeltaSurface implements Group { | ||
private _itemDelegate: ItemDelegate; | ||
private _groupDelegate: GroupDelegate; | ||
|
||
constructor(name: string) { | ||
this._groupDelegate = new GroupDelegate(this); | ||
this._groupDelegate.setColor("rgb(220, 210, 180)"); | ||
this._itemDelegate = new ItemDelegate(name); | ||
} | ||
|
||
getItemDelegate(): ItemDelegate { | ||
return this._itemDelegate; | ||
} | ||
|
||
getGroupDelegate(): GroupDelegate { | ||
return this._groupDelegate; | ||
} | ||
} |
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
72 changes: 72 additions & 0 deletions
72
frontend/src/modules/2DViewer/layers/components/DeltaSurfaceComponent.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,72 @@ | ||
import { SortableListGroup } from "@lib/components/SortableList"; | ||
|
||
import { EditName } from "./EditName"; | ||
import { EmptyContent } from "./EmptyContent"; | ||
import { ExpandCollapseAllButton } from "./ExpandCollapseAllButton"; | ||
import { LayersActionGroup, LayersActions } from "./LayersActions"; | ||
import { RemoveButton } from "./RemoveButton"; | ||
import { VisibilityToggle } from "./VisibilityToggle"; | ||
import { makeComponent } from "./utils"; | ||
|
||
import { DeltaSurface } from "../DeltaSurface"; | ||
import { GroupDelegateTopic } from "../delegates/GroupDelegate"; | ||
import { ItemDelegateTopic } from "../delegates/ItemDelegate"; | ||
import { usePublishSubscribeTopicValue } from "../delegates/PublishSubscribeDelegate"; | ||
import { Group, Item, instanceofLayer } from "../interfaces"; | ||
|
||
export type DeltaSurfaceComponentProps = { | ||
deltaSurface: DeltaSurface; | ||
actions?: LayersActionGroup[]; | ||
onActionClick?: (actionIdentifier: string, group: Group) => void; | ||
}; | ||
|
||
export function DeltaSurfaceComponent(props: DeltaSurfaceComponentProps): React.ReactNode { | ||
const children = usePublishSubscribeTopicValue(props.deltaSurface.getGroupDelegate(), GroupDelegateTopic.CHILDREN); | ||
const isExpanded = usePublishSubscribeTopicValue(props.deltaSurface.getItemDelegate(), ItemDelegateTopic.EXPANDED); | ||
const color = props.deltaSurface.getGroupDelegate().getColor(); | ||
|
||
function handleActionClick(actionIdentifier: string) { | ||
if (props.onActionClick) { | ||
props.onActionClick(actionIdentifier, props.deltaSurface); | ||
} | ||
} | ||
|
||
function makeEndAdornment() { | ||
const adornment: React.ReactNode[] = []; | ||
if ( | ||
props.actions && | ||
props.deltaSurface.getGroupDelegate().findChildren((item) => instanceofLayer(item)).length < 2 | ||
) { | ||
adornment.push(<LayersActions layersActionGroups={props.actions} onActionClick={handleActionClick} />); | ||
} | ||
adornment.push(<ExpandCollapseAllButton group={props.deltaSurface} />); | ||
adornment.push(<RemoveButton item={props.deltaSurface} />); | ||
return adornment; | ||
} | ||
|
||
return ( | ||
<SortableListGroup | ||
key={props.deltaSurface.getItemDelegate().getId()} | ||
id={props.deltaSurface.getItemDelegate().getId()} | ||
title={<EditName item={props.deltaSurface} />} | ||
contentStyle={{ | ||
backgroundColor: color ?? undefined, | ||
}} | ||
headerStyle={{ | ||
backgroundColor: color ?? undefined, | ||
}} | ||
startAdornment={ | ||
<div className="flex items-center gap-2"> | ||
<VisibilityToggle item={props.deltaSurface} /> | ||
</div> | ||
} | ||
endAdornment={<>{makeEndAdornment()}</>} | ||
contentWhenEmpty={ | ||
<EmptyContent>Drag two surface layers inside to calculate the difference between them.</EmptyContent> | ||
} | ||
expanded={isExpanded} | ||
> | ||
{children.map((child: Item) => makeComponent(child, props.actions, props.onActionClick))} | ||
</SortableListGroup> | ||
); | ||
} |
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
4 changes: 1 addition & 3 deletions
4
frontend/src/modules/2DViewer/layers/components/SettingComponent.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
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
2 changes: 1 addition & 1 deletion
2
frontend/src/modules/2DViewer/layers/components/VisibilityToggle.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
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.