예제 #1
0
파일: Node.py 프로젝트: robertsj/poropy
    def __init__(self, node):
        #QtGui.QGraphicsItem.__init__(self)
        GraphicsObject.__init__(self)
        #QObjectWorkaround.__init__(self)
        
        #self.shadow = QtGui.QGraphicsDropShadowEffect()
        #self.shadow.setOffset(5,5)
        #self.shadow.setBlurRadius(10)
        #self.setGraphicsEffect(self.shadow)
        
        self.pen = fn.mkPen(0,0,0)
        self.selectPen = fn.mkPen(200,200,200,width=2)
        self.brush = fn.mkBrush(200, 200, 200, 150)
        self.hoverBrush = fn.mkBrush(200, 200, 200, 200)
        self.selectBrush = fn.mkBrush(200, 200, 255, 200)
        self.hovered = False
        
        self.node = node
        flags = self.ItemIsMovable | self.ItemIsSelectable | self.ItemIsFocusable |self.ItemSendsGeometryChanges
        #flags =  self.ItemIsFocusable |self.ItemSendsGeometryChanges

        self.setFlags(flags)
        self.bounds = QtCore.QRectF(0, 0, 100, 100)
        self.nameItem = QtGui.QGraphicsTextItem(self.node.name(), self)
        self.nameItem.setDefaultTextColor(QtGui.QColor(50, 50, 50))
        self.nameItem.moveBy(self.bounds.width()/2. - self.nameItem.boundingRect().width()/2., 0)
        self.nameItem.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
        self.updateTerminals()
        #self.setZValue(10)

        self.nameItem.focusOutEvent = self.labelFocusOut
        self.nameItem.keyPressEvent = self.labelKeyPress
        
        self.menu = None
        self.buildMenu()
예제 #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        GraphicsObject.__init__(self)

        self.qpicture = None  ## rendered picture for display

        self.axisOrder = getConfigOption('imageAxisOrder')

        if 'edgecolors' in kwargs.keys():
            self.edgecolors = kwargs['edgecolors']
        else:
            self.edgecolors = None

        if 'antialiasing' in kwargs.keys():
            self.antialiasing = kwargs['antialiasing']
        else:
            self.antialiasing = False

        if 'cmap' in kwargs.keys():
            if kwargs['cmap'] in Gradients.keys():
                self.cmap = kwargs['cmap']
            else:
                raise NameError(
                    'Undefined colormap, should be one of the following: ' +
                    ', '.join(['"' + i + '"' for i in Gradients.keys()]) + '.')
        else:
            self.cmap = 'viridis'

        # If some data have been sent we directly display it
        if len(args) > 0:
            self.setData(*args)

        self.levels = None
예제 #3
0
 def __init__(self, image=None, **kargs):
     """
     See :func:`setImage <pyqtgraph.ImageItem.setImage>` for all allowed initialization arguments.
     """
     GraphicsObject.__init__(self)
     self.menu = None
     self.image = None   ## original image data
     self.qimage = None  ## rendered image for display
     
     self.paintMode = None
     
     self.levels = None  ## [min, max] or [[redMin, redMax], ...]
     self.lut = None
     self.autoDownsample = False
     
     self.axisOrder = getConfigOption('imageAxisOrder')
     
     # In some cases, we use a modified lookup table to handle both rescaling
     # and LUT more efficiently
     self._effectiveLut = None
     
     self.drawKernel = None
     self.border = None
     self.removable = False
     
     if image is not None:
         self.setImage(image, **kargs)
     else:
         self.setOpts(**kargs)
예제 #4
0
파일: Node.py 프로젝트: initbrain/intelwiz
    def __init__(self, node):
        #QtGui.QGraphicsItem.__init__(self)
        GraphicsObject.__init__(self)
        #QObjectWorkaround.__init__(self)
        
        #self.shadow = QtGui.QGraphicsDropShadowEffect()
        #self.shadow.setOffset(5,5)
        #self.shadow.setBlurRadius(10)
        #self.setGraphicsEffect(self.shadow)
        
        self.pen = fn.mkPen(0,0,0)
        self.selectPen = fn.mkPen(200,200,200,width=2)
        self.brush = fn.mkBrush(200, 200, 200, 150)
        self.hoverBrush = fn.mkBrush(200, 200, 200, 200)
        self.selectBrush = fn.mkBrush(200, 200, 255, 200)
        self.hovered = False
        
        self.node = node
        flags = self.ItemIsMovable | self.ItemIsSelectable | self.ItemIsFocusable |self.ItemSendsGeometryChanges
        #flags =  self.ItemIsFocusable |self.ItemSendsGeometryChanges

        self.setFlags(flags)
        self.bounds = QtCore.QRectF(0, 0, 100, 100)
        self.nameItem = QtGui.QGraphicsTextItem(self.node.name(), self)
        self.nameItem.setDefaultTextColor(QtGui.QColor(50, 50, 50))
        self.nameItem.moveBy(self.bounds.width()/2. - self.nameItem.boundingRect().width()/2., 0)
        self.nameItem.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
        self.updateTerminals()
        #self.setZValue(10)

        self.nameItem.focusOutEvent = self.labelFocusOut
        self.nameItem.keyPressEvent = self.labelKeyPress
        
        self.menu = None
        self.buildMenu()
