flowchart, canvas

This commit is contained in:
Luke Campagnola 2013-12-23 10:01:20 -05:00
parent 7777240d89
commit eaf29b5f07
21 changed files with 79 additions and 162 deletions

View File

@ -3,29 +3,21 @@ if __name__ == '__main__':
import sys, os
md = os.path.dirname(os.path.abspath(__file__))
sys.path = [os.path.dirname(md), os.path.join(md, '..', '..', '..')] + sys.path
#print md
#from pyqtgraph.GraphicsView import GraphicsView
#import pyqtgraph.graphicsItems as graphicsItems
#from pyqtgraph.PlotWidget import PlotWidget
from pyqtgraph.Qt import QtGui, QtCore, USE_PYSIDE
from pyqtgraph.graphicsItems.ROI import ROI
from pyqtgraph.graphicsItems.ViewBox import ViewBox
from pyqtgraph.graphicsItems.GridItem import GridItem
from ..Qt import QtGui, QtCore, USE_PYSIDE
from ..graphicsItems.ROI import ROI
from ..graphicsItems.ViewBox import ViewBox
from ..graphicsItems.GridItem import GridItem
if USE_PYSIDE:
from .CanvasTemplate_pyside import *
else:
from .CanvasTemplate_pyqt import *
#import DataManager
import numpy as np
from pyqtgraph import debug
#import pyqtgraph as pg
from .. import debug
import weakref
from .CanvasManager import CanvasManager
#import items
from .CanvasItem import CanvasItem, GroupCanvasItem
class Canvas(QtGui.QWidget):
@ -605,4 +597,4 @@ class SelectBox(ROI):

View File

@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtGui, QtCore, QtSvg, USE_PYSIDE
from pyqtgraph.graphicsItems.ROI import ROI
import pyqtgraph as pg
from ..Qt import QtGui, QtCore, QtSvg, USE_PYSIDE
from ..graphicsItems.ROI import ROI
from .. import SRTTransform, ItemGroup
if USE_PYSIDE:
from . import TransformGuiTemplate_pyside as TransformGuiTemplate
else:
from . import TransformGuiTemplate_pyqt as TransformGuiTemplate
from pyqtgraph import debug
from .. import debug
class SelectBox(ROI):
def __init__(self, scalable=False, rotatable=True):
@ -96,7 +96,7 @@ class CanvasItem(QtCore.QObject):
if 'transform' in self.opts:
self.baseTransform = self.opts['transform']
else:
self.baseTransform = pg.SRTTransform()
self.baseTransform = SRTTransform()
if 'pos' in self.opts and self.opts['pos'] is not None:
self.baseTransform.translate(self.opts['pos'])
if 'angle' in self.opts and self.opts['angle'] is not None:
@ -124,8 +124,8 @@ class CanvasItem(QtCore.QObject):
self.itemScale = QtGui.QGraphicsScale()
self._graphicsItem.setTransformations([self.itemRotation, self.itemScale])
self.tempTransform = pg.SRTTransform() ## holds the additional transform that happens during a move - gets added to the userTransform when move is done.
self.userTransform = pg.SRTTransform() ## stores the total transform of the object
self.tempTransform = SRTTransform() ## holds the additional transform that happens during a move - gets added to the userTransform when move is done.
self.userTransform = SRTTransform() ## stores the total transform of the object
self.resetUserTransform()
## now happens inside resetUserTransform -> selectBoxToItem
@ -200,7 +200,7 @@ class CanvasItem(QtCore.QObject):
#flip = self.transformGui.mirrorImageCheck.isChecked()
#tr = self.userTransform.saveState()
inv = pg.SRTTransform()
inv = SRTTransform()
inv.scale(-1, 1)
self.userTransform = self.userTransform * inv
self.updateTransform()
@ -231,7 +231,7 @@ class CanvasItem(QtCore.QObject):
if not self.isMovable():
return
self.rotate(180.)
# inv = pg.SRTTransform()
# inv = SRTTransform()
# inv.scale(-1, -1)
# self.userTransform = self.userTransform * inv #flip lr/ud
# s=self.updateTransform()
@ -316,7 +316,7 @@ class CanvasItem(QtCore.QObject):
def resetTemporaryTransform(self):
self.tempTransform = pg.SRTTransform() ## don't use Transform.reset()--this transform might be used elsewhere.
self.tempTransform = SRTTransform() ## don't use Transform.reset()--this transform might be used elsewhere.
self.updateTransform()
def transform(self):
@ -368,7 +368,7 @@ class CanvasItem(QtCore.QObject):
try:
#self.userTranslate = pg.Point(tr['trans'])
#self.userRotate = tr['rot']
self.userTransform = pg.SRTTransform(tr)
self.userTransform = SRTTransform(tr)
self.updateTransform()
self.selectBoxFromUser() ## move select box to match
@ -377,7 +377,7 @@ class CanvasItem(QtCore.QObject):
except:
#self.userTranslate = pg.Point([0,0])
#self.userRotate = 0
self.userTransform = pg.SRTTransform()
self.userTransform = SRTTransform()
debug.printExc("Failed to load transform:")
#print "set transform", self, self.userTranslate
@ -504,6 +504,6 @@ class GroupCanvasItem(CanvasItem):
def __init__(self, **opts):
defOpts = {'movable': False, 'scalable': False}
defOpts.update(opts)
item = pg.ItemGroup()
item = ItemGroup()
CanvasItem.__init__(self, item, **defOpts)

