-
Notifications
You must be signed in to change notification settings - Fork 194
CSE machine: StreamViz arrow drawing #3747
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
Open
of89p
wants to merge
47
commits into
master
Choose a base branch
from
streamVis
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+160
−11
Open
Changes from 40 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
e92d3ab
StreamViz arrow drawing
of89p e254f4b
Update js-slang dependency version in package.json
DaRealTristan 02c8ea1
package.json fix and formatting
Akshay-2007-1 0013166
deleted useless ts file
Akshay-2007-1 71f111c
Merge branch 'master' into streamVis
DaRealTristan 484a680
removed debug logs as per gemini suggestion
TristanTayYuHng 2d48357
removed debug logs as per gemini suggestion
TristanTayYuHng 6344e48
Fixed merger with layout feature
TristanTayYuHng 8fe8c43
Merge branch 'master' into streamVis
DaRealTristan 7b21298
missing curly brace
of89p d8758f4
Simplifying features to integrate with arrows team
DaRealTristan 5319513
Merge branch 'master' into streamVis
martin-henz 5114633
removed streamsPointStep
of89p f4d64e3
Merge branch 'streamVis' of https://github.com/source-academy/fronten…
DaRealTristan fe322c0
Merge branch 'streamVis' of https://github.com/source-academy/fronten…
TristanTayYuHng 9b9a019
Removed local resolution for 'js-slang' package.
DaRealTristan ecc11c5
simplified for mvp
TristanTayYuHng e48d282
simplified for mvp
TristanTayYuHng 27ee97c
removed redundant draw
TristanTayYuHng 599b74f
Merge branch 'master' into streamVis
martin-henz db43ec6
Drifting fixed!!
Akshay-2007-1 755bcef
print mode dotted line colour change
TristanTayYuHng a7c1787
Update js-slang dependency resolution in yarn.lock
DaRealTristan 05e6d15
Update js-slang package version
DaRealTristan 155e6d7
yarn format
TristanTayYuHng 53a5458
bumping js-slang to 1.0.90
martin-henz 05407ec
Merge branch 'master' into streamVis
martin-henz d4a1a6c
Merge branch 'master' into streamVis
martin-henz 334e2a3
trying to fix testcase
martin-henz a98d4d2
Merge remote-tracking branch 'origin/streamVis' into streamVis
martin-henz 4e795ea
streamvis now survives run
DaRealTristan e7e374f
Merge branch 'master' into streamVis
martin-henz 54af008
bumping js-slang
martin-henz 8fd160c
Fixed multiple arrows to pair issue
DaRealTristan df7b92c
Merge branch 'master' into streamVis
martin-henz 917f345
Merge branch 'master' of https://github.com/source-academy/frontend i…
RichDom2185 967f06c
Merge branch 'master' into streamVis
DaRealTristan 050f95f
resolved merge conflicts and ran yarn format
DaRealTristan c52c48b
yarn format
DaRealTristan a2475fe
fix: Line 81 bug. Removed redundant code due to mismatched ordering
Akshay-2007-1 dd5a1f2
Merge branch 'master' into streamVis
RichDom2185 fad0127
Merge branch 'master' into streamVis
martin-henz 37d480e
Merge branch 'master' into streamVis
martin-henz 34373de
removed comments and console logs
DaRealTristan c0cefd0
Merge branch 'master' into streamVis
martin-henz a117f8a
Merge branch 'master' into streamVis
martin-henz 53377b8
Merge branch 'master' into streamVis
RichDom2185 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
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
49 changes: 49 additions & 0 deletions
49
src/features/cseMachine/components/arrows/ArrowFromStreamNullaryFn.tsx
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,49 @@ | ||
| import { Config } from '../../CseMachineConfig'; | ||
| import type { StepsArray } from '../../CseMachineTypes'; | ||
| import { ArrayValue } from '../values/ArrayValue'; | ||
| import { ContValue } from '../values/ContValue'; | ||
| import { FnValue } from '../values/FnValue'; | ||
| import { GlobalFnValue } from '../values/GlobalFnValue'; | ||
| import { DottedArrow } from './DottedArrow'; | ||
|
|
||
| /** this class encapsulates an GenericArrow to be drawn between 2 points */ | ||
| export class ArrowFromStreamNullaryFn extends DottedArrow { | ||
| constructor( | ||
| from: FnValue | GlobalFnValue | ContValue, | ||
| public offsetIndex: number = 0, | ||
| ) { | ||
| super(from); | ||
| this.faded = !from.isReferenced(); | ||
| } | ||
|
|
||
| protected calculateSteps() { | ||
| const from = this.source as FnValue | GlobalFnValue | ContValue; | ||
| const to = this.target; | ||
|
|
||
| if (!to || !(to instanceof ArrayValue)) return []; | ||
|
|
||
| const verticalShift = this.offsetIndex * 20; // 20px vertical separation for multiple arrows to the same target | ||
|
|
||
| // The arrow starts from the right of the function circle | ||
| const startPointX = from.centerX + 2 * from.radius; | ||
| const startPointY = from.y(); | ||
| // The arrow ends at the top-center of the array | ||
| const endPointX = to.x() + Config.DataUnitWidth / 2; | ||
| const endPointY = to.y(); | ||
|
|
||
| // An intermediate point is used to create the arch. | ||
| // It is placed horizontally between the start and end points, | ||
| // and vertically above them to form an upward arch. | ||
| const midPointX = (startPointX + endPointX) / 2; | ||
| const archHeight = 50; | ||
| const midPointY = Math.min(startPointY, endPointY) - archHeight - verticalShift; | ||
| const steps: StepsArray = [ | ||
| // The GenericArrow class will draw a path through these points, | ||
| // creating smooth curves at the corners. | ||
| () => [startPointX, startPointY], | ||
| () => [midPointX, midPointY], | ||
| () => [endPointX, endPointY], | ||
| ]; | ||
| return steps; | ||
| } | ||
| } |
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,33 @@ | ||
| import { Arrow as KonvaArrow, Group as KonvaGroup, Path as KonvaPath } from 'react-konva'; | ||
|
|
||
| import CseMachine from '../../CseMachine'; | ||
| import { Config, ShapeDefaultProps } from '../../CseMachineConfig'; | ||
| import { Layout } from '../../CseMachineLayout'; | ||
| import type { IVisible } from '../../CseMachineTypes'; | ||
| import { GenericArrow } from './GenericArrow'; | ||
|
|
||
| export class DottedArrow extends GenericArrow<IVisible, IVisible> { | ||
| draw() { | ||
| const stroke = CseMachine.getPrintableMode() ? '#9B870C' : '#ded74e'; | ||
| return ( | ||
| <KonvaGroup key={Layout.key++} ref={this.ref} listening={false}> | ||
| <KonvaPath | ||
| {...ShapeDefaultProps} | ||
| stroke={stroke} | ||
| strokeWidth={Config.ArrowStrokeWidth} | ||
| data={this.path()} | ||
| key={Layout.key++} | ||
| dash={[10, 5]} | ||
| /> | ||
| <KonvaArrow | ||
| {...ShapeDefaultProps} | ||
| points={this.points.slice(this.points.length - 4)} | ||
| fill={stroke} | ||
| strokeEnabled={false} | ||
| pointerWidth={Config.ArrowHeadSize} | ||
| key={Layout.key++} | ||
| /> | ||
| </KonvaGroup> | ||
| ); | ||
| } | ||
| } |
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
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.