source: trunk/src/testing/ui/sageDisplayInfo.py @ 4

Revision 4, 4.1 KB checked in by ajaworski, 13 years ago (diff)

Added modified SAGE sources

Line 
1############################################################################
2#
3# SAGE UI - A Graphical User Interface for SAGE
4# Copyright (C) 2005 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# placement
42MIDDLE = -1
43LEFT = 0
44RIGHT = 1
45BOTTOM = 2
46TOP = 3
47
48
49class SageDisplay:
50    def __init__(self, tn,x,y,w,h,tw,th,dId):
51        self.tileNumber = tn
52        self.dimX = x
53        self.dimY = y
54        self.cols = x   # just an alias
55        self.rows = y
56        self.desktopWidth = w
57        self.desktopHeight = h
58        self.tileWidth = tw
59        self.tileHeight = th
60        self.sageW = w
61        self.sageH = h
62        self.displayId = dId
63        self.placement = MIDDLE  # where this display is with respect to display 0 (-1 means this is display 0 = middle)
64        #self.orientation = 0  # where down is in degrees. 0 is down, 90 is right, 180 is up, 270 is left
65       
66    def getValues(self):
67        return [self.tileNumber, self.dimX, self.dimY,
68                self.desktopWidth, self.desktopHeight,
69                self.tileWidth, self.tileHeight, self.displayId]
70
71    def getId(self):
72        return self.displayId
73   
74
75
76class SageDisplayInfo:
77
78    def __init__(self):
79        self.displays = {}
80
81
82    def getAllDisplays(self):
83        """ returns a list of SageDisplay objects """
84        return self.displays.values()
85
86
87    def getNumDisplays(self):
88        return len(self.displays)
89   
90
91    def addDisplay(self, tileNum, dimX, dimY, deskWidth, deskHeight, tileWidth, tileHeight, displayId=0):
92        d = SageDisplay(tileNum, dimX, dimY, deskWidth, deskHeight, tileWidth, tileHeight, displayId)
93        self.displays[displayId] = d
94
95
96    def getTotalWidth(self):
97        totalW = 0
98        for disp in self.displays.values():
99            pos = disp.placement
100            if pos == LEFT or pos == MIDDLE or pos == RIGHT:
101                totalW += disp.sageW
102        return totalW
103
104
105    def getTotalHeight(self):
106        totalH = 0
107        for disp in self.displays.values():
108            pos = disp.placement
109            if pos == TOP or pos == MIDDLE or pos == BOTTOM:
110                totalH += disp.sageH
111        return totalH
112   
113
114    def getDisplay(self, displayId):
115        return self.displays[displayId]
116
117           
118    def getDisplayInfo(self, displayId=0):
119        return self.displays[displayId].getValues()
120               
Note: See TracBrowser for help on using the repository browser.