1 | ############################################################################
|
---|
2 | #
|
---|
3 | # DIM - A Direct Interaction Manager for SAGE
|
---|
4 | # Copyright (C) 2007 Electronic Visualization Laboratory,
|
---|
5 | # University of Illinois at Chicago
|
---|
6 | #
|
---|
7 | # All rights reserved.
|
---|
8 | #
|
---|
9 | # Redistribution and use in source and binary forms, with or without
|
---|
10 | # modification, are permitted provided that the following conditions are met:
|
---|
11 | #
|
---|
12 | # * Redistributions of source code must retain the above copyright
|
---|
13 | # notice, this list of conditions and the following disclaimer.
|
---|
14 | # * Redistributions in binary form must reproduce the above
|
---|
15 | # copyright notice, this list of conditions and the following disclaimer
|
---|
16 | # in the documentation and/or other materials provided with the distribution.
|
---|
17 | # * Neither the name of the University of Illinois at Chicago nor
|
---|
18 | # the names of its contributors may be used to endorse or promote
|
---|
19 | # products derived from this software without specific prior written permission.
|
---|
20 | #
|
---|
21 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
---|
22 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
---|
23 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
---|
24 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
---|
25 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
26 | # EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
27 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
---|
28 | # PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
---|
29 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
---|
30 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
---|
31 | # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
32 | #
|
---|
33 | # Direct questions, comments etc about SAGE UI to www.evl.uic.edu/cavern/forum
|
---|
34 | #
|
---|
35 | # Author: Ratko Jagodic
|
---|
36 | #
|
---|
37 | ############################################################################
|
---|
38 |
|
---|
39 |
|
---|
40 |
|
---|
41 |
|
---|
42 | # placement
|
---|
43 | MIDDLE = -1
|
---|
44 | LEFT = 0
|
---|
45 | RIGHT = 1
|
---|
46 | BOTTOM = 2
|
---|
47 | TOP = 3
|
---|
48 |
|
---|
49 |
|
---|
50 | class SageDisplay:
|
---|
51 | def __init__(self, tn,x,y,w,h,tw,th,dId):
|
---|
52 | self.tileNumber = tn
|
---|
53 | self.dimX = x
|
---|
54 | self.dimY = y
|
---|
55 | self.cols = x # just an alias
|
---|
56 | self.rows = y
|
---|
57 | self.desktopWidth = w
|
---|
58 | self.desktopHeight = h
|
---|
59 | self.tileWidth = tw
|
---|
60 | self.tileHeight = th
|
---|
61 | self.sageW = w
|
---|
62 | self.sageH = h
|
---|
63 | self.displayId = dId
|
---|
64 | self.placement = MIDDLE # where this display is with respect to display 0 (-1 means this is display 0 = middle)
|
---|
65 | #self.orientation = 0 # where down is in degrees. 0 is down, 90 is right, 180 is up, 270 is left
|
---|
66 |
|
---|
67 | def getValues(self):
|
---|
68 | return [self.tileNumber, self.dimX, self.dimY,
|
---|
69 | self.desktopWidth, self.desktopHeight,
|
---|
70 | self.tileWidth, self.tileHeight, self.displayId]
|
---|
71 |
|
---|
72 | def getId(self):
|
---|
73 | return self.displayId
|
---|
74 |
|
---|
75 |
|
---|
76 |
|
---|
77 | class SageDisplayInfo:
|
---|
78 |
|
---|
79 | def __init__(self):
|
---|
80 | self.displays = {}
|
---|
81 |
|
---|
82 |
|
---|
83 | def getAllDisplays(self):
|
---|
84 | """ returns a list of SageDisplay objects """
|
---|
85 | return self.displays.values()
|
---|
86 |
|
---|
87 |
|
---|
88 | def getNumDisplays(self):
|
---|
89 | return len(self.displays)
|
---|
90 |
|
---|
91 |
|
---|
92 | def addDisplay(self, tileNum, dimX, dimY, deskWidth, deskHeight, tileWidth, tileHeight, displayId=0):
|
---|
93 | d = SageDisplay(tileNum, dimX, dimY, deskWidth, deskHeight, tileWidth, tileHeight, displayId)
|
---|
94 | self.displays[displayId] = d
|
---|
95 |
|
---|
96 |
|
---|
97 | def getTotalWidth(self):
|
---|
98 | totalW = 0
|
---|
99 | for disp in self.displays.values():
|
---|
100 | pos = disp.placement
|
---|
101 | if pos == LEFT or pos == MIDDLE or pos == RIGHT:
|
---|
102 | totalW += disp.sageW
|
---|
103 | return totalW
|
---|
104 |
|
---|
105 |
|
---|
106 | def getTotalHeight(self):
|
---|
107 | totalH = 0
|
---|
108 | for disp in self.displays.values():
|
---|
109 | pos = disp.placement
|
---|
110 | if pos == TOP or pos == MIDDLE or pos == BOTTOM:
|
---|
111 | totalH += disp.sageH
|
---|
112 | return totalH
|
---|
113 |
|
---|
114 |
|
---|
115 | def getDisplay(self, displayId):
|
---|
116 | if not displayId in self.displays:
|
---|
117 | displayId = 0
|
---|
118 | return self.displays[displayId]
|
---|
119 |
|
---|
120 |
|
---|
121 | def getDisplayInfo(self, displayId=0):
|
---|
122 | if not displayId in self.displays:
|
---|
123 | displayId = 0
|
---|
124 | return self.displays[displayId].getValues()
|
---|
125 |
|
---|