-
-
Notifications
You must be signed in to change notification settings - Fork 71
Feature/variable browser rework #638
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
Closed
Rdmkr
wants to merge
16
commits into
highperformancecoder:develop
from
Rdmkr:feature/variableBrowserRework
+1
−1
Closed
Changes from 5 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f42363e
rework of variable browser based on svg-canvas
Rdmkr 8c5f471
Merge remote-tracking branch 'origin/master' into feature/variableBro…
Rdmkr 0216610
package lock
Rdmkr 3508530
constant for integrals
Rdmkr 740842d
supported types filter
Rdmkr dccf38f
Merge remote-tracking branch 'origin/master' into feature/variableBro…
Rdmkr c75f78c
chore: Translate x86_64 to x64 in uploadSevalla script. For #1938.
highperformancecoder aab4683
Merge branch 'master' into feature/variableBrowserRework
Rdmkr ce61071
code review fixes
Rdmkr 71284f5
fixes
Rdmkr 328a0f7
D3 update
Rdmkr 0cb540a
review fixes
Rdmkr 8a7d14b
drag events
Rdmkr 87e53b0
drag/drop functionality
Rdmkr 328e075
Merge branch 'develop' into feature/variableBrowserRework
highperformancecoder ac6f1b4
Update package.json
highperformancecoder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
4 changes: 4 additions & 0 deletions
4
gui-js/libs/ui-components/src/lib/svg-canvas/classes/connector.ts
This file contains hidden or 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,4 @@ | ||
| export class Connector { | ||
| type: string; | ||
| position: (x: number, y: number, width: number, height: number) => [number,number]; | ||
| } |
22 changes: 22 additions & 0 deletions
22
gui-js/libs/ui-components/src/lib/svg-canvas/classes/datapoint.ts
This file contains hidden or 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,22 @@ | ||
| import { ElementType } from './elementtype'; | ||
| import { Connector } from './connector'; | ||
| import { Dimensions } from './dimensions'; | ||
|
|
||
| export class DataPoint { | ||
| label: string; | ||
| x?: number; | ||
| y?: number; | ||
| fx?: number; | ||
| fy?: number; | ||
| value: number; | ||
| exponent: number; | ||
| rotation: number; | ||
| anchorx?: number; | ||
| anchory?: number; | ||
| type: ElementType; | ||
| connectors: Connector[]; | ||
| canvasPosition; | ||
| symbol; | ||
| dimensions: Dimensions; | ||
| hidden = false; | ||
| } | ||
8 changes: 8 additions & 0 deletions
8
gui-js/libs/ui-components/src/lib/svg-canvas/classes/dimensions.ts
This file contains hidden or 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,8 @@ | ||
| export class Dimensions { | ||
| length: number; | ||
| boundingbox: number[]; | ||
| labelbox: number[]; | ||
| valuebox: number[]; | ||
| exponentbox: number[]; | ||
| valueline?: number[][]; | ||
| } |
10 changes: 10 additions & 0 deletions
10
gui-js/libs/ui-components/src/lib/svg-canvas/classes/elementtype.ts
This file contains hidden or 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,10 @@ | ||
| import { Connector } from './connector'; | ||
| import { Dimensions } from './dimensions'; | ||
|
|
||
| export class ElementType { | ||
| name: string; | ||
| points: (x: number, y: number, width: number, height: number) => string; | ||
| size: number[]; | ||
| connectors: Connector[]; | ||
| getDimensions: (length: number) => Dimensions; | ||
| } |
Empty file.
7 changes: 7 additions & 0 deletions
7
gui-js/libs/ui-components/src/lib/svg-canvas/components/d3line.component.html
This file contains hidden or 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,7 @@ | ||
| <svg:path #linepath [style.display]="invisibleLine ? 'none' : 'inherit'"></svg:path> | ||
|
|
||
| <svg:circle #startpoint [attr.cx]="start[0]" [attr.cy]="start[1]" r="0.00001"></svg:circle> | ||
| <svg:circle #endpoint [attr.cx]="end[0]" [attr.cy]="end[1]" r="0.00001"></svg:circle> | ||
|
|
||
| <svg:circle #midpoint dragdrop *ngFor="let p of dotPositions; let i = index" | ||
| [dragfunctions]="dragfunctions(p, i)" [attr.cx]="p.x" [attr.cy]="p.y" r="7"></svg:circle> |
113 changes: 113 additions & 0 deletions
113
gui-js/libs/ui-components/src/lib/svg-canvas/components/d3line.component.ts
This file contains hidden or 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,113 @@ | ||
| import { CommonModule } from '@angular/common'; | ||
| import { ElementRef, Input, OnChanges, ViewChild, Component, SimpleChanges, Output, EventEmitter, ViewChildren } from '@angular/core'; | ||
| import * as d3 from 'd3'; | ||
|
|
||
| @Component({ | ||
| selector: '[d3line]', | ||
| templateUrl: './d3line.component.html', | ||
| styleUrls: ['./d3line.component.css'], | ||
| imports: [CommonModule] | ||
| }) | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| export class D3LineComponent implements OnChanges { | ||
| @ViewChild('linepath', {static: true}) | ||
| linepath: ElementRef; | ||
|
|
||
| @ViewChild('startpoint', {static: true}) | ||
| startpoint: ElementRef; | ||
|
|
||
| @ViewChild('endpoint', {static: true}) | ||
| endpoint: ElementRef; | ||
|
|
||
| @ViewChildren('midpoint') | ||
| midpoints; | ||
|
|
||
| @Input() | ||
| start: [number,number,number]; | ||
|
|
||
| @Input() | ||
| end: [number,number,number]; | ||
|
|
||
| @Input() | ||
| dotsAt: number[]; | ||
|
|
||
| dotPositions: any[] = []; | ||
|
|
||
| @Input() | ||
| invisibleLine = false; | ||
|
|
||
| @Input() | ||
| draggable = true; | ||
|
|
||
| @Output() | ||
| pointMoved = new EventEmitter<any>(); | ||
|
|
||
| constructor() { | ||
|
|
||
| } | ||
|
|
||
| ngOnChanges(changes: SimpleChanges) { | ||
| if(this.start && this.end && (changes.start || changes.end)) { | ||
| const points: any = [this.start]; | ||
|
|
||
| const pointDistance = Math.sqrt(Math.pow(this.end[0] - this.start[0], 2) + Math.pow(this.end[1] - this.start[1], 2)) / 4; | ||
| if(this.start[2] !== undefined) { | ||
| points.push([this.start[0] + Math.cos(this.start[2]) * pointDistance, this.start[1] + Math.sin(this.start[2]) * pointDistance]); | ||
| } | ||
| if(this.end[2] !== undefined) { | ||
| points.push([this.end[0] + Math.cos(this.end[2]) * pointDistance, this.end[1] + Math.sin(this.end[2]) * pointDistance]); | ||
| } | ||
| points.push(this.end); | ||
|
|
||
| this.linepath.nativeElement.setAttribute('d', d3.line().curve(d3.curveBasis)(points)); | ||
| } | ||
|
|
||
| if(changes.dotsAt) { | ||
| this.handleDotsChange(); | ||
| } | ||
| } | ||
|
|
||
| handleDotsChange() { | ||
| const path = this.linepath.nativeElement; | ||
| const length = path.getTotalLength(); | ||
| this.dotPositions = this.dotsAt.map(percentage => { | ||
| return path.getPointAtLength(percentage * length); | ||
| }); | ||
| } | ||
|
|
||
| dragfunctions(p, i) { | ||
| const startBox = this.startpoint.nativeElement.getBBox(); | ||
| const endBox = this.endpoint.nativeElement.getBBox(); | ||
| const start = [startBox.x + startBox.width / 2, startBox.y + startBox.height / 2]; | ||
| const end = [endBox.x + endBox.width / 2, endBox.y + endBox.height / 2]; | ||
|
|
||
| return { | ||
| dragstarted: () => { | ||
| }, | ||
| dragged: () => { | ||
| if(this.draggable) { | ||
| const x = d3.event.x; | ||
| const y = d3.event.y; | ||
|
|
||
| const point = [x,1000]; | ||
|
|
||
| const a1 = Math.max(0, Math.PI / 2 - this.getAngle(end, start, point)); | ||
| const a2 = Math.max(0, Math.PI / 2 - this.getAngle(start, end, point)); | ||
|
|
||
| this.dotsAt[i] = a1 / (a1 + a2); | ||
| this.pointMoved.emit(this.dotsAt[i]); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
| }, | ||
| dragended: () => { | ||
|
|
||
| } | ||
| }; | ||
| } | ||
|
|
||
| getAngle(x, y, z) { | ||
| const a = [z[0] - y[0], z[1] - y[1]]; | ||
| const b = [x[0] - y[0], x[1] - y[1]]; | ||
| const al = Math.sqrt(Math.pow(a[0],2)+Math.pow(a[1],2)); | ||
| const bl = Math.sqrt(Math.pow(b[0],2)+Math.pow(b[1],2)); | ||
| const dotproduct = a[0] * b[0] + a[1] * b[1]; | ||
| return Math.acos(dotproduct / (al * bl)); | ||
| } | ||
| } | ||
24 changes: 24 additions & 0 deletions
24
gui-js/libs/ui-components/src/lib/svg-canvas/components/elementlabel.component.css
This file contains hidden or 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,24 @@ | ||
| :host { | ||
| height: 100%; | ||
| width: 100%; | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: space-evenly; | ||
| align-items: center; | ||
| overflow: visible; | ||
| } | ||
|
|
||
| .namelabel, .descriptionlabel, .valuelabel { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| -webkit-user-select: none; | ||
| -moz-user-select: none; | ||
| -ms-user-select: none; | ||
| user-select: none; | ||
| text-align: center; | ||
| } | ||
|
|
||
| .descriptionlabel { | ||
| flex-grow: 6; | ||
| } |
14 changes: 14 additions & 0 deletions
14
gui-js/libs/ui-components/src/lib/svg-canvas/components/elementlabel.component.html
This file contains hidden or 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,14 @@ | ||
| <div class="latex" latex [equation]="data.symbol" [style.fontSize]="fontSize"> | ||
| </div> | ||
|
|
||
| <div *ngIf="lines > 1" class="valuelabel" [style.fontSize]="fontSize"> | ||
| {{data.value.toFixed(4)}} | ||
| </div> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| <div *ngIf="lines > 2" class="namelabel" [style.fontSize]="fontSize"> | ||
| {{data.name}} | ||
| </div> | ||
|
|
||
| <div *ngIf="lines > 3" class="descriptionlabel" [style.fontSize]="fontSize"> | ||
| {{data.description}} | ||
| </div> | ||
22 changes: 22 additions & 0 deletions
22
gui-js/libs/ui-components/src/lib/svg-canvas/components/elementlabel.component.ts
This file contains hidden or 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,22 @@ | ||
| import { Component, Input } from '@angular/core'; | ||
| import { LatexDirective } from '../../directives/latex.directive'; | ||
| import { CommonModule } from '@angular/common'; | ||
|
|
||
| @Component({ | ||
| selector: 'elementlabel', | ||
| templateUrl: './elementlabel.component.html', | ||
| styleUrls: ['./elementlabel.component.css'], | ||
| standalone: true, | ||
| imports: [LatexDirective, CommonModule] | ||
| }) | ||
| export class ElementLabelComponent { | ||
| @Input() | ||
| data; | ||
|
|
||
| @Input() | ||
| lines: number; | ||
|
|
||
| get fontSize() { | ||
| return `${20 / this.lines}px`; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.