View File

@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtCore, QtGui
from ..Qt import QtCore, QtGui
if not hasattr(QtCore, 'Signal'):
QtCore.Signal = QtCore.pyqtSignal
import weakref

View File

@ -95,6 +95,6 @@ class Ui_Form(object):
self.mirrorSelectionBtn.setText(QtGui.QApplication.translate("Form", "Mirror Selection", None, QtGui.QApplication.UnicodeUTF8))
self.reflectSelectionBtn.setText(QtGui.QApplication.translate("Form", "MirrorXY", None, QtGui.QApplication.UnicodeUTF8))
from pyqtgraph.widgets.GraphicsView import GraphicsView
from ..widgets.GraphicsView import GraphicsView
from CanvasManager import CanvasCombo
from pyqtgraph.widgets.TreeWidget import TreeWidget
from ..widgets.TreeWidget import TreeWidget

View File

@ -90,6 +90,6 @@ class Ui_Form(object):
self.mirrorSelectionBtn.setText(QtGui.QApplication.translate("Form", "Mirror Selection", None, QtGui.QApplication.UnicodeUTF8))
self.reflectSelectionBtn.setText(QtGui.QApplication.translate("Form", "MirrorXY", None, QtGui.QApplication.UnicodeUTF8))
from pyqtgraph.widgets.GraphicsView import GraphicsView
from ..widgets.GraphicsView import GraphicsView
from CanvasManager import CanvasCombo
from pyqtgraph.widgets.TreeWidget import TreeWidget
from ..widgets.TreeWidget import TreeWidget

View File

@ -1,8 +1,9 @@
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtCore, QtGui, USE_PYSIDE
from ..Qt import QtCore, QtGui, USE_PYSIDE
from .Node import *
from pyqtgraph.pgcollections import OrderedDict
from pyqtgraph.widgets.TreeWidget import *
from ..pgcollections import OrderedDict
from ..widgets.TreeWidget import *
from .. import FileDialog, DataTreeWidget
## pyside and pyqt use incompatible ui files.
if USE_PYSIDE:
@ -15,10 +16,9 @@ else:
from .Terminal import Terminal
from numpy import ndarray
from .library import LIBRARY
from pyqtgraph.debug import printExc
import pyqtgraph.configfile as configfile
import pyqtgraph.dockarea as dockarea
import pyqtgraph as pg
from ..debug import printExc
from .. import configfile as configfile
from .. import dockarea as dockarea
from . import FlowchartGraphicsView
def strDict(d):
@ -537,7 +537,7 @@ class Flowchart(Node):
startDir = self.filePath
if startDir is None:
startDir = '.'
self.fileDialog = pg.FileDialog(None, "Load Flowchart..", startDir, "Flowchart (*.fc)")
self.fileDialog = FileDialog(None, "Load Flowchart..", startDir, "Flowchart (*.fc)")
#self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
#self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
self.fileDialog.show()
@ -558,7 +558,7 @@ class Flowchart(Node):
startDir = self.filePath
if startDir is None:
startDir = '.'
self.fileDialog = pg.FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
self.fileDialog = FileDialog(None, "Save Flowchart..", startDir, "Flowchart (*.fc)")
#self.fileDialog.setFileMode(QtGui.QFileDialog.AnyFile)
self.fileDialog.setAcceptMode(QtGui.QFileDialog.AcceptSave)
#self.fileDialog.setDirectory(startDir)
@ -821,7 +821,7 @@ class FlowchartWidget(dockarea.DockArea):
self.selDescLabel = QtGui.QLabel()
self.selNameLabel = QtGui.QLabel()
self.selDescLabel.setWordWrap(True)
self.selectedTree = pg.DataTreeWidget()
self.selectedTree = DataTreeWidget()
#self.selectedTree.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)
#self.selInfoLayout.addWidget(self.selNameLabel)
self.selInfoLayout.addWidget(self.selDescLabel)

View File