예제 #5
0
 def __init__(self, source, target=None):
     #QtGui.QGraphicsItem.__init__(self)
     GraphicsObject.__init__(self)
     self.setFlags(
         self.ItemIsSelectable | 
         self.ItemIsFocusable
     )
     self.source = source
     self.target = target
     self.length = 0
     self.hovered = False
     self.path = None
     self.shapePath = None
     self.style = {
         'shape': 'line',
         'color': (100, 100, 250),
         'width': 1.0,
         'hoverColor': (150, 150, 250),
         'hoverWidth': 1.0,
         'selectedColor': (200, 200, 0),
         'selectedWidth': 3.0,
         }
     #self.line = QtGui.QGraphicsLineItem(self)
     self.source.getViewBox().addItem(self)
     self.updateLine()
     self.setZValue(0)
예제 #6
0
 def __init__(self, *args, **kargs):
     GraphicsObject.__init__(self)
     self.data = np.empty(0,
                          dtype=[('x', float), ('y', float),
                                 ('symbol', np.uint16)])
     self._symbolList = []
     self._unusedSymbol = []  ## index of unused Symbol
     self.pointMode = False  ## Draw only point instead of symbol
     self._maxWidth = 0
     self.bounds = [None, None]  ## caches data bounds
     self.setData(*args, **kargs)
예제 #7
0
 def __init__(self, term, parent=None):
     self.term = term
     GraphicsObject.__init__(self, parent)
     self.brush = fn.mkBrush(0, 0, 0)
     self.box = QtGui.QGraphicsRectItem(0, 0, 10, 10, self)
     self.label = QtGui.QGraphicsTextItem(self.term.name(), self)
     self.label.scale(0.7, 0.7)
     self.newConnection = None
     self.setFiltersChildEvents(
         True)  # to pick up mouse events on the rectitem
     self.setZValue(1)
     self.menu = None
예제 #8
0
파일: Terminal.py 프로젝트: robertsj/poropy
 def __init__(self, source, target=None):
     #QtGui.QGraphicsItem.__init__(self)
     GraphicsObject.__init__(self)
     self.setFlags(self.ItemIsSelectable | self.ItemIsFocusable)
     self.source = source
     self.target = target
     self.length = 0
     self.hovered = False
     #self.line = QtGui.QGraphicsLineItem(self)
     self.source.getViewBox().addItem(self)
     self.updateLine()
     self.setZValue(0)
예제 #9
0
    def __init__(self,
                 module_name,
                 inputs,
                 outputs,
                 attributes,
                 module_type,
                 init_vars=None,
                 x=0,
                 y=0,
                 onlyff=False):
        #super().__init__(None)
        GraphicsObject.__init__(self)

        self.selected = True

        self.picture = QtGui.QPicture()

        self.draw_forward_only = onlyff

        self.conn_points = []

        self.size = 1000

        self.x = x
        self.y = y

        self.border = 0.11
        self.nob_size = 0.055

        self.module_name = module_name

        if init_vars is not None:
            self.init_vars = init_vars
        else:
            self.init_vars = [
                var.replace('#init', '') for var in sorted(outputs)
                if '#init' in var
            ]

        self.outputs = [var.replace('#init', '') for var in sorted(outputs)]

        self.inputs = sorted(inputs)

        self.get_arrow_positions()

        self.attributes = sorted(attributes)
        self.module_type = module_type

        self.red = (237, 85, 59, 255)
        self.green = (60, 174, 163, 255)
        self.blue = (32, 99, 155, 255)
        self.yellow = (246, 213, 92, 255)
예제 #10
0
파일: Terminal.py 프로젝트: archphy/poropy
 def __init__(self, source, target=None):
     #QtGui.QGraphicsItem.__init__(self)
     GraphicsObject.__init__(self)
     self.setFlags(
         self.ItemIsSelectable | 
         self.ItemIsFocusable
     )
     self.source = source
     self.target = target
     self.length = 0
     self.hovered = False
     #self.line = QtGui.QGraphicsLineItem(self)
     self.source.getViewBox().addItem(self)
     self.updateLine()
     self.setZValue(0)
