Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(widgets): handle registration and state delivery #7

Merged
merged 11 commits into from
Aug 23, 2024

Conversation

jourdain
Copy link
Collaborator

No description provided.

@jspanchu
Copy link
Member

jspanchu commented Jun 27, 2024

Posting stack trace of the crash that happens when uncommenting these lines in VtkLocal.js

// crash: sceneManager.unRegisterState(cid);
// crash: sceneManager.updateStatesFromObjects();
    at abort (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.mjs:688:40)
    at assert (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.mjs:456:3)
    at ___cxa_throw (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.mjs:1494:2)
    at vtkWasmSceneManager.wasm.std::__2::__throw_out_of_range[abi:ne180100](char const*) (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.wasm:wasm-function[959]:0x9b58d)
    at vtkWasmSceneManager.wasm.std::__2::map<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>, std::__2::set<vtkSmartPointer<vtkObjectBase>, std::__2::less<vtkSmartPointer<vtkObjectBase>>, std::__2::allocator<vtkSmartPointer<vtkObjectBase>>>, std::__2::less<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>>>, std::__2::allocator<std::__2::pair<std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>> const, std::__2::set<vtkSmartPointer<vtkObjectBase>, std::__2::less<vtkSmartPointer<vtkObjectBase>>, std::__2::allocator<vtkSmartPointer<vtkObjectBase>>>>>>::at(std::__2::basic_string<char, std::__2::char_traits<char>, std::__2::allocator<char>> const&) const (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.wasm:wasm-function[951]:0x9ab3d)
    at vtkWasmSceneManager.wasm.vtkObjectManager::UpdateStatesFromObjects() (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.wasm:wasm-function[950]:0x9a785)
    at vtkWasmSceneManager.wasm.(anonymous namespace)::updateStatesFromObjects() (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.wasm:wasm-function[276]:0x7ae17)
    at vtkWasmSceneManager.wasm.emscripten::internal::Invoker<void>::invoke(void (*)()) (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.wasm:wasm-function[294]:0x7bb77)
    at dynCall (http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.mjs:4893:34)
    at http://localhost:8080/__trame_vtklocal/wasm/9.3.20240626/vtkWasmSceneManager.mjs:4899:22

// crash: sceneManager.updateStatesFromObjects();
const cameraState = sceneManager.getState(cid);
console.log(`${cameraState.Position}`);
emit("camera", cameraState);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the crash in my development branch. The logs of cameraState.Position in console shows x,y,z that change as I rotate the view so I think it works.

Can you suggest how to catch this emission of the cameraState and apply it in python? I checked the protocol.py and vtklocal.py just in case, nothing seems obvious.

Copy link
Collaborator Author

@jourdain jourdain Jun 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

state.camera = None

VtkLocal(rw, camera="camera = $event")


@state.change("camera"):
def on_camera_change(camera,  **_):
    print("camera state available", camera)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! also had to do a small change in LocalView.__init__

--- a/trame_vtklocal/widgets/vtklocal.py
+++ b/trame_vtklocal/widgets/vtklocal.py
@@ -75,6 +75,7 @@ class LocalView(HtmlElement):
             "updated",
             ("memory_vtk", "memory-vtk"),
             ("memory_arrays", "memory-arrays"),
+            ("camera", "camera"),
         ]

@jourdain jourdain merged commit b12c321 into master Aug 23, 2024
6 checks passed
@jourdain jourdain deleted the widget-handling branch August 23, 2024 19:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants