Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 43 additions & 15 deletions pyforms/gui/Controls/ControlVisVis.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-

__author__ = "Ricardo Ribeiro"
__credits__ = ["Ricardo Ribeiro"]
__license__ = "MIT"
__version__ = "0.0"
__maintainer__ = "Ricardo Ribeiro"
__email__ = "ricardojvr@gmail.com"
__status__ = "Development"
__author__ = "Ricardo Ribeiro"
__credits__ = ["Ricardo Ribeiro"]
__license__ = "MIT"
__version__ = "0.0"
__maintainer__ = "Ricardo Ribeiro"
__email__ = "ricardojvr@gmail.com"
__status__ = "Development"


import pyforms.utils.tools as tools
from pyforms.gui.Controls.ControlBase import ControlBase

from visvis import Point, Pointset
from visvis import Point, Pointset
import visvis as vv
import numpy as np

Expand All @@ -27,23 +27,35 @@

class ControlVisVis(ControlBase):

def init_form(self):
self._form = QtGui.QWidget()
layout = QtGui.QVBoxLayout()
def __init__(self, label='', default=None, helptext=None, linepropertydefault=None):
super(self.__class__, self).__init__(label, default, helptext)

#https://github.com/almarklein/visvis/wiki/functions#plot
if linepropertydefault is None:
self._linepropertydefault = {'ms': 'o', 'mc': 'r', 'mw': '3', 'ls': '', 'mew': 0 }
else:
self._linepropertydefault = linepropertydefault

self._lineproperty = None


def init_form(self):
self._form = QWidget()
layout = QVBoxLayout()

if conf.PYFORMS_USE_QT5:
layout.setContentsMargins(0,0,0,0)
else:
layout.setMargin(0)

self._form.setLayout( layout )
self._app = vv.use('pyqt4')
self._app = vv.use('pyqt5')
self._app.Create()

Figure = self._app.GetFigureClass()
self._fig = Figure(self._form)

policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
policy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
widget = self._fig._widget
widget.setSizePolicy(policy)

Expand All @@ -60,9 +72,15 @@ def refresh(self):
def paint(self, visvis):
vv.clf()

colors = ['r','g','b','c','m','y','k']
for index, dataset in enumerate(self._value):
l = visvis.plot(dataset, ms='o', mc=colors[ index % len(colors) ], mw='3', ls='', mew=0 )

if self._lineproperty is None:
l = visvis.plot(dataset, **self._linepropertydefault)
else:
try:
l = visvis.plot(dataset, **self._lineproperty[index])
except:
l = visvis.plot(dataset, **self._linepropertydefault)
l.alpha = 0.3

self._a = vv.gca()
Expand Down Expand Up @@ -119,3 +137,13 @@ def value(self, value):

self.refresh()

@value.setter
def lineproperty(self, value):
self._lineproperty = []
for dataset in value:
if len(dataset)>0:
if isinstance(dataset, dict) :
self._lineproperty.append(dataset)

self.refresh()