microsoft/qdk

Public

mirrored from https://github.com/microsoft/qdkAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
billti/num2-sim

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

source/npm/qsharp/ux/circuit-vis/gateRenderData.ts

58lines · modecode

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT license.
3
4import { DataAttributes } from "./circuit";
5
6/**
7 * Enum for the various gate operations handled.
8 */
9export enum GateType {
10 /** Measurement gate. */
11 Measure,
12 /** CNOT gate. */
13 Cnot,
14 /** SWAP gate. */
15 Swap,
16 /** X gate. */
17 X,
18 /** |0⟩or |1⟩ gate. */
19 Ket,
20 /** Single/multi qubit unitary gate. */
21 Unitary,
22 /** Single/multi controlled unitary gate. */
23 ControlledUnitary,
24 /** Nested group of classically-controlled gates. */
25 ClassicalControlled,
26 /** Group of nested gates */
27 Group,
28 /** Invalid gate. */
29 Invalid,
30}
31
32/**
33 * Rendering data used to store information pertaining to a given
34 * operation for rendering its corresponding SVG.
35 */
36export interface GateRenderData {
37 /** Gate type. */
38 type: GateType;
39 /** Centre x coord for gate position. */
40 x: number;
41 /** Array of y coords of control registers. */
42 controlsY: number[];
43 /** Array of y coords of target registers.
44 * For `GateType.Unitary` or `GateType.ControlledUnitary`, this is an array of groups of
45 * y coords, where each group represents a unitary box to be rendered separately.
46 */
47 targetsY: (number | number[])[];
48 /** Gate label. */
49 label: string;
50 /** Gate arguments as string. */
51 displayArgs?: string;
52 /** Gate width. */
53 width: number;
54 /** Children operations as part of group. */
55 children?: GateRenderData[][] | GateRenderData[][][];
56 /** Custom data attributes to attach to gate element. */
57 dataAttributes?: DataAttributes;
58}
59