pyFAI icon indicating copy to clipboard operation
pyFAI copied to clipboard

[GUI] Implement vector markers ...

Open kif opened this issue 1 year ago • 3 comments

To show the X and Y vector directions.

kif avatar Jun 11 '24 06:06 kif

Tip from @vallsv : https://github.com/silx-kit/silx/blob/main/examples/compareBackends.py Tip from @t20100 :

In [1]: from silx import sx
Qt: Session management error: None of the authentication protocols specified are supported

In [2]: w = sx.plot()

In [3]: w.addShape?

In [4]: w.addShape([0, 1], [1, 0], legend='test', shape='polylines')
Out[4]: <silx.gui.plot.items.shape.Shape at 0x7fdc3da67890>

In [5]: w.addShape([0, 1], [1, 0], legend='test', shape='polylines', color='red')
Out[5]: <silx.gui.plot.items.shape.Shape at 0x7fdc3dece3c0>

In [7]: w.addMarker(0.5, 0.5, legend='test_marker', text='X', symbol='')

Thanks

kif avatar Jun 11 '24 15:06 kif

Signature of the VectorMarker class: label:str, x_start: float, y_start: float, x_stop: float, y_stop: float, arrow_size=0.1: float (ranges from 0 to 1.

def build_arrow(start, stop, eta):
         start = numpy.array(start)
         stop = numpy.array(stop)
         delta = stop-start
         delta1 = numpy.array([delta[1],-delta[0]])
         f1 = eta*start+(1-eta)*stop+eta*delta1
         f2 = eta*start+(1-eta)*stop-eta*delta1
         return numpy.array([start, stop, f1, stop, f2]).T

w.addShape(*build_arrow((5,6), (7,8), 0.1), legend='test', shape='polylines')

kif avatar Jun 12 '24 09:06 kif

Position of the marker: 1.1*stop-0.1*start

kif avatar Jun 12 '24 12:06 kif