예제 #11
0
 def __init__(self, term, parent=None):
     self.term = term
     #QtGui.QGraphicsItem.__init__(self, parent)
     GraphicsObject.__init__(self, parent)
     self.brush = fn.mkBrush(0,0,0)
     self.box = QtGui.QGraphicsRectItem(0, 0, 10, 10, self)
     self.label = QtGui.QGraphicsTextItem(self.term.name(), self)
     self.label.scale(0.7, 0.7)
     #self.setAcceptHoverEvents(True)
     self.newConnection = None
     self.setFiltersChildEvents(True)  ## to pick up mouse events on the rectitem
     if self.term.isRenamable():
         self.label.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
         self.label.focusOutEvent = self.labelFocusOut
         self.label.keyPressEvent = self.labelKeyPress
     self.setZValue(1)
     self.menu = None
예제 #12
0
파일: Terminal.py 프로젝트: robertsj/poropy
 def __init__(self, term, parent=None):
     self.term = term
     #QtGui.QGraphicsItem.__init__(self, parent)
     GraphicsObject.__init__(self, parent)
     self.brush = fn.mkBrush(0, 0, 0)
     self.box = QtGui.QGraphicsRectItem(0, 0, 10, 10, self)
     self.label = QtGui.QGraphicsTextItem(self.term.name(), self)
     self.label.scale(0.7, 0.7)
     #self.setAcceptHoverEvents(True)
     self.newConnection = None
     self.setFiltersChildEvents(
         True)  ## to pick up mouse events on the rectitem
     if self.term.isRenamable():
         self.label.setTextInteractionFlags(QtCore.Qt.TextEditorInteraction)
         self.label.focusOutEvent = self.labelFocusOut
         self.label.keyPressEvent = self.labelKeyPress
     self.setZValue(1)
     self.menu = None
예제 #13
0
 def __init__(self, **opts):
     """
     Valid keyword options are:
     x, x0, x1, y, y0, y1, width, height, pen, brush
     
     x specifies the x-position of the center of the bar.
     x0, x1 specify left and right edges of the bar, respectively.
     width specifies distance from x0 to x1.
     You may specify any combination:
         
         x, width
         x0, width
         x1, width
         x0, x1
         
     Likewise y, y0, y1, and height. 
     If only height is specified, then y0 will be set to 0
     
     Example uses:
     
         BarGraphItem(x=range(5), height=[1,5,2,4,3], width=0.5)
         
     
     """
     GraphicsObject.__init__(self)
     self.opts = dict(
         x=None,
         y=None,
         x0=None,
         y0=None,
         x1=None,
         y1=None,
         height=None,
         width=None,
         pen=None,
         brush=None,
         pens=None,
         brushes=None,
     )
     self.setOpts(**opts)
예제 #14
0
 def __init__(self, source, target=None):
     #QtGui.QGraphicsItem.__init__(self)
     GraphicsObject.__init__(self)
     self.setFlags(self.ItemIsSelectable | self.ItemIsFocusable)
     self.source = source
     self.target = target
     self.length = 0
     self.hovered = False
     self.path = None
     self.shapePath = None
     self.style = {
         'shape': 'line',
         'color': (100, 100, 250),
         'width': 1.0,
         'hoverColor': (150, 150, 250),
         'hoverWidth': 1.0,
         'selectedColor': (200, 200, 0),
         'selectedWidth': 3.0,
     }
     #self.line = QtGui.QGraphicsLineItem(self)
     self.source.getViewBox().addItem(self)
     self.updateLine()
     self.setZValue(0)
예제 #15
0
파일: Node.py 프로젝트: initbrain/intelwiz
 def itemChange(self, change, val):
     if change == self.ItemPositionHasChanged:
         for k, t in self.terminals.items():
             t[1].nodeMoved()
     return GraphicsObject.itemChange(self, change, val)
예제 #16
0
 def viewTransformChanged(self):
     self.prepareGeometryChange()
     GraphicsObject.viewTransformChanged(self)
     self.bounds = [None, None]
     self.fragments = None
예제 #17
0
 def itemChange(self, change, val):
     if change == self.ItemPositionHasChanged:
         for k, t in self.terminals.items():
             t[1].nodeMoved()
     return GraphicsObject.itemChange(self, change, val)
예제 #18
0
 def setExportMode(self, *args, **kwds):
     GraphicsObject.setExportMode(self, *args, **kwds)
     self.invalidate()