Skip to content

Commit

Permalink
update annotation test
Browse files Browse the repository at this point in the history
  • Loading branch information
fraguada committed Jul 17, 2024
1 parent a555787 commit ff7f86d
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
10 changes: 9 additions & 1 deletion docs/debugging.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Debugging rhino3dm

## JavaScript
## JavaScript / WASM

One can debug the compiled wasm in the browser or in vscode if using nodejs.

updated 2023.07.25
### Requirements
Expand All @@ -9,12 +11,18 @@ updated 2023.07.25
- A rhino3dm.js debug build (TODO Docs)

### Setup

#### Browser
- Install the required tools.
- Enable WebAssembly Debugging in Chrome.
- Open the dev tools in Chrome.
- Click on the gear icon, or press F1 to get to the settings.
- Select _Experiments_ and ensure that _WebAssembly Debugging: Enable DWARF support_ is checked.

#### vscode
TODO
- https://marketplace.visualstudio.com/items?itemName=ms-vscode.wasm-dwarf-debugging

### Debugging
- Once the setup is in place, you should have some code you'd like to debug. This is typically an html with a js script that calls rhino3dm.js.
- The debug wasm build is a much bigger binary that what we use for release and when we compile it, it includes hardcoded paths to the root. Since we might build this debug build on a number of machines or containers, we need to pay special attention to map the source hardcoded in the wasm binary to where the source is on our local machine.
Expand Down
2 changes: 1 addition & 1 deletion docs/javascript/RHINO3DM.JS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The easiest way to get started is to reference a specific version of the library
<script type="importmap">
{
"imports": {
"rhino3dm":"https://cdn.jsdelivr.net/npm/rhino3dm@8.6.1/rhino3dm.module.min.js"
"rhino3dm":"https://cdn.jsdelivr.net/npm/rhino3dm@8.9.0-beta/rhino3dm.module.min.js"
}
}
</script>
Expand Down
1 change: 0 additions & 1 deletion script/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,6 @@ def main():

global module
module = args.module
print(args.module)

global node
node = False
Expand Down
3 changes: 3 additions & 0 deletions src/bindings/bnd_annotationbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,9 @@ void initAnnotationBaseBindings(void*)
.property("richText", &BND_AnnotationBase::RichText)
.property("plainText", &BND_AnnotationBase::PlainText)
.property("plainTextWithFields", &BND_AnnotationBase::PlainTextWithFields)
.property("plane", &BND_AnnotationBase::Plane)
.property("textIsWrapped", &BND_AnnotationBase::TextIsWrapped, &BND_AnnotationBase::SetTextIsWrapped)
.function("wrapText", &BND_AnnotationBase::WrapText)
;

class_<BND_TextDot, base<BND_GeometryBase>>("TextDot")
Expand Down
24 changes: 11 additions & 13 deletions tests/javascript/annotation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,24 @@ test('createAnnotation', async () => {
const doc = rhino.File3dm.fromByteArray(arr)
const objects = doc.objects()

console.log(objects.count)

const testArray = ["Hello World!", "Hello Cruel World!", "Hi there!"]
const testArray = ["Hello World!", "Hello Cruel World!", "Hi there!", "WTF"]

for ( let i = 0; i < objects.count; i ++ ) {

const geometry = objects.get(i).geometry
console.log(geometry)
console.log(geometry.annotationType)
console.log(geometry.dimensionStyleId)
console.log(geometry.plainText)
console.log(geometry.plainTextWithFields)
console.log(geometry.richText)
const geometry = objects.get(i).geometry()

if(!testArray.includes( geometry.PlainText )){
//fail(`Text not read correctly: ${geometry.PlainText}`)
switch(geometry.objectType){
case rhino.ObjectType.Annotation:
expect(testArray.includes( geometry.plainText )).toBe(true)
break
case rhino.ObjectType.TextDot:
expect(testArray.includes( geometry.text )).toBe(true)
break
}


}

expect(true).toBe(true)


})
Binary file modified tests/models/textEntities_r8.3dm
Binary file not shown.

0 comments on commit ff7f86d

Please sign in to comment.