All classes should at least subclass 'object' to avoid being old-style classes.
[hooke.git] / hooke / plugin / viewer.py
1 '''
2 Viewer test case
3
4 Copyright (C) 2008 Alberto Gomez-Casado (University of Twente).
5
6 This program is released under the GNU General Public License version 2.
7 '''
8
9
10 import libviewer as lview
11 import libinput as linput
12
13 class viewerCommands(object):
14         
15     def _plug_init(self):
16         self.viewerlist=[]
17         #we keep a list of different viewers so it's possible to retrieve different data
18         #or process the same data differently
19                 
20
21     def do_vwnew(self,args):
22         #creates a new viewer
23         self.viewerlist.append(lview.Ascii(self.outlet))
24         dt=linput.safeinput('What type of data will this viewer handle? (force/distance/all)',['force', 'distance', 'all'])
25                     #TODO update types, make a list somewhere?
26         print dt
27         self.viewerlist[-1].setdtype(dt)
28
29
30     def do_vwaction(self,args):
31         '''
32         triggers default action of viewer number n (default 0)
33         '''
34
35         if len(args)==0:
36             args=0
37         self.viewerlist[int(args)].action()