Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 205c8dbf5a |
@@ -1,107 +0,0 @@
|
||||
version: 2.1
|
||||
|
||||
orbs:
|
||||
aws-s3: circleci/aws-s3@2.0.0
|
||||
|
||||
parameters:
|
||||
marketplace-deploy:
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
commands:
|
||||
zip-source:
|
||||
parameters:
|
||||
target:
|
||||
type: string
|
||||
outputdir:
|
||||
type: string
|
||||
steps:
|
||||
- run:
|
||||
name: "Create Archive"
|
||||
command: |
|
||||
\cp -r ".pluginconfig/<<parameters.target>>/." "./"
|
||||
mkdir -p "<<parameters.outputdir>>/"
|
||||
stashName=`git stash create`;
|
||||
git archive -o "<<parameters.outputdir>>/speckle-unreal-UE<<parameters.target>>.zip" --worktree-attributes --prefix="speckle-unreal/" $stashName
|
||||
|
||||
add-source-copyright:
|
||||
parameters:
|
||||
copyright-string:
|
||||
type: string
|
||||
steps:
|
||||
- run: #Remove BOM header, then add copyright comment
|
||||
name: "Add copyright notice to source files"
|
||||
command: |
|
||||
shopt -s globstar
|
||||
for file in Source/**/*.{cpp,hpp,c,h,cs};
|
||||
do if [ -f $file ]; then
|
||||
sed -i '1s/^\xEF\xBB\xBF//' $file;
|
||||
sed -i '1s/^/\/\/ <<parameters.copyright-string>>\n/' $file;
|
||||
echo "added copyright notice to $file";
|
||||
fi;
|
||||
done;
|
||||
|
||||
jobs:
|
||||
generate-source-zip:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
parameters:
|
||||
target:
|
||||
type: string
|
||||
steps:
|
||||
- checkout
|
||||
- add-source-copyright:
|
||||
copyright-string: "Copyright AEC SYSTEMS 2023"
|
||||
- zip-source:
|
||||
target: <<parameters.target>>
|
||||
outputdir: "output/unreal/<<parameters.target>>"
|
||||
- store_artifacts:
|
||||
path: "output/unreal/<<parameters.target>>"
|
||||
destination: "unreal-marketplace/<<parameters.target>>"
|
||||
- persist_to_workspace:
|
||||
root: ./
|
||||
paths:
|
||||
- "output/unreal/<<parameters.target>>"
|
||||
|
||||
marketplace-deploy:
|
||||
docker:
|
||||
- image: cimg/base:stable
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: ./
|
||||
- aws-s3/copy:
|
||||
arguments: "--recursive --endpoint=https://$SPACES_REGION.digitaloceanspaces.com --acl public-read"
|
||||
aws-access-key-id: SPACES_KEY
|
||||
aws-region: SPACES_REGION
|
||||
aws-secret-access-key: SPACES_SECRET
|
||||
from: '"output"'
|
||||
to: s3://speckle-releases/installers/
|
||||
|
||||
workflows:
|
||||
marketplace-publish:
|
||||
when: <<pipeline.parameters.marketplace-deploy>>
|
||||
jobs:
|
||||
- generate-source-zip:
|
||||
name: "Generate Source Archive UE4.27"
|
||||
target: "4.27"
|
||||
- generate-source-zip:
|
||||
name: "Generate Source Archive UE5.0"
|
||||
target: "5.0"
|
||||
- generate-source-zip:
|
||||
name: "Generate Source Archive UE5.1"
|
||||
target: "5.1"
|
||||
- generate-source-zip:
|
||||
name: "Generate Source Archive UE5.2"
|
||||
target: "5.2"
|
||||
- hold:
|
||||
type: approval
|
||||
requires:
|
||||
- "Generate Source Archive UE4.27"
|
||||
- "Generate Source Archive UE5.0"
|
||||
- "Generate Source Archive UE5.1"
|
||||
- "Generate Source Archive UE5.2"
|
||||
- marketplace-deploy:
|
||||
name: "Deploy to marketplace"
|
||||
context: do-spaces-speckle-releases
|
||||
requires:
|
||||
- hold
|
||||
@@ -1 +0,0 @@
|
||||
.pluginconfig/* export-ignore
|
||||
@@ -6,7 +6,73 @@ on:
|
||||
|
||||
jobs:
|
||||
update_issue:
|
||||
uses: specklesystems/github-actions/.github/workflows/project-add-issue.yml@main
|
||||
secrets: inherit
|
||||
with:
|
||||
issue-id: ${{ github.event.issue.node_id }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get project data
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
|
||||
ORGANIZATION: specklesystems
|
||||
PROJECT_NUMBER: 9
|
||||
run: |
|
||||
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
|
||||
query($org: String!, $number: Int!) {
|
||||
organization(login: $org){
|
||||
projectNext(number: $number) {
|
||||
id
|
||||
fields(first:20) {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
settings
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
|
||||
|
||||
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
|
||||
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
||||
|
||||
echo "$PROJECT_ID"
|
||||
echo "$STATUS_FIELD_ID"
|
||||
|
||||
echo 'DONE_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .settings | fromjson | .options[] | select(.name== "Done") | .id' project_data.json) >> $GITHUB_ENV
|
||||
echo "$DONE_ID"
|
||||
|
||||
- name: Add Issue to project #it's already in the project, but we do this to get its node id!
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
|
||||
ISSUE_ID: ${{ github.event.issue.node_id }}
|
||||
run: |
|
||||
item_id="$( gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
|
||||
mutation($project:ID!, $id:ID!) {
|
||||
addProjectNextItem(input: {projectId: $project, contentId: $id}) {
|
||||
projectNextItem {
|
||||
id
|
||||
}
|
||||
}
|
||||
}' -f project=$PROJECT_ID -f id=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
|
||||
|
||||
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
||||
|
||||
- name: Update Status
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
|
||||
ISSUE_ID: ${{ github.event.issue.node_id }}
|
||||
run: |
|
||||
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
|
||||
mutation($project:ID!, $status:ID!, $id:ID!, $value:String!) {
|
||||
set_status: updateProjectNextItemField(
|
||||
input: {
|
||||
projectId: $project
|
||||
itemId: $id
|
||||
fieldId: $status
|
||||
value: $value
|
||||
}
|
||||
) {
|
||||
projectNextItem {
|
||||
id
|
||||
}
|
||||
}
|
||||
}' -f project=$PROJECT_ID -f status=$STATUS_FIELD_ID -f id=$ITEM_ID -f value=${{ env.DONE_ID }}
|
||||
|
||||
|
||||
@@ -6,7 +6,45 @@ on:
|
||||
|
||||
jobs:
|
||||
track_issue:
|
||||
uses: specklesystems/github-actions/.github/workflows/project-add-issue.yml@main
|
||||
secrets: inherit
|
||||
with:
|
||||
issue-id: ${{ github.event.issue.node_id }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Get project data
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
|
||||
ORGANIZATION: specklesystems
|
||||
PROJECT_NUMBER: 9
|
||||
run: |
|
||||
gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
|
||||
query($org: String!, $number: Int!) {
|
||||
organization(login: $org){
|
||||
projectNext(number: $number) {
|
||||
id
|
||||
fields(first:20) {
|
||||
nodes {
|
||||
id
|
||||
name
|
||||
settings
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}' -f org=$ORGANIZATION -F number=$PROJECT_NUMBER > project_data.json
|
||||
|
||||
echo 'PROJECT_ID='$(jq '.data.organization.projectNext.id' project_data.json) >> $GITHUB_ENV
|
||||
echo 'STATUS_FIELD_ID='$(jq '.data.organization.projectNext.fields.nodes[] | select(.name== "Status") | .id' project_data.json) >> $GITHUB_ENV
|
||||
|
||||
- name: Add Issue to project
|
||||
env:
|
||||
GITHUB_TOKEN: ${{secrets.GHPROJECT_TOKEN}}
|
||||
ISSUE_ID: ${{ github.event.issue.node_id }}
|
||||
run: |
|
||||
item_id="$( gh api graphql --header 'GraphQL-Features: projects_next_graphql' -f query='
|
||||
mutation($project:ID!, $id:ID!) {
|
||||
addProjectNextItem(input: {projectId: $project, contentId: $id}) {
|
||||
projectNextItem {
|
||||
id
|
||||
}
|
||||
}
|
||||
}' -f project=$PROJECT_ID -f id=$ISSUE_ID --jq '.data.addProjectNextItem.projectNextItem.id')"
|
||||
|
||||
echo 'ITEM_ID='$item_id >> $GITHUB_ENV
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
.gitattributes export-ignore
|
||||
.github/* export-ignore
|
||||
.circleci/* export-ignore
|
||||
.circleci/ export-ignore
|
||||
.pluginconfig/* export-ignore
|
||||
LICENSE export-ignore
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "2.15.1",
|
||||
"FriendlyName": "Speckle Unreal",
|
||||
"Description": "Speckle is an open source data platform for Architecture, Engineering, and Construction. It has been open sourced under the Apache License 2.0, is customizable, and available in the cloud or via a self-hosted server. It allows users to exchange data between various AEC modelling and content creation platforms.",
|
||||
"Category": "AEC",
|
||||
"CreatedBy": "Speckle",
|
||||
"CreatedByURL": "https://speckle.systems/",
|
||||
"DocsURL": "https://github.com/specklesystems/speckle-unreal",
|
||||
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/98770ce9d4f143de8dd7882a707a6f81",
|
||||
"SupportURL": "https://speckle.community/",
|
||||
"CanContainContent": true,
|
||||
"IsBetaVersion": true,
|
||||
"IsExperimentalVersion": false,
|
||||
"Installed": false,
|
||||
"EngineVersion": "4.27",
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "SpeckleUnreal",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default",
|
||||
"WhitelistPlatforms": [ "Win64", "Linux", "Mac" ]
|
||||
},
|
||||
{
|
||||
"Name": "SpeckleUnrealEditor",
|
||||
"Type": "Editor",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [ "Win64", "Linux", "Mac" ]
|
||||
}
|
||||
],
|
||||
"Plugins": [
|
||||
{
|
||||
"Name": "ProceduralMeshComponent",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "LidarPointCloud",
|
||||
"Enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
.gitattributes export-ignore
|
||||
.github/* export-ignore
|
||||
.circleci/* export-ignore
|
||||
.circleci/ export-ignore
|
||||
.pluginconfig/* export-ignore
|
||||
LICENSE export-ignore
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "2.15.1",
|
||||
"FriendlyName": "Speckle Unreal",
|
||||
"Description": "Speckle is an open source data platform for Architecture, Engineering, and Construction. It has been open sourced under the Apache License 2.0, is customizable, and available in the cloud or via a self-hosted server. It allows users to exchange data between various AEC modelling and content creation platforms.",
|
||||
"Category": "AEC",
|
||||
"CreatedBy": "Speckle",
|
||||
"CreatedByURL": "https://speckle.systems/",
|
||||
"DocsURL": "https://github.com/specklesystems/speckle-unreal",
|
||||
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/98770ce9d4f143de8dd7882a707a6f81",
|
||||
"SupportURL": "https://speckle.community/",
|
||||
"CanContainContent": true,
|
||||
"IsBetaVersion": true,
|
||||
"IsExperimentalVersion": false,
|
||||
"Installed": false,
|
||||
"EngineVersion": "5.0",
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "SpeckleUnreal",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default",
|
||||
"WhitelistPlatforms": [ "Win64", "Linux", "Mac" ]
|
||||
},
|
||||
{
|
||||
"Name": "SpeckleUnrealEditor",
|
||||
"Type": "Editor",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [ "Win64", "Linux", "Mac" ]
|
||||
}
|
||||
],
|
||||
"Plugins": [
|
||||
{
|
||||
"Name": "ProceduralMeshComponent",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "LidarPointCloud",
|
||||
"Enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
.gitattributes export-ignore
|
||||
.github/* export-ignore
|
||||
.circleci/* export-ignore
|
||||
.circleci/ export-ignore
|
||||
.pluginconfig/* export-ignore
|
||||
LICENSE export-ignore
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "2.15.1",
|
||||
"FriendlyName": "Speckle Unreal",
|
||||
"Description": "Speckle is an open source data platform for Architecture, Engineering, and Construction. It has been open sourced under the Apache License 2.0, is customizable, and available in the cloud or via a self-hosted server. It allows users to exchange data between various AEC modelling and content creation platforms.",
|
||||
"Category": "AEC",
|
||||
"CreatedBy": "Speckle",
|
||||
"CreatedByURL": "https://speckle.systems/",
|
||||
"DocsURL": "https://github.com/specklesystems/speckle-unreal",
|
||||
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/98770ce9d4f143de8dd7882a707a6f81",
|
||||
"SupportURL": "https://speckle.community/",
|
||||
"CanContainContent": true,
|
||||
"IsBetaVersion": true,
|
||||
"IsExperimentalVersion": false,
|
||||
"Installed": false,
|
||||
"EngineVersion": "5.1",
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "SpeckleUnreal",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default",
|
||||
"WhitelistPlatforms": [ "Win64", "Linux", "Mac" ]
|
||||
},
|
||||
{
|
||||
"Name": "SpeckleUnrealEditor",
|
||||
"Type": "Editor",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [ "Win64", "Linux", "Mac" ]
|
||||
}
|
||||
],
|
||||
"Plugins": [
|
||||
{
|
||||
"Name": "ProceduralMeshComponent",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "LidarPointCloud",
|
||||
"Enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
.gitattributes export-ignore
|
||||
.github/* export-ignore
|
||||
.circleci/* export-ignore
|
||||
.circleci/ export-ignore
|
||||
.pluginconfig/* export-ignore
|
||||
LICENSE export-ignore
|
||||
@@ -1,42 +0,0 @@
|
||||
{
|
||||
"FileVersion": 3,
|
||||
"Version": 1,
|
||||
"VersionName": "2.15.1",
|
||||
"FriendlyName": "Speckle Unreal",
|
||||
"Description": "Speckle is an open source data platform for Architecture, Engineering, and Construction. It has been open sourced under the Apache License 2.0, is customizable, and available in the cloud or via a self-hosted server. It allows users to exchange data between various AEC modelling and content creation platforms.",
|
||||
"Category": "AEC",
|
||||
"CreatedBy": "Speckle",
|
||||
"CreatedByURL": "https://speckle.systems/",
|
||||
"DocsURL": "https://github.com/specklesystems/speckle-unreal",
|
||||
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/98770ce9d4f143de8dd7882a707a6f81",
|
||||
"SupportURL": "https://speckle.community/",
|
||||
"CanContainContent": true,
|
||||
"IsBetaVersion": true,
|
||||
"IsExperimentalVersion": false,
|
||||
"Installed": false,
|
||||
"EngineVersion": "5.2",
|
||||
"Modules": [
|
||||
{
|
||||
"Name": "SpeckleUnreal",
|
||||
"Type": "Runtime",
|
||||
"LoadingPhase": "Default",
|
||||
"WhitelistPlatforms": [ "Win64", "Linux", "Mac" ]
|
||||
},
|
||||
{
|
||||
"Name": "SpeckleUnrealEditor",
|
||||
"Type": "Editor",
|
||||
"LoadingPhase": "PostEngineInit",
|
||||
"WhitelistPlatforms": [ "Win64", "Linux", "Mac" ]
|
||||
}
|
||||
],
|
||||
"Plugins": [
|
||||
{
|
||||
"Name": "ProceduralMeshComponent",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "LidarPointCloud",
|
||||
"Enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
[CoreRedirects]
|
||||
+FunctionRedirects=(OldName="/Script/SpeckleUnreal.ObjectModelRegistry.FindClosestType",NewName="/Script/SpeckleUnreal.ObjectModelRegistry.GetAtomicType")
|
||||
@@ -1,2 +1,8 @@
|
||||
[FilterPlugin]
|
||||
/README.md
|
||||
; This section lists additional files which will be packaged along with your plugin. Paths should be listed relative to the root plugin directory, and
|
||||
; may include "...", "*", and "?" wildcards to match directories, files, and individual characters respectively.
|
||||
;
|
||||
; Examples:
|
||||
; /README.txt
|
||||
; /Extras/...
|
||||
; /Binaries/ThirdParty/*.dll
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,63 +1,34 @@
|
||||
# Speckle for Unreal Engine
|
||||
# Speckle Unreal
|
||||
|
||||
[](https://twitter.com/SpeckleSystems) [](https://speckle.community) [](https://speckle.systems) [](https://speckle.guide/user/unreal.html)
|
||||
[](https://twitter.com/SpeckleSystems) [](https://speckle.community) [](https://speckle.systems) [](https://speckle.guide/dev/)
|
||||
|
||||
Speckle makes integrating Unreal Engine with your 3D workflows even easier. </br>
|
||||
This plugin connects Unreal Engine to Speckle, allowing you to receive your versioned 3D data from Speckle inside Unreal Engine,
|
||||
enabling interoperable collaboration between Unreal and other Speckle connectors (Revit, Rhino, Blender, Sketchup, Unity, AutoCAD, [and more!](https://speckle.systems/features/connectors/))
|
||||
Plugin for Unreal Engine to import objects from Speckle v2.
|
||||
|
||||
|
||||
https://user-images.githubusercontent.com/45512892/187969471-3f548b17-3388-48ee-a07c-bd3a0ecf5149.mp4
|
||||
Screencast of an example: https://user-images.githubusercontent.com/2551138/114720093-61403e00-9d40-11eb-8045-6e8ca656554d.mp4
|
||||
|
||||
|
||||
Checkout our dedicated [Tutorials and Docs](https://speckle.systems/tag/unreal/).
|
||||
|
||||
If you are enjoying using Speckle, don't forget to ⭐ our [GitHub repositories](https://github.com/specklesystems),
|
||||
and [join our community forum](https://speckle.community/) where you can post any questions, suggestions, and discuss exciting projects!
|
||||
|
||||
## Notice
|
||||
|
||||
We officially support Unreal Engine 4.27, 5.0, 5.1, 5.2
|
||||
|
||||
**Features**:
|
||||
- [Receiving Speckle geometry as Actors in editor and standalone runtime](https://speckle.systems/tutorials/getting-started-with-speckle-for-unreal/).
|
||||
- [Material override/substitiution](https://speckle.guide/user/unreal.html#material-converter).
|
||||
- [Blueprint nodes for receiving and converting objects](https://speckle.guide/user/unreal.html#usage-blueprint).
|
||||
- [Blueprint nodes for fetching stream/branch/commit/user details](https://speckle.systems/tutorials/unreal-engine-blueprint-nodes-fetch-stream-branch-commit-info-and-more/).
|
||||
- [Ability to write/extend custom conversion functions in C++/BP](https://speckle.systems/tutorials/unreal-developing-custom-conversion-logic/).
|
||||
|
||||
**Supported Conversions**:
|
||||
|
||||
Speckle Type | | Native Type |
|
||||
| ---: | :---: | :--- |
|
||||
| [`Objects.Geometry.Mesh`](https://github.com/specklesystems/speckle-sharp/blob/main/Objects/Objects/Geometry/Mesh.cs) | → | [Static Mesh Component](https://docs.unrealengine.com/4.27/en-US/API/Runtime/Engine/Components/UStaticMeshComponent/) /<br/> [Procedural Mesh Component](https://docs.unrealengine.com/4.27/en-US/API/Plugins/ProceduralMeshComponent/UProceduralMeshComponent/) |
|
||||
| [`Objects.Geometry.PointCloud`](https://github.com/specklesystems/speckle-sharp/blob/main/Objects/Objects/Geometry/Pointcloud.cs) | → | [LiDAR Point Cloud](https://docs.unrealengine.com/4.27/en-US/WorkingWithContent/LidarPointCloudPlugin/LidarPointCloudPluginReference/) |
|
||||
| [`Objects.Other.Instance`](https://github.com/specklesystems/speckle-sharp/blob/main/Objects/Objects/Other/Instance.cs) | → | Actor with Transform |
|
||||
| [`Objects.BuiltElements.View`](https://github.com/specklesystems/speckle-sharp/blob/main/Objects/Objects/BuiltElements/View.cs) | → | [Camera](https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Framework/Camera/) |
|
||||
|
||||
**Supported platforms**: Windows, Linux, MacOS
|
||||
*Other platforms may work, but currently untested*.
|
||||
|
||||
|
||||
**Limitations**:
|
||||
- Currently no support for sending Unreal geometry to Speckle.
|
||||
- Does not use the .NET or Python SDK, or the Speckle Kit based workflow, all code is in native C++/BP.
|
||||
- Does not use our shared [Desktop UI 2](https://speckle.guide/user/ui2.html), only a simple editor UI is currently provided.
|
||||
- Does not fetch [accounts from Speckle Manager](https://speckle.guide/user/manager.html#logging-in-adding-accounts), you must generate a [personal access token (auth token)](https://speckle.guide/dev/tokens.html#personal-access-tokens) to receive non-public streams.
|
||||
## NOTICE
|
||||
|
||||
## How to install
|
||||
* Our Unreal Connector is in an beta stage of development. Currently we only support receiving objects, and there is no UI to fetch lists of streams/commits/branches.
|
||||
* We officially support Unreal Engine 4.26 and 4.27, and have experimental support for UE5.
|
||||
* Does not use the Speckle Kit workflow as conversions all happen in C++.
|
||||
|
||||
**Speckle for Unreal Engine** can be installed through the [Unreal Engine Marketplace](https://www.unrealengine.com/marketplace/en-US/product/speckle-for-unreal-engine).
|
||||
## How To Install
|
||||
|
||||
---
|
||||
|
||||
Alternatively, developers may prefer to install manually.
|
||||
1. Git clone [this repo](https://github.com/specklesystems/speckle-unreal) (or download and extract the [archive zip](https://github.com/specklesystems/speckle-unreal/archive/refs/heads/main.zip)) into your project's `Plugins` directory (created as needed)
|
||||
2. Open/Restart your Unreal project. This will build the plugin for your environment.
|
||||
1. Download `speckle-unreal` repository archive from https://github.com/specklesystems/speckle-unreal/archive/refs/heads/main.zip
|
||||
1. Extract the downloaded archive into your project's `Plugins` directory (if your project directory doesn't contain a directory called Plugins, you should create it)
|
||||
1. Open your UE project (or restart the editor if you already have it opened). This will build the plugin in your environment.
|
||||
|
||||
We will eventually look to distributing the plugin officially on the Unreal Engine Marketplace but for now you'll need to install the plugin manually like this.
|
||||
|
||||
See our [docs](https://speckle.guide/user/unreal.html) for usage instructions.
|
||||
|
||||
If you encounter build issues, try building your project from VS/Rider directly. Look at the `Saved\Logs\` files for error messages,
|
||||
and don't hesitate to reach out on our [community forums](https://speckle.community) for help!
|
||||
## Credits
|
||||
Based off the original Unreal integration for Speckle v1 by Mark and Jak which can be found here: [https://github.com/mobiusnode/SpeckleUnreal](https://github.com/mobiusnode/SpeckleUnreal).
|
||||
|
||||
https://user-images.githubusercontent.com/2551138/114720051-571e3f80-9d40-11eb-9099-d3394747a1d3.mp4
|
||||
|
||||
For contributing to any of our code repositories, please make sure you read the [contribution guidelines](https://github.com/specklesystems/speckle-sharp/blob/main/.github/CONTRIBUTING.md) for an overview of the best practices we try to follow.
|
||||
|
||||
@@ -1,17 +1,220 @@
|
||||
|
||||
#include "API/ClientAPI.h"
|
||||
#include "API/ClientAPI.h"
|
||||
|
||||
#include "HttpModule.h"
|
||||
#include "JsonObjectConverter.h"
|
||||
#include "Interfaces/IHttpResponse.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "Mixpanel.h"
|
||||
#include "Objects/HighLevel/SpeckleBranch.h"
|
||||
#include "Objects/HighLevel/SpeckleCommit.h"
|
||||
#include "Objects/HighLevel/SpeckleGlobals.h"
|
||||
#include "Objects/HighLevel/SpeckleUser.h"
|
||||
#include "Transports/Transport.h"
|
||||
|
||||
void FClientAPI::MakeGraphQLRequest(const FString& ServerUrl, const FString& AuthToken,
|
||||
const FString& ResponsePropertyName,
|
||||
const FString& PostPayload, const FString& RequestLogName,
|
||||
const FAPIResponceDelegate OnCompleteAction, const FErrorDelegate OnErrorAction)
|
||||
|
||||
void FClientAPI::StreamsGet(const FString& ServerUrl, const FString& AuthToken,
|
||||
const int Limit,
|
||||
const FFetchStreamDelegate OnCompleteAction, const FErrorDelegate OnErrorAction)
|
||||
{
|
||||
const FString RequestLogName = FString(__FUNCTION__);
|
||||
|
||||
const FString PostPayload =
|
||||
"{\"query\": \"query{user {streams(limit:" + FString::FromInt(Limit) + ") {totalCount items {id name description updatedAt createdAt isPublic role collaborators{id name role company avatar}}}}}\"}";
|
||||
|
||||
auto OnError = [=](const FString& Message) mutable
|
||||
{
|
||||
ensureAlwaysMsgf(OnErrorAction.ExecuteIfBound(Message), TEXT("%s: Unhandled error - %s"), *RequestLogName , *Message);
|
||||
};
|
||||
|
||||
auto ResponseHandler = [=](FHttpRequestPtr, FHttpResponsePtr Response, bool bWasSuccessful) mutable
|
||||
{
|
||||
if(CheckRequestFailed(bWasSuccessful, Response, RequestLogName, OnError)) return;
|
||||
|
||||
TSharedPtr<FJsonObject> Obj;
|
||||
if(!GetResponseAsJSON(Response, RequestLogName, Obj, OnError)) return;
|
||||
|
||||
TArray<TSharedPtr<FJsonValue>> StreamsArrJSON = Obj->GetObjectField(TEXT("data"))
|
||||
->GetObjectField(TEXT("user"))
|
||||
->GetObjectField(TEXT("streams"))
|
||||
->GetArrayField(TEXT("items"));
|
||||
|
||||
TArray<FSpeckleStream> Streams;
|
||||
Streams.Reserve(StreamsArrJSON.Num());
|
||||
|
||||
for (const TSharedPtr<FJsonValue> v : StreamsArrJSON)
|
||||
{
|
||||
FSpeckleStream Stream = FSpeckleStream(v);
|
||||
Streams.Add(Stream);
|
||||
}
|
||||
|
||||
UE_LOG(LogSpeckle, Log, TEXT("Operation %s completed successfully. Fetched %d items"), *RequestLogName, Streams.Num());
|
||||
ensureAlwaysMsgf(OnCompleteAction.ExecuteIfBound(Streams), TEXT("%s: Complete handler was not bound properly"), *RequestLogName);
|
||||
};
|
||||
|
||||
|
||||
const FHttpRequestRef Request = CreateGraphQLRequest(ServerUrl, AuthToken, PostPayload);
|
||||
Request->OnProcessRequestComplete().BindLambda(ResponseHandler);
|
||||
|
||||
SendGraphQLRequest(Request, RequestLogName, OnError);
|
||||
}
|
||||
|
||||
void FClientAPI::StreamGetBranches(
|
||||
const FString& ServerUrl, const FString& AuthToken,
|
||||
const FString& StreamId, const int32 Limit,
|
||||
const FFetchBranchDelegate OnCompleteAction, const FErrorDelegate OnErrorAction)
|
||||
{
|
||||
const FString RequestLogName = FString(__FUNCTION__);
|
||||
|
||||
//TODO limit
|
||||
FString PostPayload = "{\"query\": \"query{ stream (id: \\\"" +
|
||||
StreamId + "\\\"){id name branches(limit : " + FString::FromInt(Limit) + ") {totalCount cursor items{ id name description}}}}\"}";
|
||||
|
||||
// The above can be extended with author information
|
||||
//query{stream(id:"a18f8c8569"){id name branches{totalCount items{id name description author{id, name, email, commits{cursor}}}}}}
|
||||
|
||||
auto OnError = [=](const FString& Message) mutable
|
||||
{
|
||||
ensureAlwaysMsgf(OnErrorAction.ExecuteIfBound(Message), TEXT("%s: Unhandled error - %s"), *RequestLogName , *Message);
|
||||
};
|
||||
|
||||
auto ResponseHandler = [=](FHttpRequestPtr, FHttpResponsePtr Response, bool bWasSuccessful) mutable
|
||||
{
|
||||
if(CheckRequestFailed(bWasSuccessful, Response, RequestLogName, OnError)) return;
|
||||
|
||||
TSharedPtr<FJsonObject> Obj;
|
||||
if(!GetResponseAsJSON(Response, RequestLogName, Obj, OnError)) return;
|
||||
|
||||
TArray<TSharedPtr<FJsonValue>> BranchesArrJSON = Obj->GetObjectField(TEXT("data"))
|
||||
->GetObjectField(TEXT("stream"))
|
||||
->GetObjectField(TEXT("branches"))
|
||||
->GetArrayField(TEXT("items"));
|
||||
TArray<FSpeckleBranch> Branches;
|
||||
Branches.Reserve(BranchesArrJSON.Num());
|
||||
|
||||
for (const TSharedPtr<FJsonValue>& v : BranchesArrJSON)
|
||||
{
|
||||
const TSharedPtr<FJsonObject>* BranchObj;
|
||||
if(ensureAlways(v->TryGetObject(BranchObj)))
|
||||
{
|
||||
FSpeckleBranch Branch = FSpeckleBranch(*BranchObj);
|
||||
Branches.Add(Branch);
|
||||
}
|
||||
}
|
||||
|
||||
UE_LOG(LogSpeckle, Log, TEXT("Operation %s completed successfully. Fetched %d items"), *RequestLogName, Branches.Num());
|
||||
ensureAlwaysMsgf(OnCompleteAction.ExecuteIfBound(Branches), TEXT("%s: Complete handler was not bound properly"), *RequestLogName);
|
||||
};
|
||||
|
||||
|
||||
const FHttpRequestRef Request = CreateGraphQLRequest(ServerUrl, AuthToken, PostPayload);
|
||||
Request->OnProcessRequestComplete().BindLambda(ResponseHandler);
|
||||
|
||||
SendGraphQLRequest(Request, RequestLogName, OnError);
|
||||
}
|
||||
|
||||
|
||||
void FClientAPI::StreamGetCommits(const FString& ServerUrl, const FString& AuthToken,
|
||||
const FString& StreamId, const FString& BranchName, const int32 Limit,
|
||||
const FFetchCommitDelegate OnCompleteAction, const FErrorDelegate OnErrorAction)
|
||||
{
|
||||
const FString RequestLogName = FString(__FUNCTION__);
|
||||
|
||||
FString PostPayload = "{\"query\": \"query{stream (id: \\\"" + StreamId +
|
||||
"\\\"){id name createdAt updatedAt "
|
||||
+ "branch(name: \\\"" + BranchName + "\\\" ){id name description author{name id email} " +
|
||||
"commits(limit: " + FString::FromInt(Limit) + "){totalCount items {id referencedObject sourceApplication totalChildrenCount " +
|
||||
"branchName parents authorName authorId message createdAt commentCount}}}}}\"}"; // authorAvatar
|
||||
|
||||
auto OnError = [=](const FString& Message) mutable
|
||||
{
|
||||
ensureAlwaysMsgf(OnErrorAction.ExecuteIfBound(Message), TEXT("%s: Unhandled error - %s"), *RequestLogName , *Message);
|
||||
};
|
||||
|
||||
auto ResponseHandler = [=](FHttpRequestPtr, FHttpResponsePtr Response, bool bWasSuccessful) mutable
|
||||
{
|
||||
if(CheckRequestFailed(bWasSuccessful, Response, RequestLogName, OnError)) return;
|
||||
|
||||
TSharedPtr<FJsonObject> Obj;
|
||||
if(!GetResponseAsJSON(Response, RequestLogName, Obj, OnError)) return;
|
||||
|
||||
TArray<TSharedPtr<FJsonValue>> CommitsArrJSON = Obj->GetObjectField(TEXT("data"))
|
||||
->GetObjectField(TEXT("stream"))
|
||||
->GetObjectField(TEXT("branch"))
|
||||
->GetObjectField(TEXT("commits"))
|
||||
->GetArrayField(TEXT("items"));
|
||||
|
||||
TArray<FSpeckleCommit> ArrayOfCommits;
|
||||
ArrayOfCommits.Reserve(CommitsArrJSON.Num());
|
||||
|
||||
for (const TSharedPtr<FJsonValue> v : CommitsArrJSON)
|
||||
{
|
||||
FSpeckleCommit Commit = FSpeckleCommit(v);
|
||||
ArrayOfCommits.Add( Commit );
|
||||
}
|
||||
|
||||
UE_LOG(LogSpeckle, Log, TEXT("Operation %s completed successfully. Fetched %d items"), *RequestLogName, ArrayOfCommits.Num());
|
||||
ensureAlwaysMsgf(OnCompleteAction.ExecuteIfBound(ArrayOfCommits), TEXT("%s: Complete handler was not bound properly"), *RequestLogName);
|
||||
};
|
||||
|
||||
|
||||
const FHttpRequestRef Request = CreateGraphQLRequest(ServerUrl, AuthToken, PostPayload);
|
||||
Request->OnProcessRequestComplete().BindLambda(ResponseHandler);
|
||||
|
||||
SendGraphQLRequest(Request, RequestLogName, OnError);
|
||||
}
|
||||
|
||||
|
||||
void FClientAPI::FetchGlobals(const FString& ServerUrl, const FString& AuthToken,
|
||||
const FString& StreamId, const FString& ReferencedObjectId,
|
||||
const FFetchGlobalsDelegate OnCompleteAction, const FErrorDelegate OnErrorAction)
|
||||
{
|
||||
const FString RequestLogName = FString(__FUNCTION__);
|
||||
|
||||
FString PostPayload = "{\"query\": \"query{stream (id:\\\"" + StreamId +
|
||||
"\\\"){id name description updatedAt createdAt role isPublic object(id:\\\"" +
|
||||
ReferencedObjectId +
|
||||
"\\\"){id data}}}\"}";
|
||||
|
||||
auto OnError = [=](const FString& Message) mutable
|
||||
{
|
||||
ensureAlwaysMsgf(OnErrorAction.ExecuteIfBound(Message), TEXT("%s: Unhandled error - %s"), *RequestLogName , *Message);
|
||||
};
|
||||
|
||||
auto ResponseHandler = [=](FHttpRequestPtr, FHttpResponsePtr Response, bool bWasSuccessful) mutable
|
||||
{
|
||||
if(CheckRequestFailed(bWasSuccessful, Response, RequestLogName, OnError)) return;
|
||||
|
||||
TSharedPtr<FJsonObject> Obj;
|
||||
if(!GetResponseAsJSON(Response, RequestLogName, Obj, OnError)) return;
|
||||
|
||||
TSharedPtr<FJsonObject> GlobalsJSONObject = Obj->GetObjectField(TEXT("data"))
|
||||
->GetObjectField(TEXT("stream"))
|
||||
->GetObjectField(TEXT("object"))
|
||||
->GetObjectField(TEXT("data"));
|
||||
|
||||
|
||||
|
||||
|
||||
FSpeckleGlobals Globals = FSpeckleGlobals(GlobalsJSONObject);
|
||||
|
||||
UE_LOG(LogSpeckle, Log, TEXT("Operation %s completed successfully"), *RequestLogName);
|
||||
ensureAlwaysMsgf(OnCompleteAction.ExecuteIfBound(Globals), TEXT("%s: Complete handler was not bound properly"), *RequestLogName);
|
||||
};
|
||||
|
||||
|
||||
const FHttpRequestRef Request = CreateGraphQLRequest(ServerUrl, AuthToken, PostPayload);
|
||||
Request->OnProcessRequestComplete().BindLambda(ResponseHandler);
|
||||
|
||||
SendGraphQLRequest(Request, RequestLogName, OnError);
|
||||
}
|
||||
|
||||
void FClientAPI::FetchUserData(const FString& ServerUrl, const FString& AuthToken,
|
||||
const FFetchUserDelegate OnCompleteAction, const FErrorDelegate OnErrorAction)
|
||||
{
|
||||
const FString RequestLogName = FString(__FUNCTION__);
|
||||
|
||||
const FString PostPayload =
|
||||
"{\"query\": \"query{user{id name email company role suuid bio profiles avatar}}\"}";
|
||||
|
||||
|
||||
auto OnError = [=](const FString& Message) mutable
|
||||
{
|
||||
@@ -25,74 +228,24 @@ void FClientAPI::MakeGraphQLRequest(const FString& ServerUrl, const FString& Aut
|
||||
|
||||
TSharedPtr<FJsonObject> Obj;
|
||||
if(!GetResponseAsJSON(Response, RequestLogName, Obj, OnError)) return;
|
||||
|
||||
const TSharedPtr<FJsonObject>* DataObjectPtr;
|
||||
if(!Obj->TryGetObjectField("data", DataObjectPtr))
|
||||
{
|
||||
OnError(TEXT("%s responce was invalid, expected to find a \"data\" property in response"));
|
||||
return;
|
||||
}
|
||||
const TSharedPtr<FJsonObject> DataObject = *DataObjectPtr;
|
||||
|
||||
const TSharedPtr<FJsonObject>* RequestedJson;
|
||||
if(!DataObject->TryGetObjectField(ResponsePropertyName, RequestedJson))
|
||||
{
|
||||
//Requested property has a null or non-object value
|
||||
if(DataObject->HasField(ResponsePropertyName))
|
||||
{
|
||||
FString Message = FString::Printf(TEXT("%s: Response data contained the requested property \"%s\", but the value was null was or not an object."),
|
||||
*RequestLogName, *ResponsePropertyName);
|
||||
OnError(Message);
|
||||
return;
|
||||
}
|
||||
|
||||
//Requested property was missing
|
||||
TArray<FString> Options;
|
||||
Options.Reserve(DataObject->Values.Num());
|
||||
for(const auto& Properties : DataObject->Values)
|
||||
{
|
||||
Options.Add(FString::Printf(TEXT("\"%s\" "), *Properties.Key));
|
||||
}
|
||||
|
||||
FString Message = FString::Printf(TEXT("%s: Could not find the requested property name \"%s\" in responce data.\n Got { %s} instead."),
|
||||
*RequestLogName, *ResponsePropertyName, *FString::Join(Options, TEXT(", ")));
|
||||
OnError(Message);
|
||||
return;
|
||||
}
|
||||
TSharedPtr<FJsonObject> UserJSONObject = Obj->GetObjectField(TEXT("data"))
|
||||
->GetObjectField(TEXT("user"));
|
||||
|
||||
FString OutputString;
|
||||
const TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&OutputString);
|
||||
ensureAlways(FJsonSerializer::Serialize(RequestedJson->ToSharedRef(), Writer));
|
||||
|
||||
// Commented out, deserialisation done by caller
|
||||
//void* DeserializedData;
|
||||
//FSpeckleUser DeserializedData = FSpeckleUser( UserJSONObject );
|
||||
// if(!FJsonObjectConverter::JsonObjectToUStruct(*RequestedJson, OutStructType::StaticStruct(), &DeserializedData, 0, 0))
|
||||
// {
|
||||
// OnError("Failed to deserialize user object");
|
||||
// return;
|
||||
// }
|
||||
FSpeckleUser MyUserData = FSpeckleUser( UserJSONObject );
|
||||
|
||||
UE_LOG(LogSpeckle, Log, TEXT("Operation %s completed successfully"), *RequestLogName);
|
||||
ensureAlwaysMsgf(OnCompleteAction.ExecuteIfBound(OutputString), TEXT("%s: Complete handler was not bound properly"), *RequestLogName);
|
||||
ensureAlwaysMsgf(OnCompleteAction.ExecuteIfBound(MyUserData), TEXT("%s: Complete handler was not bound properly"), *RequestLogName);
|
||||
};
|
||||
|
||||
const FHttpRequestRef Request = CreatePostRequest(ServerUrl, AuthToken, PostPayload);
|
||||
const FHttpRequestRef Request = CreateGraphQLRequest(ServerUrl, AuthToken, PostPayload);
|
||||
Request->OnProcessRequestComplete().BindLambda(ResponseHandler);
|
||||
|
||||
if(Request->ProcessRequest())
|
||||
{
|
||||
UE_LOG(LogSpeckle, Log, TEXT("POST Request %s to %s was sent, awaiting response"), *RequestLogName, *Request->GetURL() );
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("POST Request %s to %s failed to send"), *RequestLogName, *Request->GetURL() );
|
||||
}
|
||||
|
||||
FAnalytics::TrackEvent(Request->GetURL(), "NodeRun", TMap<FString, FString> { {"name", __FUNCTION__}});
|
||||
SendGraphQLRequest(Request, RequestLogName, OnError);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool FClientAPI::GetResponseAsJSON(const FHttpResponsePtr Response, const FString& RequestLogName, TSharedPtr<FJsonObject>& OutObject, const TFunctionRef<void(const FString& Message)> OnErrorAction)
|
||||
{
|
||||
|
||||
@@ -120,7 +273,7 @@ bool FClientAPI::GetResponseAsJSON(const FHttpResponsePtr Response, const FStrin
|
||||
return true;
|
||||
}
|
||||
|
||||
FHttpRequestRef FClientAPI::CreatePostRequest(const FString& ServerUrl, const FString AuthToken, const FString& PostPayload, const FString& Encoding)
|
||||
FHttpRequestRef FClientAPI::CreateGraphQLRequest(const FString& ServerUrl, const FString AuthToken, const FString& PostPayload, const FString& Encoding)
|
||||
{
|
||||
FHttpRequestRef Request = FHttpModule::Get().CreateRequest();
|
||||
|
||||
@@ -128,15 +281,32 @@ FHttpRequestRef FClientAPI::CreatePostRequest(const FString& ServerUrl, const FS
|
||||
Request->SetVerb(TEXT("POST"));
|
||||
Request->SetHeader("Accept-Encoding", Encoding);
|
||||
Request->SetHeader("Content-Type", TEXT("application/json"));
|
||||
if(!AuthToken.IsEmpty())
|
||||
Request->SetHeader("Authorization","Bearer " + AuthToken);
|
||||
Request->SetHeader("apollographql-client-name", "Unreal Engine");
|
||||
Request->SetHeader("apollographql-client-version", SPECKLE_CONNECTOR_VERSION);
|
||||
Request->SetHeader("Authorization", "Bearer " + AuthToken);
|
||||
Request->SetContentAsString(PostPayload);
|
||||
|
||||
return Request;
|
||||
}
|
||||
|
||||
bool FClientAPI::SendGraphQLRequest(const FHttpRequestRef Request, const FString& RequestName,
|
||||
const TFunctionRef<void(const FString& Message)> OnErrorAction)
|
||||
{
|
||||
const bool RequestSent = Request->ProcessRequest();
|
||||
|
||||
if(!RequestSent)
|
||||
{
|
||||
const FString Message = FString::Printf(TEXT("Request \"%s\" at \"%s\" failed: \nHTTP request failed to start"),
|
||||
*RequestName, *Request->GetURL());
|
||||
|
||||
OnErrorAction(Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogSpeckle, Log, TEXT("POST Request %s to %s was sent, awaiting response"), *RequestName, *Request->GetURL() );
|
||||
FAnalytics::TrackEvent("unknown", Request->GetURL(), "NodeRun", TMap<FString, FString> { {"name", RequestName }});
|
||||
}
|
||||
|
||||
return RequestSent;
|
||||
}
|
||||
|
||||
|
||||
bool FClientAPI::CheckRequestFailed(bool bWasSuccessful, FHttpResponsePtr Response, const FString& RequestLogName, const TFunctionRef<void(const FString& Message)> OnErrorAction)
|
||||
@@ -154,8 +324,8 @@ bool FClientAPI::CheckRequestFailed(bool bWasSuccessful, FHttpResponsePtr Respon
|
||||
const int32 ResponseCode = Response->GetResponseCode();
|
||||
if (ResponseCode != 200)
|
||||
{
|
||||
FString Message = FString::Printf(TEXT("Request \"%s\" to \"%s\" failed with HTTP response %d - %s"),
|
||||
*RequestLogName, *Response->GetURL(), ResponseCode, *Response->GetContentAsString());
|
||||
FString Message = FString::Printf(TEXT("Request \"%s\" to \"%s\" failed with HTTP response %d"),
|
||||
*RequestLogName, *Response->GetURL(), ResponseCode);
|
||||
OnErrorAction(Message);
|
||||
return true;
|
||||
}
|
||||
@@ -171,7 +341,7 @@ bool FClientAPI::CheckForOperationErrors(const TSharedPtr<FJsonObject> GraphQLRe
|
||||
|
||||
bool WasError = false;
|
||||
const TArray<TSharedPtr<FJsonValue>>* Errors;
|
||||
if(GraphQLResponse->TryGetArrayField(TEXT("errors"), Errors))
|
||||
if(GraphQLResponse->TryGetArrayField(TEXT("Errors"), Errors))
|
||||
{
|
||||
for(const TSharedPtr<FJsonValue>& e : *Errors)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "API/Operations/ReceiveBranchesOperation.h"
|
||||
|
||||
#include "Mixpanel.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "API/ClientAPI.h"
|
||||
|
||||
|
||||
UReceiveBranchesOperation* UReceiveBranchesOperation::ReceiveBranchesOperation(UObject* WorldContextObject,
|
||||
const FString& ServerUrl, const FString& AuthToken,
|
||||
const FString& StreamId, int32 Limit)
|
||||
{
|
||||
FString ObjectId = "Streams";
|
||||
|
||||
UReceiveBranchesOperation* Node = NewObject<UReceiveBranchesOperation>();
|
||||
Node->StreamId = StreamId.TrimEnd();
|
||||
Node->ServerUrl = ServerUrl.TrimEnd();
|
||||
while(Node->ServerUrl.RemoveFromEnd("/")) { }
|
||||
Node->AuthToken = AuthToken.TrimEnd();
|
||||
Node->Limit = Limit;
|
||||
|
||||
Node->RegisterWithGameInstance(WorldContextObject);
|
||||
return Node;
|
||||
}
|
||||
|
||||
void UReceiveBranchesOperation::Activate()
|
||||
{
|
||||
FAnalytics::TrackEvent("unknown",
|
||||
ServerUrl, "NodeRun", TMap<FString, FString> { {"name", StaticClass()->GetName() }});
|
||||
|
||||
Request();
|
||||
}
|
||||
|
||||
void UReceiveBranchesOperation::Request()
|
||||
{
|
||||
ensureAlways(Limit > 0);
|
||||
|
||||
FFetchBranchDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindUObject(this, &UReceiveBranchesOperation::HandleReceive);
|
||||
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindUObject(this, &UReceiveBranchesOperation::HandleError);
|
||||
|
||||
FClientAPI::StreamGetBranches(ServerUrl, AuthToken, StreamId, Limit, CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
void UReceiveBranchesOperation::HandleReceive(const TArray<FSpeckleBranch>& Branches)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Log, TEXT("%s to %s Succeeded"), *StaticClass()->GetName(), *ServerUrl);
|
||||
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
OnReceiveSuccessfully.Broadcast(Branches, "");
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
void UReceiveBranchesOperation::HandleError(const FString& Message)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("%s failed - %s"), *StaticClass()->GetName(), *Message);
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
|
||||
const TArray<FSpeckleBranch> EmptyList;
|
||||
OnError.Broadcast(EmptyList, Message);
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "API/Operations/ReceiveCommitsOperation.h"
|
||||
|
||||
#include "Mixpanel.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "API/ClientAPI.h"
|
||||
|
||||
|
||||
// ReceiveOperation
|
||||
UReceiveCommitsOperation* UReceiveCommitsOperation::ReceiveCommitsOperation(UObject* WorldContextObject,
|
||||
const FString& ServerUrl, const FString& AuthToken,
|
||||
const FString& StreamId, const FString& BranchName, const int32 Limit)
|
||||
{
|
||||
UReceiveCommitsOperation* Node = NewObject<UReceiveCommitsOperation>();
|
||||
Node->ServerUrl = ServerUrl.TrimEnd();
|
||||
while(Node->ServerUrl.RemoveFromEnd("/")) { }
|
||||
Node->AuthToken = AuthToken.TrimEnd();
|
||||
Node->StreamId = StreamId.TrimEnd();
|
||||
Node->BranchName = BranchName;
|
||||
Node->Limit = Limit;
|
||||
Node->RegisterWithGameInstance(WorldContextObject);
|
||||
return Node;
|
||||
}
|
||||
|
||||
// Activate
|
||||
void UReceiveCommitsOperation::Activate()
|
||||
{
|
||||
FAnalytics::TrackEvent("unknown", ServerUrl,
|
||||
"NodeRun", TMap<FString, FString> { {"name", StaticClass()->GetName() }});
|
||||
|
||||
Request();
|
||||
}
|
||||
|
||||
void UReceiveCommitsOperation::Request()
|
||||
{
|
||||
ensureAlways(Limit > 0);
|
||||
|
||||
FFetchCommitDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindUObject(this, &UReceiveCommitsOperation::HandleReceive);
|
||||
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindUObject(this, &UReceiveCommitsOperation::HandleError);
|
||||
|
||||
FClientAPI::StreamGetCommits(ServerUrl, AuthToken, StreamId, BranchName, Limit, CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
void UReceiveCommitsOperation::HandleReceive(const TArray<FSpeckleCommit>& Commits)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Log, TEXT("%s to %s Succeeded"), *StaticClass()->GetName(), *ServerUrl);
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
|
||||
OnReceiveSuccessfully.Broadcast(Commits, "");
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
void UReceiveCommitsOperation::HandleError(const FString& Message)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("%s failed - %s"), *StaticClass()->GetName(), *Message);
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
|
||||
const TArray<FSpeckleCommit> EmptyList;
|
||||
OnError.Broadcast(EmptyList, Message);
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "API/Operations/ReceiveGlobalsOperation.h"
|
||||
|
||||
#include "Mixpanel.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "API/ClientAPI.h"
|
||||
|
||||
|
||||
UReceiveGlobalsOperation* UReceiveGlobalsOperation::ReceiveGlobalsOperation(UObject* WorldContextObject,
|
||||
const FString& ServerUrl, const FString& AuthToken,
|
||||
const FString& StreamId, const FString& ReferencedObjectId)
|
||||
{
|
||||
UReceiveGlobalsOperation* Node = NewObject<UReceiveGlobalsOperation>();
|
||||
Node->ServerUrl = ServerUrl.TrimEnd();
|
||||
while(Node->ServerUrl.RemoveFromEnd("/")) { }
|
||||
Node->AuthToken = AuthToken.TrimEnd();;
|
||||
Node->StreamId = StreamId.TrimEnd();;
|
||||
Node->ReferencedObjectId = ReferencedObjectId;
|
||||
|
||||
Node->RegisterWithGameInstance(WorldContextObject);
|
||||
return Node;
|
||||
}
|
||||
|
||||
void UReceiveGlobalsOperation::Activate()
|
||||
{
|
||||
FAnalytics::TrackEvent("unknown",
|
||||
ServerUrl, "NodeRun", TMap<FString, FString> { {"name", StaticClass()->GetName() }});
|
||||
|
||||
Request();
|
||||
}
|
||||
|
||||
void UReceiveGlobalsOperation::Request()
|
||||
{
|
||||
FFetchGlobalsDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindUObject(this, &UReceiveGlobalsOperation::HandleReceive);
|
||||
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindUObject(this, &UReceiveGlobalsOperation::HandleError);
|
||||
|
||||
FClientAPI::FetchGlobals(ServerUrl, AuthToken, StreamId, ReferencedObjectId, CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UReceiveGlobalsOperation::HandleReceive(const FSpeckleGlobals& Object)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Log, TEXT("%s to %s Succeeded"), *StaticClass()->GetName(), *ServerUrl);
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
OnReceiveSuccessfully.Broadcast(Object, "");
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
void UReceiveGlobalsOperation::HandleError(const FString& Message)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("%s failed - %s"), *StaticClass()->GetName(), *Message);
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
const FSpeckleGlobals BlankGlobals;
|
||||
OnError.Broadcast(BlankGlobals, Message);
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "API/Operations/ReceiveMyUserDataOperation.h"
|
||||
|
||||
#include "Mixpanel.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "API/ClientAPI.h"
|
||||
|
||||
|
||||
UReceiveMyUserDataOperation* UReceiveMyUserDataOperation::ReceiveMyUserDataOperation(
|
||||
UObject* WorldContextObject, const FString& ServerUrl, const FString& AuthToken)
|
||||
{
|
||||
UReceiveMyUserDataOperation* Node = NewObject<UReceiveMyUserDataOperation>();
|
||||
Node->ServerUrl = ServerUrl.TrimEnd();;
|
||||
while(Node->ServerUrl.RemoveFromEnd("/")) { }
|
||||
Node->AuthToken = AuthToken.TrimEnd();;
|
||||
|
||||
Node->RegisterWithGameInstance(WorldContextObject);
|
||||
return Node;
|
||||
}
|
||||
|
||||
void UReceiveMyUserDataOperation::Activate()
|
||||
{
|
||||
FAnalytics::TrackEvent("unknown",
|
||||
ServerUrl, "NodeRun", TMap<FString, FString> { {"name", StaticClass()->GetName() }});
|
||||
|
||||
Request();
|
||||
}
|
||||
|
||||
|
||||
void UReceiveMyUserDataOperation::Request()
|
||||
{
|
||||
FFetchUserDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindUObject(this, &UReceiveMyUserDataOperation::HandleReceive);
|
||||
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindUObject(this, &UReceiveMyUserDataOperation::HandleError);
|
||||
|
||||
FClientAPI::FetchUserData(ServerUrl, AuthToken, CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void UReceiveMyUserDataOperation::HandleReceive(const FSpeckleUser& Object)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Log, TEXT("%s to %s Succeeded"), *StaticClass()->GetName(), *ServerUrl);
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
OnReceiveSuccessfully.Broadcast(Object, "");
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
void UReceiveMyUserDataOperation::HandleError(const FString& Message)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("%s failed - %s"), *StaticClass()->GetName(), *Message);
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
const FSpeckleUser BlankUser;
|
||||
OnError.Broadcast(BlankUser, Message);
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "API/Operations/ReceiveOperation.h"
|
||||
|
||||
@@ -8,6 +10,7 @@
|
||||
#include "Mixpanel.h"
|
||||
|
||||
|
||||
// ReceiveOperation
|
||||
UReceiveOperation* UReceiveOperation::ReceiveOperation(UObject* WorldContextObject,
|
||||
const FString& ObjectId,
|
||||
TScriptInterface<ITransport> RemoteTransport,
|
||||
@@ -22,10 +25,13 @@ UReceiveOperation* UReceiveOperation::ReceiveOperation(UObject* WorldContextObje
|
||||
return Node;
|
||||
}
|
||||
|
||||
// Activate
|
||||
void UReceiveOperation::Activate()
|
||||
{
|
||||
FAnalytics::TrackEvent("unknown", "NodeRun", TMap<FString, FString> { {"name", StaticClass()->GetName()} });
|
||||
FAnalytics::TrackEvent("unknown",
|
||||
"unknown", "NodeRun", TMap<FString, FString> { {"name", StaticClass()->GetName() }});
|
||||
|
||||
//Async(EAsyncExecution::Thread, [this]{Receive();});
|
||||
Receive();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "API/Operations/ReceiveStreamsOperation.h"
|
||||
|
||||
#include "Mixpanel.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "API/ClientAPI.h"
|
||||
|
||||
|
||||
UReceiveStreamsOperation* UReceiveStreamsOperation::ReceiveStreamsOperation(UObject* WorldContextObject,
|
||||
const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const int32 Limit)
|
||||
{
|
||||
FString ObjectId = "Streams";
|
||||
|
||||
UReceiveStreamsOperation* Node = NewObject<UReceiveStreamsOperation>();
|
||||
Node->ServerUrl = ServerUrl.TrimEnd();;
|
||||
Node->AuthToken = AuthToken.TrimEnd();;
|
||||
Node->Limit = Limit;
|
||||
|
||||
Node->RegisterWithGameInstance(WorldContextObject);
|
||||
return Node;
|
||||
}
|
||||
|
||||
void UReceiveStreamsOperation::Activate()
|
||||
{
|
||||
FAnalytics::TrackEvent("unknown",
|
||||
ServerUrl, "NodeRun", TMap<FString, FString> { {"name", StaticClass()->GetName() }});
|
||||
|
||||
Request();
|
||||
}
|
||||
|
||||
void UReceiveStreamsOperation::Request()
|
||||
{
|
||||
FFetchStreamDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindUObject(this, &UReceiveStreamsOperation::HandleReceive);
|
||||
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindUObject(this, &UReceiveStreamsOperation::HandleError);
|
||||
|
||||
FClientAPI::StreamsGet(ServerUrl, AuthToken, Limit, CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
void UReceiveStreamsOperation::HandleReceive(const TArray<FSpeckleStream>& Streams)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Log, TEXT("%s to %s Succeeded"), *StaticClass()->GetName(), *ServerUrl);
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
OnReceiveSuccessfully.Broadcast(Streams, "");
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
void UReceiveStreamsOperation::HandleError(const FString& Message)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("%s failed - %s"), *StaticClass()->GetName(), *Message);
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
|
||||
const TArray<FSpeckleStream> EmptyList;
|
||||
OnError.Broadcast(EmptyList, Message);
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
#include "API/Operations/SendOperation.h"
|
||||
|
||||
|
||||
|
||||
// USendOperation* USendOperation::SendOperation(UObject* WorldContextObject, UBase* Base, TScriptArray<TScriptInterface<ITransport>> Transports)
|
||||
// {
|
||||
// USendOperation* Node = NewObject<USendOperation>();
|
||||
// Node->Base = Base;
|
||||
// Node->Transports = Transports;
|
||||
//
|
||||
// Node->RegisterWithGameInstance(WorldContextObject);
|
||||
// return Node;
|
||||
// }
|
||||
//
|
||||
// void USendOperation::Activate()
|
||||
// {
|
||||
// check(Transports.Num() > 0);
|
||||
//
|
||||
// //TODO implement
|
||||
// unimplemented();
|
||||
//
|
||||
// }
|
||||
@@ -1,68 +0,0 @@
|
||||
|
||||
#include "API/Operations/SpeckleStreamAPIOperation.h"
|
||||
|
||||
#include "JsonObjectConverter.h"
|
||||
#include "Mixpanel.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "API/ClientAPI.h"
|
||||
|
||||
|
||||
USpeckleStreamAPIOperation* USpeckleStreamAPIOperation::SpeckleStreamAPIOperation(
|
||||
const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const FString& GraphQlQuery,
|
||||
const FString& ResponsePropertyName,
|
||||
const FString& RequestLogName)
|
||||
{
|
||||
USpeckleStreamAPIOperation* Node = NewObject<USpeckleStreamAPIOperation>();
|
||||
Node->ServerUrl = ServerUrl.TrimEnd();
|
||||
Node->AuthToken = AuthToken.TrimEnd();
|
||||
Node->Query = GraphQlQuery;
|
||||
Node->ResponsePropertyName = ResponsePropertyName;
|
||||
Node->RequestLogName = RequestLogName;
|
||||
|
||||
return Node;
|
||||
}
|
||||
|
||||
void USpeckleStreamAPIOperation::Activate()
|
||||
{
|
||||
FAnalytics::TrackEvent(ServerUrl, "NodeRun", TMap<FString, FString> { {"name", RequestLogName} });
|
||||
|
||||
Request();
|
||||
}
|
||||
|
||||
void USpeckleStreamAPIOperation::Request()
|
||||
{
|
||||
FString Payload = FString::Printf(TEXT("{\"query\": \"%s\"}"), *Query.ReplaceCharWithEscapedChar());
|
||||
FAPIResponceDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindUObject(this, &USpeckleStreamAPIOperation::HandleReceive);
|
||||
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindUObject(this, &USpeckleStreamAPIOperation::HandleError);
|
||||
FClientAPI::MakeGraphQLRequest(ServerUrl, AuthToken, ResponsePropertyName, Payload,RequestLogName , CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
void USpeckleStreamAPIOperation::HandleReceive(const FString& ResponseJson)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
|
||||
UE_LOG(LogSpeckle, Log, TEXT("%s to %s Succeeded"), *StaticClass()->GetName(), *ServerUrl);
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
OnReceiveSuccessfully.Broadcast(ResponseJson, "");
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
void USpeckleStreamAPIOperation::HandleError(const FString& Message)
|
||||
{
|
||||
check(IsInGameThread());
|
||||
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("%s failed - %s"), *StaticClass()->GetName(), *Message);
|
||||
|
||||
FEditorScriptExecutionGuard ScriptGuard;
|
||||
OnError.Broadcast("", Message);
|
||||
|
||||
SetReadyToDestroy();
|
||||
}
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
|
||||
#include "API/SpeckleAPIFunctions.h"
|
||||
|
||||
#include "JsonObjectConverter.h"
|
||||
|
||||
bool USpeckleAPIFunctions::DeserializeResponse(const FString& JsonString, int32& OutStruct)
|
||||
{
|
||||
// We should never hit this! stubs to avoid NoExport on the class.
|
||||
check(0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool USpeckleAPIFunctions::GenericDeserializeResponse(const FString& JsonString, const UScriptStruct* StructType,
|
||||
void* OutStruct)
|
||||
{
|
||||
//see FJsonObjectConverter::JsonObjectStringToUStruct
|
||||
TSharedPtr<FJsonObject> JsonObject;
|
||||
TSharedRef<TJsonReader<> > JsonReader = TJsonReaderFactory<>::Create(JsonString);
|
||||
if (!FJsonSerializer::Deserialize(JsonReader, JsonObject) || !JsonObject.IsValid())
|
||||
{
|
||||
UE_LOG(LogJson, Warning, TEXT("JsonObjectStringToUStruct - Unable to parse json=[%s]"), *JsonString);
|
||||
return false;
|
||||
}
|
||||
if (!FJsonObjectConverter::JsonObjectToUStruct(JsonObject.ToSharedRef(), StructType, OutStruct, 0, 0))
|
||||
{
|
||||
UE_LOG(LogJson, Warning, TEXT("JsonObjectStringToUStruct - Unable to deserialize. json=[%s]"), *JsonString);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void USpeckleAPIFunctions::CommitReceived(FSpeckleCommit& Commit)
|
||||
{
|
||||
//TODO send read read receipt
|
||||
//FString Query = FString::Printf(TEXT("mutation{ commitReceive(input:%s) }"), );
|
||||
}
|
||||
|
||||
DEFINE_FUNCTION(USpeckleAPIFunctions::execDeserializeResponse)
|
||||
{
|
||||
// Get JsonString
|
||||
P_GET_PROPERTY(FStrProperty, JsonString);
|
||||
|
||||
// Get OutStruct
|
||||
Stack.MostRecentPropertyAddress = nullptr;
|
||||
Stack.StepCompiledIn<FStructProperty>(nullptr);
|
||||
void* OutBlueprintDataPtr = Stack.MostRecentPropertyAddress;
|
||||
FStructProperty* StructProp = CastField<FStructProperty>(Stack.MostRecentProperty);
|
||||
UScriptStruct* StructType = StructProp->Struct;
|
||||
|
||||
P_FINISH;
|
||||
|
||||
P_NATIVE_BEGIN;
|
||||
|
||||
*static_cast<bool*>(RESULT_PARAM) = GenericDeserializeResponse(JsonString, StructType, OutBlueprintDataPtr);
|
||||
P_NATIVE_END;
|
||||
}
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
#include "API/SpeckleSerializer.h"
|
||||
#include "API/SpeckleSerializer.h"
|
||||
|
||||
#include "Objects/Base.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "Objects/DisplayValueElement.h"
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
#include "Objects/ObjectModelRegistry.h"
|
||||
#include "Templates/SubclassOf.h"
|
||||
@@ -11,6 +9,7 @@
|
||||
#include "UObject/Package.h"
|
||||
|
||||
|
||||
// Create the Deserialization Base
|
||||
UBase* USpeckleSerializer::DeserializeBase(const TSharedPtr<FJsonObject> Obj,
|
||||
const TScriptInterface<ITransport> ReadTransport)
|
||||
{
|
||||
@@ -29,15 +28,13 @@ UBase* USpeckleSerializer::DeserializeBase(const TSharedPtr<FJsonObject> Obj,
|
||||
Obj->TryGetStringField("id", ObjectId);
|
||||
|
||||
TSubclassOf<UBase> BaseType;
|
||||
|
||||
FString WorkingType{};
|
||||
FString Remainder = FString(SpeckleType);
|
||||
|
||||
int32 Tries = 200;
|
||||
FString WorkingType(SpeckleType);
|
||||
|
||||
int32 Tries = 1000;
|
||||
while(ensure(Tries-- > 0))
|
||||
{
|
||||
const bool IsLastChance = !UObjectModelRegistry::SplitSpeckleType(Remainder, Remainder, WorkingType);
|
||||
|
||||
//Try and deserialize
|
||||
if(UObjectModelRegistry::TryGetRegisteredType(WorkingType, BaseType))
|
||||
{
|
||||
UBase* Base = NewObject<UBase>(GetTransientPackage(), BaseType);
|
||||
@@ -45,30 +42,20 @@ UBase* USpeckleSerializer::DeserializeBase(const TSharedPtr<FJsonObject> Obj,
|
||||
return Base;
|
||||
}
|
||||
|
||||
if(IsLastChance)
|
||||
{
|
||||
//Try a fallback displayValue object
|
||||
UBase* Base = NewObject<UBase>(GetTransientPackage(), UDisplayValueElement::StaticClass());
|
||||
if(Base->Parse(Obj, ReadTransport))
|
||||
return Base;
|
||||
|
||||
//If not, try a regular Base
|
||||
Base = NewObject<UBase>(GetTransientPackage(), UBase::StaticClass());
|
||||
if(Base->Parse(Obj, ReadTransport))
|
||||
return Base;
|
||||
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("Skipping deserilization of %s id: %s - object could not be deserilaized to Base"), *SpeckleType, *ObjectId );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//If we couldn't even deserialize this to a Base, something is quite wrong...
|
||||
//If we couldn't even deserialize this to a Base
|
||||
if(WorkingType == "Base" || BaseType == UBase::StaticClass())
|
||||
{
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("Skipping deserilization of %s id: %s - object could not be deserilaized to Base"), *SpeckleType, *ObjectId );
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//Try the next type
|
||||
if(!UObjectModelRegistry::ParentType(WorkingType, WorkingType))
|
||||
{
|
||||
WorkingType = "Base";
|
||||
UE_LOG(LogSpeckle, Verbose, TEXT("Unrecognised SpeckleType %s - Object id: %s Will be deserialized as Base"), *SpeckleType, *ObjectId );
|
||||
}
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#include "Mixpanel.h"
|
||||
#include "Mixpanel.h"
|
||||
|
||||
#include "Containers/UnrealString.h"
|
||||
#include "HttpModule.h"
|
||||
@@ -16,28 +15,23 @@ const FString FAnalytics::MixpanelToken = TEXT("acd87c5a50b56df91a795e999812a3a4
|
||||
const FString FAnalytics::MixpanelServer = TEXT("https://analytics.speckle.systems");
|
||||
const FString FAnalytics::VersionedApplicationName = FString::Printf(TEXT("Unreal Engine %d.%d"), ENGINE_MAJOR_VERSION, ENGINE_MINOR_VERSION);
|
||||
|
||||
void FAnalytics::TrackEvent(const FString& Server, const FString& EventName)
|
||||
void FAnalytics::TrackEvent(const FString& Email, const FString& Server, const FString& EventName)
|
||||
{
|
||||
const TMap<FString, FString> CustomProperties;
|
||||
TrackEvent( Server, EventName, CustomProperties);
|
||||
TrackEvent(Email, Server, EventName, CustomProperties);
|
||||
}
|
||||
|
||||
void FAnalytics::TrackEvent(const FString& Server, const FString& EventName, const TMap<FString, FString>& CustomProperties)
|
||||
void FAnalytics::TrackEvent(const FString& Email, const FString& Server, const FString& EventName, const TMap<FString, FString>& CustomProperties)
|
||||
{
|
||||
//Since we don't have access to users email address, we will hash the system user name instead (better than not tracking users at all)
|
||||
const FString UserID = FString(FPlatformProcess::ComputerName()) + FString(FPlatformProcess::UserName());
|
||||
TrackEvent(UserID, Server, EventName, CustomProperties);
|
||||
}
|
||||
#if !SUPPRESS_SPECKLE_ANALYTICS
|
||||
|
||||
void FAnalytics::TrackEvent(const FString& UserID, const FString& Server, const FString& EventName, const TMap<FString, FString>& CustomProperties)
|
||||
{
|
||||
|
||||
FString HashedUserID = "@" + Hash(UserID); //prepending an @ so we distinguish logged and non-logged users
|
||||
|
||||
FString HashedEmail = "@" + Hash(Email); //prepending an @ so we distinguish logged and non-logged users
|
||||
FString HashedServer = Hash(Server);
|
||||
|
||||
TMap<FString, FString> Properties
|
||||
{
|
||||
{ "distinct_id", HashedUserID },
|
||||
{ "distinct_id", HashedEmail },
|
||||
{ "server_id", HashedServer },
|
||||
{ "token", MixpanelToken },
|
||||
{ "hostApp", "Unreal Engine" },
|
||||
@@ -81,6 +75,7 @@ void FAnalytics::TrackEvent(const FString& UserID, const FString& Server, const
|
||||
{
|
||||
UE_LOG(LogSpeckle, Log, TEXT("Failed to send Mixpanel event to %s"), *MixpanelServer);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
FString FAnalytics::Hash(const FString& Input)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Conversion/Converters/AggregateConverter.h"
|
||||
|
||||
@@ -56,6 +57,13 @@ UObject* UAggregateConverter::ConvertToNativeInternal(const UBase* Object, UWorl
|
||||
UObject* Converter = GetConverter(Type).GetObject();
|
||||
if(!IsValid(Converter))
|
||||
{
|
||||
//TODO convert displayValues then halt traversal
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if(Type != UBase::StaticClass())
|
||||
{
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("Skipping Object %s: No conversion functions exist for %s"), *Object->Id, *Type->GetName());
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
|
||||
#include "Conversion/Converters/BlockConverter.h"
|
||||
#include "Conversion/Converters/BlockConverter.h"
|
||||
|
||||
#include "Objects/Other/BlockInstance.h"
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Objects/Other/RevitInstance.h"
|
||||
|
||||
UBlockConverter::UBlockConverter()
|
||||
{
|
||||
SpeckleTypes.Add(UBlockInstance::StaticClass());
|
||||
SpeckleTypes.Add(URevitInstance::StaticClass());
|
||||
|
||||
BlockInstanceActorType = AActor::StaticClass();
|
||||
ActorMobility = EComponentMobility::Static;
|
||||
@@ -17,13 +14,13 @@ UBlockConverter::UBlockConverter()
|
||||
|
||||
UObject* UBlockConverter::ConvertToNative_Implementation(const UBase* SpeckleBase, UWorld* World, TScriptInterface<ISpeckleConverter>&)
|
||||
{
|
||||
const UInstance* Block = Cast<UInstance>(SpeckleBase);
|
||||
const UBlockInstance* Block = Cast<UBlockInstance>(SpeckleBase);
|
||||
if(Block == nullptr) return nullptr;
|
||||
|
||||
return BlockToNative(Block, World);
|
||||
}
|
||||
|
||||
AActor* UBlockConverter::BlockToNative(const UInstance* Block, UWorld* World)
|
||||
AActor* UBlockConverter::BlockToNative(const UBlockInstance* Block, UWorld* World)
|
||||
{
|
||||
AActor* BlockActor = CreateEmptyActor(World, USpeckleObjectUtils::CreateTransform(Block->Transform));
|
||||
//Return the block actor as is,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Conversion/Converters/MaterialConverter.h"
|
||||
|
||||
@@ -6,15 +8,12 @@
|
||||
#include "Materials/MaterialInstanceDynamic.h"
|
||||
#include "Objects/Other/RenderMaterial.h"
|
||||
#include "UObject/ConstructorHelpers.h"
|
||||
#include "Materials/MaterialInterface.h"
|
||||
#include "Misc/Paths.h"
|
||||
#include "UObject/Package.h"
|
||||
|
||||
|
||||
UMaterialConverter::UMaterialConverter()
|
||||
{
|
||||
static ConstructorHelpers::FObjectFinder<UMaterialInterface> SpeckleMaterial(TEXT("Material'/SpeckleUnreal/SpeckleMaterial.SpeckleMaterial'"));
|
||||
static ConstructorHelpers::FObjectFinder<UMaterialInterface> SpeckleGlassMaterial(TEXT("Material'/SpeckleUnreal/SpeckleGlassMaterial.SpeckleGlassMaterial'"));
|
||||
static ConstructorHelpers::FObjectFinder<UMaterial> SpeckleMaterial(TEXT("Material'/SpeckleUnreal/SpeckleMaterial.SpeckleMaterial'"));
|
||||
static ConstructorHelpers::FObjectFinder<UMaterial> SpeckleGlassMaterial(TEXT("Material'/SpeckleUnreal/SpeckleGlassMaterial.SpeckleGlassMaterial'"));
|
||||
|
||||
DefaultMeshMaterial = SpeckleMaterial.Object;
|
||||
BaseMeshOpaqueMaterial = SpeckleMaterial.Object;
|
||||
@@ -81,7 +80,7 @@ bool UMaterialConverter::TryGetOverride(const URenderMaterial* SpeckleMaterial,
|
||||
{
|
||||
if(ensureAlways(IsValid(Mat)) && Mat->GetName() == Name)
|
||||
{
|
||||
OutMaterial = *MaterialOverridesByName.Find(Mat);
|
||||
OutMaterial = MaterialOverridesById[MaterialID];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Conversion/Converters/PointCloudConverter.h"
|
||||
|
||||
#include "LidarPointCloudActor.h"
|
||||
#include "LidarPointCloudShared.h"
|
||||
#include "LidarPointCloudComponent.h"
|
||||
#include "Objects/Geometry/PointCloud.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Runtime/Launch/Resources/Version.h"
|
||||
|
||||
|
||||
UPointCloudConverter::UPointCloudConverter()
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Conversion/Converters/ProceduralMeshConverter.h"
|
||||
|
||||
@@ -9,6 +10,7 @@
|
||||
#include "Objects/Other/RenderMaterial.h"
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
|
||||
// Setup some basics
|
||||
UProceduralMeshConverter::UProceduralMeshConverter()
|
||||
{
|
||||
SpeckleTypes.Add(UMesh::StaticClass());
|
||||
@@ -18,6 +20,7 @@ UProceduralMeshConverter::UProceduralMeshConverter()
|
||||
ActorMobility = EComponentMobility::Static;
|
||||
}
|
||||
|
||||
// Blueprint for converting data to 3D model
|
||||
UObject* UProceduralMeshConverter::ConvertToNative_Implementation(const UBase* SpeckleBase, UWorld* World,
|
||||
TScriptInterface<ISpeckleConverter>& AvailableConverters )
|
||||
{
|
||||
@@ -66,19 +69,19 @@ AActor* UProceduralMeshConverter::MeshToNative(const UMesh* SpeckleMesh,
|
||||
|
||||
if (n == 3) //Triangles
|
||||
{
|
||||
Faces.Add(SpeckleMesh->Faces[i + 1]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 2]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 3]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 2]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 1]);
|
||||
}
|
||||
else if(n == 4) // Quads
|
||||
{
|
||||
Faces.Add(SpeckleMesh->Faces[i + 1]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 3]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 4]);
|
||||
|
||||
Faces.Add(SpeckleMesh->Faces[i + 1]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 2]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 3]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 1]);
|
||||
|
||||
Faces.Add(SpeckleMesh->Faces[i + 3]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 2]);
|
||||
Faces.Add(SpeckleMesh->Faces[i + 1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "Conversion/Converters/StaticMeshConverter.h"
|
||||
|
||||
@@ -13,21 +14,25 @@
|
||||
#include "Conversion/Converters/MaterialConverter.h"
|
||||
#include "Misc/ScopedSlowTask.h"
|
||||
#include "Objects/DisplayValueElement.h"
|
||||
#include "Objects/Geometry/Box.h"
|
||||
#include "Objects/Other/RenderMaterial.h"
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
#include "Components/StaticMeshComponent.h"
|
||||
#include "Misc/Paths.h"
|
||||
#include "UObject/Package.h"
|
||||
#include "Materials/MaterialInterface.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FSpeckleUnrealModule"
|
||||
|
||||
bool UStaticMeshConverter::CanConvertToNative_Implementation(TSubclassOf<UBase> BaseType)
|
||||
{
|
||||
if(EnabledTypes.Contains(BaseType))
|
||||
return EnabledTypes[BaseType];
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
UStaticMeshConverter::UStaticMeshConverter()
|
||||
{
|
||||
SpeckleTypes.Add(UMesh::StaticClass());
|
||||
SpeckleTypes.Add(UDisplayValueElement::StaticClass());
|
||||
|
||||
HiddenTypes.Add("Objects.BuiltElements.Room");
|
||||
EnabledTypes.Add(UMesh::StaticClass(), true);
|
||||
EnabledTypes.Add(UDisplayValueElement::StaticClass(), true);
|
||||
EnabledTypes.Add(UBoxx::StaticClass(), true);
|
||||
|
||||
#if WITH_EDITORONLY_DATA
|
||||
UseFullBuild = true;
|
||||
@@ -63,6 +68,15 @@ UObject* UStaticMeshConverter::ConvertToNative_Implementation(const UBase* Speck
|
||||
return MeshToNativeActor(m, World, AvailableConverters);
|
||||
}
|
||||
|
||||
|
||||
const UBoxx* b = Cast<UBoxx>(SpeckleBase);
|
||||
if(b != nullptr)
|
||||
{
|
||||
//Handle Element with Display Values
|
||||
const UMesh* m = b->ToMesh();
|
||||
return MeshToNativeActor(m, World, AvailableConverters);
|
||||
}
|
||||
|
||||
const UDisplayValueElement* d = Cast<UDisplayValueElement>(SpeckleBase);
|
||||
if(d != nullptr)
|
||||
{
|
||||
@@ -121,15 +135,6 @@ AActor* UStaticMeshConverter::MeshesToNativeActor(const UBase* Parent, const TAr
|
||||
}
|
||||
|
||||
MeshComponent->SetStaticMesh(Mesh);
|
||||
|
||||
for(const FString& t: HiddenTypes)
|
||||
{
|
||||
if(Parent->SpeckleType.Contains(t))
|
||||
{
|
||||
MeshComponent->SetVisibility(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for(const UMesh* DisplayMesh : SpeckleMeshes)
|
||||
@@ -276,13 +281,6 @@ UStaticMesh* UStaticMeshConverter::MeshesToNativeMesh(UObject* Outer, const UBas
|
||||
for(int j = 0; j < n; j ++)
|
||||
{
|
||||
int32 VertIndex = SpeckleMesh->Faces[i + 1 + j];
|
||||
|
||||
if(VertIndex < 0 || VertIndex >= Vertices.Num())
|
||||
{
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("Invalid Polygon while creating mesh %s - index %d was outside the bounds of the vertex array, face is ignored"), *SpeckleMesh->Id, VertIndex);
|
||||
continue;
|
||||
}
|
||||
|
||||
FVertexID Vert = Vertices[VertIndex];
|
||||
bool AlreadyInSet;
|
||||
Verts.Add(Vert, &AlreadyInSet);
|
||||
@@ -413,8 +411,7 @@ UBase* UStaticMeshConverter::MeshToSpeckle(const UStaticMeshComponent* Object)
|
||||
|
||||
void UStaticMeshConverter::FinishConversion_Implementation()
|
||||
{
|
||||
if(StaticMeshesToBuild.Num() <= 0) return;
|
||||
|
||||
|
||||
FScopeLock Lock(&Lock_StaticMeshesToBuild);
|
||||
|
||||
#if WITH_EDITOR
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Conversion/SpeckleConverterComponent.h"
|
||||
|
||||
@@ -9,12 +11,13 @@
|
||||
#include "Conversion/Converters/StaticMeshConverter.h"
|
||||
#include "Conversion/Converters/MaterialConverter.h"
|
||||
#include "Misc/ScopedSlowTask.h"
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
#include "Transports/Transport.h"
|
||||
#include "UObject/ConstructorHelpers.h"
|
||||
#include "Dom/JsonValue.h"
|
||||
#include "LogSpeckle.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FSpeckleUnrealModule"
|
||||
|
||||
// Sets default values for this component's properties
|
||||
USpeckleConverterComponent::USpeckleConverterComponent()
|
||||
{
|
||||
//TODO consider using an object library for default converters
|
||||
@@ -57,6 +60,21 @@ AActor* USpeckleConverterComponent::RecursivelyConvertToNative(AActor* AOwner, c
|
||||
return RootActor;
|
||||
}
|
||||
|
||||
// We should convert JSON to Speckle Object Streams
|
||||
TArray<FSpeckleStream> USpeckleConverterComponent::ConvertStreamsToNative(AActor* AOwner, const UBase* Base,
|
||||
const TScriptInterface<ITransport>& LocalTransport, bool DisplayProgressBar, TArray<AActor*>& OutActors)
|
||||
{
|
||||
|
||||
return ArrayOfStreams;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AActor* USpeckleConverterComponent::RecursivelyConvertToNative_Internal(AActor* AOwner, const UBase* Base,
|
||||
const TScriptInterface<ITransport>& LocalTransport,
|
||||
FSlowTask* Task,
|
||||
@@ -88,7 +106,7 @@ AActor* USpeckleConverterComponent::RecursivelyConvertToNative_Internal(AActor*
|
||||
{
|
||||
if(Task->ShouldCancel()) break;
|
||||
|
||||
ConvertChild(Kvp.Value, NextOwner, LocalTransport, Task, OutActors);
|
||||
ConvertChild(Kvp.Value, AOwner, LocalTransport, Task, OutActors);
|
||||
}
|
||||
return AOwner;
|
||||
}
|
||||
@@ -110,7 +128,7 @@ void USpeckleConverterComponent::ConvertChild(const TSharedPtr<FJsonValue> Objec
|
||||
const TArray<TSharedPtr<FJsonValue>>* ChildArr;
|
||||
if (Object->TryGetArray(ChildArr))
|
||||
{
|
||||
for (const auto& v : *ChildArr)
|
||||
for (const auto v : *ChildArr)
|
||||
{
|
||||
ConvertChild(v, AOwner, LocalTransport, Task, OutActors);
|
||||
}
|
||||
@@ -128,14 +146,12 @@ void USpeckleConverterComponent::AttachConvertedToOwner(AActor* AOwner, const UB
|
||||
{
|
||||
#if WITH_EDITOR
|
||||
{
|
||||
FString Name = USpeckleObjectUtils::GetFriendlyObjectName(Base);
|
||||
FText NameErrors;
|
||||
|
||||
if(!FActorEditorUtils::ValidateActorName(FText::FromString(Name), NameErrors))
|
||||
FString Name;
|
||||
FText _Discard;
|
||||
if( !(Base->TryGetDynamicString("name", Name) && FActorEditorUtils::ValidateActorName(FText::FromString(Name), _Discard)) )
|
||||
{
|
||||
Name = USpeckleObjectUtils::GetBoringObjectName(Base);
|
||||
Name = FString::Printf(TEXT("%s - %s"), *Base->SpeckleType, *Base->Id);
|
||||
}
|
||||
|
||||
NativeActor->SetActorLabel(Name);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#include "LogSpeckle.h"
|
||||
#include "LogSpeckle.h"
|
||||
#include "Logging/LogMacros.h"
|
||||
|
||||
DEFINE_LOG_CATEGORY(LogSpeckle);
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Objects/DisplayValueElement.h"
|
||||
|
||||
@@ -8,6 +10,8 @@
|
||||
TArray<FString> UDisplayValueElement::DisplayValueAliasStrings = {
|
||||
"displayValue",
|
||||
"@displayValue",
|
||||
"displayMesh"
|
||||
"@displayMesh"
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Objects/Geometry/Box.h"
|
||||
|
||||
#include "Objects/Geometry/Plane.h"
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
|
||||
bool UBoxx::Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITransport> ReadTransport)
|
||||
{
|
||||
if(!Super::Parse(Obj, ReadTransport)) return false;
|
||||
|
||||
const float ScaleFactor = USpeckleObjectUtils::ParseScaleFactor(Units);
|
||||
|
||||
const FString BasePlanePropertyName = TEXT("basePlane");
|
||||
if (Obj->HasField(BasePlanePropertyName))
|
||||
{
|
||||
BasePlane = NewObject<UPlane>();
|
||||
if(!BasePlane->Parse(Obj->GetObjectField(BasePlanePropertyName), ReadTransport)) return false;
|
||||
DynamicProperties.Remove(BasePlanePropertyName);
|
||||
}
|
||||
|
||||
if(!USpeckleObjectUtils::ParseVectorProperty(Obj, "xSize", ReadTransport, XSize)) return false;
|
||||
XSize *= ScaleFactor;
|
||||
DynamicProperties.Remove("xSize");
|
||||
|
||||
if(!USpeckleObjectUtils::ParseVectorProperty(Obj, "ySize", ReadTransport, YSize)) return false;
|
||||
YSize *= ScaleFactor;
|
||||
DynamicProperties.Remove("ySize");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
UMesh* UBoxx::ToMesh(UObject* Outer) const
|
||||
{
|
||||
|
||||
TArray<FVector> Vertices = {
|
||||
FVector(),
|
||||
FVector(),
|
||||
FVector(),
|
||||
FVector(),
|
||||
FVector(),
|
||||
FVector(),
|
||||
};
|
||||
|
||||
TArray<int32> Faces = {
|
||||
};
|
||||
|
||||
//FMatrix transform =
|
||||
|
||||
|
||||
UMesh* Mesh = NewObject<UMesh>(Outer);
|
||||
return Mesh;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Objects/Geometry/Mesh.h"
|
||||
|
||||
@@ -45,7 +47,7 @@ bool UMesh::Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITra
|
||||
{
|
||||
const TArray<TSharedPtr<FJsonValue>> FaceVertices = USpeckleObjectUtils::CombineChunks(Obj->GetArrayField("faces"), ReadTransport);
|
||||
Faces.Reserve(FaceVertices.Num());
|
||||
for(const auto& VertIndex : FaceVertices)
|
||||
for(const auto VertIndex : FaceVertices)
|
||||
{
|
||||
Faces.Add(VertIndex->AsNumber());
|
||||
}
|
||||
@@ -104,7 +106,11 @@ bool UMesh::Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITra
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* If not already so, this method will align vertices
|
||||
* such that a vertex and its corresponding texture coordinates have the same index.
|
||||
* See "https://github.com/specklesystems/speckle-sharp/blob/main/Objects/Objects/Geometry/Mesh.cs"
|
||||
*/
|
||||
void UMesh::AlignVerticesWithTexCoordsByIndex()
|
||||
{
|
||||
if(TextureCoordinates.Num() == 0) return;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Objects/Geometry/Plane.h"
|
||||
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
|
||||
bool UPlane::Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITransport> ReadTransport)
|
||||
{
|
||||
if(!Super::Parse(Obj, ReadTransport)) return false;
|
||||
|
||||
const float ScaleFactor = USpeckleObjectUtils::ParseScaleFactor(Units);
|
||||
|
||||
if(!USpeckleObjectUtils::ParseVectorProperty(Obj, "origin", ReadTransport, Origin)) return false;
|
||||
Origin *= ScaleFactor;
|
||||
DynamicProperties.Remove("origin");
|
||||
|
||||
if(!USpeckleObjectUtils::ParseVectorProperty(Obj, "normal", ReadTransport, Normal)) return false;
|
||||
Normal *= ScaleFactor;
|
||||
DynamicProperties.Remove("normal");
|
||||
|
||||
if(!USpeckleObjectUtils::ParseVectorProperty(Obj, "ydir", ReadTransport, XDir)) return false;
|
||||
XDir *= ScaleFactor;
|
||||
DynamicProperties.Remove("ydir");
|
||||
|
||||
if(!USpeckleObjectUtils::ParseVectorProperty(Obj, "xdir", ReadTransport, YDir)) return false;
|
||||
YDir *= ScaleFactor;
|
||||
DynamicProperties.Remove("xdir");
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Objects/Geometry/PointCloud.h"
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
#include "Objects/ObjectModelRegistry.h"
|
||||
#include "Objects/ObjectModelRegistry.h"
|
||||
|
||||
#include "Objects/Base.h"
|
||||
#include "Templates/SubclassOf.h"
|
||||
@@ -21,81 +20,65 @@ void UObjectModelRegistry::GenerateTypeRegistry()
|
||||
if (Class->IsChildOf(UBase::StaticClass()) &&
|
||||
!Class->HasAnyClassFlags(CLASS_Abstract))
|
||||
{
|
||||
const FString& SpeckleType = Class->GetDefaultObject<UBase>()->SpeckleType;
|
||||
const FString TypeName = GetTypeName(SpeckleType);
|
||||
|
||||
ensureAlwaysMsgf(!TypeRegistry.Contains(TypeName),
|
||||
TEXT("Base class: %s conflicts with: %s for TypeName: %s"),
|
||||
const FString& SpeckleType = Class->GetDefaultObject<UBase>()->SpeckleType;;
|
||||
|
||||
ensureAlwaysMsgf(!TypeRegistry.Contains(SpeckleType),
|
||||
TEXT("Base class: %s conflicts with: %s for SpeckleType: %s"),
|
||||
*Class->GetName(),
|
||||
*TypeRegistry[SpeckleType]->GetName(),
|
||||
*SpeckleType);
|
||||
|
||||
TypeRegistry.Add(TypeName, *It);
|
||||
TypeRegistry.Add(SpeckleType, *It);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool UObjectModelRegistry::SplitSpeckleType(const FString& SpeckleType, FString& OutRemainder, FString& OutTypeName, const FString& Split)
|
||||
|
||||
TSubclassOf<UBase> UObjectModelRegistry::FindClosestType(const FString& SpeckleType)
|
||||
{
|
||||
if(SpeckleType.Split(Split, &OutRemainder, &OutTypeName, ESearchCase::CaseSensitive, ESearchDir::FromEnd))
|
||||
FString TypeString(SpeckleType);
|
||||
TSubclassOf<UBase> Type = nullptr;
|
||||
|
||||
while(!TryGetRegisteredType(TypeString, Type))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
OutTypeName = SpeckleType;
|
||||
return false;
|
||||
if(!ParentType(TypeString, TypeString)) return nullptr;
|
||||
}
|
||||
|
||||
return Type;
|
||||
|
||||
}
|
||||
|
||||
FString UObjectModelRegistry::GetTypeName(const FString& SpeckleType)
|
||||
bool UObjectModelRegistry::ParentType(const FString& Type, FString& NextType)
|
||||
{
|
||||
FString Discard, Ret;
|
||||
SplitSpeckleType(SpeckleType, Discard, Ret);
|
||||
return Ret;
|
||||
int32 DotSplitIndex;
|
||||
Type.FindLastChar('.', DotSplitIndex);
|
||||
int32 ColonSplitIndex;
|
||||
Type.FindLastChar(':', ColonSplitIndex);
|
||||
const int32 SplitIndex = FGenericPlatformMath::Max(DotSplitIndex, ColonSplitIndex);
|
||||
|
||||
if(SplitIndex <= 0) return false;
|
||||
|
||||
NextType = Type.Left(SplitIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
FString UObjectModelRegistry::GetSimplifiedTypeName(const FString& SpeckleType)
|
||||
{
|
||||
FString Discard, Ret;
|
||||
SplitSpeckleType(SpeckleType,Discard, Ret, ".");
|
||||
return Ret;
|
||||
}
|
||||
|
||||
TSubclassOf<UBase> UObjectModelRegistry::GetAtomicType(const FString& SpeckleType)
|
||||
{
|
||||
|
||||
FString WorkingType;
|
||||
FString Remainder = FString(SpeckleType);
|
||||
|
||||
while(SplitSpeckleType(Remainder, Remainder, WorkingType))
|
||||
{
|
||||
TSubclassOf<UBase> Type;
|
||||
if(TryGetRegisteredType(WorkingType, Type))
|
||||
{
|
||||
return Type;
|
||||
}
|
||||
}
|
||||
return UBase::StaticClass();
|
||||
}
|
||||
|
||||
TSubclassOf<UBase> UObjectModelRegistry::GetRegisteredType(const FString& TypeName)
|
||||
TSubclassOf<UBase> UObjectModelRegistry::GetRegisteredType(const FString& SpeckleType)
|
||||
{
|
||||
TSubclassOf<UBase> Type = nullptr;
|
||||
TryGetRegisteredType(TypeName, Type);
|
||||
TryGetRegisteredType(SpeckleType, Type);
|
||||
return Type;
|
||||
}
|
||||
|
||||
bool UObjectModelRegistry::TryGetRegisteredType(const FString& TypeName, TSubclassOf<UBase>& OutType)
|
||||
bool UObjectModelRegistry::TryGetRegisteredType(const FString& SpeckleType, TSubclassOf<UBase>& OutType)
|
||||
{
|
||||
if(TypeRegistry.Num() == 0) GenerateTypeRegistry();
|
||||
|
||||
|
||||
const bool Contains = TypeRegistry.Contains(TypeName);
|
||||
const bool Contains = TypeRegistry.Contains(SpeckleType);
|
||||
if(Contains)
|
||||
{
|
||||
OutType = *TypeRegistry.Find(TypeName);
|
||||
OutType = *TypeRegistry.Find(SpeckleType);
|
||||
}
|
||||
return Contains;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Objects/Other/BlockInstance.h"
|
||||
#include "LogSpeckle.h"
|
||||
@@ -19,23 +21,15 @@ bool UBlockInstance::Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInte
|
||||
|
||||
|
||||
//Geometries
|
||||
//NOTE: This logic differs greatly from sharp/py implementations
|
||||
const TSharedPtr<FJsonObject>* DefPtr;
|
||||
if(!(Obj->TryGetObjectField("definition", DefPtr) || Obj->TryGetObjectField("blockDefinition", DefPtr) )) return false;
|
||||
const TSharedPtr<FJsonObject>* BlockDefinitionPtr;
|
||||
if(!Obj->TryGetObjectField("blockDefinition", BlockDefinitionPtr)) return false;
|
||||
|
||||
const FString RefID = DefPtr->operator->()->GetStringField("referencedId");
|
||||
const TSharedPtr<FJsonObject> Definition = ReadTransport->GetSpeckleObject(RefID);
|
||||
const FString RefID = BlockDefinitionPtr->operator->()->GetStringField("referencedId");
|
||||
const TSharedPtr<FJsonObject> BlockDefinition = ReadTransport->GetSpeckleObject(RefID);
|
||||
|
||||
if(!Obj->TryGetStringField("name", Name))
|
||||
{
|
||||
if(Definition->TryGetStringField("name", Name))
|
||||
{
|
||||
//The instance has no name, so we'll steal it from the definition
|
||||
DynamicProperties.Add("name", Definition->TryGetField("name"));
|
||||
}
|
||||
}
|
||||
if(BlockDefinition->TryGetStringField("name", Name)) DynamicProperties.Remove("Name");
|
||||
|
||||
const auto Geometries = Definition->GetArrayField("geometry");
|
||||
const auto Geometries = BlockDefinition->GetArrayField("geometry");
|
||||
|
||||
if(Geometries.Num() <= 0)
|
||||
{
|
||||
@@ -43,7 +37,7 @@ bool UBlockInstance::Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInte
|
||||
return false;
|
||||
}
|
||||
|
||||
for(const auto& Geo : Geometries)
|
||||
for(const auto Geo : Geometries)
|
||||
{
|
||||
const TSharedPtr<FJsonObject> MeshReference = Geo->AsObject();
|
||||
const FString ChildId = MeshReference->GetStringField("referencedId");
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
|
||||
#include "Objects/Other/RevitInstance.h"
|
||||
#include "LogSpeckle.h"
|
||||
|
||||
#include "API/SpeckleSerializer.h"
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
#include "Transports/Transport.h"
|
||||
|
||||
bool URevitInstance::Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITransport> ReadTransport)
|
||||
{
|
||||
if(!Super::Parse(Obj, ReadTransport)) return false;
|
||||
|
||||
const float ScaleFactor = USpeckleObjectUtils::ParseScaleFactor(Units);
|
||||
|
||||
//Transform
|
||||
if(!USpeckleObjectUtils::TryParseTransform(Obj, Transform)) return false;
|
||||
Transform.ScaleTranslation(FVector(ScaleFactor));
|
||||
DynamicProperties.Remove("Transform");
|
||||
|
||||
|
||||
//Geometries
|
||||
//NOTE: This logic differs greatly from sharp/py implementations
|
||||
const TSharedPtr<FJsonObject>* DefPtr;
|
||||
if(!Obj->TryGetObjectField("definition", DefPtr)) return false;
|
||||
|
||||
const FString RefID = DefPtr->operator->()->GetStringField("referencedId");
|
||||
const TSharedPtr<FJsonObject> Definition = ReadTransport->GetSpeckleObject(RefID);
|
||||
|
||||
if(!Obj->TryGetStringField("name", Name))
|
||||
{
|
||||
if(Definition->TryGetStringField("name", Name))
|
||||
{
|
||||
//The instance has no name, so we'll steal it from the definition
|
||||
DynamicProperties.Add("name", Definition->TryGetField("name"));
|
||||
}
|
||||
}
|
||||
auto Geometries = TArray<TSharedPtr<FJsonValue>>();
|
||||
const TArray<TSharedPtr<FJsonValue>>* ElementsPtr;
|
||||
if(Definition->TryGetArrayField("elements", ElementsPtr))
|
||||
Geometries.Append(*ElementsPtr);
|
||||
const TArray<TSharedPtr<FJsonValue>>* DisplayValuePtr;
|
||||
if(Definition->TryGetArrayField("displayValue", DisplayValuePtr))
|
||||
Geometries.Append(*DisplayValuePtr);
|
||||
|
||||
|
||||
if(Geometries.Num() <= 0)
|
||||
{
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("Instance definition has no geometry. id: %s"), *RefID)
|
||||
return false;
|
||||
}
|
||||
|
||||
for(const auto& Geo : Geometries)
|
||||
{
|
||||
const TSharedPtr<FJsonObject> MeshReference = Geo->AsObject();
|
||||
const FString ChildId = MeshReference->GetStringField("referencedId");
|
||||
|
||||
if(ReadTransport->HasObject(ChildId))
|
||||
{
|
||||
UBase* Child = USpeckleSerializer::DeserializeBase(ReadTransport->GetSpeckleObject(ChildId), ReadTransport);
|
||||
if(IsValid(Child))
|
||||
Geometry.Add(Child);
|
||||
}
|
||||
else UE_LOG(LogSpeckle, Warning, TEXT("Block definition references an unknown object id: %s"), *ChildId)
|
||||
}
|
||||
DynamicProperties.Remove("geometry");
|
||||
|
||||
// Intentionally don't remove blockDefinition from dynamic properties,
|
||||
// because we want the converter to create the child geometries for us
|
||||
//DynamicProperties.Remove("blockDefinition");
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
// Copyright AEC Systems Ltd
|
||||
|
||||
|
||||
#include "Objects/Other/View3D.h"
|
||||
|
||||
@@ -10,7 +12,7 @@ bool UView3D::Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<IT
|
||||
const float ScaleFactor = USpeckleObjectUtils::ParseScaleFactor(Units);
|
||||
|
||||
// Parse optional Name property
|
||||
if(Obj->TryGetStringField("name", Name)) { }
|
||||
if(Obj->TryGetStringField("name", Name)) DynamicProperties.Remove("name");
|
||||
|
||||
// Parse Origin
|
||||
if(!USpeckleObjectUtils::ParseVectorProperty(Obj, "origin", ReadTransport, Origin)) return false;
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Objects/Utils/SpeckleObjectUtils.h"
|
||||
|
||||
#include "LogSpeckle.h"
|
||||
#include "API/SpeckleSerializer.h"
|
||||
#include "Engine/World.h"
|
||||
#include "Objects/ObjectModelRegistry.h"
|
||||
#include "Objects/Geometry/Mesh.h"
|
||||
#include "Transports/Transport.h"
|
||||
#include "Serialization/JsonWriter.h"
|
||||
#include "Serialization/JsonSerializer.h"
|
||||
|
||||
|
||||
TArray<TSharedPtr<FJsonValue>> USpeckleObjectUtils::CombineChunks(const TArray<TSharedPtr<FJsonValue>>& ArrayField, const TScriptInterface<ITransport> Transport)
|
||||
{
|
||||
@@ -72,9 +71,6 @@ float USpeckleObjectUtils::ParseScaleFactor(const FString& UnitsString)
|
||||
if (LUnits == "miles" || LUnits == "mile" || LUnits == "mi")
|
||||
return 160934.4;
|
||||
|
||||
if (LUnits == "us_ft" || LUnits == "ussurveyfeet")
|
||||
return 12000.0 / 3937.0;
|
||||
|
||||
return 100;
|
||||
};
|
||||
|
||||
@@ -99,7 +95,7 @@ bool USpeckleObjectUtils::TryParseTransform(const TSharedPtr<FJsonObject> Speckl
|
||||
if(SpeckleObject->TryGetArrayField("transform", TransformData)) //Handle transform as array
|
||||
{ }
|
||||
else if(SpeckleObject->TryGetObjectField("transform", TransformObject)
|
||||
&& (*TransformObject)->TryGetArrayField("matrix", TransformData)) //Handle transform as object
|
||||
&& (*TransformObject)->TryGetArrayField("value", TransformData)) //Handle transform as object
|
||||
{ }
|
||||
else return false;
|
||||
|
||||
@@ -147,6 +143,41 @@ bool USpeckleObjectUtils::ParseVector(const TSharedPtr<FJsonObject> Object,
|
||||
return ParseSpeckleObject<UMesh>(Obj, Transport, Mesh);
|
||||
}
|
||||
|
||||
bool USpeckleObjectUtils::ParseIntervalProperty(const TSharedPtr<FJsonObject> Base, const FString& PropertyName,
|
||||
const TScriptInterface<ITransport> ReadTransport, FVector2f<float>& OutObject)
|
||||
{
|
||||
const TSharedPtr<FJsonObject>* OriginObject;
|
||||
if(Base->TryGetObjectField(PropertyName, OriginObject)
|
||||
&& ParseInterval(*OriginObject, ReadTransport, OutObject))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool USpeckleObjectUtils::ParseInterval(const TSharedPtr<FJsonObject> Object,
|
||||
const TScriptInterface<ITransport> Transport, FVector2f& OutObject)
|
||||
{
|
||||
if(!ensure(Object != nullptr)) return false;
|
||||
|
||||
TSharedPtr<FJsonObject> Obj;
|
||||
if(!ResolveReference(Object, Transport, Obj)) Obj = Object;
|
||||
|
||||
double x = 0, y = 0, z = 0;
|
||||
|
||||
if(!(Obj->TryGetNumberField("start", x)
|
||||
&& Obj->TryGetNumberField("end", y)) return false;
|
||||
|
||||
OutObject = FVector2f(x,y,z);
|
||||
//return true;
|
||||
|
||||
UMesh* Mesh;
|
||||
return ParseSpeckleObject<UMesh>(Obj, Transport, Mesh);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename TBase>
|
||||
bool USpeckleObjectUtils::ParseSpeckleObject(const TSharedPtr<FJsonObject> Object,
|
||||
const TScriptInterface<ITransport> Transport, TBase*& OutObject)
|
||||
@@ -162,36 +193,7 @@ bool USpeckleObjectUtils::ParseSpeckleObject(const TSharedPtr<FJsonObject> Objec
|
||||
}
|
||||
|
||||
|
||||
AActor* USpeckleObjectUtils::SpawnActorInWorld(const UObject* WorldContextObject, const TSubclassOf<AActor> Class, UPARAM(ref) const FTransform& Transform)
|
||||
AActor* USpeckleObjectUtils::SpawnActorInWorld(const TSubclassOf<AActor> Class, UWorld* World, const FTransform& Transform)
|
||||
{
|
||||
return WorldContextObject->GetWorld()->SpawnActor(Class, &Transform, FActorSpawnParameters());
|
||||
return World->SpawnActor(Class, &Transform, FActorSpawnParameters());
|
||||
}
|
||||
|
||||
FString USpeckleObjectUtils::DisplayAsString(const FString& msg, const TSharedPtr<FJsonObject> Obj)
|
||||
{
|
||||
FString OutputString;
|
||||
TSharedRef<TJsonWriter<>> Writer = TJsonWriterFactory<>::Create(&OutputString);
|
||||
FJsonSerializer::Serialize(Obj.ToSharedRef(), Writer);
|
||||
UE_LOG(LogSpeckle, Display, TEXT("resulting jsonString from %s -> %s"), *msg, *OutputString);
|
||||
return OutputString;
|
||||
}
|
||||
|
||||
FString USpeckleObjectUtils::GetFriendlyObjectName(const UBase* SpeckleObject)
|
||||
{
|
||||
FString Prefix;
|
||||
if(!(SpeckleObject->TryGetDynamicString("name", Prefix)
|
||||
|| SpeckleObject->TryGetDynamicString("Name", Prefix)
|
||||
|| SpeckleObject->TryGetDynamicString("Family", Prefix)))
|
||||
{
|
||||
Prefix = UObjectModelRegistry::GetSimplifiedTypeName(SpeckleObject->SpeckleType);
|
||||
}
|
||||
|
||||
return FString::Printf(TEXT("%s -- %s"), *Prefix, *SpeckleObject->Id);
|
||||
|
||||
}
|
||||
|
||||
FString USpeckleObjectUtils::GetBoringObjectName(const UBase* SpeckleObject)
|
||||
{
|
||||
const FString Prefix = UObjectModelRegistry::GetSimplifiedTypeName(SpeckleObject->SpeckleType);
|
||||
return FString::Printf(TEXT("%s -- %s"), *Prefix, *SpeckleObject->Id);
|
||||
}
|
||||
@@ -1,427 +0,0 @@
|
||||
|
||||
#include "ReceiveSelectionComponent.h"
|
||||
|
||||
#include "API/Models/SpeckleUser.h"
|
||||
#include "API/ClientAPI.h"
|
||||
#include "JsonObjectConverter.h"
|
||||
#include "LogSpeckle.h"
|
||||
|
||||
#if WITH_EDITOR
|
||||
void UReceiveSelectionComponent::PostEditChangeProperty(FPropertyChangedEvent& e)
|
||||
{
|
||||
Super::PostEditChangeProperty(e);
|
||||
|
||||
const FName PropertyName = (e.Property != nullptr) ? e.Property->GetFName() : NAME_None;
|
||||
PropertyChangeHandler(PropertyName);
|
||||
}
|
||||
#endif
|
||||
|
||||
void UReceiveSelectionComponent::PropertyChangeHandler(const FName& PropertyName)
|
||||
{
|
||||
if(bManualMode) return;
|
||||
|
||||
if (PropertyName == GET_MEMBER_NAME_CHECKED(UReceiveSelectionComponent, bManualMode))
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
else if (PropertyName == GET_MEMBER_NAME_CHECKED(UReceiveSelectionComponent, AuthToken)
|
||||
|| PropertyName == GET_MEMBER_NAME_CHECKED(UReceiveSelectionComponent, ServerUrl))
|
||||
{
|
||||
IsAccountValid = !AuthToken.IsEmpty() && !ServerUrl.IsEmpty();
|
||||
if(IsAccountValid)
|
||||
{
|
||||
//TODO maybe we should check URL is a valid URL?
|
||||
ServerUrl.TrimEndInline();
|
||||
while(ServerUrl.RemoveFromEnd("/")) { }
|
||||
AuthToken.TrimEndInline();
|
||||
}
|
||||
|
||||
UpdateStreams();
|
||||
}
|
||||
else if (PropertyName == GET_MEMBER_NAME_CHECKED(UReceiveSelectionComponent, SelectedStreamText)
|
||||
&& !SelectedStreamText.IsEmpty())
|
||||
{
|
||||
IsStreamValid = Streams.Contains(SelectedStreamText);
|
||||
if(IsStreamValid)
|
||||
{
|
||||
SelectStream(SelectedStreamText);
|
||||
}
|
||||
else UpdateStreams();
|
||||
}
|
||||
else if (PropertyName == GET_MEMBER_NAME_CHECKED(UReceiveSelectionComponent, SelectedBranchText)
|
||||
&& !SelectedBranchText.IsEmpty())
|
||||
{
|
||||
IsBranchValid = Branches.Contains(SelectedBranchText);
|
||||
if(IsBranchValid)
|
||||
{
|
||||
SelectBranch(SelectedBranchText);
|
||||
}
|
||||
else UpdateBranches();
|
||||
}
|
||||
else if (PropertyName == GET_MEMBER_NAME_CHECKED(UReceiveSelectionComponent, SelectedCommitText)
|
||||
&& !SelectedCommitText.IsEmpty())
|
||||
{
|
||||
IsCommitValid = Commits.Contains(SelectedCommitText);
|
||||
if(IsCommitValid)
|
||||
{
|
||||
SelectCommit(SelectedCommitText);
|
||||
}
|
||||
else UpdateCommits();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void UReceiveSelectionComponent::Refresh()
|
||||
{
|
||||
IsAccountValid = !AuthToken.IsEmpty() && !ServerUrl.IsEmpty();
|
||||
|
||||
UpdateStreams();
|
||||
}
|
||||
|
||||
|
||||
bool UReceiveSelectionComponent::TryGetSelectedCommit(FSpeckleCommit& OutCommit) const
|
||||
{
|
||||
if(!bManualMode && IsCommitValid)
|
||||
{
|
||||
OutCommit = Commits.FindRef(SelectedCommitText);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UReceiveSelectionComponent::TryGetSelectedBranch(FSpeckleBranch& OutBranch) const
|
||||
{
|
||||
if(!bManualMode && IsBranchValid)
|
||||
{
|
||||
OutBranch = Branches.FindRef(SelectedBranchText);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UReceiveSelectionComponent::TryGetSelectedStream(FSpeckleStream& OutStream) const
|
||||
{
|
||||
if(!bManualMode && IsStreamValid)
|
||||
{
|
||||
OutStream = Streams.FindRef(SelectedStreamText);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UReceiveSelectionComponent::OpenURLInBrowser() const
|
||||
{
|
||||
const FString URL = GetUrl();
|
||||
|
||||
if(!ensure(FPlatformProcess::CanLaunchURL(*URL))) return;
|
||||
|
||||
FString LaunchErrors;
|
||||
FPlatformProcess::LaunchURL(*URL, nullptr, &LaunchErrors);
|
||||
|
||||
if(LaunchErrors.IsEmpty())
|
||||
{
|
||||
UE_LOG(LogSpeckle, Log, TEXT("Launched URL \"%s\" in browser"), *URL);
|
||||
}
|
||||
else
|
||||
{
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("Failed to launched URL \"%s\" in browser - %s"), *URL, *LaunchErrors);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool UReceiveSelectionComponent::IsSelectionComplete(FString& OutStatusMessage) const
|
||||
{
|
||||
if(bManualMode)
|
||||
{
|
||||
if(ServerUrl.IsEmpty()) OutStatusMessage = TEXT("Server Url is invalid, must specify a valid url");
|
||||
else if(StreamId.IsEmpty()) OutStatusMessage = TEXT("Stream id is invalid, must specify a streamId");
|
||||
else if(ObjectId.IsEmpty()) OutStatusMessage = TEXT("Object id is invalid, must specify a objectId");
|
||||
else
|
||||
{
|
||||
OutStatusMessage = TEXT("Ready to recieve object");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!IsAccountValid) OutStatusMessage = TEXT("Account is invalid, please specify a valid server URL and token. (tokens can be created from your Speckle profiles page)");
|
||||
else if(!IsStreamValid) OutStatusMessage = TEXT("Selected stream is invalid");
|
||||
else if(!IsBranchValid) OutStatusMessage = TEXT("Selected branch is invalid");
|
||||
else if(!IsCommitValid) OutStatusMessage = TEXT("Selected commit is invalid");
|
||||
else
|
||||
{
|
||||
ensure(!ServerUrl.IsEmpty());
|
||||
ensure(!StreamId.IsEmpty());
|
||||
ensure(!ObjectId.IsEmpty());
|
||||
OutStatusMessage = TEXT("Ready to recieve commit");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
FString UReceiveSelectionComponent::GetUrl() const
|
||||
{
|
||||
if(bManualMode)
|
||||
{
|
||||
return FString::Printf(TEXT("%s/streams/%s/objects/%s"),
|
||||
*ServerUrl, *StreamId, *ObjectId);
|
||||
}
|
||||
|
||||
if(!IsStreamValid) return ServerUrl;
|
||||
|
||||
if(!IsBranchValid)
|
||||
return FString::Printf(TEXT("%s/streams/%s/"),
|
||||
*ServerUrl, *GetSelectedStream().ID);
|
||||
|
||||
if(!IsCommitValid)
|
||||
return FString::Printf(TEXT("%s/streams/%s/branches/%s"),
|
||||
*ServerUrl, *GetSelectedStream().ID, *GetSelectedBranch().Name);
|
||||
|
||||
return FString::Printf(TEXT("%s/streams/%s/commits/%s"),
|
||||
*ServerUrl, *GetSelectedStream().ID, *GetSelectedCommit().ID);
|
||||
}
|
||||
|
||||
TArray<FString> UReceiveSelectionComponent::GetStreamsOptions() const
|
||||
{
|
||||
TArray<FString> Options;
|
||||
Streams.GetKeys(Options);
|
||||
return Options;
|
||||
}
|
||||
|
||||
bool UReceiveSelectionComponent::SelectStream(const FString& DisplayId)
|
||||
{
|
||||
const bool IsValid = !DisplayId.IsEmpty() && Streams.Contains(DisplayId);
|
||||
if(IsValid && !bManualMode)
|
||||
{
|
||||
SelectedStreamText = DisplayId;
|
||||
IsStreamValid = true;
|
||||
StreamId = GetSelectedStream().ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedStreamText = "";
|
||||
IsStreamValid = false;
|
||||
}
|
||||
UpdateBranches();
|
||||
return IsStreamValid;
|
||||
}
|
||||
|
||||
void UReceiveSelectionComponent::UpdateStreams()
|
||||
{
|
||||
Streams.Reset();
|
||||
SelectStream("");
|
||||
|
||||
if(!IsAccountValid || bManualMode) return;
|
||||
|
||||
const FString LogName(__FUNCTION__);
|
||||
const FString Payload = FString::Printf(TEXT("{\"query\": \"query{activeUser{id streams(limit: %d){items{id name}}}}\"}"), Limit);
|
||||
|
||||
//Response Handling
|
||||
auto OnComplete = [&](const FString& ResponseJson)
|
||||
{
|
||||
if(bManualMode) return;
|
||||
|
||||
FSpeckleUser Response;
|
||||
|
||||
if(!ensure(FJsonObjectConverter::JsonObjectStringToUStruct(*ResponseJson, &Response, 0, 0))) return;
|
||||
|
||||
const TArray<FSpeckleStream>& AvailableStreams = Response.Streams.Items;
|
||||
//Assemble stream map
|
||||
Streams.Reserve(AvailableStreams.Num());
|
||||
for(const auto& s : Response.Streams.Items)
|
||||
{
|
||||
FString DisplayId = FString::Printf(TEXT("%s - %s"), *s.Name, *s.ID);
|
||||
Streams.Add(DisplayId, s);
|
||||
}
|
||||
|
||||
//Set default selection
|
||||
if(AvailableStreams.Num() > 0)
|
||||
{
|
||||
const FSpeckleStream& s = AvailableStreams[0];
|
||||
FString DisplayId = FString::Printf(TEXT("%s - %s"), *s.Name, *s.ID);
|
||||
|
||||
SelectStream(DisplayId);
|
||||
}
|
||||
|
||||
UE_LOG(LogSpeckle, Verbose, TEXT("%s was successful"), *LogName);
|
||||
};
|
||||
FAPIResponceDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindLambda(OnComplete);
|
||||
|
||||
//On error
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindStatic(LogError, LogName);
|
||||
|
||||
FClientAPI::MakeGraphQLRequest(ServerUrl, AuthToken, "activeUser", Payload, LogName, CompleteDelegate, ErrorDelegate);
|
||||
|
||||
}
|
||||
|
||||
FSpeckleStream UReceiveSelectionComponent::GetSelectedStream() const
|
||||
{
|
||||
return Streams[SelectedStreamText];
|
||||
}
|
||||
|
||||
TArray<FString> UReceiveSelectionComponent::GetBranchOptions()
|
||||
{
|
||||
TArray<FString> Options;
|
||||
Branches.GetKeys(Options);
|
||||
return Options;
|
||||
}
|
||||
|
||||
bool UReceiveSelectionComponent::SelectBranch(const FString& DisplayId)
|
||||
{
|
||||
const bool IsValid = !DisplayId.IsEmpty() && Branches.Contains(DisplayId);
|
||||
if(IsValid && !bManualMode)
|
||||
{
|
||||
SelectedBranchText = DisplayId;
|
||||
IsBranchValid = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedBranchText = "";
|
||||
IsBranchValid=false;
|
||||
}
|
||||
UpdateCommits();
|
||||
return IsBranchValid;
|
||||
}
|
||||
|
||||
|
||||
void UReceiveSelectionComponent::UpdateBranches()
|
||||
{
|
||||
Branches.Reset();
|
||||
SelectBranch("");
|
||||
|
||||
if(!IsStreamValid || bManualMode) return;
|
||||
|
||||
const FString LogName(__FUNCTION__);
|
||||
const FString Payload = FString::Printf(TEXT("{\"query\": \"query{stream(id: \\\"%s\\\"){branches(limit: %d){items{id name}}}}\"}"), *GetSelectedStream().ID, Limit);
|
||||
|
||||
//Response Handling
|
||||
auto OnComplete = [&](const FString& ResponseJson)
|
||||
{
|
||||
if(bManualMode) return;
|
||||
|
||||
FSpeckleStream Response;
|
||||
|
||||
if(!ensure(FJsonObjectConverter::JsonObjectStringToUStruct(*ResponseJson, &Response, 0, 0))) return;
|
||||
|
||||
const TArray<FSpeckleBranch>& AvailableBranches = Response.Branches.Items;
|
||||
|
||||
//Assemble stream map
|
||||
Branches.Reserve(AvailableBranches.Num());
|
||||
for(const auto& b : AvailableBranches)
|
||||
{
|
||||
FString DisplayId = FString::Printf(TEXT("%s"), *b.Name);
|
||||
Branches.Add(DisplayId, b);
|
||||
}
|
||||
|
||||
UE_LOG(LogSpeckle, Verbose, TEXT("%s was successful"), *LogName);
|
||||
|
||||
//Set default selection
|
||||
if(AvailableBranches.Num() > 0)
|
||||
{
|
||||
const FSpeckleBranch& b = AvailableBranches[0];
|
||||
FString DisplayId = FString::Printf(TEXT("%s"), *b.Name);
|
||||
|
||||
SelectBranch(DisplayId);
|
||||
}
|
||||
};
|
||||
FAPIResponceDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindLambda(OnComplete);
|
||||
|
||||
//On error
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindStatic(LogError, LogName);
|
||||
|
||||
FClientAPI::MakeGraphQLRequest(ServerUrl, AuthToken, "stream", Payload,LogName, CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
|
||||
FSpeckleBranch UReceiveSelectionComponent::GetSelectedBranch() const
|
||||
{
|
||||
return Branches[SelectedBranchText];
|
||||
}
|
||||
|
||||
TArray<FString> UReceiveSelectionComponent::GetCommitOptions()
|
||||
{
|
||||
TArray<FString> Options;
|
||||
Commits.GetKeys(Options);
|
||||
return Options;
|
||||
}
|
||||
|
||||
bool UReceiveSelectionComponent::SelectCommit(const FString& DisplayId)
|
||||
{
|
||||
const bool IsValid = !DisplayId.IsEmpty() && Commits.Contains(DisplayId);
|
||||
if(IsValid && !bManualMode)
|
||||
{
|
||||
SelectedCommitText = DisplayId;
|
||||
IsCommitValid = true;
|
||||
ObjectId = GetSelectedCommit().ReferencedObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
SelectedCommitText = "";
|
||||
IsCommitValid=false;
|
||||
ObjectId = "";
|
||||
}
|
||||
return IsCommitValid;
|
||||
}
|
||||
|
||||
void UReceiveSelectionComponent::UpdateCommits()
|
||||
{
|
||||
Commits.Reset();
|
||||
SelectCommit("");
|
||||
|
||||
if(!IsBranchValid || bManualMode) return;
|
||||
|
||||
const FString LogName(__FUNCTION__);
|
||||
const FString Payload = FString::Printf(TEXT("{\"query\": \"query{stream(id: \\\"%s\\\"){branch(name: \\\"%s\\\"){commits(limit: %d){items{id message referencedObject}}}}}\"}"), *GetSelectedStream().ID, *GetSelectedBranch().Name, Limit);
|
||||
|
||||
//Response Handling
|
||||
auto OnComplete = [&](const FString& ResponseJson)
|
||||
{
|
||||
if(bManualMode) return;
|
||||
|
||||
FSpeckleStream Response;
|
||||
|
||||
if(!ensure(FJsonObjectConverter::JsonObjectStringToUStruct(*ResponseJson, &Response, 0, 0))) return;
|
||||
|
||||
const TArray<FSpeckleCommit>& AvailableCommits = Response.Branch.Commits.Items;
|
||||
|
||||
//Assemble stream map
|
||||
for(const auto& c :AvailableCommits)
|
||||
{
|
||||
FString DisplayId = FString::Printf(TEXT("%s - %s"), *c.Message, *c.ID);
|
||||
Commits.Add(DisplayId, c);
|
||||
}
|
||||
|
||||
UE_LOG(LogSpeckle, Verbose, TEXT("%s was successful"), *LogName);
|
||||
|
||||
//Set default selection
|
||||
if(AvailableCommits.Num() > 0)
|
||||
{
|
||||
const FSpeckleCommit& c = AvailableCommits[0];
|
||||
FString DisplayId = FString::Printf(TEXT("%s - %s"), *c.Message, *c.ID);
|
||||
SelectCommit(DisplayId);
|
||||
}
|
||||
};
|
||||
FAPIResponceDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindLambda(OnComplete);
|
||||
|
||||
//On error
|
||||
FErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindStatic(LogError, LogName);
|
||||
|
||||
FClientAPI::MakeGraphQLRequest(ServerUrl, AuthToken, "stream", Payload,LogName, CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
FSpeckleCommit UReceiveSelectionComponent::GetSelectedCommit() const
|
||||
{
|
||||
return Commits[SelectedCommitText];
|
||||
}
|
||||
|
||||
void UReceiveSelectionComponent::LogError(const FString& Message, const FString LogName)
|
||||
{
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("%s: %s"), *LogName, *Message)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "SpeckleUnreal.h"
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
|
||||
#include "SpeckleUnrealManager.h"
|
||||
|
||||
#include "ReceiveSelectionComponent.h"
|
||||
#include "API/Operations/ReceiveOperation.h"
|
||||
|
||||
#include "Transports/MemoryTransport.h"
|
||||
#include "Transports/ServerTransport.h"
|
||||
#include "LogSpeckle.h"
|
||||
@@ -11,8 +10,8 @@
|
||||
#include "Misc/ScopedSlowTask.h"
|
||||
#include "Objects/Base.h"
|
||||
#include "Mixpanel.h"
|
||||
#include "API/SpeckleAPIFunctions.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Interfaces/IHttpRequest.h"
|
||||
|
||||
#define LOCTEXT_NAMESPACE "FSpeckleUnrealModule"
|
||||
|
||||
@@ -24,12 +23,15 @@ ASpeckleUnrealManager::ASpeckleUnrealManager()
|
||||
RootComponent->SetRelativeScale3D(FVector(1,1,1));
|
||||
RootComponent->SetMobility(EComponentMobility::Static);
|
||||
|
||||
// Convert JSON to object models
|
||||
Converter = CreateDefaultSubobject<USpeckleConverterComponent>(FName("Converter"));
|
||||
ReceiveSelection = CreateDefaultSubobject<UReceiveSelectionComponent>(FName("ReceiveSelection"));
|
||||
|
||||
KeepCache = true;
|
||||
DisplayProgressBar = true;
|
||||
ServerUrl = "https://speckle.xyz";
|
||||
}
|
||||
|
||||
// Begin Play function (Receive)
|
||||
void ASpeckleUnrealManager::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
@@ -37,86 +39,104 @@ void ASpeckleUnrealManager::BeginPlay()
|
||||
if(ImportAtRuntime) Receive();
|
||||
}
|
||||
|
||||
// Start the Receive process
|
||||
void ASpeckleUnrealManager::Receive()
|
||||
{
|
||||
// Check object to receive has been specified properly
|
||||
FString StatusMessage;
|
||||
if(!ReceiveSelection->IsSelectionComplete(StatusMessage))
|
||||
{
|
||||
HandleError(StatusMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete all actors from previous receive operations
|
||||
DeleteObjects();
|
||||
|
||||
const FString ServerUrl = ReceiveSelection->ServerUrl;
|
||||
const FString AuthToken = ReceiveSelection->AuthToken;
|
||||
const FString StreamId = ReceiveSelection->StreamId;
|
||||
const FString ObjectId = ReceiveSelection->ObjectId;
|
||||
|
||||
FAnalytics::TrackEvent( ServerUrl, "NodeRun", TMap<FString, FString> { {"name", StaticClass()->GetName() }, {"worldType", FString::FromInt(GetWorld()->WorldType)}});
|
||||
FString Message = FString::Printf(TEXT("Fetching Objects from Speckle Server: %s"), *ServerUrl);
|
||||
PrintMessage(Message);
|
||||
|
||||
// Setup network transports
|
||||
UServerTransport* ServerTransport = UServerTransport::CreateServerTransport(ServerUrl, StreamId, AuthToken);
|
||||
|
||||
if(!KeepCache && LocalObjectCache)
|
||||
// Trim parameters
|
||||
ServerUrl.TrimEndInline();
|
||||
while(ServerUrl.RemoveFromEnd("/")) { }
|
||||
StreamID.TrimEndInline();
|
||||
ObjectID.TrimEndInline();
|
||||
AuthToken.TrimEndInline();
|
||||
|
||||
// Analytics
|
||||
FAnalytics::TrackEvent(
|
||||
"unknown",
|
||||
"unknown",
|
||||
"NodeRun",
|
||||
TMap<FString, FString> {
|
||||
{"name", StaticClass()->GetName() },
|
||||
{"worldType", FString::FromInt(GetWorld()->WorldType)}}
|
||||
);
|
||||
|
||||
// Clear cache
|
||||
if(!KeepCache && LocalObjectCache.GetObjectRef() != nullptr)
|
||||
{
|
||||
LocalObjectCache.GetObjectRef()->ConditionalBeginDestroy();
|
||||
LocalObjectCache = UMemoryTransport::CreateEmptyMemoryTransport();
|
||||
}
|
||||
if(!LocalObjectCache) LocalObjectCache = UMemoryTransport::CreateEmptyMemoryTransport();
|
||||
|
||||
// Setup delegate callbacks
|
||||
// Probably a duplication
|
||||
if(LocalObjectCache.GetObjectRef() == nullptr)
|
||||
{
|
||||
LocalObjectCache = UMemoryTransport::CreateEmptyMemoryTransport();
|
||||
}
|
||||
|
||||
// Debug message
|
||||
FString Message = FString::Printf(TEXT("Fetching Objects from Speckle Server: %s"), *ServerUrl);
|
||||
PrintMessage(Message);
|
||||
|
||||
// Error delegate
|
||||
FTransportErrorDelegate ErrorDelegate;
|
||||
ErrorDelegate.BindUObject(this, &ASpeckleUnrealManager::HandleError);
|
||||
|
||||
// Complete delegate
|
||||
FTransportCopyObjectCompleteDelegate CompleteDelegate;
|
||||
CompleteDelegate.BindUObject(this, &ASpeckleUnrealManager::HandleReceive, DisplayProgressBar);
|
||||
|
||||
// Send request for objects
|
||||
ServerTransport->CopyObjectAndChildren(ObjectId, LocalObjectCache, CompleteDelegate, ErrorDelegate);
|
||||
|
||||
// Read receipt (if receiving a commit object)
|
||||
FSpeckleCommit Commit;
|
||||
if(ReceiveSelection->TryGetSelectedCommit(Commit))
|
||||
{
|
||||
//TODO read receipt
|
||||
USpeckleAPIFunctions::CommitReceived(Commit);
|
||||
}
|
||||
// Create a server transport
|
||||
UServerTransport* ServerTransport = UServerTransport::CreateServerTransport(ServerUrl,StreamID,AuthToken);
|
||||
|
||||
// Receive
|
||||
ServerTransport->CopyObjectAndChildren(ObjectID, LocalObjectCache, CompleteDelegate, ErrorDelegate);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Handle Received JSON
|
||||
void ASpeckleUnrealManager::HandleReceive(TSharedPtr<FJsonObject> RootObject, bool DisplayProgress)
|
||||
{
|
||||
if(RootObject == nullptr) return;
|
||||
|
||||
|
||||
// Create a Base Deserialization Object Model
|
||||
const UBase* Res = USpeckleSerializer::DeserializeBase(RootObject, LocalObjectCache);
|
||||
|
||||
if(IsValid(Res))
|
||||
{
|
||||
// Start conversion
|
||||
Converter->RecursivelyConvertToNative(this, Res, LocalObjectCache, DisplayProgress, Actors);
|
||||
|
||||
|
||||
// Finished Conversion - show debug message
|
||||
FString Message = FString::Printf(TEXT("Converted %d Actors"), Actors.Num());
|
||||
PrintMessage(Message);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Object id from Json
|
||||
FString Id;
|
||||
|
||||
// Try to get JSON id field
|
||||
RootObject->TryGetStringField("id", Id);
|
||||
|
||||
// Debug message for error wrt to id
|
||||
FString Message = FString::Printf(TEXT("Failed to deserialise root object: %s"), *Id);
|
||||
|
||||
// Print Message
|
||||
HandleError(Message);
|
||||
}
|
||||
}
|
||||
|
||||
// Error handler just prints a debug message
|
||||
void ASpeckleUnrealManager::HandleError(FString& Message)
|
||||
{
|
||||
PrintMessage(Message, true);
|
||||
}
|
||||
|
||||
// Print debug message
|
||||
void ASpeckleUnrealManager::PrintMessage(FString& Message, bool IsError) const
|
||||
{
|
||||
// Show at Console log: "Error" or just "Log" message (Errors are shown in red in output console)
|
||||
if(IsError)
|
||||
{
|
||||
UE_LOG(LogSpeckle, Error, TEXT("%s"), *Message);
|
||||
@@ -125,16 +145,19 @@ void ASpeckleUnrealManager::PrintMessage(FString& Message, bool IsError) const
|
||||
{
|
||||
UE_LOG(LogSpeckle, Log, TEXT("%s"), *Message);
|
||||
}
|
||||
|
||||
|
||||
// Error as a debug message
|
||||
FColor Color = IsError? FColor::Red : FColor::Green;
|
||||
GEngine->AddOnScreenDebugMessage(0, 5.0f, Color, Message);
|
||||
}
|
||||
|
||||
|
||||
// Delete Actors containing all the 3D models
|
||||
void ASpeckleUnrealManager::DeleteObjects()
|
||||
{
|
||||
// If still converting, terminate process
|
||||
Converter->FinishConversion();
|
||||
|
||||
|
||||
// Destroy actors
|
||||
for (AActor* a : Actors)
|
||||
{
|
||||
if(IsValid(a)) a->Destroy();
|
||||
@@ -143,4 +166,7 @@ void ASpeckleUnrealManager::DeleteObjects()
|
||||
Actors.Empty();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#undef LOCTEXT_NAMESPACE
|
||||
@@ -1,77 +0,0 @@
|
||||
|
||||
#include "LogSpeckle.h"
|
||||
#include "Misc/AutomationTest.h"
|
||||
#include "ReceiveSelectionComponent.h"
|
||||
#include "Tests/AutomationCommon.h"
|
||||
|
||||
#if WITH_DEV_AUTOMATION_TESTS
|
||||
|
||||
|
||||
class UMock : public UReceiveSelectionComponent
|
||||
{
|
||||
friend class FReceiveSelectionComponentTest;
|
||||
friend class FCheckValidSelection;
|
||||
friend class FCheckLimitMatch;
|
||||
};
|
||||
|
||||
DEFINE_LATENT_AUTOMATION_COMMAND_TWO_PARAMETER(FCheckValidSelection, FAutomationTestBase*, Test, UMock*, SelectionComponent);
|
||||
bool FCheckValidSelection::Update()
|
||||
{
|
||||
const UMock* s = SelectionComponent;
|
||||
|
||||
Test->TestTrue(TEXT("Account valid on set"), s->IsAccountValid);
|
||||
Test->TestTrue(TEXT("Stream valid on set"), s->IsStreamValid);
|
||||
Test->TestTrue(TEXT("Branch valid on set"), s->IsBranchValid);
|
||||
Test->TestTrue(TEXT("Commit valid on set"), s->IsCommitValid);
|
||||
return true;
|
||||
}
|
||||
|
||||
DEFINE_LATENT_AUTOMATION_COMMAND_TWO_PARAMETER(FCheckLimitMatch, FAutomationTestBase*, Test, UMock*, SelectionComponent);
|
||||
bool FCheckLimitMatch::Update()
|
||||
{
|
||||
const UMock* s = SelectionComponent;
|
||||
|
||||
Test->TestTrue(TEXT("Fetched streams is less than limit"), s->Streams.Num() <= s->Limit);
|
||||
Test->TestTrue(TEXT("Fetched branches is less than limit"), s->Branches.Num() <= s->Limit);
|
||||
Test->TestTrue(TEXT("Fetched commits is less than limit"), s->Commits.Num() <= s->Limit);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FReceiveSelectionComponentTest, "SpeckleUnreal.ReceiveSelectionComponentTest", EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
||||
|
||||
bool FReceiveSelectionComponentTest::RunTest(const FString& Parameters)
|
||||
{
|
||||
#ifdef TEST_AUTH_TOKEN
|
||||
UMock* s = NewObject<UMock>();
|
||||
|
||||
|
||||
//Test initialisation
|
||||
TestFalse(TEXT("Account valid on initialise"), s->IsAccountValid);
|
||||
TestFalse(TEXT("Stream valid on initialise"), s->IsStreamValid);
|
||||
TestFalse(TEXT("Branch valid on initialise"), s->IsBranchValid);
|
||||
TestFalse(TEXT("Commit valid on initialise"), s->IsCommitValid);
|
||||
|
||||
|
||||
s->AuthToken = TEST_AUTH_TOKEN;
|
||||
s->ServerUrl = TEXT("https://latest.speckle.dev");
|
||||
s->bManualMode = false;
|
||||
s->Refresh();
|
||||
|
||||
//wait 5 seconds for HTTP requests to finish
|
||||
ADD_LATENT_AUTOMATION_COMMAND(FWaitLatentCommand(5.0f));
|
||||
|
||||
ADD_LATENT_AUTOMATION_COMMAND(FCheckValidSelection(this, s));
|
||||
ADD_LATENT_AUTOMATION_COMMAND(FCheckLimitMatch(this, s));
|
||||
|
||||
|
||||
#else
|
||||
TestTrue(TEXT("TEST_AUTH_TOKEN definition exists"), false);
|
||||
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#include "Misc/AutomationTest.h"
|
||||
#include "Objects/Base.h"
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#include "Misc/AutomationTest.h"
|
||||
#include "Objects/Base.h"
|
||||
#include "Transports/ServerTransport.h"
|
||||
|
||||
|
||||
#if WITH_DEV_AUTOMATION_TESTS
|
||||
|
||||
IMPLEMENT_SIMPLE_AUTOMATION_TEST(FServerTransportTest, "SpeckleUnreal.Transports.ServerTransport", EAutomationTestFlags::EditorContext | EAutomationTestFlags::ProductFilter)
|
||||
|
||||
|
||||
bool FServerTransportTest::RunTest(const FString& Parameters)
|
||||
{
|
||||
FString ServerUrl = TEXT("https://example.com");
|
||||
FString StreamId = TEXT("1234");
|
||||
FString Token = TEXT("MyAuthToken");
|
||||
auto Transport = UServerTransport::CreateServerTransport(ServerUrl, StreamId, Token);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@@ -1,6 +1,7 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Transports/MemoryTransport.h"
|
||||
|
||||
#include "LogSpeckle.h"
|
||||
|
||||
bool UMemoryTransport::HasObject(const FString& ObjectId) const
|
||||
@@ -17,5 +18,5 @@ TSharedPtr<FJsonObject> UMemoryTransport::GetSpeckleObject(const FString& Object
|
||||
void UMemoryTransport::SaveObject(const FString& ObjectId, const TSharedPtr<FJsonObject> SerializedObject)
|
||||
{
|
||||
SpeckleObjects.Add(ObjectId, SerializedObject);
|
||||
UE_LOG(LogSpeckle, Verbose, TEXT("Added %s to in memory transport, now %d objects total "), *ObjectId, SpeckleObjects.Num());
|
||||
UE_LOG(LogSpeckle, Log, TEXT("-----------> ADDED <-------------- %d"), SpeckleObjects.Num());
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "Transports/ServerTransport.h"
|
||||
|
||||
#include "LogSpeckle.h"
|
||||
#include "Mixpanel.h"
|
||||
|
||||
#include "JsonObjectConverter.h"
|
||||
#include "HttpModule.h"
|
||||
#include "Interfaces/IHttpRequest.h"
|
||||
@@ -27,6 +29,7 @@ bool UServerTransport::HasObject(const FString& ObjectId) const
|
||||
return false;
|
||||
}
|
||||
|
||||
// Parse Root JSON
|
||||
void UServerTransport::HandleRootObjectResponse(const FString& RootObjSerialized,
|
||||
TScriptInterface<ITransport> TargetTransport,
|
||||
const FString& ObjectId) const
|
||||
@@ -59,6 +62,7 @@ void UServerTransport::HandleRootObjectResponse(const FString& RootObjSerialized
|
||||
}
|
||||
|
||||
|
||||
// Create HTTP Request for Commit Root objects (only ids of children)
|
||||
void UServerTransport::CopyObjectAndChildren(const FString& ObjectId,
|
||||
TScriptInterface<ITransport> TargetTransport,
|
||||
const FTransportCopyObjectCompleteDelegate& OnCompleteAction,
|
||||
@@ -73,10 +77,7 @@ void UServerTransport::CopyObjectAndChildren(const FString& ObjectId,
|
||||
Request->SetVerb("GET");
|
||||
Request->SetURL(Endpoint);
|
||||
Request->SetHeader("Accept", TEXT("text/plain"));
|
||||
if(!AuthToken.IsEmpty())
|
||||
Request->SetHeader("Authorization","Bearer " + AuthToken);
|
||||
Request->SetHeader("apollographql-client-name", "Unreal Engine");
|
||||
Request->SetHeader("apollographql-client-version", SPECKLE_CONNECTOR_VERSION);
|
||||
Request->SetHeader("Authorization", "Bearer " + AuthToken);
|
||||
|
||||
// Response Callback
|
||||
auto ResponseHandler = [=](FHttpRequestPtr, FHttpResponsePtr Response, bool bWasSuccessful) mutable
|
||||
@@ -111,16 +112,17 @@ void UServerTransport::CopyObjectAndChildren(const FString& ObjectId,
|
||||
return;
|
||||
}
|
||||
UE_LOG(LogSpeckle, Verbose, TEXT("GET Request sent for root object at %s, awaiting response"), *Endpoint );
|
||||
FAnalytics::TrackEvent(ServerUrl, "Receive");
|
||||
FAnalytics::TrackEvent("unknown", ServerUrl, "Receive");
|
||||
}
|
||||
|
||||
// Fetch Children JSON and parse it
|
||||
void UServerTransport::FetchChildren(TScriptInterface<ITransport> TargetTransport, const FString& ObjectId,
|
||||
const TArray<FString>& ChildrenIds, int32 CStart) const
|
||||
const TArray<FString>& ChildrenIds, int32 CStart) const
|
||||
{
|
||||
// Check if all children have been fetched
|
||||
if(ChildrenIds.Num() <= CStart)
|
||||
{
|
||||
UE_LOG(LogSpeckle, Log, TEXT("Finished fetching child Speckle objects"));
|
||||
UE_LOG(LogSpeckle, Log, TEXT("----------->PJSON < CSTART <-----------"));
|
||||
ensureAlwaysMsgf(this->OnComplete.ExecuteIfBound(TargetTransport->GetSpeckleObject(ObjectId)),
|
||||
TEXT("Complete handler was not bound properly"));
|
||||
return;
|
||||
@@ -136,7 +138,8 @@ void UServerTransport::FetchChildren(TScriptInterface<ITransport> TargetTranspor
|
||||
for (int32 i = CStart; i < CEnd; i++)
|
||||
{
|
||||
Writer->WriteValue(ChildrenIds[i]);
|
||||
} Writer->WriteArrayEnd();
|
||||
}
|
||||
Writer->WriteArrayEnd();
|
||||
Writer->Close();
|
||||
}
|
||||
|
||||
@@ -156,8 +159,7 @@ void UServerTransport::FetchChildren(TScriptInterface<ITransport> TargetTranspor
|
||||
Request->SetVerb("POST");
|
||||
Request->SetURL(EndPoint);
|
||||
Request->SetHeader("Accept", TEXT("text/plain"));
|
||||
if(!AuthToken.IsEmpty())
|
||||
Request->SetHeader("Authorization","Bearer " + AuthToken);
|
||||
Request->SetHeader("Authorization", "Bearer " + AuthToken);
|
||||
Request->SetHeader("Content-Type", "application/json");
|
||||
Request->SetContentAsString(Body);
|
||||
}
|
||||
@@ -165,7 +167,7 @@ void UServerTransport::FetchChildren(TScriptInterface<ITransport> TargetTranspor
|
||||
// Response Callback
|
||||
auto ResponseHandler = [=](FHttpRequestPtr, FHttpResponsePtr Response, bool bWasSuccessful) mutable
|
||||
{
|
||||
// Request Fail
|
||||
// Any Fail
|
||||
if(!bWasSuccessful)
|
||||
{
|
||||
FString Message = FString::Printf(TEXT("Request for children of root object %s/%s failed: %s"),
|
||||
@@ -191,7 +193,7 @@ void UServerTransport::FetchChildren(TScriptInterface<ITransport> TargetTranspor
|
||||
|
||||
UE_LOG(LogSpeckle, Verbose, TEXT("Parsing %d downloaded objects..."), LineCount)
|
||||
|
||||
// Warning: Fewer/More objects then expected
|
||||
// Warning: Less objects then expected
|
||||
if(LineCount != CEnd - CStart)
|
||||
{
|
||||
UE_LOG(LogSpeckle, Warning, TEXT("Requested %d objects, but received %d"), CEnd - CStart, LineCount);
|
||||
|
||||
@@ -1,52 +1,80 @@
|
||||
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
#pragma once
|
||||
|
||||
#include "Interfaces/IHttpRequest.h"
|
||||
#include "Dom/JsonObject.h"
|
||||
|
||||
struct FSpeckleStream;
|
||||
struct FSpeckleBranch;
|
||||
struct FSpeckleCommit;
|
||||
struct FSpeckleGlobals;
|
||||
struct FSpeckleUser;
|
||||
|
||||
DECLARE_DELEGATE_OneParam(FErrorDelegate, const FString&);
|
||||
DECLARE_DELEGATE_OneParam(FAPIResponceDelegate, const FString&);
|
||||
DECLARE_DELEGATE_OneParam(FFetchStreamDelegate, const TArray<FSpeckleStream>&);
|
||||
DECLARE_DELEGATE_OneParam(FFetchBranchDelegate, const TArray<FSpeckleBranch>&);
|
||||
DECLARE_DELEGATE_OneParam(FFetchCommitDelegate, const TArray<FSpeckleCommit>&);
|
||||
DECLARE_DELEGATE_OneParam(FFetchGlobalsDelegate, const FSpeckleGlobals&);
|
||||
DECLARE_DELEGATE_OneParam(FFetchUserDelegate, const FSpeckleUser&);
|
||||
|
||||
/**
|
||||
* C++ wrapper of Speckle's GraphQL API
|
||||
* Encapsulates sending HTTP requests with GraphQL Queries for specific resources
|
||||
*
|
||||
* Used to send GraphQL requests for commits, branches, streams, user info, collaborators etc.
|
||||
*
|
||||
* See `API/Operations` for usage examples
|
||||
*/
|
||||
class FClientAPI
|
||||
{
|
||||
/**
|
||||
* C++ wrapper for GraphQL requests
|
||||
* See Operations to use with blueprint
|
||||
*/
|
||||
class FClientAPI
|
||||
{
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Creates and sends a graphql query to the specified url.
|
||||
* Will check HTTP response for errors,
|
||||
* and unpack the response "data" object.
|
||||
* @param ServerUrl URL of the Speckle Server endpoint
|
||||
* @param AuthToken
|
||||
* @param ResponsePropertyName Property name of the requested object. This will be the first name in the query (e.g. "stream", "streams", "user", etc)
|
||||
* @param PostPayload The POST payload containing the GraphQL request
|
||||
* @param RequestLogName Friendly name for this request (for error handling and logging)
|
||||
* @param OnCompleteAction Callback invoked on successful completion of the request, with the request object (as a JSON string)
|
||||
* @param OnErrorAction Callback invoked on any fatal error with, the error message.
|
||||
*/
|
||||
static void MakeGraphQLRequest(const FString& ServerUrl, const FString& AuthToken, const FString& ResponsePropertyName,
|
||||
const FString& PostPayload, const FString& RequestLogName,
|
||||
const FAPIResponceDelegate OnCompleteAction, const FErrorDelegate OnErrorAction);
|
||||
static void StreamsGet( const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const int32 Limit,
|
||||
const FFetchStreamDelegate OnCompleteAction,
|
||||
const FErrorDelegate OnErrorAction);
|
||||
|
||||
|
||||
static void StreamGetBranches( const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const FString& StreamId,
|
||||
const int32 Limit,
|
||||
const FFetchBranchDelegate OnCompleteAction,
|
||||
const FErrorDelegate OnErrorAction);
|
||||
|
||||
//protected:
|
||||
|
||||
/// Helper function for creating post requests with a GraphQL query
|
||||
static FHttpRequestRef CreatePostRequest(const FString& ServerUrl, FString AuthToken, const FString& PostPayload,
|
||||
const FString& Encoding = TEXT("gzip"));
|
||||
static void StreamGetCommits( const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const FString& StreamId,
|
||||
const FString& BranchName,
|
||||
const int32 Limit,
|
||||
const FFetchCommitDelegate OnCompleteAction,
|
||||
const FErrorDelegate OnErrorAction);
|
||||
|
||||
static void FetchGlobals( const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const FString& StreamId,
|
||||
const FString& ReferencedObjectId,
|
||||
const FFetchGlobalsDelegate OnCompleteAction,
|
||||
const FErrorDelegate OnErrorAction);
|
||||
|
||||
static void FetchUserData( const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const FFetchUserDelegate OnCompleteAction,
|
||||
const FErrorDelegate OnErrorAction);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Utility functions
|
||||
|
||||
static FHttpRequestRef CreateGraphQLRequest(const FString& ServerUrl, FString AuthToken, const FString& PostPayload,
|
||||
const FString& Encoding = TEXT("gzip"));
|
||||
|
||||
static bool SendGraphQLRequest(const FHttpRequestRef Request, const FString& RequestName, const TFunctionRef<void(const FString& Message)> OnErrorAction);
|
||||
|
||||
static bool GetResponseAsJSON(const FHttpResponsePtr Response, const FString& RequestLogName, TSharedPtr<FJsonObject>& OutObject, const TFunctionRef<void(const FString& Message)> OnErrorAction);
|
||||
|
||||
static bool CheckForOperationErrors(const TSharedPtr<FJsonObject> GraphQLResponse, FString& OutErrorMessage);
|
||||
|
||||
static bool CheckForOperationErrors(const TSharedPtr<FJsonObject> GraphQLResponse, FString& OutErrorMessage);
|
||||
static bool CheckRequestFailed(bool bWasSuccessful, FHttpResponsePtr Response, const FString& RequestName, const TFunctionRef<void(const FString& Message)> OnErrorAction);
|
||||
|
||||
};
|
||||
@@ -1,45 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SpeckleCommit.h"
|
||||
#include "SpeckleBranch.generated.h"
|
||||
|
||||
/*
|
||||
* GraphQL model for Branch data
|
||||
* Properties are only when they explicitly requested (through the GraphQL request)
|
||||
* see https://github.com/specklesystems/speckle-sharp/blob/main/Core/Core/Api/GraphQL/Models.cs
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleBranch
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString ID;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Description;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FSpeckleCommits Commits;
|
||||
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleBranches
|
||||
{
|
||||
GENERATED_BODY();
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
int32 TotalCount = 0;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Cursor;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
TArray<FSpeckleBranch> Items;
|
||||
};
|
||||
@@ -1,29 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SpeckleCollaborator.generated.h"
|
||||
|
||||
/*
|
||||
* GraphQL model for Collaborator data
|
||||
* Properties are only when they explicitly requested (through the GraphQL request)
|
||||
* see https://github.com/specklesystems/speckle-sharp/blob/main/Core/Core/Api/GraphQL/Models.cs
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleCollaborator
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Id;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Role;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Avatar;
|
||||
|
||||
};
|
||||
@@ -1,65 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SpeckleCommit.generated.h"
|
||||
|
||||
/*
|
||||
* GraphQL model for Commit data
|
||||
* Properties are only when they explicitly requested (through the GraphQL request)
|
||||
* see https://github.com/specklesystems/speckle-sharp/blob/main/Core/Core/Api/GraphQL/Models.cs
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleCommit
|
||||
{
|
||||
GENERATED_BODY();
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString ID;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Message;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString BranchName;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString AuthorName;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString AuthorId;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString AuthorAvatar;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString CreatedAt;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString SourceApplication;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models", DisplayName="Referenced Object Id")
|
||||
FString ReferencedObject;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString TotalChildrenCount;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
TArray<FString> Parents;
|
||||
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleCommits
|
||||
{
|
||||
GENERATED_BODY();
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
int32 TotalCount = 0;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Cursor;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
TArray<FSpeckleCommit> Items;
|
||||
};
|
||||
@@ -1,77 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SpeckleBranch.h"
|
||||
#include "SpeckleCollaborator.h"
|
||||
|
||||
#include "SpeckleStream.generated.h"
|
||||
|
||||
/*
|
||||
* GraphQL model for Stream data
|
||||
* Properties are only when they explicitly requested (through the GraphQL request)
|
||||
* see https://github.com/specklesystems/speckle-sharp/blob/main/Core/Core/Api/GraphQL/Models.cs
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleStream
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models", DisplayName="Stream Id")
|
||||
FString ID;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
FString Description;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
bool IsPublic = false;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
FString Role;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
FString CreatedAt;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
FString UpdatedAt;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
FString FavoritedDate;
|
||||
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
TArray<FSpeckleCollaborator> Collaborators;
|
||||
|
||||
// Object properties are only set if explicitly requested by a custom GraphQL request
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
FSpeckleBranches Branches;
|
||||
|
||||
// Object properties are only set if explicitly requested by a custom GraphQL request
|
||||
UPROPERTY(BlueprintReadOnly, DisplayName="Branch (Request Only)", Category="Speckle|API Models", AdvancedDisplay)
|
||||
FSpeckleBranch Branch;
|
||||
|
||||
// Object properties are only set if explicitly requested by a custom GraphQL request
|
||||
UPROPERTY(BlueprintReadOnly, DisplayName="Commit (Request Only)", Category="Speckle|API Models", AdvancedDisplay)
|
||||
FSpeckleCommit Commit;
|
||||
|
||||
// Object properties are only set if explicitly requested by a custom GraphQL request
|
||||
UPROPERTY(BlueprintReadOnly, Category="Speckle|API Models")
|
||||
FSpeckleCommits Commits;
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleStreams
|
||||
{
|
||||
GENERATED_BODY();
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
int32 TotalCount = 0;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Cursor;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
TArray<FSpeckleStream> Items;
|
||||
};
|
||||
@@ -1,47 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SpeckleStream.h"
|
||||
#include "SpeckleUser.generated.h"
|
||||
|
||||
/*
|
||||
* GraphQL model for User data
|
||||
* Properties are only when they explicitly requested (through the GraphQL request)
|
||||
* see https://github.com/specklesystems/speckle-sharp/blob/main/Core/Core/Api/GraphQL/Models.cs
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleUser
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Id;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Email;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Bio;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Company;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Avatar;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
bool Verified;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Role;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FSpeckleStreams Streams;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FSpeckleStreams FavoriteStreams;
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||
#include "Objects/HighLevel/SpeckleBranch.h"
|
||||
|
||||
#include "ReceiveBranchesOperation.generated.h"
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FReceiveBranchesOperationHandler,
|
||||
const TArray<FSpeckleBranch>&, Branches,
|
||||
const FString&, ErrorMessage);
|
||||
|
||||
/**
|
||||
* Receive All streams
|
||||
*/
|
||||
UCLASS()
|
||||
class SPECKLEUNREAL_API UReceiveBranchesOperation : public UBlueprintAsyncActionBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveBranchesOperationHandler OnReceiveSuccessfully;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveBranchesOperationHandler OnError;
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "Speckle|Operations", meta = (WorldContext = "WorldContextObject"))
|
||||
static UReceiveBranchesOperation* ReceiveBranchesOperation(UObject* WorldContextObject,
|
||||
const FString& ServerUrl, const FString& AuthToken, const FString& StreamId, int32 Limit = 20);
|
||||
virtual void Activate() override;
|
||||
|
||||
protected:
|
||||
void Request();
|
||||
|
||||
FString ServerUrl;
|
||||
FString AuthToken;
|
||||
FString StreamId;
|
||||
int32 Limit;
|
||||
|
||||
void HandleReceive(const TArray<FSpeckleBranch>& Branches);
|
||||
|
||||
void HandleError(const FString& Message);
|
||||
};
|
||||
@@ -0,0 +1,53 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||
#include "Objects/HighLevel/SpeckleCommit.h"
|
||||
|
||||
#include "ReceiveCommitsOperation.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FReceiveCommitsOperationHandler, const TArray<FSpeckleCommit>&, Commits, FString, ErrorMessage);
|
||||
|
||||
|
||||
/**
|
||||
* Receive All Commits
|
||||
*/
|
||||
UCLASS()
|
||||
class SPECKLEUNREAL_API UReceiveCommitsOperation : public UBlueprintAsyncActionBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveCommitsOperationHandler OnReceiveSuccessfully;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveCommitsOperationHandler OnError;
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "Speckle|Operations",
|
||||
meta = (WorldContext = "WorldContextObject", BranchName = "main"))
|
||||
static UReceiveCommitsOperation* ReceiveCommitsOperation(UObject* WorldContextObject,
|
||||
const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const FString& StreamId,
|
||||
const FString& BranchName,
|
||||
const int32 Limit = 20);
|
||||
virtual void Activate() override;
|
||||
|
||||
protected:
|
||||
void Request();
|
||||
|
||||
FString ServerUrl;
|
||||
FString AuthToken;
|
||||
FString StreamId;
|
||||
FString BranchName;
|
||||
int32 Limit;
|
||||
|
||||
void HandleReceive(const TArray<FSpeckleCommit>& Commits);
|
||||
|
||||
void HandleError(const FString& Message);
|
||||
};
|
||||
@@ -0,0 +1,48 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||
#include "Objects/HighLevel/SpeckleGlobals.h"
|
||||
|
||||
#include "ReceiveGlobalsOperation.generated.h"
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FReceiveGlobalsOperationHandler, const FSpeckleGlobals, Globals, FString, ErrorMessage);
|
||||
|
||||
|
||||
/**
|
||||
* Receive My User Data in Speckle
|
||||
*/
|
||||
UCLASS()
|
||||
class SPECKLEUNREAL_API UReceiveGlobalsOperation : public UBlueprintAsyncActionBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveGlobalsOperationHandler OnReceiveSuccessfully;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveGlobalsOperationHandler OnError;
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "Speckle|Operations", meta = (WorldContext = "WorldContextObject"))
|
||||
static UReceiveGlobalsOperation* ReceiveGlobalsOperation(UObject* WorldContextObject,
|
||||
const FString& ServerUrl, const FString& AuthToken,
|
||||
const FString& StreamId, const FString& ReferencedObjectId);
|
||||
virtual void Activate() override;
|
||||
|
||||
protected:
|
||||
void Request();
|
||||
|
||||
FString ServerUrl;
|
||||
FString AuthToken;
|
||||
FString StreamId;
|
||||
FString ReferencedObjectId;
|
||||
|
||||
void HandleReceive(const FSpeckleGlobals& Object);
|
||||
|
||||
void HandleError(const FString& Message);
|
||||
};
|
||||
@@ -0,0 +1,49 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||
#include "Objects/HighLevel/SpeckleUser.h"
|
||||
|
||||
#include "ReceiveMyUserDataOperation.generated.h"
|
||||
|
||||
struct FSpeckleUser;
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FReceiveMyUserDataOperationHandler, const FSpeckleUser, MyUserData, FString, ErrorMessage);
|
||||
|
||||
|
||||
/**
|
||||
* Receive My User Data in Speckle
|
||||
*/
|
||||
UCLASS()
|
||||
class SPECKLEUNREAL_API UReceiveMyUserDataOperation : public UBlueprintAsyncActionBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveMyUserDataOperationHandler OnReceiveSuccessfully;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveMyUserDataOperationHandler OnError;
|
||||
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "Speckle|Operations",
|
||||
meta = (WorldContext = "WorldContextObject"))
|
||||
static UReceiveMyUserDataOperation* ReceiveMyUserDataOperation(UObject* WorldContextObject,
|
||||
const FString& ServerUrl, const FString& AuthToken);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
protected:
|
||||
void Request();
|
||||
|
||||
FString ServerUrl;
|
||||
FString AuthToken;
|
||||
|
||||
void HandleReceive(const FSpeckleUser& Object);
|
||||
|
||||
void HandleError(const FString& Message);
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||
#include "Objects/HighLevel/SpeckleStream.h"
|
||||
|
||||
#include "ReceiveStreamsOperation.generated.h"
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FReceiveStreamsOperationHandler, const TArray<FSpeckleStream>&, Streams, FString, ErrorMessage);
|
||||
|
||||
/**
|
||||
* Receive All streams
|
||||
*/
|
||||
UCLASS()
|
||||
class SPECKLEUNREAL_API UReceiveStreamsOperation : public UBlueprintAsyncActionBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveStreamsOperationHandler OnReceiveSuccessfully;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FReceiveStreamsOperationHandler OnError;
|
||||
|
||||
UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "Speckle|Operations", meta = (WorldContext = "WorldContextObject"))
|
||||
static UReceiveStreamsOperation* ReceiveStreamsOperation(UObject* WorldContextObject, const FString& ServerUrl, const FString& AuthToken, const int32 Limit = 20);
|
||||
virtual void Activate() override;
|
||||
|
||||
protected:
|
||||
void Request();
|
||||
|
||||
FString ServerUrl;
|
||||
FString AuthToken;
|
||||
int32 Limit;
|
||||
|
||||
void HandleReceive(const TArray<FSpeckleStream>& Streams);
|
||||
|
||||
void HandleError(const FString& Message);
|
||||
};
|
||||
@@ -0,0 +1,47 @@
|
||||
// // Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
//
|
||||
// #pragma once
|
||||
//
|
||||
// #include "CoreMinimal.h"
|
||||
// #include "Kismet/BlueprintAsyncActionBase.h"
|
||||
//
|
||||
// #include "SendOperation.generated.h"
|
||||
//
|
||||
//
|
||||
// class ITransport;
|
||||
// class UBase;
|
||||
//
|
||||
// DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FSendOperationHandler, const FString&, Id, const FString&, ErrorMessage);
|
||||
//
|
||||
// /**
|
||||
// *
|
||||
// */
|
||||
// UCLASS()
|
||||
// class SPECKLEUNREAL_API USendOperation : public UBlueprintAsyncActionBase
|
||||
// {
|
||||
// GENERATED_BODY()
|
||||
//
|
||||
// public:
|
||||
//
|
||||
// UPROPERTY(BlueprintAssignable)
|
||||
// FSendOperationHandler OnSendSuccessfully;
|
||||
//
|
||||
//
|
||||
// UPROPERTY(BlueprintAssignable)
|
||||
// FSendOperationHandler OnErrorAction;
|
||||
//
|
||||
//
|
||||
// UFUNCTION(BlueprintCallable, Category = "Speckle|Operations", meta = (WorldContext = "WorldContextObject"))
|
||||
// static USendOperation* SendOperation(UObject* WorldContextObject, UBase* Base, TArray<TScriptInterface<ITransport>> Transports);
|
||||
//
|
||||
// virtual void Activate() override;
|
||||
//
|
||||
// protected:
|
||||
//
|
||||
//
|
||||
// TWeakObjectPtr<UBase> Base;
|
||||
//
|
||||
// TScriptArray<TScriptInterface<ITransport>> Transports;
|
||||
//
|
||||
//
|
||||
// };
|
||||
@@ -1,62 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintAsyncActionBase.h"
|
||||
|
||||
#include "SpeckleStreamAPIOperation.generated.h"
|
||||
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FAPIResponseHandler, FString, JsonResponse, FString, ErrorMessage);
|
||||
|
||||
/**
|
||||
* Allows sending GraphQL queries to the Speckle GraphQL API
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class SPECKLEUNREAL_API USpeckleStreamAPIOperation : public UBlueprintAsyncActionBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FAPIResponseHandler OnReceiveSuccessfully;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FAPIResponseHandler OnError;
|
||||
|
||||
/**
|
||||
* Sends an GraphQL queries to a speckle server's "/graphql" endpoint
|
||||
* E.g. for fetching stream/branch/commit/user info.
|
||||
*
|
||||
* @param ServerUrl The URL of the Speckle server
|
||||
* @param AuthToken The auth token of the user (optional for unprivilaged requests)
|
||||
* @param GraphQlQuery The GraphQl query (starting with `query{ }`)
|
||||
* @param ResponsePropertyName The name of the root property being requested. (e.g. for a "query{user{...}" query, then the property name is "user")
|
||||
* @param RequestLogName A friendly name for this request (logging and analytics)
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, BlueprintInternalUseOnly, Category = "Speckle|Operations")
|
||||
static USpeckleStreamAPIOperation* SpeckleStreamAPIOperation(
|
||||
const FString& ServerUrl,
|
||||
const FString& AuthToken,
|
||||
const FString& GraphQlQuery,
|
||||
const FString& ResponsePropertyName,
|
||||
const FString& RequestLogName);
|
||||
|
||||
virtual void Activate() override;
|
||||
|
||||
protected:
|
||||
void Request();
|
||||
|
||||
FString ServerUrl;
|
||||
FString AuthToken;
|
||||
FString Query;
|
||||
FString RequestLogName;
|
||||
FString ResponsePropertyName;
|
||||
|
||||
void HandleReceive(const FString& ResponseJson);
|
||||
|
||||
void HandleError(const FString& Message);
|
||||
|
||||
};
|
||||
@@ -1,30 +0,0 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
|
||||
#include "SpeckleAPIFunctions.generated.h"
|
||||
|
||||
struct FSpeckleCommit;
|
||||
/**
|
||||
* Blueprint function library for Speckle API
|
||||
*/
|
||||
UCLASS()
|
||||
class SPECKLEUNREAL_API USpeckleAPIFunctions : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
|
||||
UFUNCTION(BlueprintCallable, CustomThunk, Category="Speckle|API", meta=(CustomStructureParam="OutStruct", ExpandBoolAsExecs="ReturnValue"))
|
||||
static UPARAM(DisplayName = "WasSucessful") bool DeserializeResponse(const FString& JsonString, int32& OutStruct);
|
||||
DECLARE_FUNCTION(execDeserializeResponse);
|
||||
|
||||
static bool GenericDeserializeResponse(const FString& JsonString, const UScriptStruct* StructType, void* OutStruct);
|
||||
|
||||
static void CommitReceived(FSpeckleCommit& Commit);
|
||||
|
||||
|
||||
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -9,7 +10,7 @@
|
||||
|
||||
#include "BlockConverter.generated.h"
|
||||
|
||||
class UInstance;
|
||||
class UBlockInstance;
|
||||
|
||||
/**
|
||||
* Converts Speckle Block Instance objects empty native actors with transform.
|
||||
@@ -36,7 +37,7 @@ public:
|
||||
virtual UBase* ConvertToSpeckle_Implementation(const UObject* Object) override;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="ToNative")
|
||||
virtual AActor* BlockToNative(const UInstance* Block, UWorld* World);
|
||||
virtual AActor* BlockToNative(const UBlockInstance* Block, UWorld* World);
|
||||
|
||||
protected:
|
||||
virtual AActor* CreateEmptyActor(UWorld* World, const FTransform& Transform, const FActorSpawnParameters& SpawnParameters = FActorSpawnParameters());
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -29,9 +30,6 @@ class SPECKLEUNREAL_API UStaticMeshConverter : public UObject, public ISpeckleCo
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ToNative")
|
||||
TSet<FString> HiddenTypes;
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="ToNative")
|
||||
TSubclassOf<AActor> MeshActorType;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "Objects/HighLevel/SpeckleStream.h"
|
||||
|
||||
#include "SpeckleConverterComponent.generated.h"
|
||||
|
||||
@@ -11,7 +13,6 @@ class ITransport;
|
||||
class ISpeckleConverter;
|
||||
class UBase;
|
||||
class UAggregateConverter;
|
||||
class FJsonValue;
|
||||
struct FSlowTask;
|
||||
|
||||
/**
|
||||
@@ -30,14 +31,29 @@ public:
|
||||
|
||||
// Sets default values for this component's properties
|
||||
USpeckleConverterComponent();
|
||||
|
||||
|
||||
// Converts the given Base and all children into native actors.
|
||||
UFUNCTION(BlueprintCallable, Category="Speckle|Conversion")
|
||||
UPARAM(DisplayName = "RootActor") AActor* RecursivelyConvertToNative(AActor* AOwner, const UBase* Base,
|
||||
const TScriptInterface<ITransport>& LocalTransport, bool DisplayProgressBar, TArray<AActor*>& OutActors);
|
||||
|
||||
|
||||
|
||||
// Converts the given Base and all children into native actors.
|
||||
UFUNCTION(BlueprintCallable, Category="Speckle|Conversion")
|
||||
UPARAM(DisplayName = "RootActor") TArray<FSpeckleStream> ConvertStreamsToNative(
|
||||
AActor* AOwner,
|
||||
const UBase* Base,
|
||||
const TScriptInterface<ITransport>& LocalTransport,
|
||||
bool DisplayProgressBar,
|
||||
TArray<AActor*>& OutActors
|
||||
);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category="Speckle|Conversion")
|
||||
virtual void FinishConversion();
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Speckle|Conversion")
|
||||
TArray<FSpeckleStream> ArrayOfStreams;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -13,8 +14,8 @@ protected:
|
||||
static const FString VersionedApplicationName;
|
||||
|
||||
public:
|
||||
static void TrackEvent(const FString& Server, const FString& EventName);
|
||||
static void TrackEvent(const FString& Server, const FString& EventName, const TMap<FString, FString>& CustomProperties);
|
||||
static void TrackEvent(const FString& UserID, const FString& Server, const FString& EventName, const TMap<FString, FString>& CustomProperties);
|
||||
static void TrackEvent(const FString& Email, const FString& Server, const FString& EventName);
|
||||
static void TrackEvent(const FString& Email, const FString& Server, const FString& EventName,
|
||||
const TMap<FString, FString>& CustomProperties);
|
||||
static FString Hash(const FString& Input);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -12,7 +13,7 @@ class ASpeckleUnrealManager;
|
||||
/**
|
||||
* Base type that all Object Models inherit from
|
||||
*/
|
||||
UCLASS(BlueprintType, meta=(DisplayName="Speckle Object (Base)"))
|
||||
UCLASS(BlueprintType)
|
||||
class SPECKLEUNREAL_API UBase : public UObject
|
||||
{
|
||||
public:
|
||||
@@ -21,7 +22,7 @@ public:
|
||||
|
||||
protected:
|
||||
|
||||
explicit UBase(const TCHAR* SpeckleType): SpeckleType(FString(SpeckleType)) {}
|
||||
explicit UBase(const wchar_t* SpeckleType): SpeckleType(SpeckleType) {}
|
||||
explicit UBase(const FString& SpeckleType) : SpeckleType(SpeckleType) {}
|
||||
|
||||
public:
|
||||
@@ -31,21 +32,14 @@ public:
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Speckle|Objects")
|
||||
FString Id;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Speckle|Objects")
|
||||
int64 TotalChildrenCount;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Speckle|Objects")
|
||||
FString ApplicationId;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Speckle|Objects")
|
||||
FString SpeckleType;
|
||||
|
||||
TMap<FString, TSharedPtr<FJsonValue>> DynamicProperties; //TODO this won't be serialised!
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Speckle|Objects")
|
||||
FString Units;
|
||||
|
||||
TMap<FString, TSharedPtr<FJsonValue>> DynamicProperties; //TODO this won't be serialised!
|
||||
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category="Speckle|Objects")
|
||||
FString SpeckleType;
|
||||
|
||||
virtual bool Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITransport> ReadTransport)
|
||||
{
|
||||
@@ -59,8 +53,6 @@ public:
|
||||
|
||||
if(Obj->TryGetStringField("units", Units)) DynamicProperties.Remove("units");
|
||||
if(Obj->TryGetStringField("speckle_type", SpeckleType)) DynamicProperties.Remove("speckle_type");
|
||||
if(Obj->TryGetStringField("applicationId", ApplicationId)) DynamicProperties.Remove("applicationId");
|
||||
if(Obj->TryGetNumberField("totalChildrenCount", TotalChildrenCount)) DynamicProperties.Remove("totalChildrenCount");
|
||||
|
||||
return IsValid;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -10,10 +11,9 @@
|
||||
class UMesh;
|
||||
|
||||
/**
|
||||
* This class does not exist in speckle sharp,
|
||||
* This is a type to represent objects that have displayValues
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
UCLASS(meta=(ScriptName="Display Value Element (Speckle.Objects)"))
|
||||
class SPECKLEUNREAL_API UDisplayValueElement : public UBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
@@ -23,7 +23,7 @@ protected:
|
||||
|
||||
public:
|
||||
|
||||
UDisplayValueElement() : UBase(TEXT("Objects.Other.DisplayValueElement")) {}
|
||||
UDisplayValueElement() : UBase(TEXT("Objects.BuiltElements")) {}
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Speckle|Objects")
|
||||
TArray<UMesh*> DisplayValue;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Mesh.h"
|
||||
#include "Objects/Base.h"
|
||||
#include "Box.generated.h"
|
||||
|
||||
class UPlane;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(meta=(ScriptName="Box (Speckle.Objects)"))
|
||||
class SPECKLEUNREAL_API UBoxx : public UBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Speckle|Objects")
|
||||
UPlane* BasePlane;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Speckle|Objects")
|
||||
FVector2f XSize, YSize;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Speckle|Objects")
|
||||
float Area;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Speckle|Objects")
|
||||
float Volume;
|
||||
|
||||
|
||||
virtual bool Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITransport> ReadTransport) override;
|
||||
|
||||
UFUNCTION(BlueprintCallable)
|
||||
virtual UMesh* ToMesh(UObject* Outer = GetTransientPackage()) const;
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -11,7 +12,7 @@ class URenderMaterial;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
UCLASS(meta=(ScriptName="Mesh (Speckle.Objects)"))
|
||||
class SPECKLEUNREAL_API UMesh : public UBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
@@ -41,10 +42,5 @@ public:
|
||||
virtual bool Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITransport> ReadTransport) override;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/// If not already so, this method will align vertices
|
||||
/// such that a vertex and its corresponding texture coordinates have the same index.
|
||||
/// See "https://github.com/specklesystems/speckle-sharp/blob/main/Objects/Objects/Geometry/Mesh.cs"
|
||||
virtual void AlignVerticesWithTexCoordsByIndex();
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Objects/Base.h"
|
||||
#include "Plane.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(meta=(ScriptName="Plane (Speckle.Objects)"))
|
||||
class SPECKLEUNREAL_API UPlane : public UBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
|
||||
public:
|
||||
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category="Speckle|Objects")
|
||||
FVector Origin, Normal, XDir, YDir;
|
||||
|
||||
|
||||
virtual bool Parse(const TSharedPtr<FJsonObject> Obj, const TScriptInterface<ITransport> ReadTransport) override;
|
||||
|
||||
};
|
||||
@@ -1,3 +1,4 @@
|
||||
// Copyright 2022 AEC Systems, Licensed under the Apache License, Version 2.0
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -9,7 +10,7 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
UCLASS(meta=(ScriptName="Point Cloud (Speckle.Objects)"))
|
||||
class SPECKLEUNREAL_API UPointCloud : public UBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "FSpeckleActivity.generated.h"
|
||||
|
||||
/*
|
||||
* Struct that holds all the properties required
|
||||
* for the User Activities
|
||||
* received from GraphQL.
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleActivity
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FString ActionType;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FString Time;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FString Message;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FString StreamId;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FString ResourceType;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FString ResourceId;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite)
|
||||
FString Info;
|
||||
|
||||
FSpeckleActivity(){};
|
||||
|
||||
FSpeckleActivity(const FString& ActionType, const FString& Time, const FString& Message,
|
||||
const FString& StreamId, const FString& ResourceType, const FString& ResourceId,
|
||||
const FString& Info):
|
||||
ActionType(ActionType), Time(Time), Message(Message), StreamId(StreamId),
|
||||
ResourceType(ResourceType), ResourceId(ResourceId), Info(Info){}
|
||||
};
|
||||
@@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "FSpeckleEnum.generated.h"
|
||||
|
||||
UENUM()
|
||||
enum ESpeckleItemType {Stream, Commit, Branch};
|
||||
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SpeckleCollaborator.h"
|
||||
#include "SpeckleBranch.generated.h"
|
||||
|
||||
|
||||
/*
|
||||
* Struct that holds all the properties required
|
||||
* from a speckle Branch
|
||||
* received from GraphQL.
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleBranch
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString ID;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Description;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Author;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Commits;
|
||||
|
||||
void DisplayAsString(const FString& msg, const TSharedPtr<FJsonObject> Obj) const
|
||||
{
|
||||
FString OutputString;
|
||||
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&OutputString);
|
||||
FJsonSerializer::Serialize(Obj.ToSharedRef(), Writer);
|
||||
UE_LOG(LogTemp, Log, TEXT("resulting jsonString from %s -> %s"), *msg, *OutputString);
|
||||
}
|
||||
|
||||
FSpeckleBranch(const TSharedPtr<FJsonObject> Obj)
|
||||
{
|
||||
ensureAlways(Obj->TryGetStringField("id", ID));
|
||||
ensureAlways(Obj->TryGetStringField("name", Name));
|
||||
Obj->TryGetStringField("description", Description);
|
||||
}
|
||||
|
||||
FSpeckleBranch(){};
|
||||
//
|
||||
// FSpeckleBranch(const FString& ID, const FString& Name, const FString& Description):
|
||||
// ID(ID), Name(Name), Description(Description){}
|
||||
//
|
||||
// FSpeckleBranch(const FString& ID, const FString& Name, const FString& Description, const FString& Author, const FString& Commits):
|
||||
// ID(ID), Name(Name), Description(Description), Author(Author), Commits(Commits){}
|
||||
};
|
||||
@@ -0,0 +1,46 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SpeckleCollaborator.generated.h"
|
||||
|
||||
/*
|
||||
* Struct that holds all the properties required
|
||||
* from a Collaborator in a Stream
|
||||
* received from GraphQL.
|
||||
* See https://github.com/specklesystems/speckle-sharp/blob/main/Core/Core/Api/GraphQL/Models.cs
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleCollaborator
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Id;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Name;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Role;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Avatar;
|
||||
|
||||
FSpeckleCollaborator() { }
|
||||
|
||||
FSpeckleCollaborator(const TSharedPtr<FJsonObject> JsonObject)
|
||||
{
|
||||
ensureAlways(JsonObject->TryGetStringField("id", Id));
|
||||
ensureAlways(JsonObject->TryGetStringField("name", Name));
|
||||
JsonObject->TryGetStringField("role", Role);
|
||||
JsonObject->TryGetStringField("avatar", Avatar);
|
||||
}
|
||||
|
||||
FSpeckleCollaborator(const FString& Id, const FString& Name, const FString& Company, const FString& Role, const FString& Avatar)
|
||||
: Id(Id),
|
||||
Name(Name),
|
||||
Role(Role),
|
||||
Avatar(Avatar)
|
||||
{
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,115 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "SpeckleCommit.generated.h"
|
||||
|
||||
/*
|
||||
* Struct that holds all the properties required
|
||||
* from a speckle commit
|
||||
* received from GraphQL.
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FSpeckleCommit
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString ID;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString Message;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString BranchName;
|
||||
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString AuthorName;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString AuthorId;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString AuthorAvatar;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString CreatedAt;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString SourceApplication;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString ReferenceObjectID;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString TotalChildrenCount;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
TArray<FString> Parents;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category="Speckle|API Models")
|
||||
FString CommentCount;
|
||||
|
||||
|
||||
|
||||
void DisplayAsString(const FString& msg, const TSharedPtr<FJsonObject> Obj) const
|
||||
{
|
||||
FString OutputString;
|
||||
TSharedRef< TJsonWriter<> > Writer = TJsonWriterFactory<>::Create(&OutputString);
|
||||
FJsonSerializer::Serialize(Obj.ToSharedRef(), Writer);
|
||||
UE_LOG(LogTemp, Log, TEXT("resulting jsonString from %s -> %s"), *msg, *OutputString);
|
||||
}
|
||||
|
||||
FSpeckleCommit(){};
|
||||
|
||||
FSpeckleCommit(const TSharedPtr<FJsonValue> CommitAsJSONValue)
|
||||
{
|
||||
TSharedPtr<FJsonObject> obj = CommitAsJSONValue->AsObject();
|
||||
ensureAlways(obj->TryGetStringField("id", ID));
|
||||
obj->TryGetStringField("message", Message);
|
||||
obj->TryGetStringField("branchName", BranchName);
|
||||
obj->TryGetStringField("authorName", AuthorName);
|
||||
obj->TryGetStringField("authorId", AuthorId);
|
||||
obj->TryGetStringField("authorAvatar", AuthorAvatar);
|
||||
obj->TryGetStringField("createdAt", CreatedAt);
|
||||
obj->TryGetStringField("sourceApplication", SourceApplication);
|
||||
obj->TryGetStringField("totalChildrenCount", TotalChildrenCount);
|
||||
ensureAlways(obj->TryGetStringField("referencedObject", ReferenceObjectID));
|
||||
obj->TryGetStringArrayField("parents", Parents);
|
||||
obj->TryGetStringField("commentCount", CommentCount); //TODO is this a prop?
|
||||
|
||||
}
|
||||
|
||||
|
||||
// FSpeckleCommit(const FString& ReferenceObjectID, const FString& Author, const FString& Message, const FString& BranchName)
|
||||
// : ReferenceObjectID(ReferenceObjectID),
|
||||
// Author(Author),
|
||||
// Message(Message),
|
||||
// BranchName(BranchName)
|
||||
// {
|
||||
// }
|
||||
|
||||
// FSpeckleCommit(const FString& ReferenceObjectID, const FString& AuthorName, const FString& Message, const FString& BranchName,
|
||||
// const FString& Id, const FString& SourceApplication, const FString& TotalChildrenCount, const FString& Parents,
|
||||
// const FString& AuthorId, const FString& AuthorAvatar, const FString& CreatedAt)
|
||||
// : ReferenceObjectID(ReferenceObjectID),
|
||||
// Author(Author),
|
||||
// Message(Message),
|
||||
// BranchName(BranchName),
|
||||
// ID(Id),
|
||||
// SourceApplication(SourceApplication),
|
||||
// TotalChildrenCount(TotalChildrenCount),
|
||||
// Parents(Parents),
|
||||
// AuthorId(AuthorId),
|
||||
// AuthorAvatar(AuthorAvatar),
|
||||
// CreatedAt(CreatedAt)
|
||||
// {
|
||||
// }
|
||||
|
||||
//Operators overloading
|
||||
|
||||
// FORCEINLINE bool operator==(const FSpeckleCommit &Other) const
|
||||
// {
|
||||
// return ReferenceObjectID == Other.ReferenceObjectID;
|
||||
// }
|
||||
};
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user