Compare commits

..

66 Commits

Author SHA1 Message Date
oguzhankoral f85bde5dee WIP 2024-02-22 16:19:13 +03:00
oguzhankoral 05e7472051 WIP 2024-02-22 15:02:23 +03:00
oguzhankoral 006691db7e WIP 2024-02-22 15:02:19 +03:00
oguzhankoral a663881368 WIPWIPWIPWIP 2024-02-22 14:52:01 +03:00
oguzhankoral c8cc8576b0 Instant message sender for App 2024-02-22 14:52:01 +03:00
oguzhankoral 31df7e77ba Merge branch 'development' into oguzhan/dui3
# Conflicts:
#	speckle_connector/src/actions/receive_objects.rb
#	speckle_connector/src/commands/speckle_menu_commands.rb
#	speckle_connector/src/ui/legacy_binding.rb
2024-02-22 14:51:17 +03:00
oguzhankoral f9473f558a Merge branch 'development' into oguzhan/dui3 2023-11-20 10:51:35 +03:00
oguzhankoral 88078bad4c Zoom selection for highlight 2023-10-11 10:04:01 +03:00
oguzhankoral 1a3d6ec800 Update sqlite3 submodule hash ref 2023-10-09 13:23:24 +03:00
oguzhankoral 9b5fc2cd74 Highlight model for send cards 2023-10-04 10:17:45 +02:00
oguzhankoral c26398a13f Remove cards from model 2023-09-18 09:36:16 +03:00
oguzhankoral fdb874b616 Add action name to error message for commands 2023-09-15 18:40:52 +03:00
oguzhankoral dfd06544ec First successful receive 2023-09-15 18:40:52 +03:00
oguzhankoral 69c10ed1e7 Send progressbar with Sketchup.status_text
Thanks to library of thomthom
2023-09-15 18:40:52 +03:00
oguzhankoral 00df9800ed Send model card id via sendViaBrowserArgs 2023-09-15 18:40:51 +03:00
oguzhankoral 6494fd6b41 Get source app version via base bindings 2023-09-15 18:40:51 +03:00
oguzhankoral e9cb673f3a Send message from sender card 2023-09-15 18:40:51 +03:00
oguzhankoral 4e5cb64710 Correct send data 2023-09-15 18:40:50 +03:00
oguzhankoral aaa6ff9938 Real send via DUI3 2023-09-15 18:40:50 +03:00
oguzhankoral 099cb6b13b Trigger sendersExpired when objects modified 2023-09-15 18:40:50 +03:00
oguzhankoral 75c4065d27 Use AddModel action for updateModel command 2023-09-15 18:40:49 +03:00
oguzhankoral f3ce5c8993 Place binding classes into folder 2023-09-15 18:40:49 +03:00
oguzhankoral 9760d3f0d5 Enable error catch for command 2023-09-15 18:40:49 +03:00
oguzhankoral dab851f3d4 Update model card 2023-09-15 18:40:49 +03:00
oguzhankoral 81b3d4d6d7 Add type discriminator 2023-09-15 18:40:48 +03:00
oguzhankoral 5b09566c49 Reorganize send bindings 2023-09-15 18:40:48 +03:00
oguzhankoral 70dcc23b25 Split account binding from base 2023-09-15 18:40:48 +03:00
oguzhankoral 4c90b3fb16 Align with Dim's works 2023-09-15 18:40:47 +03:00
oguzhankoral 87931df9b6 WIP: selection bindings - add cards to model 2023-09-15 18:40:47 +03:00
oguzhankoral 5d03229d35 WIP: filters 2023-09-15 18:40:47 +03:00
oguzhankoral fb31d662cc Convert tag colors to hex 2023-09-15 18:40:46 +03:00
oguzhankoral 489ec8701f Get default filters 2023-09-15 18:40:46 +03:00
oguzhankoral e1afe66c7e Get model state and send filter for sketchup 2023-09-15 18:40:46 +03:00
oguzhankoral b920d822ef WIP: connector configs 2023-09-15 18:40:46 +03:00
oguzhankoral 0908763d33 Implement config_binding 2023-09-15 18:40:45 +03:00
oguzhankoral 847ad87b23 Introduce ruby traverse_and_construct 2023-09-15 18:40:45 +03:00
oguzhankoral 90cf165dcf Send-Receive operations test via ruby 2023-09-15 18:40:45 +03:00
oguzhankoral 8b0307bc72 Remove test bridge.js 2023-09-15 18:40:44 +03:00
oguzhankoral a645e2829a Unit test for send operation 2023-09-15 18:40:44 +03:00
oguzhankoral 33d8644dd6 Enable collect preferences 2023-09-15 18:40:44 +03:00
oguzhankoral de713a848c Emit only documentChanged instead of passing data 2023-09-15 18:40:43 +03:00
oguzhankoral e9aa91fe7f Rename views to bindings 2023-09-15 18:40:43 +03:00
oguzhankoral 9661c79bd6 Report errors to UI 2023-09-15 18:40:43 +03:00
oguzhankoral 91fab4dcd4 Resolve triggerEvent 2023-09-15 18:40:43 +03:00
oguzhankoral 29488a2d87 Implement test bindings 2023-09-15 18:40:42 +03:00
oguzhankoral a3f1dd2459 Create random sketchup binding 2023-09-15 18:40:42 +03:00
oguzhankoral ab12145e4d Implement on_document_changed action 2023-09-15 18:40:42 +03:00
oguzhankoral 442ea7e6ab Add command for get document info 2023-09-15 18:40:41 +03:00
oguzhankoral 04f0024734 Remove get_commands action and command 2023-09-15 18:40:41 +03:00
oguzhankoral 831cc60ab2 Apply same dialog-view relationship to legacy UI 2023-09-15 18:40:41 +03:00
oguzhankoral 7fc4c55362 Control views via dialog 2023-09-15 18:40:41 +03:00
oguzhankoral 78e8202d1c Remove unnecssary init from view 2023-09-15 18:40:40 +03:00
oguzhankoral f35e953531 Collect command names from related view for SketchupBridge 2023-09-15 18:40:40 +03:00
oguzhankoral f5796bdec8 Pass view to commands 2023-09-15 18:40:40 +03:00
oguzhankoral 9f87c22424 Send messages to correct view/binding 2023-09-15 18:40:39 +03:00
oguzhankoral 88ba11a836 Solve missing resolve_id arguments for commands and actions 2023-09-15 18:40:39 +03:00
oguzhankoral 53f370d24e Run legacy and dui3 at the same time 2023-09-15 18:40:39 +03:00
oguzhankoral 9e0998f054 Pass resolve id from arguments 2023-09-15 18:40:38 +03:00
oguzhankoral 0dce0cb88c Replace Bridge with inhouse resolve_id solution 2023-09-15 18:40:38 +03:00
oguzhankoral a61097bdcd Pass serialized accounts data as json object 2023-09-15 18:40:38 +03:00
oguzhankoral ec073bd544 Pass correct request id for getAccounts 2023-09-15 18:40:38 +03:00
oguzhankoral 1c23da6fb2 Request id temp hack 2023-09-15 18:40:37 +03:00
oguzhankoral 7e6b993b06 Add get commands 2023-09-15 18:40:37 +03:00
oguzhankoral 792251dfb9 Add bridge sample 2023-09-15 18:40:37 +03:00
oguzhankoral 1c4ebb5380 Check correct dui3 id ui controller 2023-09-15 18:40:36 +03:00
oguzhankoral 4ac76d23ca Add new dialog for dui3 2023-09-15 18:40:24 +03:00
459 changed files with 17206 additions and 4795 deletions
Vendored
BIN
View File
Binary file not shown.
+271 -12
View File
@@ -1,17 +1,276 @@
version: 2.1
# Define the jobs we want to run for this project
jobs:
build:
docker:
- image: cimg/base:2023.03
steps:
- run: echo "so long and thanks for all the fish"
orbs:
# Using windows for builds
win: circleci/windows@2.4.0
# Upload artifacts to s3
aws-s3: circleci/aws-s3@2.0.0
jobs:
build-ui:
docker:
- image: "circleci/node:16"
steps:
- checkout
- run:
command: "npm install"
working_directory: "ui"
- run:
command: "npm run build"
working_directory: "ui"
- persist_to_workspace:
root: ./
paths:
- speckle_connector/vue_ui
build-connector: # Reusable job for basic connectors
executor:
name: win/default # comes with python 3.7.3
shell: cmd.exe
parameters:
slug:
type: string
default: ""
steps:
- checkout
- attach_workspace:
at: ./
- run:
name: Create Innosetup signing cert
shell: powershell.exe
command: |
echo $env:PFX_B64 > "speckle-sharp-ci-tools\SignTool\AEC Systems Ltd.txt"
certutil -decode "speckle-sharp-ci-tools\SignTool\AEC Systems Ltd.txt" "speckle-sharp-ci-tools\SignTool\AEC Systems Ltd.pfx"
- run:
name: Set Environment Variable
shell: powershell.exe
command: |
$tag = if([string]::IsNullOrEmpty($env:CIRCLE_TAG)) { "2.0.999" } else { $env:CIRCLE_TAG }
$semver = if($tag.Contains('/')) {$tag.Split("/")[0] } else { $tag }
$ver = if($semver.Contains('-')) {$semver.Split("-")[0] } else { $semver }
$version = "$($ver).$($env:WORKFLOW_NUM)"
python patch_version.py $semver
environment:
WORKFLOW_NUM: << pipeline.number >>
- run:
name: Build Installer
command: speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss /Sbyparam=$p
shell: cmd.exe #does not work in powershell
#- run:
# name: Patch
# shell: powershell.exe
# command:
# | # If no tag, use 0.0.0.1 and don't make any YML (for testing only!)
# $tag = if([string]::IsNullOrEmpty($env:CIRCLE_TAG)) { "0.0.0" } else { $env:CIRCLE_TAG }
# $semver = if($tag.Contains('/')) {$tag.Split("/")[1] } else { $tag }
# $ver = if($semver.Contains('-')) {$semver.Split("-")[0] } else { $semver }
# $channel = if($semver.Contains('-')) {$semver.Split("-")[1] } else { "latest" }
# $version = "$($ver).$($env:CIRCLE_BUILD_NUM)"
# New-Item -Force "speckle-sharp-ci-tools/Installers/sketchup/$channel.yml" -ItemType File -Value "version: $semver"
# echo $version
# python patch_version.py $semver
# speckle-sharp-ci-tools\InnoSetup\ISCC.exe speckle-sharp-ci-tools\sketchup.iss
- persist_to_workspace:
root: ./
paths:
- speckle-sharp-ci-tools/Installers
build-connector-mac:
macos:
xcode: 12.5.1
parameters:
projname:
type: string
default: ""
slug:
type: string
default: ""
installer:
type: boolean
default: false
converter-files:
type: string
default: ""
installername:
type: string
default: ""
build-config:
type: string
default: Release
bundlename:
type: string
default: ""
steps:
- checkout
- attach_workspace:
at: ./
- run:
name: Install dotnet
command: |
curl -sSL https://dot.net/v1/dotnet-install.sh | bash /dev/stdin --channel Current
$HOME/.dotnet/dotnet --version
$HOME/.dotnet/dotnet --list-runtimes
$HOME/.dotnet/dotnet --list-sdks
- run:
name: Create installer target dir
command: |
mkdir -p speckle-sharp-ci-tools/Installers/<< parameters.slug >>
- run:
name: Set Environment Variable
command: |
TAG=$(if [ "${CIRCLE_TAG}" ]; then echo $CIRCLE_TAG; else echo "2.0.999"; fi;)
SEMVER=$(echo "$TAG" | sed -e 's/\/[a-zA-Z-]*//')
VER=$(echo "$SEMVER" | sed -e 's/-.*//')
VERSION=$(echo $VER.$WORKFLOW_NUM)
python3 patch_version.py $SEMVER
environment:
WORKFLOW_NUM: << pipeline.number >>
- run:
name: Zip Connector files
command: |
zip -r << parameters.slug >>-mac.zip "./speckle_connector" "./speckle_connector.rb"
# Copy installer files
- run:
name: Copy files to installer
command: |
mkdir -p speckle-sharp-ci-tools/Mac/<< parameters.installername >>/.installationFiles/
cp << parameters.slug >>-mac.zip speckle-sharp-ci-tools/Mac/<<parameters.installername>>/.installationFiles
# Create installer
- run:
name: Exit if External PR
command: if [ "$CIRCLE_PR_REPONAME" ]; then circleci-agent step halt; fi
- run:
name: Build Mac installer
command: ~/.dotnet/dotnet publish speckle-sharp-ci-tools/Mac/<<parameters.installername>>/<<parameters.installername>>.sln -r osx-x64 -c Release
- run:
name: Zip installer
command: |
cd speckle-sharp-ci-tools/Mac/<<parameters.installername>>/bin/Release/net6.0/osx-x64/publish/
zip -r <<parameters.slug>>.zip ./
- store_artifacts:
path: speckle-sharp-ci-tools/Mac/<<parameters.installername>>/bin/Release/net6.0/osx-x64/publish/<<parameters.slug>>.zip
- run:
name: Copy to installer location
command: |
TAG=$(if [ "${CIRCLE_TAG}" ]; then echo $CIRCLE_TAG; else echo "2.0.999"; fi;)
SEMVER=$(echo "$TAG" | sed -e 's/\/[a-zA-Z-]*//')
VER=$(echo "$SEMVER" | sed -e 's/-.*//')
VERSION=$(echo $VER.$WORKFLOW_NUM)
cp speckle-sharp-ci-tools/Mac/<<parameters.installername>>/bin/Release/net6.0/osx-x64/publish/<<parameters.slug>>.zip speckle-sharp-ci-tools/Installers/<< parameters.slug >>/<<parameters.slug>>-$SEMVER.zip
environment:
WORKFLOW_NUM: << pipeline.number >>
- when:
condition: << pipeline.git.tag >>
steps:
- persist_to_workspace:
root: ./
paths:
- speckle-sharp-ci-tools/Installers
get-ci-tools: # Clones our ci tools and persists them to the workspace
docker:
- image: cimg/base:2021.01
steps:
- add_ssh_keys:
fingerprints:
- "03:2e:ee:4f:14:67:2b:88:32:e8:cc:f0:cb:df:92:29"
- run:
name: I know Github as a host
command: |
mkdir ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
- run:
name: Clone
command: git clone git@github.com:specklesystems/speckle-sharp-ci-tools.git speckle-sharp-ci-tools
- persist_to_workspace:
root: ./
paths:
- speckle-sharp-ci-tools
- persist_to_workspace:
root: ./
paths:
- speckle-sharp-ci-tools
deploy-manager2:
docker:
- image: mcr.microsoft.com/dotnet/sdk:6.0
parameters:
slug:
type: string
os:
type: string
extension:
type: string
steps:
- checkout
- attach_workspace:
at: ./
- run:
name: Install Manager Feed CLI
command: dotnet tool install --global Speckle.Manager.Feed
- run:
name: Upload new version
command: |
TAG=$(if [ "${CIRCLE_TAG}" ]; then echo $CIRCLE_TAG; else echo "0.0.0"; fi;)
SEMVER=$(echo "$TAG" | sed -e 's/\/[a-zA-Z-]*//')
/root/.dotnet/tools/Speckle.Manager.Feed deploy -s << parameters.slug >> -v ${SEMVER} -u https://releases.speckle.dev/installers/<< parameters.slug >>/<< parameters.slug >>-${SEMVER}.<< parameters.extension >> -o << parameters.os >> -f speckle-sharp-ci-tools/Installers/<< parameters.slug >>/<< parameters.slug >>-${SEMVER}.<< parameters.extension >>
# Orchestrate our job run sequence
workflows:
build_and_test:
when:
false
build-and-deploy:
jobs:
- build
- get-ci-tools:
filters:
tags:
only: /.*/
- build-ui:
filters:
tags:
only: /.*/
- build-connector:
slug: sketchup
requires:
- get-ci-tools
- build-ui
filters:
tags:
only: /.*/
context: innosetup
- build-connector-mac:
slug: sketchup
requires:
- get-ci-tools
- build-ui
filters:
tags:
only: /.*/
installername: SpeckleSketchUpInstall
- deploy-manager2:
context: do-spaces-speckle-releases
slug: sketchup
os: Win
extension: exe
requires:
- build-connector
filters:
tags:
only: /([0-9]+)\.([0-9]+)\.([0-9]+)(?:-\w+)?$/
branches:
ignore: /.*/ # For testing only! /ci\/.*/
- deploy-manager2:
context: do-spaces-speckle-releases
slug: sketchup
os: OSX
extension: zip
requires:
- build-connector-mac
filters:
tags:
only: /([0-9]+)\.([0-9]+)\.([0-9]+)(?:-\w+)?$/
branches:
ignore: /.*/ # For testing only! /ci\/.*/
-64
View File
@@ -1,64 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Build
on:
pull_request:
workflow_call:
outputs:
semver:
description: "The full SemVer 2.0 version of this build, e.g. '3.0.0-alpha.1234' (note: no 'v'-prefix)"
value: ${{ jobs.build.outputs.semver }}
file_version:
description: "The file info version, e.g. '3.0.0.1234'"
value: ${{ jobs.build.outputs.file_version }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
semver: ${{ steps.set-version.outputs.semver }}
file_version: ${{ steps.set-version.outputs.file-version }}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- id: set-version
name: Set version to output
shell: bash
run: |
TAG=${{ github.ref_name }}
if [[ "${{ github.ref }}" != refs/tags/* ]]; then
TAG="v3.0.99.${{ github.run_number }}"
fi
SEMVER="${TAG#v}"
FILE_VERSION=$(echo "$TAG" | sed -E 's/^v([0-9]+\.[0-9]+\.[0-9]+).*/\1/')
FILE_VERSION="$FILE_VERSION.${{ github.run_number }}"
echo "semver=$SEMVER" >> "$GITHUB_OUTPUT"
echo "file-version=$FILE_VERSION" >> "$GITHUB_OUTPUT"
echo $SEMVER
echo $FILE_VERSION
- name: Set connector version
run: |
python patch_version.py ${{steps.set-version.outputs.semver}}
- uses: montudor/action-zip@v1
with:
args: zip -q -r sketchup.zip vendor speckle_connector_3/ speckle_connector_3.rb
- name: ⬆️ Upload artifacts
uses: actions/upload-artifact@v4
with:
name: output-${{steps.set-version.outputs.semver}}
path: sketchup.zip
retention-days: 1
if-no-files-found: error
compression-level: 0 # no compression
-42
View File
@@ -1,42 +0,0 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
name: Build and deploy
on:
push:
branches: ["main", "installer-test/**"]
tags: ["v3.*.*"] # Manual delivery on every 3.x tag
jobs:
build:
uses: ./.github/workflows/build.yml
deploy-installers:
runs-on: ubuntu-latest
needs: build
env:
IS_PUBLIC_RELEASE: ${{ github.ref_type == 'tag' }}
steps:
- name: 🔫 Trigger Build Installer(s)
uses: the-actions-org/workflow-dispatch@v4.0.0
with:
workflow: Build Installers
repo: specklesystems/connector-installers
token: ${{ secrets.CONNECTORS_GH_TOKEN }}
inputs: '{
"run_id": "${{ github.run_id }}",
"semver": "${{ needs.build.outputs.semver }}",
"file_version": "${{ needs.build.outputs.file_version }}",
"repo": "${{ github.repository }}",
"is_public_release": ${{ env.IS_PUBLIC_RELEASE }}
}'
ref: main
wait-for-completion: true
wait-for-completion-interval: 10s
wait-for-completion-timeout: 10m
display-workflow-run-url: true
display-workflow-run-url-interval: 10s
- uses: geekyeggo/delete-artifact@v5
with:
name: output-*
+38
View File
@@ -0,0 +1,38 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
name: Ruby
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
permissions:
contents: read
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7']
steps:
- uses: actions/checkout@v3
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake
+2 -2
View File
@@ -10,8 +10,8 @@
settings.json
# vue app build dist folder
speckle_connector_3/vue_ui
speckle_connector_3/html
speckle_connector/vue_ui
speckle_connector/html
# speckle-sharp-ci-tools
/speckle-sharp-ci-tools
+1 -1
View File
@@ -18,7 +18,7 @@ AllCops:
- '_tools/su_attributes/**/*.rb'
- '_sqlite3/**/*.rb'
- 'ui/**/*'
- 'speckle_connector_3/src/ext/**/*.rb'
- 'speckle_connector/src/ext/**/*.rb'
- 'vendor/bundle/**/*'
- 'tests/**/*.rb'
SketchUp:
+1 -1
View File
@@ -1,6 +1,6 @@
require_paths:
- "C:/Program Files/SketchUp/SketchUp 2021/Tools"
- speckle_connector_3
- speckle_connector
require:
- sketchup-api-stubs
+1 -3
View File
@@ -24,8 +24,6 @@ group :development do
gem 'rubycritic', '~> 4.3', '>= 4.3.3', require: false
# Auto completions for SketchUp API.
gem 'sketchup-api-stubs'
# Runtime dependency of skippy for Ruby 3.2. Have it!
gem 'sorted_set', '~> 1.0'
# Aid with common SketchUp extension tasks.
gem 'skippy', '~> 0.5.2.a'
gem 'skippy', '~> 0.4.1.a'
end
+5 -13
View File
@@ -26,7 +26,7 @@ GEM
path_expander (~> 1.0)
ruby_parser (~> 3.1, > 3.1.0)
sexp_processor (~> 4.8)
git (1.19.1)
git (1.18.0)
addressable (~> 2.8)
rchardet (~> 1.8)
ice_nine (0.11.2)
@@ -51,7 +51,6 @@ GEM
public_suffix (5.0.1)
rainbow (3.1.1)
rake (13.0.6)
rbtree (0.4.6)
rchardet (1.8.0)
reek (6.1.1)
kwalify (~> 0.7.0)
@@ -90,7 +89,6 @@ GEM
simplecov (>= 0.17.0)
tty-which (~> 0.4.0)
virtus (~> 1.0)
set (1.1.0)
sexp_processor (4.16.1)
simplecov (0.21.2)
docile (~> 1.1)
@@ -99,15 +97,11 @@ GEM
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sketchup-api-stubs (0.7.8)
skippy (0.5.2.a)
skippy (0.4.3.a)
git (~> 1.3)
naturally (~> 2.1)
sorted_set (~> 1.0)
thor (>= 0.19, < 2.0)
sorted_set (1.0.3)
rbtree
set (~> 1.0)
thor (1.3.1)
thor (~> 0.19)
thor (0.20.3)
thread_safe (0.3.6)
tty-which (0.4.2)
unicode-display_width (1.8.0)
@@ -118,7 +112,6 @@ GEM
equalizer (~> 0.0, >= 0.0.9)
PLATFORMS
x64-mingw-ucrt
x64-mingw32
x64-unknown
x86_64-linux
@@ -134,8 +127,7 @@ DEPENDENCIES
rubocop-sketchup
rubycritic (~> 4.3, >= 4.3.3)
sketchup-api-stubs
skippy (~> 0.5.2.a)
sorted_set (~> 1.0)
skippy (~> 0.4.1.a)
BUNDLED WITH
2.3.25
-11
View File
@@ -1,11 +0,0 @@
workflow: GitFlow/v1
next-version: 3.0.0
mode: ManualDeployment
branches:
main:
label: rc
develop:
regex: ^dui3/alpha$
label: beta
unknown:
increment: None
+4 -18
View File
@@ -49,9 +49,9 @@ This repo is split into three parts:
### 1. **Speckle Connector extension**
Includes the `ruby` source files to run extension on SketchUp environment. SketchUp Extensions are composed of
a **.rb** file as entry and **folder** that .rb file refers to. In our case entry file is `speckle_connector_3.rb`
a **.rb** file as entry and **folder** that .rb file refers to. In our case entry file is `speckle_connector.rb`
that responsible to register Speckle Connector extension to SketchUp and also it shows address to where extension
will start to read extension. Source folder is `speckle_connector_3`.
will start to read extension. Source folder is `speckle_connector`.
### 2. **User Interface**
@@ -64,7 +64,7 @@ This repo is split into three parts:
we use extensions as native part of the source `ruby` code.
After building `sqlite3.sln` file, compiled `sqlite3.so` (for Windows) and `sqlite3.bundle` (for OSX) dynamic library files are created
by solution to place them into source code into `speckle_connector_3/src/ext`. Building this project should be only
by solution to place them into source code into `speckle_connector/src/ext`. Building this project should be only
happen when SketchUp starts to support newer Ruby versions (currently it is `2.7`).
## Contribution Guide
@@ -115,23 +115,9 @@ You can now open up the repo in VS Code or you can use JetBrains' tools RubyMine
If you will use VS Code, make sure you've installed the Ruby extension for VS Code.
#### RubyMine
To debug:
- Add configuration as **'Ruby remote debug'**
- Remote host: localhost
- Remote port: 7000
- Remote root folder: <repo_path>
- Local port: 26162
- Local root folder: <repo_path>
- Run below script
bundle exec skippy sketchup:debug 2024
- When sketchup opened, click Debug button on RubyMine
### Loading the Speckle Connector Plugin
1. Find already prepared `speckle_connector_3_loader.rb` file on the `_tools`
1. Find already prepared `speckle_connector_loader.rb` file on the `_tools`
folder.
2. Copy this Ruby file into your SketchUp Plugins directory. You will likely find this at:
`C:\Users\{YOU}\AppData\Roaming\SketchUp\SketchUp 20XX\SketchUp\Plugins`
+3 -3
View File
@@ -32,12 +32,12 @@ end
# Glob pattern to match source files. Defaults to FileList['.'].
ruby_critic_paths = FileList[
'speckle_connector_3/**/*.rb',
'speckle_connector_3.rb',
'speckle_connector/**/*.rb',
'speckle_connector.rb',
'tests/**/*.rb'] -
FileList[
'_tools/**/*.rb',
'speckle_connector_3/src/ext/**/*.rb',
'speckle_connector/src/ext/**/*.rb',
]
# for local
-15
View File
@@ -1,15 +0,0 @@
# This is for automated pre-debugger configuration.
# We run skippy first, then activate debugger.
# The purpose of this file to wait till skp is live
# To establish a configuration
# 1. Create 'Run External Tool' before lunch step
# 2. Program -> C:\Ruby32-x64\bin\ruby.exe or whatever
# 3. Arguments -> C:\Users\KORAL\Documents\Git\Speckle\speckle-sketchup\_tools\debugger\bundle_exec_2024.rb or whatever
# 4. Working directory -> C:\Users\KORAL\Documents\Git\Speckle\speckle-sketchup or whatever
# Add a delay of 10 seconds, it is arbitrary, do not hesitate to change for what works best for you
sleep(10)
# Execute the original command
exec('bundle exec skippy sketchup:debug 2024')
+1 -1
View File
@@ -24,7 +24,7 @@ module JF_RubyToolbar
def self.load_toolbar
@last_dir = "#{$LOAD_PATH[0]}/"
@last_dir = @last_dir.gsub('/', '\\\\\\\\')
@last_dir = File.join($JF_RUBYTOOLBAR, 'speckle_connector_3')
@last_dir = File.join($JF_RUBYTOOLBAR, 'speckle_connector')
curdir = File.dirname __FILE__
# create toolbar
@@ -10,7 +10,7 @@
# Create a link to Plugins folder with this command
# rubocop:disable Layout/LineLength
# New-Item -ItemType SymbolicLink -Path '~\AppData\Roaming\SketchUp\SketchUp 2022\SketchUp\Plugins\speckle_connector_3_loader.rb' -Target ~\Git\Speckle\speckle-sketchup\_tools\speckle_connector_3_loader.rb
# New-Item -ItemType SymbolicLink -Path '~\AppData\Roaming\SketchUp\SketchUp 2022\SketchUp\Plugins\speckle_connector_loader.rb' -Target ~\Git\Speckle\speckle-sketchup\_tools\speckle_connector_loader.rb
# rubocop:enable Layout/LineLength
SKETCHUP_CONSOLE.show # if you want to show Ruby console on startup
@@ -32,7 +32,7 @@ $LOAD_PATH << File.join(speckle_path, '_tools')
$JF_RUBYTOOLBAR = speckle_path
# rubocop:enable Style/GlobalVars
files = %w[speckle_connector_3 jf_RubyPanel su_attributes]
files = %w[speckle_connector jf_RubyPanel su_attributes]
files.each do |ruby_file|
puts "Loading #{ruby_file}"
+2 -8
View File
@@ -4,7 +4,7 @@ import sys
def patch_connector(tag):
"""Patches the connector version within the connector file"""
rb_file = "speckle_connector_3.rb"
rb_file = "speckle_connector.rb"
with open(rb_file, "r") as file:
lines = file.readlines()
@@ -15,12 +15,6 @@ def patch_connector(tag):
print(f"Patched connector version number in {rb_file}")
break
for (index, line) in enumerate(lines):
if 'DEV_MODE = ' in line:
lines[index] = f' DEV_MODE = false\n'
print(f"Patched dev mode to false in {rb_file}")
break
with open(rb_file, "w") as file:
file.writelines(lines)
@@ -51,7 +45,7 @@ def main():
print(f"Patching version: {tag}")
patch_connector(tag)
# patch_installer(tag)
patch_installer(tag)
if __name__ == "__main__":
@@ -4,7 +4,7 @@ require 'sketchup'
require 'extensions'
# Speckle connector module to enable multiplayer mode ON!
module SpeckleConnector3
module SpeckleConnector
# Version - patched by CI
CONNECTOR_VERSION = '0.0.0'
@@ -23,11 +23,11 @@ module SpeckleConnector3
PATH = File.join(PATH_ROOT, folder_name).freeze
# Run from localhost or from build files
DEV_MODE = true
DEV_MODE = false
puts("Loading Speckle Connector v#{CONNECTOR_VERSION} from #{DEV_MODE ? 'dev' : 'build'}")
unless file_loaded?(__FILE__)
ex = SketchupExtension.new('Speckle SketchUp v3', File.join(PATH, 'bootstrap'))
ex = SketchupExtension.new('Speckle SketchUp', File.join(PATH, 'bootstrap'))
ex.description = 'Speckle Connector for SketchUp'
ex.version = CONNECTOR_VERSION
ex.copyright = 'AEC Systems Ltd.'
@@ -2,7 +2,7 @@
require 'sketchup'
require 'pathname'
require 'speckle_connector_3/debug'
require 'speckle_connector/debug'
require_relative 'src/log/log'
require_relative 'src/ui/sketchup_ui'
require_relative 'src/ui/ui_controller'
@@ -13,7 +13,7 @@ require_relative 'src/states/initial_state'
require_relative 'src/commands/speckle_menu_commands'
# Speckle Connector on SketchUp to enable Multiplayer mode ON!
module SpeckleConnector3
module SpeckleConnector
SKETCHUP_VERSION = Sketchup.version.to_i
dir = __dir__.dup
@@ -24,9 +24,9 @@ module SpeckleConnector3
sketchup_ui = Ui::SketchupUi.new
ui_controller = Ui::UiController.new(sketchup_ui)
menu_commands = Commands::MenuCommandHandler.new
user_state = SpeckleConnector3::States::UserState.new({})
initial_state = SpeckleConnector3::States::InitialState.new(user_state)
app = SpeckleConnector3::App::SpeckleConnectorApp.new(menu_commands, initial_state, ui_controller)
user_state = SpeckleConnector::States::UserState.new({})
initial_state = SpeckleConnector::States::InitialState.new(user_state)
app = SpeckleConnector::App::SpeckleConnectorApp.new(menu_commands, initial_state, ui_controller)
# Add menu commands to SketchUp and Speckle application
Commands::SpeckleMenuCommands.add_initial_commands!(app)
app
@@ -1,7 +1,7 @@
# frozen_string_literal: true
# Speckle connector module to enable multiplayer mode ON!
module SpeckleConnector3
module SpeckleConnector
# from thomthom
# https://github.com/thomthom/true-bend/blob/master/src/tt_truebend/debug.rb

Before

Width:  |  Height:  |  Size: 798 B

After

Width:  |  Height:  |  Size: 798 B

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 665 B

After

Width:  |  Height:  |  Size: 665 B

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Before

Width:  |  Height:  |  Size: 639 B

After

Width:  |  Height:  |  Size: 639 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

@@ -3,29 +3,12 @@
require 'JSON'
require_relative '../ext/sqlite3'
require_relative '../constants/path_constants'
require_relative '../preferences/preferences'
module SpeckleConnector3
module SpeckleConnector
# Accounts to communicate with models on user's account.
module Accounts
# Load accounts from user's app data.
def self.load_accounts
db_path = SPECKLE_ACCOUNTS_DB_PATH
unless File.exist?(db_path)
File.new(SPECKLE_ACCOUNTS_DB_PATH, "w")
db = Sqlite3::Database.new(SPECKLE_ACCOUNTS_DB_PATH)
Preferences.create_objects_table(db)
db.close
return []
end
db = Sqlite3::Database.new(db_path)
rows = db.exec('SELECT * FROM objects')
db.close
rows.map { |row| JSON.parse(row[1]) }
end
def self.remove_account(account_id)
db_path = SPECKLE_ACCOUNTS_DB_PATH
unless File.exist?(db_path)
raise(
@@ -34,16 +17,11 @@ module SpeckleConnector3
https://speckle.guide/user/manager.html#adding-accounts"
)
end
db = Sqlite3::Database.new(db_path)
begin
db.exec("DELETE FROM objects WHERE hash = '#{account_id}'")
puts "Account with hash #{account_id} has been removed."
rescue StandardError => e
puts "An error occurred: #{e}"
ensure
db.close
end
db = Sqlite3::Database.new(db_path)
rows = db.exec('SELECT * FROM objects')
db.close
rows.map { |row| JSON.parse(row[1]) }
end
def self.get_account_by_id(id)
@@ -1,6 +1,6 @@
# frozen_string_literal: true
module SpeckleConnector3
module SpeckleConnector
module Actions
# State changer object.
class Action
@@ -3,7 +3,7 @@
require_relative 'action'
require_relative 'deactivate_diffing'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Deactivate diffing for stream.
class ActivateDiffing < Action
@@ -2,7 +2,7 @@
require_relative 'action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Adds material to speckle state and Sketchup.
class AddMaterial < Action
@@ -5,7 +5,7 @@ require_relative 'mapped_entities_updated'
require_relative 'events/selection_event_action'
require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Apply mappings for selected entities.
class ApplyMappings < Action
@@ -37,7 +37,7 @@ module SpeckleConnector3
end
# Collect entities from entity ids that comes from UI as list
entities_to_map = entities.select { |e| @entities_to_map.include?(e.persistent_id.to_s) }
entities_to_map = entities.select { |e| @entities_to_map.include?(e.persistent_id) }
# Switch to definitions if all entities are component instance and UI flag shows that
if entities_to_map.all? { |e| e.is_a?(Sketchup::ComponentInstance) } && @is_definition
@@ -0,0 +1,47 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../cards/send_card'
require_relative '../../cards/receive_card'
require_relative '../../filters/send/everything_filter'
require_relative '../../filters/send/selection_filter'
require_relative '../../filters/send_filters'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector
module Actions
# Action to add send card.
class AddModel < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, data)
if data['typeDiscriminator'] == 'ReceiverModelCard'
receive_card = Cards::ReceiveCard.new(data['id'], data['accountId'],
data['projectId'], data['projectName'],
data['modelId'], data['modelName'],
data['referencedObject'])
SketchupModel::Dictionary::ModelCardDictionaryHandler
.save_card_to_model(receive_card, state.sketchup_state.sketchup_model)
new_speckle_state = state.speckle_state.with_receive_card(receive_card)
state = state.with_speckle_state(new_speckle_state)
js_script = "baseBinding.receiveResponse('#{resolve_id}')"
return state.with_add_queue_js_command('addSendCard', js_script)
end
send_filter = Filters::SendFilters.get_filter_from_ui_data(data['sendFilter'])
# Init card and add to the state
send_card = Cards::SendCard.new(data['id'], data['accountId'], data['projectId'], data['modelId'],
send_filter, {})
SketchupModel::Dictionary::ModelCardDictionaryHandler
.save_card_to_model(send_card, state.sketchup_state.sketchup_model)
new_speckle_state = state.speckle_state.with_send_card(send_card)
state = state.with_speckle_state(new_speckle_state)
# Resolve promise
js_script = "baseBinding.receiveResponse('#{resolve_id}')"
state.with_add_queue_js_command('addSendCard', js_script)
end
end
end
end
@@ -0,0 +1,30 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../cards/send_card'
require_relative '../../filters/send_filters'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector
module Actions
# Add model to document state.
class AddModelToDocumentState < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, model)
puts model.to_json
send_filter = Filters::SendFilters.get_filter_from_ui_data(model['sendFilter'])
send_card = Cards::SendCard.new(model['id'], model['accountId'], model['projectId'], model['modelId'], send_filter, {})
SketchupModel::Dictionary::ModelCardDictionaryHandler
.save_card_to_model(send_card, state.sketchup_state.sketchup_model)
new_speckle_state = state.speckle_state.with_send_card(send_card)
state = state.with_speckle_state(new_speckle_state)
js_script = "baseBinding.receiveResponse('#{resolve_id}')"
state.with_add_queue_js_command('addModelToDocumentState', js_script)
end
end
end
end
@@ -0,0 +1,40 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../filters/send_filters'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector
module Actions
# Gets document state.
class GetDocumentState < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id)
send_cards_hash = SketchupModel::Dictionary::ModelCardDictionaryHandler
.get_cards_from_dict(state.sketchup_state.sketchup_model)
send_cards = send_cards_hash.collect do |id, card|
filter = Filters::SendFilters.get_filter_from_document(card['sendFilter'])
send_card = Cards::SendCard.new(id, card['account_id'], card['project_id'], card['model_id'], filter, {})
new_speckle_state = state.speckle_state.with_send_card(send_card)
state = state.with_speckle_state(new_speckle_state)
{
id: send_card.id,
accountId: send_card.account_id,
projectId: send_card.project_id,
modelId: send_card.model_id,
sendFilter: send_card.send_filter,
typeDiscriminator: send_card.type_discriminator
}
end
model_state = { models: send_cards }
js_script = "baseBinding.receiveResponse('#{resolve_id}', #{model_state.to_json})"
state.with_add_queue_js_command('getDocumentState', js_script)
end
end
end
end
@@ -0,0 +1,38 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../filters/send_filters'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector
module Actions
# Gets model state.
class GetModelState < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id)
send_cards_hash = SketchupModel::Dictionary::ModelCardDictionaryHandler
.get_cards_from_dict(state.sketchup_state.sketchup_model)
send_cards = send_cards_hash.collect do |id, card|
filters = Filters::SendFilters.get_filters_from_model(card['filters'])
send_card = Cards::SendCard.new(id, card['account_id'], card['project_id'], card['model_id'], filters)
new_speckle_state = state.speckle_state.with_send_card(send_card)
state = state.with_speckle_state(new_speckle_state)
{
accountId: send_card.account_id,
projectId: send_card.project_id,
modelId: send_card.model_id,
filters: send_card.filters
}
end
model_state = { sendCards: send_cards }
js_script = "baseBinding.receiveResponse('#{resolve_id}', #{model_state.to_json})"
state.with_add_queue_js_command('getModelState', js_script)
end
end
end
end
@@ -3,7 +3,7 @@
require_relative '../action'
require_relative '../../filters/send_filters'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to get send filter.
class GetSendFilters < Action
@@ -2,14 +2,14 @@
require_relative '../action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Get source app name.
class GetSourceAppName < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id)
js_command = "baseBinding.receiveResponse('#{resolve_id}', 'sketchup')"
js_command = "baseBinding.receiveResponse('#{resolve_id}', 'Sketchup')"
state.with_add_queue_js_command('getSourceAppName', js_command)
end
end
@@ -2,7 +2,7 @@
require_relative '../action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Get source app version.
class GetSourceAppVersion < Action
@@ -0,0 +1,45 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../sketchup_model/query/entity'
module SpeckleConnector
module Actions
# Action to add send card.
class HighlightModel < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, model_card_id)
# objects_to_highlight = if data['typeDiscriminator'] == 'ReceiverModelCard'
# # model_card = state.speckle_state.receive_cards[model_card_id]
# # TODO: return received objects
# []
# else
# model_card = state.speckle_state.send_cards[model_card_id]
# model_card.send_filter.selected_object_ids
# end
objects_to_highlight = state.speckle_state.send_cards[model_card_id].send_filter.selected_object_ids
state.sketchup_state.sketchup_model.selection.clear
# Flat entities to select entities on card
flat_entities = SketchupModel::Query::Entity.flat_entities(state.sketchup_state.sketchup_model.entities)
flat_entities.each do |entity|
next unless objects_to_highlight.include?(entity.persistent_id)
if entity.is_a?(Sketchup::ComponentDefinition)
state.sketchup_state.sketchup_model.selection.add(entity.instances)
end
state.sketchup_state.sketchup_model.selection.add(entity)
end
state.sketchup_state.sketchup_model.active_view.zoom(state.sketchup_state.sketchup_model.selection)
# Resolve promise
js_script = "baseBinding.receiveResponse('#{resolve_id}')"
state.with_add_queue_js_command('highlightModel', js_script)
end
end
end
end
@@ -8,7 +8,7 @@ require_relative '../../filters/send/selection_filter'
require_relative '../../filters/send_filters'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to remove send card.
class RemoveModel < Action
@@ -3,7 +3,7 @@
require_relative '../action'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to update send filter.
class UpdateSendFilter < Action
@@ -3,7 +3,7 @@
require_relative 'action'
require_relative '../sketchup_model/dictionary/speckle_entity_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Clear mapper source.
class ClearMapperSource < Action
@@ -5,7 +5,7 @@ require_relative 'mapped_entities_updated'
require_relative 'events/selection_event_action'
require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Clear mappings for selected entities.
class ClearMappings < Action
@@ -28,7 +28,7 @@ module SpeckleConnector3
end
# Collect entities from entity ids that comes from UI as list
entities_to_map = entities.select { |e| @entities_to_map.include?(e.persistent_id.to_s) }
entities_to_map = entities.select { |e| @entities_to_map.include?(e.persistent_id) }
# Switch to definitions if all entities are component instance and UI flag shows that
if entities_to_map.all? { |e| e.is_a?(Sketchup::ComponentInstance) } && @is_definition
@@ -5,7 +5,7 @@ require_relative 'mapped_entities_updated'
require_relative 'events/selection_event_action'
require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Clear mappings for selected entities from mapped elements table.
class ClearMappingsFromTable < Action
@@ -20,7 +20,7 @@ module SpeckleConnector3
# Store speckle state to update with mapped entities.
speckle_state = state.speckle_state
flat_entities.each do |entity|
next unless entity_ids.include?(entity.persistent_id.to_s)
next unless entity_ids.include?(entity.persistent_id)
SketchupModel::Dictionary::SpeckleSchemaDictionaryHandler.remove_dictionary(entity)
speckle_state = speckle_state.with_removed_mapped_entity(entity)
@@ -2,7 +2,7 @@
require_relative 'action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Clear queue from state.
class ClearQueue < Action
@@ -4,7 +4,7 @@ require_relative 'action'
require_relative '../ext/sqlite3'
require_relative '../constants/path_constants'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to collect preferences from database to UI.
class CollectPreferences < Action
@@ -2,7 +2,7 @@
require_relative 'action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to collect versions from sketchup and connector to track user's version by mixpanel.
class CollectVersions < Action
@@ -11,7 +11,7 @@ module SpeckleConnector3
def self.update_state(state, _resolve_id, _data)
versions = {
sketchup: Sketchup.version.to_i,
speckle: SpeckleConnector3::CONNECTOR_VERSION
speckle: SpeckleConnector::CONNECTOR_VERSION
}
state.with_add_queue('collectVersions', versions.to_json, [])
end
@@ -2,7 +2,7 @@
require_relative '../action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to get config.
class GetConfig < Action
@@ -3,7 +3,7 @@
require_relative '../action'
require_relative '../user_preferences_updated'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to update config.
class UpdateConfig < Action
@@ -15,7 +15,7 @@ module SpeckleConnector3
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, config)
config.each do |key, value|
state = Actions::UserPreferencesUpdated.new('Sketchup', KEY_VALUES[key], value).update_state(state)
state = Actions::UserPreferencesUpdated.new('configSketchup', KEY_VALUES[key], value).update_state(state)
end
js_script = "configBinding.receiveResponse('#{resolve_id}')"
@@ -1,6 +1,6 @@
# frozen_string_literal: true
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to update connected state of application.
class Connected < Action
@@ -6,7 +6,7 @@ require_relative '../actions/save_stream'
require_relative '../actions/queue_send'
require_relative '../convertors/converter'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Create stream.
class CreateStream < Action
@@ -2,7 +2,7 @@
require_relative 'action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Deactivate diffing.
class DeactivateDiffing < Action
@@ -5,7 +5,7 @@ require_relative 'on_document_changed'
require_relative '../load_sketchup_model'
require_relative '../collect_preferences'
module SpeckleConnector3
module SpeckleConnector
module Actions
module Events
# Handle events that are triggered by the {AppObserver}.
@@ -0,0 +1,89 @@
# frozen_string_literal: true
require_relative 'event_action'
require_relative '../../actions/send_actions/send_card_expiration_check'
require_relative '../../sketchup_model/utils/face_utils'
require_relative '../../constants/dict_constants'
module SpeckleConnector
module Actions
module Events
# Event actions related to entities.
class EntitiesEventAction < EventAction
# Event action when element added.
class OnElementAdded
# @param state [States::State] the current state of the SpeckleConnector Application
def self.update_state(state, event_data)
modified_entities = event_data.to_a.collect { |e| e[1] }
# do not copy speckle base object specific attributes, because they are entity specific
modified_entities.each { |entity| entity.delete_attribute(SPECKLE_BASE_OBJECT) }
state
end
end
# Event action when element modified.
class OnElementModified
# @param state [States::State] the current state of the SpeckleConnector Application
def self.update_state(state, event_data)
speckle_state = state.speckle_state
modified_entity = event_data[0][1]
modified_entities = event_data.collect { |data| data[1] }
new_speckle_state = state.speckle_state.with_changed_object_ids(modified_entities.collect(&:persistent_id))
state = state.with_speckle_state(new_speckle_state)
state = Actions::SendCardExpirationCheck.update_state(state)
# if modified_entity.is_a?(Sketchup::Face)
# path = state.sketchup_state.sketchup_model.active_path
# modified_faces = SketchupModel::Utils::FaceUtils.near_faces(modified_entity.edges)
# path_objects = path.nil? ? [] : path + path.collect(&:definition)
# parent_ids = path_objects.collect(&:persistent_id)
# ids_to_invalidate = modified_faces.collect(&:persistent_id) + parent_ids
# entities_to_invalidate = speckle_entities_to_invalidate(speckle_state, ids_to_invalidate)
# new_speckle_state = invalidate_speckle_entities(speckle_state, entities_to_invalidate)
# # This is the place we can send information to UI for diffing check
# diffing = state.user_state.preferences[:user][:diffing]
# new_speckle_state = new_speckle_state.with_invalid_streams_queue if diffing
# return state.with_speckle_state(new_speckle_state)
# end
state
end
# @param speckle_state [States::SpeckleState] the current state of the Speckle
def self.speckle_entities_to_invalidate(speckle_state, ids)
speckle_state.speckle_entities.to_h.select { |id, _| ids.include?(id) }
end
# @param speckle_state [States::SpeckleState] the current state of the Speckle
def self.invalidate_speckle_entities(speckle_state, entities_to_invalidate)
speckle_entities = speckle_state.speckle_entities
entities_to_invalidate.each do |id, speckle_entity|
edited_speckle_entity = speckle_entity.with_invalid
speckle_entities = speckle_entities.put(id, edited_speckle_entity)
end
speckle_state.with_speckle_entities(speckle_entities)
end
end
# Event action when element removed.
class OnElementRemoved
# @param state [States::State] the current state of the SpeckleConnector Application
def self.update_state(state, _event_data)
# TODO: Do state updates when element removed
state
end
end
# Handlers that are used to handle specific events
ACTIONS = {
onElementRemoved: OnElementRemoved,
onElementAdded: OnElementAdded,
onElementModified: OnElementModified
}.freeze
def self.actions
ACTIONS
end
end
end
end
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true
module SpeckleConnector3
module SpeckleConnector
module Actions
# This module contains actions that are performed to handle events triggered by observers in Sketchup.
module Events
@@ -3,7 +3,7 @@
require_relative 'event_action'
require_relative '../load_sketchup_model'
module SpeckleConnector3
module SpeckleConnector
module Actions
module Events
# Handle events that are triggered by the {ModelObserver}.
@@ -18,22 +18,12 @@ module SpeckleConnector3
sketchup_state = state.sketchup_state
active_path = sketchup_state.sketchup_model.active_path
observers = state.speckle_state.observers
update_entity_observers(active_path, observers)
update_object_observers(active_path, observers)
return state
end
def self.update_entity_observers(path, observers)
unless path.nil?
new_path_entities = path[-1].definition.entities
new_path_entities.add_observer(observers[ENTITIES_OBSERVER])
# attach observers to only orphan edges since face edges can be detected via face changes.
edges = new_path_entities.grep(Sketchup::Edge).filter { |edge| edge.faces.none? }
edges.each do |edge|
edge.add_observer(observers[ENTITY_OBSERVER])
edge.start.add_observer(observers[ENTITY_OBSERVER])
edge.end.add_observer(observers[ENTITY_OBSERVER])
end
end
def self.update_object_observers(path, observers)
path[-1].definition.entities.add_observer(observers[ENTITIES_OBSERVER]) unless path.nil?
end
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true
module SpeckleConnector3
module SpeckleConnector
module Actions
# Triggers whenever document has changed.
class OnDocumentChanged < Action
@@ -8,7 +8,7 @@ require_relative '../../sketchup_model/reader/speckle_entities_reader'
require_relative '../../sketchup_model/reader/mapper_reader'
require_relative '../../sketchup_model/query/entity'
module SpeckleConnector3
module SpeckleConnector
module Actions
module Events
# Update selected speckle objects when the selection changes for mapper tool.
@@ -18,14 +18,10 @@ module SpeckleConnector3
def self.update_state(state, event_data)
return state unless event_data&.any?
# POC: Not happy with it. We log also entity.entityID property since
# onElementRemoved observer only return them! :/ Reconsider this in BETA!
selected_object_ids = state.sketchup_state.sketchup_model.selection.collect(&:persistent_id).collect(&:to_s) +
state.sketchup_state.sketchup_model.selection.collect(&:entityID).collect(&:to_s)
summary = "Selected #{selected_object_ids.length / 2} objects." # POC: OFFF. I'll fix it
selection_info = UiData::Sketchup::SelectionInfo.new(selected_object_ids, summary)
js_script = "selectionBinding.emit('setSelection', #{selection_info.to_json})"
state.with_add_queue_js_command('setSelection', js_script)
# Get sketchup selection
sketchup_selection = state.sketchup_state.sketchup_model.selection
Actions::GetSelection.update_state(state)
# Collect and return mapper selection info.
# Later we can add more selection info for different scopes.
@@ -1,10 +1,10 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../accounts/accounts'
require_relative '../load_saved_streams'
require_relative 'action'
require_relative '../accounts/accounts'
require_relative 'load_saved_streams'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to initialize local accounts from database.
class GetAccounts < Action
@@ -12,7 +12,7 @@ module SpeckleConnector3
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id)
puts 'Initialisation of Speckle accounts requested by plugin'
accounts_data = SpeckleConnector3::Accounts.load_accounts
accounts_data = state.speckle_state.accounts
js_script = "accountsBinding.receiveResponse('#{resolve_id}', #{accounts_data.to_json})"
state.with_add_queue_js_command('getAccounts', js_script)
end
@@ -2,7 +2,7 @@
require_relative 'action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Get document info.
class GetDocumentInfo < Action
@@ -1,14 +1,10 @@
# frozen_string_literal: true
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to return error message to UI.
# It is "TopLevelExceptionHandler" equivalent of C#.
class HandleError < Action
# @return [StandardError] error
attr_reader :error
# @param error [StandardError] error
# @param error [String] error
# @param view_name [String] name of the view (binding)
# @param action [Action] action that error happened
# @param parameters [Array<String>] arguments
@@ -23,13 +19,11 @@ module SpeckleConnector3
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def update_state(state)
# TODO: Log here when it is ready!!!
host_app_error = {
message: error.message,
error: error,
stackTrace: error.backtrace
error_message = "Error: #{@error}\nBinding: #{@view_name}\nAction:#{@action}\nArgs: #{@args}\n"
error = {
error: error_message
}
js_error_script = "#{@view_name}.receiveResponse('#{@args.first}', #{host_app_error.to_json})"
js_error_script = "#{@view_name}.receiveResponse('#{@args.first}', #{error.to_json})"
state.with_add_queue_js_command("error_#{@view_name}", js_error_script)
end
end
@@ -4,7 +4,7 @@ require_relative 'action'
require_relative 'events/selection_event_action'
require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Hide entities that selected from mapped elements table.
class HideMappingsFromTable < Action
@@ -19,7 +19,7 @@ module SpeckleConnector3
# Store speckle state to update with mapped entities.
flat_entities.each do |entity|
next unless entity_ids.include?(entity.persistent_id.to_s)
next unless entity_ids.include?(entity.persistent_id)
if entity.is_a?(Sketchup::ComponentDefinition)
entity.instances.each do |instance|
@@ -4,7 +4,7 @@ require_relative 'action'
require_relative '../accounts/accounts'
require_relative 'load_saved_streams'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to initialize local accounts from database.
class InitLocalAccounts < Action
@@ -4,7 +4,7 @@ require_relative 'action'
require_relative 'add_material'
require_relative '../constants/mat_constants'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to initialize materials
class InitializeMaterials < Action
@@ -9,16 +9,16 @@ require_relative '../preferences/preferences'
require_relative '../constants/observer_constants'
require_relative '../ext/worker'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Initialization of the real state of the speckle.
class InitializeSpeckle < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, observers, instant_message_sender)
worker = SpeckleConnector3::Worker.new([])
worker = SpeckleConnector::Worker.new()
attach_app_observer!(observers[APP_OBSERVER])
accounts = SpeckleConnector3::Accounts.load_accounts
accounts = SpeckleConnector::Accounts.load_accounts
speckle_state = States::SpeckleState.new(accounts, observers, {}, {})
# This should be the only point that `Sketchup_active_model` passed to application state.
sketchup_state = States::SketchupState.new(Sketchup.active_model)
@@ -4,7 +4,7 @@ require_relative 'action'
require_relative 'events/selection_event_action'
require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Isolate entities that selected from mapped elements table.
class IsolateMappingsFromTable < Action
@@ -38,13 +38,13 @@ module SpeckleConnector3
faces_or_edges_ids = faces_or_edges.collect { |e| e['entityId'] }
face_edge_flat_entities.select { |e| faces_or_edges_ids.include?(e.persistent_id.to_s) }.each do |entity|
face_edge_flat_entities.select { |e| faces_or_edges_ids.include?(e.persistent_id) }.each do |entity|
entity.hidden = false
end
comps_or_groups_ids = comps_or_groups.collect { |e| e['entityId'] }
comp_flat_entities.select { |e| comps_or_groups_ids.include?(e.persistent_id.to_s) }.each do |entity|
comp_flat_entities.select { |e| comps_or_groups_ids.include?(e.persistent_id) }.each do |entity|
if entity.is_a?(Sketchup::ComponentDefinition)
entity.instances.each do |instance|
instance.hidden = false
@@ -2,7 +2,7 @@
require_relative 'action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to load saved streams.
class LoadSavedStreams < Action
@@ -9,7 +9,7 @@ require_relative '../states/state'
require_relative '../states/sketchup_state'
require_relative '../constants/observer_constants'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Switch sketchup model wit a new one
class LoadSketchupModel < Action
@@ -27,14 +27,12 @@ module SpeckleConnector3
new_state = InitializeMaterials.update_state(new_state)
# Read speckle entities
#new_speckle_entities = SketchupModel::Reader::SpeckleEntitiesReader.read(sketchup_model.entities)
#new_speckle_state = new_state.speckle_state.with_speckle_entities(Immutable::Hash.new(new_speckle_entities))
# POC: Reconsider it when we will do caching between sessions!
# new_speckle_state = new_speckle_state.with_empty_object_references
new_speckle_entities = SketchupModel::Reader::SpeckleEntitiesReader.read(sketchup_model.entities)
new_speckle_state = new_state.speckle_state.with_speckle_entities(Immutable::Hash.new(new_speckle_entities))
# Read mapped entities
# new_mapped_entities = SketchupModel::Reader::MapperReader.read_mapped_entities(sketchup_model.entities)
# new_speckle_state = new_speckle_state.with_mapped_entities(Immutable::Hash.new(new_mapped_entities))
# new_state = new_state.with_speckle_state(new_speckle_state)
new_mapped_entities = SketchupModel::Reader::MapperReader.read_mapped_entities(sketchup_model.entities)
new_speckle_state = new_speckle_state.with_mapped_entities(Immutable::Hash.new(new_mapped_entities))
new_state = new_state.with_speckle_state(new_speckle_state)
# Read preferences from database and model.
preferences = Preferences.read_preferences(new_state.sketchup_state.sketchup_model)
@@ -53,8 +51,6 @@ module SpeckleConnector3
# layers = sketchup_model.layers
# layers.add_observer(observers[LAYERS_OBSERVER_NAME])
entities = sketchup_model.entities
edges = entities.grep(Sketchup::Edge)
edges.each { |edge| edge.add_observer(observers[ENTITY_OBSERVER]) }
entities.add_observer(observers[ENTITIES_OBSERVER])
sketchup_model.add_observer(observers[MODEL_OBSERVER])
# materials = sketchup_model.materials
@@ -3,7 +3,7 @@
require_relative 'action'
require_relative '../sketchup_model/reader/mapper_reader'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Triggers when mapped entities updated.
class MappedEntitiesUpdated < Action
@@ -4,7 +4,7 @@ require_relative 'action'
require_relative '../mapper/category/revit_category'
require_relative '../mapper/category/revit_family_category'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Collects mapper selection info.
class MapperInitialized < Action
@@ -7,7 +7,7 @@ require_relative '../sketchup_model/reader/mapper_reader'
require_relative '../sketchup_model/reader/speckle_entities_reader'
require_relative '../sketchup_model/dictionary/speckle_entity_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Collects mapper selection info.
class MapperSelectionChanged < Action
@@ -5,7 +5,7 @@ require_relative '../constants/type_constants'
require_relative '../mapper/mapper_source'
require_relative '../speckle_objects/built_elements/revit/revit_element_type'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to update mapper source.
class MapperSourceUpdated < Action
@@ -6,7 +6,7 @@ require_relative '../accounts/accounts'
require_relative '../constants/path_constants'
require_relative '../sketchup_model/dictionary/speckle_model_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# When preference updated by UI.
class ModelPreferencesUpdated < Action
@@ -3,18 +3,16 @@
require_relative 'action'
require_relative 'events/app_event_action'
require_relative 'events/entities_event_action'
require_relative 'events/entity_event_action'
require_relative 'events/model_event_action'
require_relative 'events/selection_event_action'
require_relative '../constants/observer_constants'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Handle events that were collected by observers
class OnEventsAction < Action
RUN_ORDER = {
APP_OBSERVER => Events::AppEventAction,
ENTITY_OBSERVER => Events::EntityEventAction,
ENTITIES_OBSERVER => Events::EntitiesEventAction,
MODEL_OBSERVER => Events::ModelEventAction,
# MATERIALS_OBSERVER => Events::MaterialsEventAction,
@@ -0,0 +1,45 @@
# frozen_string_literal: true
require_relative 'action'
require_relative '../accounts/accounts'
require_relative '../actions/create_stream'
require_relative '../actions/queue_send'
require_relative '../convertors/to_speckle'
module SpeckleConnector
module Actions
# Sends to speckle.
class OneClickSend < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state)
puts 'send to speckle'
default_account = Accounts.default_account
if default_account.nil?
puts 'No local account found. Please refer to speckle.guide for more information.'
return state
end
sketchup_model = state.sketchup_state.sketchup_model
to_convert = sketchup_model.selection.count > 0 ? sketchup_model.selection : sketchup_model.entities
first_saved_stream = first_saved_stream(sketchup_model)
action = if first_saved_stream.nil?
Actions::CreateStream.new
else
Actions::QueueSend.new(first_saved_stream, convert_to_speckle(sketchup_model, to_convert))
end
action.update_state(state)
end
def self.first_saved_stream(model)
(saved_streams = model.attribute_dictionary('speckle', true)['streams']) or []
saved_streams.nil? || saved_streams.empty? ? nil : saved_streams[0]
end
def self.convert_to_speckle(sketchup_model, to_convert)
converter = Converters::ToSpeckle.new(sketchup_model)
to_convert.map { |entity| converter.convert(entity) }
end
end
end
end
@@ -5,7 +5,7 @@ require_relative '../states/state'
require_relative '../states/speckle_state'
require_relative '../actions/send_from_queue'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Send queue from state.
class QueueSend < Action
@@ -2,7 +2,7 @@
require_relative '../action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to let sketchup know receive from server is finished..
class AfterReceive < Action
@@ -2,7 +2,7 @@
require_relative '../action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to let sketchup know receive will be started.
class BeforeReceive < Action
@@ -6,7 +6,7 @@ require_relative '../action'
require_relative '../../convertors/units'
require_relative '../../convertors/to_native'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Clear mappings for selected entities.
class ReceiveSingleObject < Action
@@ -0,0 +1,26 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../convertors/to_native'
require_relative '../../ext/TT_Lib2/progressbar'
module SpeckleConnector
module Actions
# Receive from server.
class AfterGetObjects < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, model_card_id, source_application, root_obj)
model_card = state.speckle_state.receive_cards[model_card_id]
converter = Converters::ToNative.new(state, model_card.model_id, model_card.project_name,
model_card.model_name, source_application)
# Have side effects on the sketchup model. It effects directly on the entities by adding new objects.
state = converter.receive_commit_object(root_obj)
resolve_js_script = "receiveBinding.receiveResponse('#{resolve_id}')"
state.with_add_queue_js_command('receive', resolve_js_script)
end
end
end
end
@@ -5,23 +5,29 @@ require_relative '../../accounts/accounts'
require_relative '../../convertors/units'
require_relative '../../convertors/to_speckle'
require_relative '../../operations/send'
require_relative '../../ext/TT_Lib2/progressbar'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Receive from server.
class Receive < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, model_card_id)
def self.update_state(state, resolve_id, model_card_id, source_application)
model_card = state.speckle_state.receive_cards[model_card_id]
account = Accounts.get_account_by_id(model_card.account_id)
resolve_js_script = "receiveBinding.receiveResponse('#{resolve_id}')"
state = state.with_add_queue_js_command('receive', resolve_js_script)
args = {
modelCardId: model_card_id,
projectId: model_card.project_id,
accountId: model_card.account_id,
modelId: model_card.model_id,
selectedVersionId: model_card.selected_version_id
token: account['token'],
serverUrl: account['serverInfo']['url'],
accountId: model_card.account_id,
objectId: model_card.object_id,
sourceApplication: source_application
}
js_script = "receiveBinding.emit('receiveViaBrowser', #{args.to_json})"
state.with_add_queue_js_command('receiveViaBrowser', js_script)
@@ -6,7 +6,7 @@ require_relative '../convertors/to_native'
require_relative '../operations/receive'
require_relative '../convertors/clean_up'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to receive objects from Speckle Server.
class ReceiveObjects < Action
@@ -4,7 +4,7 @@ require_relative 'action'
require_relative '../accounts/accounts'
require_relative 'load_saved_streams'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to reload accounts from database.
class ReloadAccounts < Action
@@ -5,7 +5,7 @@ require_relative '../accounts/accounts'
require_relative '../convertors/units'
require_relative '../convertors/converter'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to remove stream.
# Currently it is not a state changer.
@@ -3,7 +3,7 @@
require_relative 'action'
require_relative '../accounts/accounts'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Save stream.
# Currently it is not a state changer.
@@ -4,7 +4,7 @@ require_relative 'action'
require_relative 'events/selection_event_action'
require_relative '../sketchup_model/dictionary/speckle_schema_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Select entities that selected from mapped elements table.
class SelectMappingsFromTable < Action
@@ -22,7 +22,7 @@ module SpeckleConnector3
# Store speckle state to update with mapped entities.
flat_entities.each do |entity|
next unless entity_ids.include?(entity.persistent_id.to_s)
next unless entity_ids.include?(entity.persistent_id)
if entity.is_a?(Sketchup::ComponentDefinition)
state.sketchup_state.sketchup_model.selection.add(entity.instances)
@@ -0,0 +1,22 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../ui_data/sketchup/selection_info'
module SpeckleConnector
module Actions
# Action to get selection.
class GetSelection < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state)
selected_object_ids = state.sketchup_state.sketchup_model.selection.collect(&:persistent_id)
summary = "Selected #{selected_object_ids.length} objects."
selection_info = UiData::Sketchup::SelectionInfo.new(selected_object_ids, summary)
# js_script = "selectionBinding.receiveResponse('#{resolve_id}', #{selection_info.to_json})"
js_script = "selectionBinding.emit('setSelection', #{selection_info.to_json})"
state.with_add_queue_js_command('setSelection', js_script)
end
end
end
end
@@ -3,7 +3,7 @@
require_relative '../action'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to activate send filter.
class ActivateSendFilter < Action
@@ -3,7 +3,7 @@
require_relative '../action'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to activate send filter tag.
class ActivateSendFilterTag < Action
@@ -0,0 +1,86 @@
# frozen_string_literal: true
require_relative '../action'
require_relative '../../accounts/accounts'
require_relative '../../convertors/units'
require_relative '../../convertors/to_speckle'
require_relative '../../operations/send'
require_relative '../../ext/TT_Lib2/progressbar'
require_relative '../../ext/worker'
module SpeckleConnector
module Actions
# Send to server.
class Send < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state, resolve_id, model_card_id)
model_card = state.speckle_state.send_cards[model_card_id]
account = Accounts.get_account_by_id(model_card.account_id)
converter = Converters::ToSpeckle.new(state, model_card_id, model_card.send_filter)
new_speckle_state, base = converter.convert_selection_to_base(state.user_state.preferences)
id, total_children_count, batches, new_speckle_state = converter.serialize(base, new_speckle_state,
state.user_state.preferences)
# update_test(state)
puts("converted #{base.count} objects for stream #{@stream_id}")
state = state.with_speckle_state(new_speckle_state)
resolve_js_script = "sendBinding.receiveResponse('#{resolve_id}')"
state = state.with_add_queue_js_command('send', resolve_js_script)
args = {
modelCardId: model_card_id,
projectId: model_card.project_id,
modelId: model_card.model_id,
token: account['token'],
serverUrl: account['serverInfo']['url'],
accountId: model_card.account_id,
message: model_card.message,
sendObject: {
id: id,
totalChildrenCount: total_children_count,
batches: batches
}
}
js_script = "sendBinding.emit('sendViaBrowser', #{args.to_json})"
state.with_add_queue_js_command('sendViaBrowser', js_script)
end
def self.update_test(state)
dialog = UI::HtmlDialog.new(
{
:dialog_title => 'Dialog Example',
:preferences_key => 'com.sample.plugin',
:scrollable => true,
:resizable => true,
:width => 600,
:height => 400,
:left => 10,
:top => 10,
:min_width => 50,
:min_height => 50,
:max_width =>1000,
:max_height => 1000,
:style => UI::HtmlDialog::STYLE_DIALOG
})
html = '<div id="hi"><b>Hello world!</b></div>'
dialog.set_html(html)
dialog.show
action = Proc.new do |status|
js_command = "document.getElementById('hi').innerHTML = '<b>#{status}</b>'"
log_js_command = "console.log('test')"
dialog.execute_script(js_command)
dialog.execute_script(log_js_command)
end
selected_object_ids = state.sketchup_state.sketchup_model.selection.collect(&:persistent_id)
state.worker.add_jobs(1000.times.to_a.map { |i| Job.new(i, &action) })
state.worker.do_work(Time.now.to_f, &action)
end
end
end
end
@@ -3,21 +3,20 @@
require_relative '../action'
require_relative '../../sketchup_model/dictionary/model_card_dictionary_handler'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to check send card expirations.
class SendCardExpirationCheck < Action
# @param state [States::State] the current state of the {App::SpeckleConnectorApp}
# @return [States::State] the new updated state object
def self.update_state(state)
return state unless state.speckle_state.changed_entity_persistent_ids.any? || state.speckle_state.changed_entity_ids.any?
return state unless state.speckle_state.changed_entity_ids.any?
expired_send_cards_ids = state.speckle_state.send_cards.select do |_id, send_card|
send_card.send_filter.check_expiry(state.speckle_state.changed_entity_persistent_ids) ||
send_card.send_filter.check_expiry(state.speckle_state.changed_entity_ids)
send_card.send_filter.check_expiry(state.speckle_state.changed_entity_ids)
end.keys.to_a
js_script = "sendBinding.emit('setModelsExpired', #{expired_send_cards_ids.to_json})"
state.with_add_queue_js_command('setModelsExpired', js_script)
js_script = "sendBinding.emit('sendersExpired', #{expired_send_cards_ids.to_json})"
state.with_add_queue_js_command('sendersExpired', js_script)
end
end
end
@@ -3,7 +3,7 @@
require_relative 'action'
require_relative '../accounts/accounts'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Send already converted objects from queue if exist on stream.
class SendFromQueue < Action
@@ -6,7 +6,7 @@ require_relative '../convertors/units'
require_relative '../convertors/to_speckle'
require_relative '../operations/send'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Send selection to server.
class SendSelection < Action
@@ -20,8 +20,9 @@ module SpeckleConnector3
def update_state(state)
state = DeactivateDiffing.update_state(state, nil, {})
converter = Converters::ToSpeckle.new(state, @stream_id, {})
new_speckle_state, base = converter.convert_selection_to_base
id, batches = converter.serialize(base, state.user_state.preferences)
new_speckle_state, base = converter.convert_selection_to_base(state.user_state.preferences)
id, total_children_count, batches, new_speckle_state = converter.serialize(base, new_speckle_state,
state.user_state.preferences)
# TODO: Later active send operation.
# Operations.send(@stream_id, batches)
@@ -35,7 +36,7 @@ module SpeckleConnector3
new_state.with_add_queue('convertedFromSketchup', @stream_id, [
{ is_string: false, val: batches },
{ is_string: true, val: id },
{ is_string: false, val: 0 }
{ is_string: false, val: total_children_count }
])
end
end
@@ -2,7 +2,7 @@
require_relative 'action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Show all entities on the model.
class ShowAllEntities < Action
@@ -2,7 +2,7 @@
require_relative '../action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to get user config.
class GetUserConfig < Action
@@ -2,7 +2,7 @@
require_relative '../action'
module SpeckleConnector3
module SpeckleConnector
module Actions
# Action to get user config.
class UpdateUserConfig < Action

Some files were not shown because too many files have changed in this diff Show More