diff --git a/timApp/static/scripts/tim/plugin/quantumcircuit/quantum-circuit-board.component.scss b/timApp/static/scripts/tim/plugin/quantumcircuit/quantum-circuit-board.component.scss index 8ecf9d1dde..440084430c 100644 --- a/timApp/static/scripts/tim/plugin/quantumcircuit/quantum-circuit-board.component.scss +++ b/timApp/static/scripts/tim/plugin/quantumcircuit/quantum-circuit-board.component.scss @@ -38,10 +38,6 @@ svg text::selection { border-right: 1px solid black; } -.left-block { - border-bottom: 1px solid black; -} - .qubit { display: flex; @@ -61,6 +57,31 @@ svg text::selection { margin-right: 0.1em; } +.left-block { + border-bottom: 1px solid black; + position: relative; +} + +.axis-text-qubit { + font-size: 12px; + position: absolute; + bottom: 0; + left: 0; +} + +.axis-text-time { + font-size: 12px; + position: absolute; + top: 0; + right: 0; +} + +.axis-line { + height: 1px; + background-color: black; + transform-origin: top left; +} + .moments { display: flex; flex-direction: row; diff --git a/timApp/static/scripts/tim/plugin/quantumcircuit/quantum-circuit-board.component.ts b/timApp/static/scripts/tim/plugin/quantumcircuit/quantum-circuit-board.component.ts index 8a5e530b0e..1828a4f7cc 100644 --- a/timApp/static/scripts/tim/plugin/quantumcircuit/quantum-circuit-board.component.ts +++ b/timApp/static/scripts/tim/plugin/quantumcircuit/quantum-circuit-board.component.ts @@ -2,7 +2,12 @@ * Quantum circuit board. */ -import type {OnInit, PipeTransform} from "@angular/core"; +import type { + OnChanges, + OnInit, + PipeTransform, + SimpleChanges, +} from "@angular/core"; import { Component, EventEmitter, @@ -93,16 +98,21 @@ export class RangePipe implements PipeTransform {
-
-
+
Aika
+
+
Kubitti
+
+
-
-
- - +
@@ -205,7 +216,7 @@ export class RangePipe implements PipeTransform { `, styleUrls: ["./quantum-circuit-board.component.scss"], }) -export class QuantumCircuitBoardComponent implements OnInit { +export class QuantumCircuitBoardComponent implements OnInit, OnChanges { protected readonly Control = Control; protected readonly Swap = Swap; @@ -215,6 +226,9 @@ export class QuantumCircuitBoardComponent implements OnInit { // gate that is currently being dragged gateBeingDragged: GateBeingDragged | null = null; + axisLineWidth!: number; + axisLineTransform!: string; + @ViewChild("svgElement") svgElement!: ElementRef; @@ -253,7 +267,30 @@ export class QuantumCircuitBoardComponent implements OnInit { constructor() {} - ngOnInit(): void {} + ngOnChanges(changes: SimpleChanges): void { + if (changes.circuitStyleOptions) { + this.updateAxisStyles(); + } + } + + ngOnInit(): void { + this.updateAxisStyles(); + } + + /** + * Sets css properties to draw a diagonal line. + */ + updateAxisStyles() { + this.axisLineWidth = + this.circuitStyleOptions.baseSize + + this.circuitStyleOptions.inputWidth + + 5; + + const angle = Math.asin( + this.circuitStyleOptions.timeAxisHeight / this.axisLineWidth + ); + this.axisLineTransform = `rotate(${angle}rad)`; + } /** * The value of qubit changed.