Changeset 695
- Timestamp:
- 09/08/03 21:39:33 (5 years ago)
- Files:
-
- trunk/RBRapier/RBRapier/Tools/ViewBox.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/RBRapier/RBRapier/Tools/ViewBox.py
r694 r695 4 4 5 5 import Numeric 6 from OpenGL import GL 6 7 from Geometry import Curves 7 8 … … 141 142 return self.ViewBoxSize(self.GetSize(), aspectYX, largest) 142 143 143 def MapPointFrom0to1(self, posIn0to1):144 blend, = self._ascoords(posIn0to1)145 _box = self.GetBox()146 result = (1-blend)*_box[0]+blend*_box[1]147 return result148 149 def MapPointTo0to1(self, pos):150 pos, = self._ascoords(pos)151 _box = self.GetBox()152 return (pos-_box[0])/(_box[1]-_box[0])153 154 144 def ZoomCenter(self, factor, center=(0., 0.), relative=True): 155 145 center, = self._ascoords(center) … … 178 168 179 169 def ViewBoxSize(self, dim, aspectYX=None, largest=True): 180 return self.SetCenterAndSize(self.GetCenter(), self._GetViewBoxSize(dim, aspectYX, largest)) 170 size = self._GetViewBoxSize(dim, aspectYX, largest) 171 return self.SetCenterAndSize(self.GetCenter(), size) 181 172 182 173 def ViewBox(self, pos, dim, aspectYX=None, largest=True): 183 return self.SetCenterAndSize(pos, self._GetViewBoxSize(dim, aspectYX, largest)) 174 size = self._GetViewBoxSize(dim, aspectYX, largest) 175 return self.SetCenterAndSize(pos, size) 184 176 185 177 def ViewBoxPts(self, pos0, pos1, aspectYX=None, largest=True): 186 178 pos0, pos1 = self._ascoords(pos0, pos1) 187 179 pos0, pos1 = Numeric.minimum(pos0, pos1), Numeric.maximum(pos0, pos1) 188 dim = abs(pos1-pos0) 189 center = 0.5*(pos0+pos1) 190 return self.SetCenterAndSize(center, self._GetViewBoxSize(dim, aspectYX, largest)) 180 size = self._GetViewBoxSize(abs(pos1-pos0), aspectYX, largest) 181 return self.SetCenterAndSize(0.5*(pos0+pos1), size) 182 183 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 184 185 def MapPointFrom0to1(self, posIn0to1): 186 blend, = self._ascoords(posIn0to1) 187 _box = self.GetBox() 188 result = (1-blend)*_box[0]+blend*_box[1] 189 return result 190 191 def MapPointTo0to1(self, pos): 192 pos, = self._ascoords(pos) 193 _box = self.GetBox() 194 return (pos-_box[0])/(_box[1]-_box[0]) 195 196 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 197 198 def Draw(self, style=GL.GL_LINE_LOOP): 199 (x0, y0), (x1, y1) = self.GetBox() 200 GL.glBegin(style) 201 GL.glVertex2f(x0,y0) 202 GL.glVertex2f(x0,y1) 203 GL.glVertex2f(x1,y1) 204 GL.glVertex2f(x1,y0) 205 GL.glEnd() 191 206 192 207 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ … … 225 240 self.viewbox1 = viewbox1 226 241 227 def GetBlend(self , blend):242 def GetBlend(self): 228 243 return self.blend 229 244 … … 249 264 else: return self 250 265 266
