Howdy,
I do not have an answer, but your images are interesting.  Are you making a 
stand-alone PCB viewer?  Perhaps bringing up BOM information on the component 
selected?  I’d interested to hear more.

Cheers
Justin


> On Jun 7, 2020, at 15:30, Nathan Jessurun <[email protected]> wrote:
> 
> 
> Attempt number 2. I tried to make a custom symbol (like the 
> pyqtgraph.examples one with text as the scatterplot item) for each segment. 
> It's close, but I can't find out how to make each triangle 'life-sized'. Can 
> someone with experience using QPainterPaths weigh in? Thanks!
> 
> import pyqtgraph as pg
> from pyqtgraph.Qt import QtWidgets, QtCore, QtGui
> import numpy as np
> 
> tri = np.array([[0,0], [0,5], [5,5], [0,0]])
> tris = []
> xyLocs = []
> datas = []
> for ii in np.arange(0, 16, 5):
>   curTri = tri + ii
>   tris.append(curTri)
>   xyLocs.append(curTri.min(0))
>   datas.append(ii)
> 
> def ptsClicked(item, pts):
>   print(f'ID {pts[0].data()} Clicked!')
> 
> def makeSymbol(verts: np.ndarray):
>   outSymbol = QtGui.QPainterPath()
>   symPath = pg.arrayToQPath(*verts.T)
>   outSymbol.addPath(symPath)
>   # From pyqtgraph.examples for plotting text
>   br = outSymbol.boundingRect()
>   tr = QtGui.QTransform()
>   tr.scale(1/br.width(), 1/br.height())
>   tr.translate(-br.x() - br.width()/2., -br.y() - br.height()/2.)
>   outSymbol = tr.map(outSymbol)
>   return outSymbol
> 
> app = pg.mkQApp()
> 
> symbs = []
> for xyLoc, tri in zip(xyLocs, tris):
>   symbs.append(makeSymbol(tri))
> 
> xyLocs = np.vstack(xyLocs)
> tri2 = pg.PlotDataItem(*xyLocs.T, symbol=symbs, data=datas, connect='finite',
>                        pen=None)
> # Now each 'point' is one of the triangles, hopefully
> tri2.sigPointsClicked.connect(ptsClicked)
> 
> w = pg.PlotWindow()
> w.plotItem.addItem(tri2)
> w.show()
> app.exec()
> Enter code here...
> 
> 
> 
>> On Saturday, June 6, 2020 at 9:44:36 PM UTC-4, Nathan Jessurun wrote:
>> Hi there,
>> 
>> My overall goal is to have several clickable regions overlaid on an image, 
>> and if the plot boundary of any region is clicked I get a signal with the ID 
>> of that region. Something like this:
>> 
>> I tried making each boundary a separate plot data item, but I have 1000s of 
>> bounds that update frequently so it lagged a ton. So, I just used 
>> connect='finite' within the same plot item to make it much faster.
>> 
>> However, now I can't give a separate ID to each boundary. I have to make the 
>> vertices stand out, and connect to sigclicked(...pts) instead:
>> 
>> 
>> This works, but I'd love to be able to click anywhere on one of the line 
>> segments for the same effect. Is there any way to make this happen?
>> 
>> Relevant code is just a PlotDataItem on a plot widget.
>> 
>> Thanks!
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "pyqtgraph" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/pyqtgraph/3199cb82-a432-4434-aed4-c716fbcd932eo%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"pyqtgraph" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/pyqtgraph/4A0EA6B1-89CC-44BA-956E-2D23752CD939%40gmail.com.

Reply via email to