Skip to content

Commit

Permalink
feat(ui): Improve coverage view
Browse files Browse the repository at this point in the history
  • Loading branch information
Hypfer committed Aug 6, 2022
1 parent dac68c4 commit 4ac2928
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion frontend/src/map/Map.tsx
Expand Up @@ -235,7 +235,7 @@ class Map<P, S> extends React.Component<P & MapProps, S & MapState > {
mapWidth: this.props.rawMap.size.x,
mapHeight: this.props.rawMap.size.y,
pixelSize: this.props.rawMap.pixelSize,
theme: this.props.theme,
paletteMode: this.props.theme.palette.mode,
});

this.drawableComponents.push(pathsImage);
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/map/PathDrawer.ts
@@ -1,12 +1,12 @@
import {RawMapEntity, RawMapEntityType} from "../api";
import {Theme} from "@mui/material";
import {PaletteMode} from "@mui/material";

type PathDrawerOptions = {
paths: Array<RawMapEntity>,
mapWidth: number,
mapHeight: number,
pixelSize: number,
theme: Theme,
paletteMode: PaletteMode,
width?: number
};

Expand All @@ -33,7 +33,7 @@ export class PathDrawer {
const {
mapWidth,
mapHeight,
theme,
paletteMode,
paths,
pixelSize,
width
Expand All @@ -42,7 +42,7 @@ export class PathDrawer {
let svg = `<svg xmlns="http://www.w3.org/2000/svg" width="${mapWidth}" height="${mapHeight}" viewBox="0 0 ${mapWidth} ${mapHeight}">`;
let pathColor : string;

switch (theme.palette.mode) {
switch (paletteMode) {
case "light":
pathColor = "#ffffff";
break;
Expand Down
16 changes: 14 additions & 2 deletions frontend/src/map/RobotCoverageMap.tsx
Expand Up @@ -42,15 +42,27 @@ class RobotCoverageMap extends Map<CleanupCoverageMapProps, CleanupCoverageMapSt
await this.mapLayerRenderer.draw(this.props.rawMap, this.props.theme);
this.drawableComponents.push(this.mapLayerRenderer.getCanvas());

const coveragePathImage = await PathDrawer.drawPaths( {
paths: this.props.rawMap.entities.filter(e => {
return e.type === RawMapEntityType.Path;
}),
mapWidth: this.props.rawMap.size.x,
mapHeight: this.props.rawMap.size.y,
pixelSize: this.props.rawMap.pixelSize,
paletteMode: this.props.theme.palette.mode === "dark" ? "light" : "dark",
width: 5
});

this.drawableComponents.push(coveragePathImage);

const pathsImage = await PathDrawer.drawPaths( {
paths: this.props.rawMap.entities.filter(e => {
return e.type === RawMapEntityType.Path || e.type === RawMapEntityType.PredictedPath;
}),
mapWidth: this.props.rawMap.size.x,
mapHeight: this.props.rawMap.size.y,
pixelSize: this.props.rawMap.pixelSize,
theme: this.props.theme,
width: 5
paletteMode: this.props.theme.palette.mode,
});

this.drawableComponents.push(pathsImage);
Expand Down

0 comments on commit 4ac2928

Please sign in to comment.