Show
Ignore:
Timestamp:
10/23/03 11:46:44 (5 years ago)
Author:
sholloway
Message:

*** empty log message ***

Files:

Legend:

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

    r703 r728  
    4444    projection = None 
    4545    animate = False 
     46    drawAnimation = False 
    4647 
    47     bgcolor = (1.,.7,.7
    48     fgcolor = (1.,.7,.7
     48    bgcolor = (1.,1.,1.,.2
     49    fgcolor = (1.,1.,1.,.8
    4950 
    5051    #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
     
    6970        self.modelview.GLSelect(context) 
    7071 
     72    def GLDeselect(self, context): 
     73        self.modelview.GLDeselect(context) 
     74        self.projection.GLDeselect(context) 
     75 
    7176    def GLExecute(self, context): 
    72         vb = self.viewboxes.get('animate') 
    73         if vb is not None: 
    74             vb, alpha = vb.viewbox1, .2*(1.-vb.GetBlend()) 
    75         else: 
    76             vb, alpha = self.viewboxes.get('draw'), 0.2 
     77        vb = None 
     78        if not vb and self.drawAnimation: 
     79            vbAnimation = self.viewboxes.get('animate') 
     80            if vbAnimation: 
     81                vb = vbAnimation.viewbox1 
     82                alpha = (1.-vbAnimation.GetBlend()) 
     83        if not vb: 
     84            vb = self.GetViewBox('draw') 
     85            alpha = 1. 
    7786 
    7887        if vb is not None: 
     
    8493                self._DrawViewBox(vb) 
    8594 
    86     def GLDeselect(self, context): 
    87         self.modelview.GLDeselect(context) 
    88         self.projection.GLDeselect(context) 
    89  
    90     def _DrawViewBox(self, drawVB, bgalpha=0.2): 
     95    def _DrawViewBox(self, drawVB, bgAlpha=1., fgAlpha=1.): 
    9196        if self.useblending: 
    92             GL.glColor4fv(self.bgcolor+(bgalpha,)) 
     97            r,g,b,a = self.bgcolor 
     98            GL.glColor4f(r,g,b,a*bgAlpha) 
    9399            drawVB.Draw(GL.GL_TRIANGLE_FAN) 
    94100 
    95         GL.glColor4fv(self.fgcolor+(0.8,)) 
     101        r,g,b,a = self.fgcolor 
     102        GL.glColor4f(r,g,b,a*fgAlpha) 
    96103        drawVB.Draw() 
    97104 
     
    116123        self.viewboxes['displayed'] = viewbox 
    117124 
     125    def AnimateToViewBox(self, viewbox, animationspan=0.5, key=None, drawAnimation=True): 
     126        viewbox0 = self.GetViewBox().copy() 
     127        self.viewboxes['animate'] = ViewBox.BlendedViewBox(viewbox0, viewbox) 
     128        self.SetViewBox(self.viewboxes['animate'], key) 
     129        self.animation = Animation.TimeBlend.fromSpan(animationspan) 
     130        self.drawAnimation = drawAnimation 
     131 
    118132    def GetViewBox(self, which=None): 
    119133        return self.viewboxes.get(which) 
     
    123137        except KeyError: 
    124138            return self.viewboxes[None] 
    125  
    126     def AnimateToViewBox(self, viewbox, animationspan=0.5, key=None): 
    127         viewbox0 = self.GetViewBox().copy() 
    128         self.viewboxes['animate'] = ViewBox.BlendedViewBox(viewbox0, viewbox) 
    129         self.SetViewBox(self.viewboxes['animate'], key) 
    130         self.animation = Animation.TimeBlend.fromSpan(animationspan) 
    131  
    132139    def SetViewBox(self, viewbox, key=None): 
    133140        if 'draw' in self.viewboxes: 
    134141            del self.viewboxes['draw'] 
    135         self.viewboxes[key] = viewbox 
     142        if viewbox is None: 
     143            try: del self.viewboxes[key] 
     144            except KeyError: pass 
     145        else: 
     146            self.viewboxes[key] = viewbox 
    136147 
    137148