Changeset 695

Show
Ignore:
Timestamp:
09/08/03 21:39:33 (5 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/RBRapier/RBRapier/Tools/ViewBox.py

    r694 r695  
    44 
    55import Numeric 
     6from OpenGL import GL 
    67from Geometry import Curves 
    78 
     
    141142        return self.ViewBoxSize(self.GetSize(), aspectYX, largest) 
    142143 
    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 result 
    148  
    149     def MapPointTo0to1(self, pos): 
    150         pos, = self._ascoords(pos) 
    151         _box = self.GetBox() 
    152         return (pos-_box[0])/(_box[1]-_box[0]) 
    153  
    154144    def ZoomCenter(self, factor, center=(0., 0.), relative=True): 
    155145        center, = self._ascoords(center) 
     
    178168 
    179169    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) 
    181172 
    182173    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) 
    184176 
    185177    def ViewBoxPts(self, pos0, pos1, aspectYX=None, largest=True): 
    186178        pos0, pos1 = self._ascoords(pos0, pos1) 
    187179        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() 
    191206 
    192207    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    225240        self.viewbox1 = viewbox1 
    226241 
    227     def GetBlend(self, blend): 
     242    def GetBlend(self): 
    228243        return self.blend 
    229244 
     
    249264        else: return self 
    250265 
     266