dusunax / dicom-and-three-js-viewer

🩻 great viewer for dcm & ply file
3 stars 0 forks source link

230603 - Refactor Components and Hook, Finish Tool Selection Box #2

Closed dusunax closed 1 year ago

dusunax commented 1 year ago

230603 - Refactor Components and Hook, Finish Tool Selection Box


πŸ—‚ Works μž‘μ—…λ‚΄μš©

1. Refactor Example Component & Custom Hook.


1. Refactor Example Component & useCornerstone Custom Hook. ✨

πŸ“Œ Refactor Example Component

src\example\ExampleComponent.tsx

export default function CurrentTabComponent({ tabIndex, }: { tabIndex: number; }) { const exampleComponents = [ {component: }, ... ];

return <>{exampleComponents[tabIndex].component}</>; }


### πŸ“Œ Refactor `useCornerstone.ts` Custom Hook.

src\example\hooks\useCornerstone.ts

- check out rest of the tools from [cornerstone document](https://www.cornerstonejs.org/docs/examples/)
  - add to `LEFT_MOUSE_TOOLS`,  `RIGHT_MOUSE_TOOLS`
- refactor types from `src\example\models\cornerstone.ts`
- current custom hook's return type
  - todo: After implementing the functionality, move the constants to the `/constants` folder. 
```tsx
function useCornerstone () : {
    imageIndex: number;
    setImageIndex: React.Dispatch<React.SetStateAction<number>>;
    itemSrcArray: string[];

    ITEM_LENGTH: number;
    EXAMPLE_OPTION: ExampleOption[];
    LEFT_MOUSE_TOOLS: ExampleOption[];
    RIGHT_MOUSE_TOOLS: ExampleOption[];
    OVERLAY_TOOLS: ExampleOption[];

    itemLayers: Layer[];
    colorMapList: {
        id: any;
        key: any;
    }[]
}

πŸ“Œ [UI] add loading state & spinner

{loadImageOptionState.loading && (
  <div className="my-4 flex items-center justify-center">
    loading...
    <Spinner />
  </div>
)}

2. Finish to build tools select box. ✨

πŸ“Œ from documentation

https://tools.cornerstonejs.org/api/#Tools.EraserTool https://tools.cornerstonejs.org/examples/

πŸ“Œ keep the tools that are functioning properly in the menu.

πŸ“Œ refactor setToolsByIndex function


todo πŸ‘©β€πŸ’»

1. change `setImageIndex` function from `src\example\render\StackOfImages.tsx` to Stack Scroll MouseWheel Tool.
2. fix `element not enabled` error at first loading.
dusunax commented 1 year ago

β›” had Issue on SharedArrayBuffer

ERROR: SharedArrayBuffer is NOT supported in your browser. #3

and my goal is implement the level 2 by this weekend. so skip 3D volume part and proceed directly to Level 2. => Instead of using calculated 3D volume data, use an exported .ply file.


~Todo~