diff --git a/src/GlobalStates/GlobalStore.ts b/src/GlobalStates/GlobalStore.ts index bea8ab47..23b75382 100644 --- a/src/GlobalStates/GlobalStore.ts +++ b/src/GlobalStates/GlobalStore.ts @@ -47,6 +47,7 @@ type StoreState = { textureArrayDepths: number[]; textureData: Uint8Array; clampExtremes: boolean; + permute: number[] | undefined; // setters setDataShape: (dataShape: number[]) => void; @@ -116,6 +117,7 @@ export const useGlobalStore = create((set, get) => ({ DPR: 1, scalingFactor: null, clampExtremes: false, + permute: undefined, //Dim permutations // setters setDataShape: (dataShape) => set({ dataShape }), diff --git a/src/GlobalStates/PlotStore.ts b/src/GlobalStates/PlotStore.ts index 5f0e34f7..4fb3a0aa 100644 --- a/src/GlobalStates/PlotStore.ts +++ b/src/GlobalStates/PlotStore.ts @@ -64,6 +64,7 @@ type PlotState ={ maskValue: number; cameraPosition: THREE.Vector3; disablePointScale: boolean; + permute: number[]; // Need one in plotStore as well so plot states don't change when permute changes from UI setQuality: (quality: number) => void; setTimeScale: (timeScale : number) =>void; @@ -185,6 +186,7 @@ export const usePlotStore = create((set, get) => ({ borderWidth: 0.05, cameraPosition: new THREE.Vector3(0, 0, 5), disablePointScale: false, + permute: [0,1,2], setVTransferRange: (vTransferRange) => set({ vTransferRange }), setVTransferScale: (vTransferScale) => set({ vTransferScale }), diff --git a/src/components/plots/AxisLines.tsx b/src/components/plots/AxisLines.tsx index b21196bb..4020ae1c 100644 --- a/src/components/plots/AxisLines.tsx +++ b/src/components/plots/AxisLines.tsx @@ -12,7 +12,7 @@ import { LineSegmentsGeometry } from 'three/addons/lines/LineSegmentsGeometry.js import { LineSegments2 } from 'three/addons/lines/LineSegments2.js'; import { LineMaterial } from 'three-stdlib'; import { useFrame } from '@react-three/fiber'; -import { parseLoc, coarsenFlatArray } from '@/utils/HelperFuncs'; +import { parseLoc, coarsenFlatArray, permuteArr } from '@/utils/HelperFuncs'; import { useCSSVariable } from '../ui'; import * as THREE from 'three' @@ -41,12 +41,12 @@ const CubeAxis = ({flipX, flipY, flipDown}: {flipX: boolean, flipY: boolean, fli is4D: state.is4D }))) - const {xRange, yRange, zRange, plotType, timeScale, animProg, zSlice, ySlice, xSlice, coarsen} = usePlotStore(useShallow(state => ({ + const {xRange, yRange, zRange, plotType, timeScale, animProg, zSlice, ySlice, xSlice, coarsen, permute} = usePlotStore(useShallow(state => ({ xRange: state.xRange, yRange: state.yRange, zRange: state.zRange, plotType: state.plotType, timeScale: state.timeScale, animProg: state.animProg, zSlice: state.zSlice, ySlice: state.ySlice, - xSlice: state.xSlice, coarsen: state.coarsen, + xSlice: state.xSlice, coarsen: state.coarsen, permute:state.permute }))) const {hideAxis, hideAxisControls} = useImageExportStore(useShallow( state => ({ hideAxis: state.hideAxis, @@ -73,13 +73,15 @@ const CubeAxis = ({flipX, flipY, flipDown}: {flipX: boolean, flipY: boolean, fli const [yResolution, setYResolution] = useState(AXIS_CONSTANTS.INITIAL_RESOLUTION) const [zResolution, setZResolution] = useState(AXIS_CONSTANTS.INITIAL_RESOLUTION) + const permuteShape = useMemo(()=>permuteArr(dataShape,permute),[dataShape, permute]) const isPC = useMemo(()=>plotType == 'point-cloud',[plotType]) - const globalScale = isPC ? dataShape[2]/AXIS_CONSTANTS.PC_GLOBAL_SCALE_DIVISOR : 1 + const globalScale = isPC ? permuteShape[2]/AXIS_CONSTANTS.PC_GLOBAL_SCALE_DIVISOR : 1 + - const depthRatio = useMemo(()=>dataShape[0]/dataShape[2]*timeScale,[dataShape, timeScale]); - const shapeRatio = useMemo(()=>dataShape[1]/dataShape[2], [dataShape]) - const timeRatio = Math.max(dataShape[0]/dataShape[2], 2); + const depthRatio = useMemo(()=>permuteShape[0]/permuteShape[2]*timeScale,[permuteShape, timeScale]); + const shapeRatio = useMemo(()=>permuteShape[1]/permuteShape[2], [permuteShape]) + const timeRatio = Math.max(permuteShape[0]/permuteShape[2], 2); const secondaryColor = useCSSVariable('--text-plot') //replace with needed variable const colorHex = useMemo(()=>{ diff --git a/src/components/plots/Sphere.tsx b/src/components/plots/Sphere.tsx index a9eb589e..5575269d 100644 --- a/src/components/plots/Sphere.tsx +++ b/src/components/plots/Sphere.tsx @@ -40,7 +40,6 @@ export const Sphere = ({textures} : {textures: THREE.Data3DTexture[] | THREE.Dat flipY: state.flipY, textureArrayDepths: state.textureArrayDepths }))) - const {animate, animProg, cOffset, cScale, valueRange, selectTS, nanColor, nanTransparency, sphereDisplacement, sphereResolution, zSlice, ySlice, xSlice, fillValue, borderTexture, maskTexture, maskValue, getColorIdx, incrementColorIdx} = usePlotStore(useShallow(state=> ({ @@ -179,11 +178,13 @@ export const Sphere = ({textures} : {textures: THREE.Data3DTexture[] | THREE.Dat return ( <> + {/* Don't really understand why now I have to ALSO flip the sphere in this update. Maybe something about the updated GetCurrentArray */} + selectTS && HandleTimeSeries(e)}/> + - selectTS && HandleTimeSeries(e)}/> - + ) } diff --git a/src/components/ui/Elements/DimensionOrder.tsx b/src/components/ui/Elements/DimensionOrder.tsx new file mode 100644 index 00000000..52461ec4 --- /dev/null +++ b/src/components/ui/Elements/DimensionOrder.tsx @@ -0,0 +1,61 @@ +import React, {useRef, useState, useEffect} from 'react' +import { useGlobalStore } from '@/GlobalStates/GlobalStore' +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; + +export const DimensionOrder = ({dimNames, setDuplicateDims}: {dimNames: string[], setDuplicateDims: React.Dispatch>}) => { + const {permute} = useGlobalStore.getState() // Just need the value on mount to set initial handleChange(slotIdx, Number(v))} + > + + + + + {dimNames.map((dim, dimIdx) => ( + + {dim} + + ))} + + + ))} + + {warnDuplicates &&

+ DUPLICATE DIMENSION USED +

} + + ); +}; + + diff --git a/src/components/ui/MainPanel/MetaDataInfo.tsx b/src/components/ui/MainPanel/MetaDataInfo.tsx index 53abdfef..81323b76 100644 --- a/src/components/ui/MainPanel/MetaDataInfo.tsx +++ b/src/components/ui/MainPanel/MetaDataInfo.tsx @@ -7,7 +7,8 @@ import { useShallow } from 'zustand/shallow' import { SliderThumbs } from "@/components/ui/Widgets/SliderThumbs" import Metadata, { defaultAttributes, renderAttributes } from "@/components/ui/MetaData" import { BsFillQuestionCircleFill } from "react-icons/bs"; -import { parseLoc, HandleCoarselNums } from "@/utils/HelperFuncs" +import { parseLoc, permuteArr } from "@/utils/HelperFuncs" +import { DimensionOrder } from "../Elements/DimensionOrder"; import { Tooltip, TooltipContent, @@ -58,9 +59,9 @@ function HandleCustomSteps(e: string, chunkSize: number){ const MetaDataInfo = ({ meta, metadata, setShowMeta, setOpenVariables, popoverSide }: { meta: any, metadata: Record, setShowMeta: React.Dispatch>, setOpenVariables: (open: boolean) => void, popoverSide: string }) => { - const {is4D, idx4D, variable, initStore, setIs4D, setIdx4D, setVariable, setTextureArrayDepths} = useGlobalStore(useShallow(state => ({ + const {is4D, idx4D, variable, initStore, permute, setIs4D, setIdx4D, setVariable, setTextureArrayDepths} = useGlobalStore(useShallow(state => ({ is4D: state.is4D, idx4D: state.idx4D, variable: state.variable, - initStore: state.initStore, + initStore: state.initStore, permute:state.permute, setIs4D: state.setIs4D, setIdx4D: state.setIdx4D, setVariable: state.setVariable, setTextureArrayDepths: state.setTextureArrayDepths, }))) @@ -78,12 +79,14 @@ const MetaDataInfo = ({ meta, metadata, setShowMeta, setOpenVariables, popoverSi const {maxTextureSize, max3DTextureSize} = usePlotStore(useShallow(state => ({maxTextureSize: state.maxTextureSize, max3DTextureSize: state.max3DTextureSize}))) const [tooBig, setTooBig] = useState(false) + const [duplicateDims, setDuplicateDims] = useState(false) const [cached, setCached] = useState(false) const [cachedChunks, setCachedChunks] = useState(null) const [texCount, setTexCount] = useState(0) const [displaySpat, setDisplaySpat] = useState(String(kernelSize)) const [displayDepth, setDisplayDepth] = useState(String(kernelDepth)) + // ---- Meta Info ---- // const {dimArrays, dimNames, dimUnits} = meta.dimInfo const totalSize = meta.totalSize ? meta.totalSize : 0 @@ -190,7 +193,7 @@ const MetaDataInfo = ({ meta, metadata, setShowMeta, setOpenVariables, popoverSi } },[currentSize, meta]) - const smallCache = cachedSize > cacheSize + const smallCache = cachedSize > cacheSize // If the current cache is too small useEffect(()=>{ const this4D = meta.shape.length == 4; @@ -224,7 +227,6 @@ const MetaDataInfo = ({ meta, metadata, setShowMeta, setOpenVariables, popoverSi setCached(false) } },[meta, chunkIDs]) - return ( <> {`${meta.long_name} `} @@ -246,15 +248,17 @@ const MetaDataInfo = ({ meta, metadata, setShowMeta, setOpenVariables, popoverSi
}
+ {/* This doesn't work on more than 3D at the moment. But it's a start */} + {shapeLength <= 3 && }
Data Shape - {`[${formatArray(dataShape)}]`} + {`[${formatArray(permuteArr(dataShape, permute))}]`}
Chunk Shape - {`[${formatArray(chunkShape)}]`} + {`[${formatArray(permuteArr(chunkShape, permute))}]`}
@@ -483,7 +487,7 @@ const MetaDataInfo = ({ meta, metadata, setShowMeta, setOpenVariables, popoverSi {!tooBig &&