-
Notifications
You must be signed in to change notification settings - Fork 9
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
5bb5155
commit 74ca76e
Showing
2 changed files
with
48 additions
and
48 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 |
---|---|---|
@@ -1,62 +1,63 @@ | ||
import React from "react"; | ||
|
||
import { ModuleFCProps } from "@framework/Module"; | ||
import { useViewStatusWriter } from "@framework/StatusWriter"; | ||
import { ContentError, ContentInfo } from "@modules/_shared/components/ContentMessage"; | ||
import { useSurfaceDataQueryByAddress } from "@modules_shared/Surface"; | ||
import SubsurfaceViewer from "@webviz/subsurface-viewer"; | ||
|
||
import { MapState } from "./MapState"; | ||
import { makeSurfaceAddressString } from "@modules_shared/Surface/surfaceAddress"; | ||
|
||
//----------------------------------------------------------------------------------------------------------- | ||
export function MapView(props: ModuleFCProps<MapState>) { | ||
const surfaceAddress = props.moduleContext.useStoreValue("surfaceAddress"); | ||
|
||
const renderCount = React.useRef(0); | ||
React.useEffect(function incrementRenderCount() { | ||
renderCount.current = renderCount.current + 1; | ||
}); | ||
|
||
console.debug(`render MapView start [${surfaceAddress ? makeSurfaceAddressString(surfaceAddress) : "null"}]`); | ||
|
||
const statusWriter = useViewStatusWriter(props.moduleContext); | ||
const surfDataQuery = useSurfaceDataQueryByAddress(surfaceAddress); | ||
console.debug(`surfDataQuery.status=${surfDataQuery.status}`); | ||
|
||
if (!surfDataQuery.data) { | ||
return <div>No data</div>; | ||
} | ||
const isLoading = surfDataQuery.isFetching; | ||
statusWriter.setLoading(isLoading); | ||
|
||
console.debug(`render MapView done [${surfaceAddress ? makeSurfaceAddressString(surfaceAddress) : "null"}]`); | ||
const hasError = surfDataQuery.isError; | ||
if (hasError) { | ||
statusWriter.addError("Error fetching surface data"); | ||
} | ||
|
||
const surfData = surfDataQuery.data; | ||
return ( | ||
<div className="relative w-full h-full flex flex-col"> | ||
<SubsurfaceViewer | ||
id="deckgl" | ||
layers={[ | ||
{ | ||
"@@type": "MapLayer", | ||
id: "mesh-layer", | ||
// Drop conversion as soon as SubsurfaceViewer accepts typed arrays | ||
meshData: Array.from(surfData.valuesFloat32Arr), | ||
frame: { | ||
origin: [surfData.x_ori, surfData.y_ori], | ||
count: [surfData.x_count, surfData.y_count], | ||
increment: [surfData.x_inc, surfData.y_inc], | ||
rotDeg: surfData.rot_deg, | ||
{hasError ? ( | ||
<ContentError>Error loading surface data</ContentError> | ||
) : isLoading ? ( | ||
<ContentInfo>Is loading surface data</ContentInfo> | ||
) : !surfData ? ( | ||
<ContentInfo>No surface data - make valid selection</ContentInfo> | ||
) : ( | ||
<SubsurfaceViewer | ||
id="deckgl" | ||
layers={[ | ||
{ | ||
"@@type": "MapLayer", | ||
id: "mesh-layer", | ||
// Drop conversion as soon as SubsurfaceViewer accepts typed arrays | ||
meshData: Array.from(surfData.valuesFloat32Arr), | ||
frame: { | ||
origin: [surfData.x_ori, surfData.y_ori], | ||
count: [surfData.x_count, surfData.y_count], | ||
increment: [surfData.x_inc, surfData.y_inc], | ||
rotDeg: surfData.rot_deg, | ||
}, | ||
|
||
contours: [0, 100], | ||
isContoursDepth: true, | ||
gridLines: false, | ||
material: true, | ||
smoothShading: true, | ||
colorMapName: "Physics", | ||
}, | ||
|
||
contours: [0, 100], | ||
isContoursDepth: true, | ||
gridLines: false, | ||
material: true, | ||
smoothShading: true, | ||
colorMapName: "Physics", | ||
}, | ||
]} | ||
/> | ||
<div className="absolute bottom-5 right-5 italic text-pink-400"> | ||
{props.moduleContext.getInstanceIdString()} | ||
</div> | ||
]} | ||
/> | ||
)} | ||
</div> | ||
); | ||
} |