Skip to content
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

Feature/add export and import data #183

Draft
wants to merge 15 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/@types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export type ManualMode = typeof MANUAL_MODE[keyof typeof MANUAL_MODE]
export type MaskMode = typeof MASK_MODE[keyof typeof MASK_MODE]
export type PointMode = typeof POINT_MODE[keyof typeof POINT_MODE]

//e.g. 1.2.0 is described as [1, 2, 0]
export type SemanticVersion = [number, number, number]
Copy link
Collaborator Author

@yu-smc yu-smc Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added new type 'SemanticVersion' to describe versions as an array of numbers(referred to WPD json
schema)

SemanticVersionConverter(string <-> array) will be implemented soon, mauybe...


// INFO: Coord is coordinate
export type Coord = {
xPx: number
Expand All @@ -14,3 +17,8 @@ export type Point = {
xPx: number
yPx: number
}

export type XYValue = {
x: number,
y: number
}
11 changes: 11 additions & 0 deletions src/infrastructure/dataSchemas/allDataSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SemanticVersion } from '@/@types/types'
import { ConfigDataSchema } from './configDataSchema'
import { PlotDataSchema } from './plotDataSchema'

//NOTE: Other interfaces have a prefix 'Interface' but this one doesn't have: It is intentional, mainly because this interface is kind of special one to just define data schema literally
export interface AllDataSchema {
appVersion: SemanticVersion
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As a type, it's a semantic version, and when actually used, it's the app version. This usage looks good.

plotImageBase64: string
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added plot image as base 64 string.
The reason why it is not in the plotDataSchema is that we may want to export plot data without image data.

plotData: PlotDataSchema
configData: ConfigDataSchema
}
35 changes: 35 additions & 0 deletions src/infrastructure/dataSchemas/configDataSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { PointMode, SemanticVersion } from '@/@types/types'

//NOTE: Add any information about StarryDigitizer configurations which is necassary to reconstruct the application states here.
//NOTE: Other interfaces have a prefix 'Interface' but this one doesn't have: It is intentional, mainly because this interface is kind of special one to just define data schema literally
export interface ConfigDataSchema {
schemaVersion: SemanticVersion
figure: {
scale: number
}
axisSets: Array<{
id: number
pointMode: PointMode
isVisible: boolean
shouldConsiderGraphTilt: boolean
}>
interpolator: {
isActive: boolean
interval: number
}
magnifier: {
magnificationTimes: number
}
extractor: {
strategy: 'Symbol Extract' | 'Line Extract'
colorDiffThresholdPercent: number
symbolExtraction: {
minDiameterPx: number
maxDiamiterPx: number
}
lineExtraction: {
deltaXPx: number
deltaYPx: number
}
}
}
42 changes: 42 additions & 0 deletions src/infrastructure/dataSchemas/plotDataSchema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
//NOTE: Includes the actual data collected from a figure: axis values, axis scale, data point values and so
//NOTE: Do not include any data which depends on StarryDigitizer app(e.g. setting axis by 2 points or 4 points etc...)

import { Coord, SemanticVersion, XYValue } from '@/@types/types'
//TODO: move definition of type Coord to more global directoly (e.g. @types)

//NOTE: Other interfaces have a prefix 'Interface' but this one doesn't have: It is intentional, mainly because this interface is kind of special one to just define data schema literally
export interface PlotDataSchema {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that configDataSchema and PlotDataSchema are not consistently using camelCase and PascalCase.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed in: 9fb1e4b

schemaVersion: SemanticVersion
axisSets: Array<{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Used Array<{}> instead of {}[]
I think Array<{}> is better to clearly know it is array

id: number
name: string
x1: {
value: number
coord: Coord
}
x2: {
value: number
coord: Coord
}
y1: {
value: number
coord: Coord
}
y2: {
value: number
coord: Coord
}
//TODO: create type AxisScale: 'linear' | 'log'
xScale: 'linear' | 'log'
yScale: 'linear' | 'log'
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated overall schema of axis set to be more simple and following the original data structure of StarryDigitizer.

}>
datasets: Array<{
id: number
name: string
axisSetId: number
points: Array<{
value: XYValue
coord: Coord
}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the pixelDataSchema and integrated it into the plotDataSchema: now each axis and point has the combination of coordinates(pixel) and an actual value

}>
}
Loading