@ -67,5 +67,5 @@ class Ui_Form(object):
self.reloadBtn.setText(QtGui.QApplication.translate("Form", "Reload Libs", None, QtGui.QApplication.UnicodeUTF8))
self.showChartBtn.setText(QtGui.QApplication.translate("Form", "Flowchart", None, QtGui.QApplication.UnicodeUTF8))
from pyqtgraph.widgets.FeedbackButton import FeedbackButton
from pyqtgraph.widgets.TreeWidget import TreeWidget
from ..widgets.FeedbackButton import FeedbackButton
from ..widgets.TreeWidget import TreeWidget

View File

@ -62,5 +62,5 @@ class Ui_Form(object):
self.reloadBtn.setText(QtGui.QApplication.translate("Form", "Reload Libs", None, QtGui.QApplication.UnicodeUTF8))
self.showChartBtn.setText(QtGui.QApplication.translate("Form", "Flowchart", None, QtGui.QApplication.UnicodeUTF8))
from pyqtgraph.widgets.FeedbackButton import FeedbackButton
from pyqtgraph.widgets.TreeWidget import TreeWidget
from ..widgets.FeedbackButton import FeedbackButton
from ..widgets.TreeWidget import TreeWidget

View File

@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtGui, QtCore
from pyqtgraph.widgets.GraphicsView import GraphicsView
from pyqtgraph.GraphicsScene import GraphicsScene
from pyqtgraph.graphicsItems.ViewBox import ViewBox
from ..Qt import QtGui, QtCore
from ..widgets.GraphicsView import GraphicsView
from ..GraphicsScene import GraphicsScene
from ..graphicsItems.ViewBox import ViewBox
#class FlowchartGraphicsView(QtGui.QGraphicsView):
class FlowchartGraphicsView(GraphicsView):

View File

@ -55,5 +55,5 @@ class Ui_Form(object):
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
from pyqtgraph.widgets.DataTreeWidget import DataTreeWidget
from pyqtgraph.flowchart.FlowchartGraphicsView import FlowchartGraphicsView
from ..widgets.DataTreeWidget import DataTreeWidget
from ..flowchart.FlowchartGraphicsView import FlowchartGraphicsView

View File

@ -50,5 +50,5 @@ class Ui_Form(object):
def retranslateUi(self, Form):
Form.setWindowTitle(QtGui.QApplication.translate("Form", "Form", None, QtGui.QApplication.UnicodeUTF8))
from pyqtgraph.widgets.DataTreeWidget import DataTreeWidget
from pyqtgraph.flowchart.FlowchartGraphicsView import FlowchartGraphicsView
from ..widgets.DataTreeWidget import DataTreeWidget
from ..flowchart.FlowchartGraphicsView import FlowchartGraphicsView

View File

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.graphicsItems.GraphicsObject import GraphicsObject
import pyqtgraph.functions as fn
from ..Qt import QtCore, QtGui
from ..graphicsItems.GraphicsObject import GraphicsObject
from .. import functions as fn
from .Terminal import *
from pyqtgraph.pgcollections import OrderedDict
from pyqtgraph.debug import *
from ..pgcollections import OrderedDict
from ..debug import *
import numpy as np
from .eq import *

View File

@ -1,4 +1,4 @@
from pyqtgraph.pgcollections import OrderedDict
from ..pgcollections import OrderedDict
from .Node import Node
def isNodeClass(cls):

View File

@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtCore, QtGui
from ..Qt import QtCore, QtGui
import weakref
from pyqtgraph.graphicsItems.GraphicsObject import GraphicsObject
import pyqtgraph.functions as fn
from pyqtgraph.Point import Point
from ..graphicsItems.GraphicsObject import GraphicsObject
from .. import functions as fn
from ..Point import Point
#from PySide import QtCore, QtGui
from .eq import *

View File

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from numpy import ndarray, bool_
from pyqtgraph.metaarray import MetaArray
from ..metaarray import MetaArray
def eq(a, b):
"""The great missing equivalence function: Guaranteed evaluation to a single bool value."""

View File

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
from ..Node import Node
from pyqtgraph.Qt import QtGui, QtCore
from ...Qt import QtGui, QtCore
import numpy as np
from .common import *
from pyqtgraph.SRTTransform import SRTTransform
from pyqtgraph.Point import Point
from pyqtgraph.widgets.TreeWidget import TreeWidget
from pyqtgraph.graphicsItems.LinearRegionItem import LinearRegionItem
from ...SRTTransform import SRTTransform
from ...Point import Point
from ...widgets.TreeWidget import TreeWidget
from ...graphicsItems.LinearRegionItem import LinearRegionItem
from . import functions

View File

