Skip to content

Fixing image carousel in viewer #30

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/viewer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@mui/icons-material": "^5.14.19",
"@mui/material": "^5.14.19",
"@protobuf-ts/plugin": "^2.9.1",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
Expand Down
20 changes: 12 additions & 8 deletions src/viewer/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,18 @@ function App() {
>
<h1 style={{ textAlign: "center" }}>Cost Matrix Viewer</h1>
<div className="costMatrix" style={{ backgroundColor: "ghostwhite" }}>
<ProtoLoader
onLoad={setCostMatrixProto}
messageType={MessageType.CostMatrix}
/>
<ProtoLoader
onLoad={setMatchingResultProto}
messageType={MessageType.MatchingResult}
/>
<div style={{display: "flex", flexDirection: "column", alignItems: "center"}}>
<div>
<ProtoLoader
onLoad={setCostMatrixProto}
messageType={MessageType.CostMatrix}
/>
<ProtoLoader
onLoad={setMatchingResultProto}
messageType={MessageType.MatchingResult}
/>
</div>
</div>
{costMatrix && (
<CostMatrixComponent
costMatrix={costMatrix}
Expand Down
24 changes: 20 additions & 4 deletions src/viewer/src/CostMatrixComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { ImageCostMatrix, ZoomBlockParams } from "./ImageCostMatrix";
import { MatchingResultElement } from "./matchingResult";
import InteractiveCostMatrix from "./InteractiveCostMatrix";

import { FormGroup, FormControlLabel, Switch } from "@mui/material";

function getMatchingResultInZoomBlock(
results: MatchingResultElement[],
zoomParams: ZoomBlockParams
Expand Down Expand Up @@ -82,10 +84,24 @@ function CostMatrixComponent(props: CostMatrixProps): React.ReactElement {
flexDirection: "column",
}}
>
<div>
<input id="checkbox" type="checkbox" onChange={showMatchingResult} />
<label htmlFor="checkbox">Show matching result</label>
</div>
<FormGroup
style={{
display: "flex",
flexDirection: "row",
justifyContent: "center",
}}
>
<FormControlLabel
disabled={matchingResult ? false : true}
control={<Switch onChange={showMatchingResult} color="secondary" />}
label="Matching result"
/>
<FormControlLabel
disabled
control={<Switch onChange={showMatchingResult} />}
label="Expanded nodes"
/>
</FormGroup>
<div
style={{
display: "flex",
Expand Down
2 changes: 2 additions & 0 deletions src/viewer/src/ImageCostMatrix.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const ZoomTooltip = forwardRef((props: ZoomTooltipProps, pixelZoomRef: any) => {
left: props.coordX + "px",
border: "3px solid pink",
visibility: props.coordX && props.coordY ? "visible" : "hidden",
zIndex: 2
}}
>
<canvas ref={pixelZoomRef}></canvas>
Expand Down Expand Up @@ -262,6 +263,7 @@ function ImageCostMatrix(props: ImageCostMatrixProps): React.ReactElement {
maxWidth: "800px",
overflow: "auto",
margin: "10px",
zIndex: 2,
}}
>
<canvas
Expand Down
45 changes: 45 additions & 0 deletions src/viewer/src/ImagesLoader.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
.imageCarousel{
position: relative;
min-width: 200px;
min-height: 100px;
width: 600px;
height: 400px;
display: flex;
justify-content: center;
align-items: center;
z-index: 1;
}

.slide{
border-radius: 0.5rem;
box-shadow: 0px 0px 7px #666;
width: 100%;
height:100%;
}

.info{
position: absolute;
background-color:rgba(255,255,255,.8);
top: -1rem;
}

.arrow{
position: absolute;
width: 3rem;
height: 3rem;
color: black;
background-color: white;
box-shadow: 0px 0px 7px #666;
border-radius: 0.5rem;
}
.arrow:hover{
cursor: pointer;
}

.arrow-right{
right: 2rem;
}

.arrow-left{
left: 2rem;
}
17 changes: 12 additions & 5 deletions src/viewer/src/ImagesLoader.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { useState, useEffect } from "react";

import "./ImagesLoader.css"

import ArrowForwardIosRoundedIcon from '@mui/icons-material/ArrowForwardIosRounded';
import ArrowBackIosRoundedIcon from '@mui/icons-material/ArrowBackIosRounded';
import { Input } from '@mui/material';

function readImageAsync(file: Blob) {
return new Promise<string>((resolve, reject) => {
let reader = new FileReader();
Expand Down Expand Up @@ -95,17 +101,18 @@ function ImagesLoader(props: ImageLoaderProps) {
{images &&
images.length > currentImageId &&
images[currentImageId] !== undefined && (
<div>
<img src={images[currentImageId].base64Encoding} alt="preview" />
<p>
<div className="imageCarousel">
<img src={images[currentImageId].base64Encoding} alt="preview" className="slide"/>
<p className="info">
id: {images[currentImageId].id}; filename:{" "}
{images[currentImageId].fileName}
</p>

<ArrowForwardIosRoundedIcon className ="arrow arrow-right" onClick={handleNextClick}></ArrowForwardIosRoundedIcon>
<ArrowBackIosRoundedIcon className ="arrow arrow-left" onClick={handlePrevClick}></ArrowBackIosRoundedIcon>
</div>
)}
<div>
<button onClick={handlePrevClick}>prev</button>
<button onClick={handleNextClick}>next</button>
</div>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/viewer/src/ProtoLoader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function ProtoLoader(props: ProtoLoaderProps): React.ReactElement {
return (
<div>
<label htmlFor="folder">
Select *.{props.messageType.toString()}.proto file{" "}
Select <b>*.{props.messageType.toString()}.proto</b> file{" "}
</label>
<input type="file" id="fileInput" onChange={processFile}></input>
</div>
Expand Down