Skip to content

Commit

Permalink
feat: adding using System, adding ColormapModel
Browse files Browse the repository at this point in the history
  • Loading branch information
dbirman committed Mar 29, 2024
1 parent 92bb659 commit f045562
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 9 deletions.
12 changes: 12 additions & 0 deletions models/csharp/DockModels.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
[Serializable]
public struct BucketModel
{
Expand All @@ -11,6 +12,17 @@ public BucketModel(string token, string password)
}
}

[Serializable]
public struct DownloadModel
{
public string Password;

public DownloadModel(string password)
{
Password = password;
}
}

[Serializable]
public struct LoadModel
{
Expand Down
1 change: 1 addition & 0 deletions models/csharp/EphysLinkModels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using System;

[Serializable]
public struct AngularResponse
Expand Down
1 change: 1 addition & 0 deletions models/csharp/GenericModels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using System;
[Serializable]
public struct BoolData
{
Expand Down
1 change: 1 addition & 0 deletions models/csharp/LoggingModels.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
[Serializable]
public struct Log
{
Expand Down
1 change: 1 addition & 0 deletions models/csharp/PinpointModels.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using System;
[Serializable]
public struct CraniotomyGroup
{
Expand Down
24 changes: 19 additions & 5 deletions models/csharp/UrchinModels.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using UnityEngine;
using System;

[Serializable]
public struct AtlasModel
{
public string Name;
public Vector3 ReferenceCoord;
public StructureModel[] Areas;
public string Colormap;
public ColormapModel Colormap;

public AtlasModel(string name, Vector3 referenceCoord, StructureModel[] areas, string colormap)
public AtlasModel(string name, Vector3 referenceCoord, StructureModel[] areas, ColormapModel colormap)
{
Name = name;
ReferenceCoord = referenceCoord;
Expand Down Expand Up @@ -68,6 +69,21 @@ public CameraRotationModel(Vector3 startRotation, Vector3 endRotation)
}
}

[Serializable]
public struct ColormapModel
{
public string Name;
public float Min;
public float Max;

public ColormapModel(string name, float min, float max)
{
Name = name;
Min = min;
Max = max;
}
}


[Serializable]
public struct CustomAtlasModel
Expand Down Expand Up @@ -189,7 +205,6 @@ public PrimitiveMeshModel(MeshModel[] data)
[Serializable]
public struct StructureModel
{
public int Index;
public string Name;
public string Acronym;
public int AtlasId;
Expand All @@ -199,9 +214,8 @@ public struct StructureModel
public int Side;
public string Material;

public StructureModel(int index, string name, string acronym, int atlasId, Color color, bool visible, float colorIntensity, int side, string material)
public StructureModel(string name, string acronym, int atlasId, Color color, bool visible, float colorIntensity, int side, string material)
{
Index = index;
Name = name;
Acronym = acronym;
AtlasId = atlasId;
Expand Down
1 change: 1 addition & 0 deletions models/schemas/dock/DownloadModel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"properties": {"Password": {"title": "Password", "type": "string"}}, "required": ["Password"], "title": "DownloadModel", "type": "object"}
2 changes: 1 addition & 1 deletion models/schemas/urchin/AtlasModel.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"$defs": {"Color": {"properties": {"r": {"maximum": 1.0, "minimum": 0.0, "title": "R", "type": "number"}, "g": {"maximum": 1.0, "minimum": 0.0, "title": "G", "type": "number"}, "b": {"maximum": 1.0, "minimum": 0.0, "title": "B", "type": "number"}, "a": {"default": 1, "maximum": 1.0, "minimum": 0.0, "title": "A", "type": "number"}}, "required": ["r", "g", "b"], "title": "Color", "type": "object"}, "StructureModel": {"properties": {"Index": {"title": "Index", "type": "integer"}, "Name": {"title": "Name", "type": "string"}, "Acronym": {"title": "Acronym", "type": "string"}, "AtlasId": {"title": "Atlasid", "type": "integer"}, "Color": {"$ref": "#/$defs/Color"}, "Visible": {"default": false, "title": "Visible", "type": "boolean"}, "ColorIntensity": {"default": -1, "title": "Colorintensity", "type": "number"}, "Side": {"default": 0, "title": "Side", "type": "integer"}, "Material": {"default": "default", "title": "Material", "type": "string"}}, "required": ["Index", "Name", "Acronym", "AtlasId", "Color"], "title": "StructureModel", "type": "object"}, "Vector3": {"properties": {"x": {"default": 0.0, "title": "X", "type": "number"}, "y": {"default": 0.0, "title": "Y", "type": "number"}, "z": {"default": 0.0, "title": "Z", "type": "number"}}, "title": "Vector3", "type": "object"}}, "properties": {"Name": {"title": "Name", "type": "string"}, "ReferenceCoord": {"allOf": [{"$ref": "#/$defs/Vector3"}], "default": null}, "Areas": {"items": {"$ref": "#/$defs/StructureModel"}, "title": "Areas", "type": "array"}, "Colormap": {"default": "", "title": "Colormap", "type": "string"}}, "required": ["Name", "Areas"], "title": "AtlasModel", "type": "object"}
{"$defs": {"Color": {"properties": {"r": {"maximum": 1.0, "minimum": 0.0, "title": "R", "type": "number"}, "g": {"maximum": 1.0, "minimum": 0.0, "title": "G", "type": "number"}, "b": {"maximum": 1.0, "minimum": 0.0, "title": "B", "type": "number"}, "a": {"default": 1, "maximum": 1.0, "minimum": 0.0, "title": "A", "type": "number"}}, "required": ["r", "g", "b"], "title": "Color", "type": "object"}, "ColormapModel": {"properties": {"Name": {"title": "Name", "type": "string"}, "Min": {"title": "Min", "type": "number"}, "Max": {"title": "Max", "type": "number"}}, "required": ["Name", "Min", "Max"], "title": "ColormapModel", "type": "object"}, "StructureModel": {"properties": {"Name": {"title": "Name", "type": "string"}, "Acronym": {"title": "Acronym", "type": "string"}, "AtlasId": {"title": "Atlasid", "type": "integer"}, "Color": {"$ref": "#/$defs/Color"}, "Visible": {"default": false, "title": "Visible", "type": "boolean"}, "ColorIntensity": {"default": -1, "title": "Colorintensity", "type": "number"}, "Side": {"default": 0, "title": "Side", "type": "integer"}, "Material": {"default": "default", "title": "Material", "type": "string"}}, "required": ["Name", "Acronym", "AtlasId", "Color"], "title": "StructureModel", "type": "object"}, "Vector3": {"properties": {"x": {"default": 0.0, "title": "X", "type": "number"}, "y": {"default": 0.0, "title": "Y", "type": "number"}, "z": {"default": 0.0, "title": "Z", "type": "number"}}, "title": "Vector3", "type": "object"}}, "properties": {"Name": {"title": "Name", "type": "string"}, "ReferenceCoord": {"allOf": [{"$ref": "#/$defs/Vector3"}], "default": null}, "Areas": {"items": {"$ref": "#/$defs/StructureModel"}, "title": "Areas", "type": "array"}, "Colormap": {"$ref": "#/$defs/ColormapModel"}}, "required": ["Name", "Areas", "Colormap"], "title": "AtlasModel", "type": "object"}
1 change: 1 addition & 0 deletions models/schemas/urchin/ColormapModel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"properties": {"Name": {"title": "Name", "type": "string"}, "Min": {"title": "Min", "type": "number"}, "Max": {"title": "Max", "type": "number"}}, "required": ["Name", "Min", "Max"], "title": "ColormapModel", "type": "object"}
2 changes: 1 addition & 1 deletion models/schemas/urchin/StructureModel.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"$defs": {"Color": {"properties": {"r": {"maximum": 1.0, "minimum": 0.0, "title": "R", "type": "number"}, "g": {"maximum": 1.0, "minimum": 0.0, "title": "G", "type": "number"}, "b": {"maximum": 1.0, "minimum": 0.0, "title": "B", "type": "number"}, "a": {"default": 1, "maximum": 1.0, "minimum": 0.0, "title": "A", "type": "number"}}, "required": ["r", "g", "b"], "title": "Color", "type": "object"}}, "properties": {"Index": {"title": "Index", "type": "integer"}, "Name": {"title": "Name", "type": "string"}, "Acronym": {"title": "Acronym", "type": "string"}, "AtlasId": {"title": "Atlasid", "type": "integer"}, "Color": {"$ref": "#/$defs/Color"}, "Visible": {"default": false, "title": "Visible", "type": "boolean"}, "ColorIntensity": {"default": -1, "title": "Colorintensity", "type": "number"}, "Side": {"default": 0, "title": "Side", "type": "integer"}, "Material": {"default": "default", "title": "Material", "type": "string"}}, "required": ["Index", "Name", "Acronym", "AtlasId", "Color"], "title": "StructureModel", "type": "object"}
{"$defs": {"Color": {"properties": {"r": {"maximum": 1.0, "minimum": 0.0, "title": "R", "type": "number"}, "g": {"maximum": 1.0, "minimum": 0.0, "title": "G", "type": "number"}, "b": {"maximum": 1.0, "minimum": 0.0, "title": "B", "type": "number"}, "a": {"default": 1, "maximum": 1.0, "minimum": 0.0, "title": "A", "type": "number"}}, "required": ["r", "g", "b"], "title": "Color", "type": "object"}}, "properties": {"Name": {"title": "Name", "type": "string"}, "Acronym": {"title": "Acronym", "type": "string"}, "AtlasId": {"title": "Atlasid", "type": "integer"}, "Color": {"$ref": "#/$defs/Color"}, "Visible": {"default": false, "title": "Visible", "type": "boolean"}, "ColorIntensity": {"default": -1, "title": "Colorintensity", "type": "number"}, "Side": {"default": 0, "title": "Side", "type": "integer"}, "Material": {"default": "default", "title": "Material", "type": "string"}}, "required": ["Name", "Acronym", "AtlasId", "Color"], "title": "StructureModel", "type": "object"}
2 changes: 2 additions & 0 deletions src/vbl_aquarium/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def remove_ignored_classes(module):
output += pydantic_to_csharp(cclass, cclass.model_json_schema()).strip() + "\n\n"

# Move using statement to top
output = "using System;\n" + output

if "using UnityEngine;" in output:
output = "using UnityEngine;\n" + output.replace("using UnityEngine;", "")

Expand Down
2 changes: 2 additions & 0 deletions src/vbl_aquarium/models/dock.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ class UploadModel(VBLBaseModel):
data: str
password: str

class DownloadModel(VBLBaseModel):
password: str

# Models for sending save/load messages
class SaveModel(VBLBaseModel):
Expand Down
11 changes: 9 additions & 2 deletions src/vbl_aquarium/models/urchin.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,10 @@ class AtlasModel(VBLBaseModel):
name: str
reference_coord: Vector3 = None
areas: list[StructureModel]
colormap: str = ""
colormap: ColormapModel


class StructureModel(VBLBaseModel):
index: int
name: str
acronym: str
atlas_id: int
Expand Down Expand Up @@ -112,3 +111,11 @@ class ParticleGroupModel(VBLBaseModel):
zs: list[float]

colors: list[Color]


# Utilities

class ColormapModel(VBLBaseModel):
name: str
min: float
max: float

0 comments on commit f045562

Please sign in to comment.