silx-kit / silx

silx toolkit
http://www.silx.org/doc/silx/latest/
MIT License
126 stars 73 forks source link

Customization of roi handles #4083

Open kklmn opened 5 months ago

kklmn commented 5 months ago

Hello,

In connection to PlotWindow, I want to create a set of data correction tools for 1D curves. I imagine four tools in it: 1) delete data points within a given range, 2) vertically scale data points within a given range, 3) step correction, 4) replace data points in a region by a spline.

To display these tools in PlotWindow, I need something similar to silx’s rois. In all four cases this would be a horizontal range roi with two draggable vertical lines, and additionally one handle for (2) to drag it vertically and n handles for (4) representing the spline nodes that would be draggable in all directions or only vertically.

Please advise very sketchy on how to modify HorizontalRangeROI to add custom draggable handles and emit custom Qt signals.

Thank you in advance!

vallsv commented 5 months ago

Hi Konstantin,

I think it's already the case.

You have signal send whenever a ROI region change. You also have signals to catch user interaction.

    sigRegionChanged = qt.Signal()
    """Signal emitted everytime the shape or position of the ROI changes"""

    sigEditingStarted = qt.Signal()
    """Signal emitted when the user start editing the roi"""

    sigEditingFinished = qt.Signal()
    """Signal emitted when the region edition is finished. During edition
    sigEditionChanged will be emitted several times and 
    sigRegionEditionFinished only at end"""

Everything is inherited from silx/gui/plot/items/_roi_base.py

kklmn commented 5 months ago

Hi Valentin,

Yes, no doubt that what is implemented does work as it should and it sends signals. :)

My question was how to add custom handles to a roi -- those draggable marks in the plot that interact with the mouse.

vallsv commented 5 months ago

On 2024-03-26 11:59, Konstantin Klementiev wrote:

Hi Valentin,

Yes, no doubt that what is implemented does work as it should and it sends signals. :)

My question was how to add custom handles to a roi -- those draggable marks in the plot that interact with the mouse.

-- Reply to this email directly, view it on GitHub [1], or unsubscribe [2]. You are receiving this because you commented.Message ID: @.***>

Oh, in this case there is not much to help.

Your better choice is to copy-paste the most convenient ROI and to tune it.

There is some basic roles handled by HandleBasedROI.

And the most complex ROI is the ArcROI. This implementation could help you to have an idea of what kind of stuffs you can do.

Links:

[1] https://github.com/silx-kit/silx/issues/4083#issuecomment-2020121878 [2] https://github.com/notifications/unsubscribe-auth/ABZ2NOPH6NSH7R4KNSGBWFLY2FBH7AVCNFSM6AAAAABEYWFIC2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMRQGEZDCOBXHA