pyqtgraphRedefine

Module Contents

isOnWindows

Other modified files (directly): ScatterPlotItem.py, to change point selection. Ctrl + clic: select area. Clic: only one single point:

class OnClicSelector:
def __init__(self):

self.p_list = []

def add_point(self, newp):

self.p_list.append(newp)

def draw(self, painter):
if len(self.p_list) > 2:

pen = fn.mkPen(1) pen.setWidthF(2) painter.setPen(pen) painter.drawPolyline(QtGui.QPolygonF(self.p_list))

def reset(self):

self.p_list = []

def getPath(self):

return path.Path([(p.x(), p.y()) for p in self.p_list] + [(self.p_list[-1].x(), self.p_list[-1].y())])

def mouseDragEvent(self, ev):
if ev.modifiers() and QtCore.Qt.ControlModifier:

ev.accept() self.clicSelector.add_point(ev.pos()) if ev.isFinish():

path = self.clicSelector.getPath() points = self.points() contains_points = path.contains_points([(p.pos().x(), p.pos().y()) for p in points]) indices = [i for i, cond in enumerate(contains_points) if cond] points_clicked = [points[i] for i in indices] self.ptsClicked = points_clicked self.sigClicked.emit(self, self.ptsClicked) self.clicSelector.reset()

self.update()

else:

ev.ignore()

class myGraphicsLayoutWidget(parent=None, **_kwargs)[source]

Bases: optimeed.visualize.gui.widgets.graphsVisualWidget.pyqtgraph.GraphicsView

useOpenGL(self, b=True)[source]

Overwrited to fix bad antialiasing while using openGL

class myGraphicsLayout[source]

Bases: optimeed.visualize.gui.widgets.graphsVisualWidget.pyqtgraph.GraphicsLayout

addItem(self, item, row=None, col=None, rowspan=1, colspan=1)[source]

Add an item to the layout and place it in the next available cell (or in the cell specified). The item must be an instance of a QGraphicsWidget subclass.

set_graph_disposition(self, item, row=1, col=1, rowspan=1, colspan=1)[source]

Function to modify the position of an item in the list

Parameters
  • item – WidgetPlotItem to set

  • row – Row

  • col – Column

  • rowspan

  • colspan

Returns

class myItemSample(item)[source]

Bases: optimeed.visualize.gui.widgets.graphsVisualWidget.pyqtgraph.graphicsItems.LegendItem.ItemSample

set_offset(self, offset)[source]
set_width_cell(self, width)[source]
paint(self, p, *args)[source]

Overwrites to make matlab-like samples

class myLegend(size=None, offset=(30, 30), is_light=False)[source]

Bases: optimeed.visualize.gui.widgets.graphsVisualWidget.pyqtgraph.LegendItem

Legend that fixes bugs (flush left + space) from pyqtgraph’s legend

set_space_sample_label(self, theSpace)[source]

To set the gap between the sample and the label

set_offset_sample(self, offset)[source]

To tune the offset between the sample and the text

set_width_cell_sample(self, width)[source]

Set width of sample

updateSize(self)[source]
addItem(self, item, name)[source]

Overwrites to flush left

apply_width_sample(self)[source]
set_font(self, font_size, font_color, fontname=None)[source]
paint(self, p, *args)[source]

Overwrited to select background color

set_position(self, position, offset)[source]

Set the position of the legend, in a corner.

Parameters
  • position – String (NW, NE, SW, SE), indicates which corner the legend is close

  • offset – Tuple (xoff, yoff), x and y offset from the edge

Returns

class myLabelItem[source]

Bases: optimeed.visualize.gui.widgets.graphsVisualWidget.pyqtgraph.LabelItem

setText(self, text, **args)[source]

Overwrited to add font-family to options

class myAxis(orientation)[source]

Bases: optimeed.visualize.gui.widgets.graphsVisualWidget.pyqtgraph.AxisItem

get_label_pos(self)[source]

Overwrited to place label closer to the axis

resizeEvent(self, ev=None)[source]

Overwrited to place label closer to the axis

set_label_pos(self, orientation, x_offset=0, y_offset=0)[source]
set_number_ticks(self, number)[source]