/usr/share/pyshared/pgm/graph/drawable.py is in python-pgm 0.3.12-2build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | # -*- mode: python; coding: utf-8 -*-
#
# Pigment Python tools
#
# Copyright © 2006, 2007, 2008 Fluendo Embedded S.L.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
import pgm
class Drawable(object):
def __init__(self):
self._position_offset=(0.0, 0.0, 0.0)
self._opacity=self.widget_class.get_opacity(self)
self._opacity_factor=1.0
self._visible=self.widget_class.is_visible (self)
self._parent_visibility=True
self._cached_abs_position = self.widget_class.get_position(self)
def position__get(self):
absolute_position = self._cached_abs_position
x = absolute_position[0]-self._position_offset[0]
y = absolute_position[1]-self._position_offset[1]
z = absolute_position[2]-self._position_offset[2]
return (x, y, z)
def x__get(self):
x = self.widget_class.get_position(self)[0]
relative_x = x - self._position_offset[0]
return relative_x
def x__set(self, value):
#FIXME : there is not set_x function in pigment.... need to add
current_position = self.position
current_position = (value, current_position[1], current_position[2])
self.position = current_position
def y__get(self):
y = self.widget_class.get_position(self)[1]
relative_y = y - self._position_offset[1]
return relative_y
def y__set(self, value):
#FIXME : there is not set_x function in pigment.... need to add
current_position = self.position
current_position = (current_position[0], value, current_position[2])
self.position = current_position
def z__get(self):
z = self.widget_class.get_position(self)[2]
relative_z = z - self._position_offset[2]
return relative_z
def z__set(self, value):
#FIXME : there is not set_x function in pigment.... need to add
current_position = self.position
current_position = (current_position[0], current_position[1], value)
self.position = current_position
def position__set(self, relative_position):
x = self._position_offset[0]+relative_position[0]
y = self._position_offset[1]+relative_position[1]
z = self._position_offset[2]+relative_position[2]
if (x, y, z) != self._cached_abs_position:
self.widget_class.set_position(self, x, y, z)
self._cached_abs_position = (x, y, z)
def position_offset__get(self):
return self._position_offset
def position_offset__set(self, value):
previous_position = self.position
self._position_offset = value
self.position = previous_position
def opacity_factor_offset__set(self, factor):
self._opacity_factor = factor
self.opacity = self._opacity
def opacity_factor_offset__get(self):
return self._opacity_factor
def x_offset__get(self):
return self._position_offset[0]
def y_offset__get(self):
return self._position_offset[1]
def z_offset__get(self):
return self._position_offset[2]
def x_offset__set(self, value):
previous_position = self.position
new_position = (value, previous_position[1], previous_position[2])
self.position_offset = new_position
def y_offset__set(self, value):
previous_position = self.position
new_position = (previous_position[0], value, previous_position[2])
self.position_offset = new_position
def z_offset__set(self, value):
previous_position = self.position
new_position = (previous_position[0], previous_position[1], value)
self.position_offset = new_position
def opacity__get(self):
return self._opacity
def opacity__set(self, value):
#if value != self._opacity:
self._opacity = value
new_opacity = value * self._opacity_factor
self.widget_class.set_opacity(self, int(new_opacity))
def parent_visibility__get (self):
return self._parent_visibility
def parent_visibility__set (self, value):
self._parent_visibility = value
self.visible=self._visible
def visible__get (self):
return self.widget_class.is_visible(self)
def visible__set(self, value):
self._visible = value
if self._visible and self._parent_visibility:
self.widget_class.show(self)
else:
self.widget_class.hide(self)
position = property(position__get, position__set)
position_offset = property(position_offset__get, position_offset__set)
x_offset = property(x_offset__get, x_offset__set)
y_offset = property(y_offset__get, y_offset__set)
z_offset = property(z_offset__get, z_offset__set)
opacity = property(opacity__get, opacity__set)
visible = property(visible__get, visible__set)
parent_visibility = property(parent_visibility__get, parent_visibility__set)
x = property(x__get, x__set)
y = property(y__get, y__set)
z = property(z__get, z__set)
opacity_factor_offset = property(opacity_factor_offset__get,
opacity_factor_offset__set)
|