@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
from ..Node import Node
import weakref
#from pyqtgraph import graphicsItems
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.graphicsItems.ScatterPlotItem import ScatterPlotItem
from pyqtgraph.graphicsItems.PlotCurveItem import PlotCurveItem
from pyqtgraph import PlotDataItem
from ...Qt import QtCore, QtGui
from ...graphicsItems.ScatterPlotItem import ScatterPlotItem
from ...graphicsItems.PlotCurveItem import PlotCurveItem
from ... import PlotDataItem
from .common import *
import numpy as np
@ -272,4 +271,4 @@ class ScatterPlot(CtrlNode):
#pos = file.

View File

@ -1,14 +1,14 @@
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtCore, QtGui
from ...Qt import QtCore, QtGui
from ..Node import Node
from scipy.signal import detrend
from scipy.ndimage import median_filter, gaussian_filter
#from pyqtgraph.SignalProxy import SignalProxy
#from ...SignalProxy import SignalProxy
from . import functions
from .common import *
import numpy as np
import pyqtgraph.metaarray as metaarray
from ... import metaarray as metaarray
class Downsample(CtrlNode):

View File

@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
from pyqtgraph.pgcollections import OrderedDict
#from pyqtgraph import importModules
from ...pgcollections import OrderedDict
import os, types
from pyqtgraph.debug import printExc
#from ..Node import Node
from ...debug import printExc
from ..NodeLibrary import NodeLibrary, isNodeClass
import pyqtgraph.reload as reload
from ... import reload as reload
# Build default library
@ -21,82 +19,10 @@ getNodeType = LIBRARY.getNodeType
# Add all nodes to the default library
from . import Data, Display, Filters, Operators
for mod in [Data, Display, Filters, Operators]:
#mod = getattr(__import__('', fromlist=[modName], level=1), modName)
#mod = __import__(modName, level=1)
nodes = [getattr(mod, name) for name in dir(mod) if isNodeClass(getattr(mod, name))]
for node in nodes:
LIBRARY.addNodeType(node, [(mod.__name__.split('.')[-1],)])
#NODE_LIST = OrderedDict() ## maps name:class for all registered Node subclasses
#NODE_TREE = OrderedDict() ## categorized tree of Node subclasses
#def getNodeType(name):
#try:
#return NODE_LIST[name]
#except KeyError:
#raise Exception("No node type called '%s'" % name)
#def getNodeTree():
#return NODE_TREE
#def registerNodeType(cls, paths, override=False):
#"""
#Register a new node type. If the type's name is already in use,
#an exception will be raised (unless override=True).
#Arguments:
#cls - a subclass of Node (must have typ.nodeName)
#paths - list of tuples specifying the location(s) this
#type will appear in the library tree.
#override - if True, overwrite any class having the same name
#"""
#if not isNodeClass(cls):
#raise Exception("Object %s is not a Node subclass" % str(cls))
#name = cls.nodeName
#if not override and name in NODE_LIST:
#raise Exception("Node type name '%s' is already registered." % name)
#NODE_LIST[name] = cls
#for path in paths:
#root = NODE_TREE
#for n in path:
#if n not in root:
#root[n] = OrderedDict()
#root = root[n]
#root[name] = cls
#def isNodeClass(cls):
#try:
#if not issubclass(cls, Node):
#return False
#except:
#return False
#return hasattr(cls, 'nodeName')
#def loadLibrary(reloadLibs=False, libPath=None):
#"""Import all Node subclasses found within files in the library module."""
#global NODE_LIST, NODE_TREE
#if reloadLibs:
#reload.reloadAll(libPath)
#mods = importModules('', globals(), locals())
#for name, mod in mods.items():
#nodes = []
#for n in dir(mod):
#o = getattr(mod, n)
#if isNodeClass(o):
#registerNodeType(o, [(name,)], override=reloadLibs)
#def reloadLibrary():
#loadLibrary(reloadLibs=True)
#loadLibrary()

View File

@ -1,12 +1,12 @@
# -*- coding: utf-8 -*-
from pyqtgraph.Qt import QtCore, QtGui
from pyqtgraph.widgets.SpinBox import SpinBox
#from pyqtgraph.SignalProxy import SignalProxy
from pyqtgraph.WidgetGroup import WidgetGroup
from ...Qt import QtCore, QtGui
from ...widgets.SpinBox import SpinBox
#from ...SignalProxy import SignalProxy
from ...WidgetGroup import WidgetGroup
#from ColorMapper import ColorMapper
from ..Node import Node
import numpy as np
from pyqtgraph.widgets.ColorButton import ColorButton
from ...widgets.ColorButton import ColorButton
try:
import metaarray
HAVE_METAARRAY = True

View File

@ -1,6 +1,6 @@
import scipy
import numpy as np
from pyqtgraph.metaarray import MetaArray
from ...metaarray import MetaArray
def downsample(data, n, axis=0, xvals='subsample'):
"""Downsample by averaging points together across axis.