-
Notifications
You must be signed in to change notification settings - Fork 593
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
Customize shapes / Add custom shape factories #1713
Comments
Hi, thanks for trying dwv! For a custom factory, you need a class that exposes the same api as the current factories and to register it, add it to the And for your information, I'm refactoring the factories and draw tools... See #1020 for progress, the goal is to save the annnotations as dicom and not use the Konva json format. The changes are quite big... |
Thank you @ivmartel for your kind and quick reply. I could successfully change to color of a shape thanks to your example. Yet changing the font type seems impossible, as the style property is protected and initially instanciated in the I am basically using bounding boxes (Rectangle) and polygons (Roi). What I am looking for, essentially, is the simplest way to tweak them: display/change the text labels, font type, keep polygons open before closing them on the final double click, remove the trash (shapes would be removed a different way). I would like if possible to keep npm-importing dwv instead of forking the code and doing my changes in there. I have tried so far to extract and duplicate the minimum of code and pull the strings of imports down to where they took me, but I have ended copying most of the package. Is there any simpler way to achieve this according to you? |
The toolOptions is now exported and allows for adding custom options. It is available in the latest code and will be in the next release (not before september) |
Hi @xgrg, did you make some progress with your issue? |
Having |
Hi @ivmartel,
First of all, thank you very much for the great work on creating and maintaining DWV.
I am currently using dwv (through npm install, v0.33.1) and I would like to customize the existing shape factories coming with the Draw tool.
I did my best to exhaust all the provided examples, documentation, issues and satellite projects. For instance, some issues on adding custom tools (eg.
AlertTool
) were quite informative but unfortunately did not cover shape factories.For instance I would like the Konva line rendered by Draw/Roi tool not to be closed until the shape is complete. Also, I could find a way to change the color of the shape/label but not the text, or the font of the label/tag itself . I can manage to change these live in the JS object but they would come back to the original style as soon as a
draw*
event is fired. One solution, I assume, would be to derive my own shape factory, but then I could not figure how to do that without directly changing the codebase.Is there any way to add custom shape factories on an
npm
-importeddwv
?I hope the description of the issue is clear enough. Thank you in advance for any assistance.
The text was updated successfully, but these errors were encountered: