Package pyforms :: Package gui :: Package Controls :: Module ControlVisVis |
[hide private]
[frames] | no frames]

# Source Code for Module pyforms.gui.Controls.ControlVisVis

     1  #!/usr/bin/python
     2  # -*- coding: utf-8 -*-
     3
     4  __author__      = "Ricardo Ribeiro"
     5  __credits__     = ["Ricardo Ribeiro"]
     6  __license__     = "MIT"
     7  __version__     = "0.0"
     8  __maintainer__  = "Ricardo Ribeiro"
     9  __email__       = "ricardojvr@gmail.com"
    10  __status__      = "Development"
    11
    12
    13  import pyforms.Utils.tools as tools
    14  from PyQt4 import uic, QtGui, QtCore
    15  from pyforms.gui.Controls.ControlBase import ControlBase
    16
    17  from visvis import Point, Pointset
    18  import visvis as vv
    19  import numpy as np
    20
    21 -class ControlVisVis(ControlBase):
    22
    23 -    def initForm(self):
    24          self._form = QtGui.QWidget();layout = QtGui.QVBoxLayout();layout.setMargin(0);self._form.setLayout( layout )
    25          self._app = vv.use('pyqt4')
    26
    27          Figure = self._app.GetFigureClass()
    28          self._fig = Figure(self._form)
    29
    30          policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
    31          widget = self._fig._widget
    32          widget.setSizePolicy(policy)
    33
    34          layout.addWidget(widget)
    35
    36
    37
    38 -    def refresh(self):
    39          vv.figure(self._fig.nr)
    40          self._app = vv.use()
    41          self.paint(vv)
    42
    43
    44
    45 -    def paint(self, visvis):
    46          visvis.clf()
    47          a = visvis.gca()
    48          a.cameraType = '3d'
    49          a.daspectAuto = True
    50
    51          colors = ['r','g','b','c','m','y','k','w']
    52          for index, dataset in enumerate(self._value):
    53              l = visvis.plot(dataset, ms='o', mc=colors[ index % len(colors) ], mw='3', ls='', mew=0 )
    54              #l = visvis.plot(dataset, ms='o', mc=colors[ index % len(colors) ], mw='3', ls='', mew=0 )
    55              l.alpha = 0.3
    56
    57
    58
    59
    60      ############################################################################
    61      ############ Properties ####################################################
    62      ############################################################################
    63
    64
    65
    66
    67
    68
    69      @property
    70 -    def value(self): return None
    71
    72      @value.setter
    73 -    def value(self, value):
    74          self._value = []
    75          for dataset in value:
    76              if len(dataset)>0:
    77                  if isinstance(dataset[0], list) or isinstance(dataset[0], tuple) :
    78                      self._value.append( Pointset( np.array(dataset) ) )
    79                  else:
    80                      self._value.append( dataset )
    81
    82          self.refresh()
    83