-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(protocol-designer, components): prep work for deck config in PD (#…
- Loading branch information
Showing
16 changed files
with
337 additions
and
141 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
File renamed without changes.
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export * from './BaseDeck' | ||
export * from './SingleSlotFixture' | ||
export * from './StagingAreaFixture' | ||
export * from './WasteChuteFixture' | ||
export * from './WasteChuteStagingAreaFixture' |
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,8 +1,9 @@ | ||
export * from './RobotWorkSpace' | ||
export * from './DeckFromData' | ||
export * from './FlexTrash' | ||
export * from './getDeckDefinitions' | ||
export * from './MoveLabwareOnDeck' | ||
export * from './RobotCoordsForeignDiv' | ||
export * from './RobotCoordsForeignObject' | ||
export * from './RobotCoordsText' | ||
export * from './RobotWorkSpace' | ||
export * from './SlotLabels' | ||
export * from './FlexTrash' | ||
export * from './getDeckDefinitions' | ||
export * from './MoveLabwareOnDeck' |
File renamed without changes.
65 changes: 65 additions & 0 deletions
65
components/src/hardware-sim/RobotCoordinateSpace/RobotCoordinateSpaceWithDOMCoords.tsx
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 |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import * as React from 'react' | ||
import { Svg } from '../../primitives' | ||
import type { DeckDefinition, DeckSlot } from '@opentrons/shared-data' | ||
|
||
export interface RobotCoordinateSpaceWithDOMCoordsRenderProps { | ||
deckSlotsById: { [slotId: string]: DeckSlot } | ||
getRobotCoordsFromDOMCoords: ( | ||
domX: number, | ||
domY: number | ||
) => { x: number; y: number } | ||
} | ||
|
||
interface RobotCoordinateSpaceWithDOMCoordsProps | ||
extends React.ComponentProps<typeof Svg> { | ||
viewBox?: string | null | ||
deckDef?: DeckDefinition | ||
children?: ( | ||
props: RobotCoordinateSpaceWithDOMCoordsRenderProps | ||
) => React.ReactNode | ||
} | ||
|
||
type GetRobotCoordsFromDOMCoords = RobotCoordinateSpaceWithDOMCoordsRenderProps['getRobotCoordsFromDOMCoords'] | ||
|
||
export function RobotCoordinateSpaceWithDOMCoords( | ||
props: RobotCoordinateSpaceWithDOMCoordsProps | ||
): JSX.Element | null { | ||
const { children, deckDef, viewBox, ...restProps } = props | ||
const wrapperRef = React.useRef<SVGSVGElement>(null) | ||
const getRobotCoordsFromDOMCoords: GetRobotCoordsFromDOMCoords = (x, y) => { | ||
if (wrapperRef.current == null) return { x: 0, y: 0 } | ||
|
||
const cursorPoint = wrapperRef.current.createSVGPoint() | ||
|
||
cursorPoint.x = x | ||
cursorPoint.y = y | ||
|
||
return cursorPoint.matrixTransform( | ||
wrapperRef.current.getScreenCTM()?.inverse() | ||
) | ||
} | ||
if (deckDef == null && viewBox == null) return null | ||
|
||
let wholeDeckViewBox | ||
let deckSlotsById = {} | ||
if (deckDef != null) { | ||
const [viewBoxOriginX, viewBoxOriginY] = deckDef.cornerOffsetFromOrigin | ||
const [deckXDimension, deckYDimension] = deckDef.dimensions | ||
|
||
deckSlotsById = deckDef.locations.orderedSlots.reduce( | ||
(acc, deckSlot) => ({ ...acc, [deckSlot.id]: deckSlot }), | ||
{} | ||
) | ||
wholeDeckViewBox = `${viewBoxOriginX} ${viewBoxOriginY} ${deckXDimension} ${deckYDimension}` | ||
} | ||
return ( | ||
<Svg | ||
viewBox={viewBox || wholeDeckViewBox} | ||
ref={wrapperRef} | ||
transform="scale(1, -1)" | ||
{...restProps} | ||
> | ||
{children?.({ deckSlotsById, getRobotCoordsFromDOMCoords })} | ||
</Svg> | ||
) | ||
} |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './RobotCoordinateSpaceWithDOMCoords' | ||
export * from './RobotCoordinateSpace' |
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,5 +1,7 @@ | ||
export * from './BaseDeck' | ||
export * from './Deck' | ||
export * from './DeckConfigurator' | ||
export * from './Labware' | ||
export * from './Module' | ||
export * from './Pipette' | ||
export * from './RobotCoordinateSpace' |
50 changes: 50 additions & 0 deletions
50
protocol-designer/src/components/DeckSetup/NullDeckState.tsx
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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as React from 'react' | ||
import { | ||
FONT_SIZE_BODY_1, | ||
FONT_WEIGHT_BOLD, | ||
getDeckDefinitions, | ||
RobotCoordsText, | ||
RobotWorkSpace, | ||
TEXT_TRANSFORM_UPPERCASE, | ||
} from '@opentrons/components' | ||
import { i18n } from '../../localization' | ||
import { | ||
VIEWBOX_HEIGHT, | ||
VIEWBOX_MIN_X, | ||
VIEWBOX_MIN_Y, | ||
VIEWBOX_WIDTH, | ||
} from './constants' | ||
import { DECK_LAYER_BLOCKLIST } from './index' | ||
|
||
import styles from './DeckSetup.css' | ||
|
||
export const NullDeckState = (): JSX.Element => { | ||
const deckDef = React.useMemo(() => getDeckDefinitions().ot2_standard, []) | ||
|
||
return ( | ||
<div className={styles.deck_row}> | ||
<div className={styles.deck_wrapper}> | ||
<RobotWorkSpace | ||
deckLayerBlocklist={DECK_LAYER_BLOCKLIST} | ||
deckDef={deckDef} | ||
viewBox={`${VIEWBOX_MIN_X} ${VIEWBOX_MIN_Y} ${VIEWBOX_WIDTH} ${VIEWBOX_HEIGHT}`} | ||
width="100%" | ||
height="100%" | ||
> | ||
{() => ( | ||
<RobotCoordsText | ||
x={5} | ||
y={375} | ||
style={{ textTransform: TEXT_TRANSFORM_UPPERCASE }} | ||
fill="#cccccc" | ||
fontWeight={FONT_WEIGHT_BOLD} | ||
fontSize={FONT_SIZE_BODY_1} | ||
> | ||
{i18n.t('deck.inactive_deck')} | ||
</RobotCoordsText> | ||
)} | ||
</RobotWorkSpace> | ||
</div> | ||
</div> | ||
) | ||
} |
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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { STANDARD_SLOT_LOAD_NAME } from '@opentrons/shared-data' | ||
|
||
const cutouts = [ | ||
'A1', | ||
'A2', | ||
'A3', | ||
'B1', | ||
'B2', | ||
'B3', | ||
'C1', | ||
'C2', | ||
'C3', | ||
'D1', | ||
'D2', | ||
'D3', | ||
] | ||
|
||
export const DEFAULT_SLOTS = cutouts.map((cutout, index) => ({ | ||
fixtureId: (index + 1).toString(), | ||
fixtureLocation: cutout, | ||
loadName: STANDARD_SLOT_LOAD_NAME, | ||
})) | ||
|
||
export const VIEWBOX_MIN_X = -64 | ||
export const VIEWBOX_MIN_Y = -10 | ||
export const VIEWBOX_WIDTH = 520 | ||
export const VIEWBOX_HEIGHT = 414 |
Oops, something went wrong.