DINO-Unity21
Sample Unity 2021 Project for HL2-DINO
Loading...
Searching...
No Matches
ToolConfigUtilities.JSONUtils Class Reference

Public Types

enum  MainFileKeys { fileSettings , tools }
 The top level keys we are expecting to read in the config file.
 
enum  FileSettingsKeys { units }
 The current iteration of 'settings' related to the config object, which should contain right-handed information only, but can have metres or millimetres as units.
 
enum  ToolKeys { name , id , coordinates }
 The info we require for each trackable tool definition as specified in ToolTrackingUtils.TrackedTool.
 

Static Public Member Functions

static bool CheckEnumKeys< TEnum > (JObject jsonObject)
 Template function to validate if a JObject contains some desired keys.
 
static JObject TryReadingToolConfigJSON (string filepath)
 Function which returns a properly populated JObject if it matches the expected config file structure for this app.
 
static List< TrackedToolCreateTrackedToolsetFromJSON (JObject configObject)
 Reads configObject and tries to return a list of TrackedTool based on info contained in the JObject.
 
static bool IsValidToolPacket (JObject toolObject, JObject configSettings, ref int integerID, ref string stringID, ref List< Vector3 > CoordinateSet)
 Reads the toolObject and then tries to populate the other fields passed in if valid.
 
static List< Vector3 > GetCoordinatesList (JObject toolObject, JObject configSettings)
 Construct a List of Vector3 of marker coordinate centres, as parsed from toolObject.
 
static string GetJSONToolStringHL2 (string JSONFilepath)
 Publicly available helper function, to prepare a JSON string to pass into the HL2-DINO-DLL which will be used to set up the Tool Dictionary on the C++ side.
 

Static Private Member Functions

static bool IsValidCoordinateArray (JToken coordinateSet)
 Helper function to check we have an array of 3 values.
 
static JObject PrepareJObjectForHL2 (JObject configObject)
 A sanitising function which checks.
 

Member Function Documentation

◆ CheckEnumKeys< TEnum >()

static bool ToolConfigUtilities.JSONUtils.CheckEnumKeys< TEnum > ( JObject  jsonObject)
inlinestatic

Template function to validate if a JObject contains some desired keys.

Template Parameters
TEnumEnum of keys to check against
Parameters
jsonObjectJObject to 'validate'
Returns

True only if all keys in

TEnum are contained in

jsonObject

Type Constraints
TEnum :System.Enum 

◆ CreateTrackedToolsetFromJSON()

static List< TrackedTool > ToolConfigUtilities.JSONUtils.CreateTrackedToolsetFromJSON ( JObject  configObject)
inlinestatic

Reads configObject and tries to return a list of TrackedTool based on info contained in the JObject.

Parameters
configObjectConfiguration JSON object to parse
Returns
A list of TrackedTool if valid

◆ GetCoordinatesList()

static List< Vector3 > ToolConfigUtilities.JSONUtils.GetCoordinatesList ( JObject  toolObject,
JObject  configSettings 
)
inlinestatic

Construct a List of Vector3 of marker coordinate centres, as parsed from toolObject.

Parameters
toolObjectJSON object to parse
configSettingsFile settings
Returns
A list of marker coordinates if valid, empty list otherwise

◆ GetJSONToolStringHL2()

static string ToolConfigUtilities.JSONUtils.GetJSONToolStringHL2 ( string  JSONFilepath)
inlinestatic

Publicly available helper function, to prepare a JSON string to pass into the HL2-DINO-DLL which will be used to set up the Tool Dictionary on the C++ side.

Parameters
JSONFilepathJSON filepath
Returns
Formatted JSON string, if filepath contains a valid JSON file. Empty string otherwise

◆ IsValidCoordinateArray()

static bool ToolConfigUtilities.JSONUtils.IsValidCoordinateArray ( JToken  coordinateSet)
inlinestaticprivate

Helper function to check we have an array of 3 values.

Parameters
coordinateSet
Returns

◆ IsValidToolPacket()

static bool ToolConfigUtilities.JSONUtils.IsValidToolPacket ( JObject  toolObject,
JObject  configSettings,
ref int  integerID,
ref string  stringID,
ref List< Vector3 >  CoordinateSet 
)
inlinestatic

Reads the toolObject and then tries to populate the other fields passed in if valid.

Parameters
toolObjectThe JSON equivalent of a TrackedTool
configSettingsFile settings
integerIDTool ID (numeric)
stringIDTool String ID (for labelling)
CoordinateSetVector3 coordinate list (for positioning objects)
Returns
True if toolObject contains all the necessary info, false otherwise

◆ PrepareJObjectForHL2()

static JObject ToolConfigUtilities.JSONUtils.PrepareJObjectForHL2 ( JObject  configObject)
inlinestaticprivate

A sanitising function which checks.

Parameters
configObjectis in the right format for the HL2-DINO Plugin (only works in metres in this version)
configObject
Returns
Reconfigured JObject which should have all coordinates in metres.

◆ TryReadingToolConfigJSON()

static JObject ToolConfigUtilities.JSONUtils.TryReadingToolConfigJSON ( string  filepath)
inlinestatic

Function which returns a properly populated JObject if it matches the expected config file structure for this app.

Parameters
filepathString filepath for .json config file
Returns
Null if invalid, or a JObject if valid

The documentation for this class was generated from the following file: