Giter VIP home page Giter VIP logo

Comments (3)

ivmartel avatar ivmartel commented on September 2, 2024

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 app.init config argument (there is a tools property). I've not tried it for some time, I hope it works well!
For some code that changes the color of a shape, check out the dwv-jqmobile repo (demo).
I do not know of any custom shape factories repositories.

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...

from dwv.

xgrg avatar xgrg commented on September 2, 2024

Thank you @ivmartel for your kind and quick reply.
I did my best to put your advice into practice but I have been facing some further problems.
I can indeed create a new class that exposes the same api as the currently existing tools and pass it to app.init using the tools property. I also needed to add it to the toolList property which registers the constructors of the various tool classes.
However, I am getting trouble when it comes to registering the shape factories (namely Rectangle and Roi, the two I am interested in) as the App initialization function would look for their constructors in a private property called toolOptions which is not exported.
I tried to work it around by selecting my custom tool (eg. app.setTool("CustomDraw")) then using setOptions() with the desired factories, but it breaks anyway at a later stage. In particular, when creating and binding the layer group - cf addViewLayer and bindLayerGroupToApp - since the two aforementioned functions look for the Draw tool specifically to bind the (private) handler with drawing related events.

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 App constructor with no chance of changing it later.

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?
Thank you very much for your assistance.

from dwv.

ivmartel avatar ivmartel commented on September 2, 2024

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)
I created a gist for an example custom shape: https://gist.github.com/ivmartel/d192402542208aa75e6a1f622cae12ae (update the dwv path to one you locally built)

from dwv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.