Skip to content

Commit 8cfe668

Browse files
committed
Merge branch 'development'
2 parents 0165af9 + a3c6c38 commit 8cfe668

12 files changed

Lines changed: 229 additions & 22 deletions

File tree

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "typedb-studio",
3-
"version": "3.3.0",
3+
"version": "3.3.1",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
@@ -58,6 +58,7 @@
5858
"@sanity/types" : "3.14.4",
5959
"@types/chroma-js": "3.1.1",
6060
"@types/jasmine": "~5.1.0",
61+
"graphology-types": "0.24.8",
6162
"jasmine-core": "~5.1.0",
6263
"karma": "~6.4.0",
6364
"karma-chrome-launcher": "~3.2.0",

pnpm-lock.yaml

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "typedb-studio"
3-
version = "3.3.0"
3+
version = "3.3.1"
44
description = "A Tauri App"
55
authors = ["you"]
66
edition = "2021"

src-tauri/tauri.conf.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"$schema": "https://schema.tauri.app/config/2",
33
"productName": "TypeDB Studio",
4-
"version": "3.3.0",
4+
"version": "3.3.1",
55
"identifier": "com.typedb.studio",
66
"build": {
77
"beforeDevCommand": "pnpm start",

src/framework/graph-visualiser/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {DataVertex, DataVertexKind, VertexUnavailable} from "./graph";
33
import {Color} from "chroma-js";
44

55
export interface StudioConverterStyleParameters {
6-
vertex_colors: Record<DataVertexKind, Color>,
6+
vertex_colors: Record<DataVertexKind, string>,
77
vertex_shapes: Record<DataVertexKind, string>,
88
vertex_size: number,
99

src/framework/graph-visualiser/converter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class StudioConverter implements ILogicalGraphConverter {
5151
const shape = this.styleParameters.vertex_shapes[vertex.kind];
5252
return {
5353
label: this.styleParameters.vertex_default_label(vertex),
54-
color: color.hex(),
54+
color: color,
5555
size: vertex.kind === "roleType" ? 5 : this.styleParameters.vertex_size,
5656
type: shape,
5757
x: Math.random(),

src/framework/graph-visualiser/defaults.ts

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,47 @@ import EdgeCurveProgram from "@sigma/edge-curve";
77
import {ForceLayoutSettings} from "graphology-layout-force";
88
import {Settings as SigmaSettings} from "sigma/settings";
99
import {StudioConverterStructureParameters, StudioConverterStyleParameters} from "./config";
10+
import { NodeDiamondProgram } from "./node-diamond";
11+
12+
const darkPalette = {
13+
black: "#09022F",
14+
blue1: "#7BA0FF",
15+
green: "#02DAC9",
16+
orange: "#B0740C",
17+
yellow: "#F6C94C",
18+
pink: "#FF87DC",
19+
purple1: "#0E0D17",
20+
purple2: "#14121F",
21+
purple3: "#151322",
22+
purple4: "#1A182A",
23+
purple5: "#232135",
24+
purple6: "#2D2A46",
25+
red1: "#CF4A55",
26+
red2: "#FF8080",
27+
white: "#FFFFFF",
28+
white2: "#D5CCFF"
29+
};
1030

1131
export const defaultQueryStyleParameters: StudioConverterStyleParameters = {
1232
vertex_colors: {
13-
entity: chroma("pink"),
14-
relation: chroma("yellow"),
15-
attribute: chroma("green"),
16-
entityType: chroma("magenta"),
17-
relationType: chroma("orange"),
18-
attributeType: chroma("darkgreen"),
19-
roleType: chroma("darkorange"),
20-
value: chroma("grey"),
21-
unavailable: chroma("darkgrey"),
22-
expression: chroma("white"),
23-
functionCall: chroma("white")
33+
entity: darkPalette.pink,
34+
relation: darkPalette.yellow,
35+
attribute: darkPalette.blue1,
36+
entityType: darkPalette.pink,
37+
relationType: darkPalette.yellow,
38+
attributeType: darkPalette.blue1,
39+
roleType: darkPalette.orange,
40+
value: "#999",
41+
unavailable: "#666",
42+
expression: darkPalette.white2,
43+
functionCall: darkPalette.white2,
2444
},
2545
vertex_shapes: {
26-
entity: "circle",
27-
relation: "square",
46+
entity: "square",
47+
relation: "diamond",
2848
attribute: "circle",
29-
entityType: "circle",
30-
relationType: "square",
49+
entityType: "square",
50+
relationType: "diamond",
3151
attributeType: "circle",
3252
roleType: "circle",
3353
value: "circle",
@@ -139,6 +159,7 @@ export const defaultSigmaSettings: Partial<SigmaSettings> = {
139159
renderEdgeLabels: true,
140160
nodeProgramClasses: {
141161
square: NodeSquareProgram,
162+
diamond: NodeDiamondProgram,
142163
},
143164
edgeProgramClasses: {
144165
curved: EdgeCurveProgram,
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { Attributes } from "graphology-types";
2+
import { NodeProgram, ProgramInfo } from "sigma/rendering";
3+
import { NodeDisplayData, RenderParams } from "sigma/types";
4+
import { floatColor } from "sigma/utils";
5+
6+
import FRAGMENT_SHADER_SOURCE from "./shader-frag";
7+
import VERTEX_SHADER_SOURCE from "./shader-vert";
8+
import { drawSquareNodeHover, drawSquareNodeLabel } from "./utils";
9+
10+
const { UNSIGNED_BYTE, FLOAT } = WebGLRenderingContext;
11+
12+
const UNIFORMS = ["u_sizeRatio", "u_correctionRatio", "u_cameraAngle", "u_matrix"] as const;
13+
14+
const PI = Math.PI;
15+
16+
export class NodeDiamondProgram<
17+
N extends Attributes = Attributes,
18+
E extends Attributes = Attributes,
19+
G extends Attributes = Attributes,
20+
> extends NodeProgram<(typeof UNIFORMS)[number], N, E, G> {
21+
override drawHover = drawSquareNodeHover;
22+
override drawLabel = drawSquareNodeLabel;
23+
24+
getDefinition() {
25+
return {
26+
VERTICES: 6,
27+
VERTEX_SHADER_SOURCE: VERTEX_SHADER_SOURCE,
28+
FRAGMENT_SHADER_SOURCE: FRAGMENT_SHADER_SOURCE,
29+
METHOD: WebGLRenderingContext.TRIANGLES,
30+
UNIFORMS,
31+
ATTRIBUTES: [
32+
{ name: "a_position", size: 2, type: FLOAT },
33+
{ name: "a_size", size: 1, type: FLOAT },
34+
{ name: "a_color", size: 4, type: UNSIGNED_BYTE, normalized: true },
35+
{ name: "a_id", size: 4, type: UNSIGNED_BYTE, normalized: true },
36+
],
37+
CONSTANT_ATTRIBUTES: [{ name: "a_angle", size: 1, type: FLOAT }],
38+
CONSTANT_DATA: [[PI / 4], [(3 * PI) / 4], [-PI / 4], [(3 * PI) / 4], [-PI / 4], [(-3 * PI) / 4]],
39+
};
40+
}
41+
42+
processVisibleItem(nodeIndex: number, startIndex: number, data: NodeDisplayData) {
43+
const array = this.array;
44+
const color = floatColor(data.color);
45+
46+
array[startIndex++] = data.x;
47+
array[startIndex++] = data.y;
48+
array[startIndex++] = data.size;
49+
array[startIndex++] = color;
50+
array[startIndex++] = nodeIndex;
51+
}
52+
53+
setUniforms(params: RenderParams, { gl, uniformLocations }: ProgramInfo): void {
54+
const { u_sizeRatio, u_correctionRatio, u_cameraAngle, u_matrix } = uniformLocations;
55+
56+
gl.uniform1f(u_sizeRatio, params.sizeRatio);
57+
gl.uniform1f(u_cameraAngle, params.cameraAngle);
58+
gl.uniform1f(u_correctionRatio, params.correctionRatio);
59+
gl.uniformMatrix3fv(u_matrix, false, params.matrix);
60+
}
61+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// language=GLSL
2+
const SHADER_SOURCE = /*glsl*/ `
3+
precision mediump float;
4+
5+
varying vec4 v_color;
6+
7+
void main(void) {
8+
gl_FragColor = v_color;
9+
}
10+
`;
11+
12+
export default SHADER_SOURCE;

0 commit comments

Comments
 (0)