Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
KScienceSaver Class Reference

#include <science.h>

Collaboration diagram for KScienceSaver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 KScienceSaver (WId id, bool setup=false, bool gP=false)
virtual ~KScienceSaver ()
void do_refresh (const QRect &rect)
void setMode (int mode)
void setMoveX (signed int s)
void setMoveY (signed int s)
void setMove (bool s)
void setSize (signed int s)
void setIntensity (signed int s)
void setSpeed (signed int s)
void setInverse (bool b)
void setGravity (bool b)
void setHideBG (bool b)
void myAssert (bool term, const char *sMsg)

Protected Slots

void slotTimeout ()

Protected Member Functions

void grabRootWindow ()
void grabPreviewWidget ()
void initWhirlLens ()
void initSphereLens ()
void initExponentialLens ()
void initWaveLens ()
void initCurvatureLens ()
void blackPixel (int x, int y)
void blackPixelUndo (int x, int y)
void applyLens8bpp (int xs, int ys, int xd, int yd, int w, int h)
void applyLens16bpp (int xs, int ys, int xd, int yd, int w, int h)
void applyLens24bpp (int xs, int ys, int xd, int yd, int w, int h)
void applyLens32bpp (int xs, int ys, int xd, int yd, int w, int h)

Protected Attributes

QTimer timer
bool moveOn
bool setup
bool grabPixmap
int mode
bool inverse [MAX_MODES]
bool gravity [MAX_MODES]
bool hideBG [MAX_MODES]
signed int size [MAX_MODES]
signed int moveX [MAX_MODES]
signed int moveY [MAX_MODES]
signed int speed [MAX_MODES]
signed int intensity [MAX_MODES]
int xcoord
int ycoord
double x
double y
double vx
double vy
signed int bpp
signed int side
int border
int radius
int diam
int origin
int imgnext
char blackRestore [4]
KScienceDatad

Private Member Functions

void readSettings ()
void initLens ()
void initialize ()
void releaseLens ()

Private Attributes

void(KScienceSaver::* applyLens )(int xs, int ys, int xd, int yd, int w, int h)

Detailed Description

Definition at line 38 of file science.h.


Constructor & Destructor Documentation

KScienceSaver::KScienceSaver ( WId  id,
bool  setup = false,
bool  gP = false 
)

Definition at line 141 of file science.cpp.

    : KScreenSaver( id )
{
    setAttribute( Qt::WA_NoSystemBackground );

    d = new KScienceData;
    d->gc = XCreateGC(QX11Info::display(), id, 0, 0);
    d->xRootWin = 0;
    d->buffer = 0;

    moveOn = true;
    grabPixmap = gP;
    setup = s;

    vx = vy = 0.0;
    readSettings();

    if( !grabPixmap )
    {
        grabRootWindow();
        initialize();
        do_refresh( QRect ( 0, 0, width(), height() ) );
    }

    connect( &timer, SIGNAL( timeout() ), SLOT( slotTimeout() ) );
    timer.start( SCI_MAX_SPEED - speed[mode] );
}

Here is the call graph for this function:

Definition at line 169 of file science.cpp.

{
    timer.stop();
    releaseLens();
    if ( d->xRootWin )
        XDestroyImage( d->xRootWin );
    XFreeGC(QX11Info::display(), d->gc );
    delete d;
}

Here is the call graph for this function:


Member Function Documentation

void KScienceSaver::applyLens16bpp ( int  xs,
int  ys,
int  xd,
int  yd,
int  w,
int  h 
) [protected]

Definition at line 792 of file science.cpp.

{
       T32bit *off;
       char *img1, *img2, *data;
       int ix, iy, datanext = d->buffer->bytes_per_line - (w << 1);

       img1 = d->xRootWin->data + (xd << 1) + yd*imgnext;
       data = d->buffer->data;
       for(iy = ys; iy < ys+h; iy++)
       {
              off = d->offset[iy] + xs;
              img2 = img1;
              for(ix = w; ix > 0; ix--) {
                     *data++ = img2++[*off];
                     *data++ = img2++[*off++];
              }
              img1 += imgnext;
              data += datanext;
       }
}

Here is the caller graph for this function:

void KScienceSaver::applyLens24bpp ( int  xs,
int  ys,
int  xd,
int  yd,
int  w,
int  h 
) [protected]

Definition at line 813 of file science.cpp.

{
       T32bit *off;
       char *img1, *img2, *data;
       signed int ix, iy, datanext = d->buffer->bytes_per_line - 3*w;

       img1 = d->xRootWin->data + 3*xd + yd*imgnext;
       data = d->buffer->data;
       for(iy = ys; iy < ys+h; iy++)
       {
              off = d->offset[iy] + xs;
              img2 = img1;
              for(ix = w; ix > 0; ix--) {
                     *data++ = img2++[*off];
                     *data++ = img2++[*off];
                     *data++ = img2++[*off++];
              }
              img1 += imgnext;
              data += datanext;
       }
}

Here is the caller graph for this function:

void KScienceSaver::applyLens32bpp ( int  xs,
int  ys,
int  xd,
int  yd,
int  w,
int  h 
) [protected]

Definition at line 835 of file science.cpp.

{
       T32bit *off;
       char *img1, *img2, *data;
       signed int ix, iy, datanext = d->buffer->bytes_per_line - (w << 2);

       img1 = d->xRootWin->data + (xd << 2) + yd*imgnext;
       data = d->buffer->data;
       for(iy = ys; iy < ys+h; iy++)
       {
              off = d->offset[iy] + xs;
              img2 = img1;
              for(ix = w; ix > 0; ix--) {
                     *data++ = img2++[*off];
                     *data++ = img2++[*off];
                     *data++ = img2++[*off];
                     *data++ = img2++[*off++];
              }
              img1 += imgnext;
              data += datanext;
       }
}

Here is the caller graph for this function:

void KScienceSaver::applyLens8bpp ( int  xs,
int  ys,
int  xd,
int  yd,
int  w,
int  h 
) [protected]

Definition at line 772 of file science.cpp.

{
       T32bit *off;
       char *img1, *img2, *data;
       signed int ix, iy, datanext = d->buffer->bytes_per_line - w;

       img1 = d->xRootWin->data + xd + yd*imgnext;
       data = d->buffer->data;
       for(iy = ys; iy < ys+h; iy++)
       {
              off = d->offset[iy] + xs;
              img2 = img1;
              for(ix = w; ix > 0; ix--)
                     *data++ = img2++[*off++];
              img1 += imgnext;
              data += datanext;
       }

}

Here is the caller graph for this function:

void KScienceSaver::blackPixel ( int  x,
int  y 
) [protected]

Definition at line 752 of file science.cpp.

{
       unsigned char black = (char) BlackPixel( QX11Info::display(), QX11Info::appScreen() );
       unsigned int adr = x*bpp + y*imgnext;

       for(int i=0; i<bpp; i++) {
              blackRestore[i] = d->xRootWin->data[adr];
              d->xRootWin->data[adr++] = black;
       }
}

Here is the caller graph for this function:

void KScienceSaver::blackPixelUndo ( int  x,
int  y 
) [protected]

Definition at line 763 of file science.cpp.

{
       unsigned int adr = x*bpp + y*imgnext;
       for(int i=0; i<bpp; i++)
              d->xRootWin->data[adr++] = blackRestore[i];
}

Here is the caller graph for this function:

void KScienceSaver::do_refresh ( const QRect &  rect)

Definition at line 599 of file science.cpp.

{
       if( grabPixmap )
              return;
        QRect rect(origRect.normalized());

       if( hideBG[mode] )
       {
              XSetWindowBackground( QX11Info::display(), winId(), QColormap::instance().pixel(Qt::black) );
              XClearArea( QX11Info::display(), winId(), rect.left(), rect.top(),
                            rect.width(), rect.height(), false );
       }
       else
       {
              myAssert( d->xRootWin != 0, "root window not grabbed" );
              XPutImage( QX11Info::display(), winId(), d->gc, d->xRootWin,
                         rect.left(), rect.top(),
                           rect.left(), rect.top(),
                           rect.width(), rect.height() );
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::grabPreviewWidget ( ) [protected]

Definition at line 737 of file science.cpp.

{
       myAssert( QWidget::find(winId())->isActiveWindow(), "cannot grab preview widget: dialog not active()" );

       if( d->xRootWin )
              XDestroyImage( d->xRootWin );

       Display *dsp = QX11Info::display();
       d->xRootWin = XGetImage( dsp, winId(), 0, 0, width(), height(), AllPlanes, ZPixmap);
       myAssert( d->xRootWin, "unable to grab preview window\n" );

       imgnext = d->xRootWin->bytes_per_line;
       bpp = ( d->xRootWin->bits_per_pixel ) >> 3;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::grabRootWindow ( ) [protected]

Definition at line 720 of file science.cpp.

{
       Display *dsp = QX11Info::display();
       Window rootwin = RootWindow( dsp, QX11Info::appScreen() );

       // grab contents of root window
       if( d->xRootWin )
              XDestroyImage( d->xRootWin );

       d->xRootWin = XGetImage( dsp, rootwin, 0, 0, width(),
                             height(), AllPlanes, ZPixmap);
       myAssert( d->xRootWin, "unable to grab root window\n" );

       imgnext = d->xRootWin->bytes_per_line;
       bpp = ( d->xRootWin->bits_per_pixel ) >> 3;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::initCurvatureLens ( ) [protected]

Definition at line 334 of file science.cpp.

{
       double dx, dy, r, f, intens;
       T32bit *off;
       T32bit xo, yo;

       intens = (double) radius*intensity[mode] / 20.0;
       if( inverse[mode] ) intens = -intens;

       for(int y = side-1; y >= 0; y--)
       {
              dy = y - origin;
              off = d->offset[y] = (T32bit *) malloc(sizeof(T32bit) * side);
              myAssert( off != 0, "too few memory" );
              for(int x = side-1; x >= 0; x--)
              {
                  dx = x - origin;
                  r = sqrt( dx*dx + dy*dy );

                  if( r < radius )
                  {
                         if( r == 0.0 )
                                f = 0.0;
                         else
                                f = (r - intens * sin(M_PI * r/(double)radius)) / r;
                         xo = (T32bit) ( origin + f*dx - x );
                         yo = (T32bit) ( origin + f*dy - y );
                         off[x] = xo*bpp + yo*imgnext;
                  }
                  else
                     if( hideBG[mode] )
                            off[x] = (border-y)*imgnext + (border-x)*bpp;
                     else
                            off[x] = 0;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::initExponentialLens ( ) [protected]

Definition at line 291 of file science.cpp.

{
       double dx, dy, r, rnew, f, intens;
       T32bit *off;
       T32bit xo, yo;

       if( mode == MODE_EXPONENTIAL )
              intens = - (0.1 + 0.8 * double( intensity[mode] + 2) / 10.0);
       else
              intens = 0.9 - 0.8 * double( intensity[mode] ) / 10.0;

       for(int y = side-1; y >= 0; y--)
       {
              dy = y - origin;
              off = d->offset[y] = (T32bit *) malloc(sizeof(T32bit) * side);
              myAssert( off != 0, "too few memory" );
              for(int x = side-1; x >= 0; x--)
              {
                  dx = x - origin;
                  r = sqrt( dx*dx + dy*dy );

                  if( r < radius )
                  {
                         if( r == 0.0 )
                                f = 0.0;
                         else
                         {
                                rnew = radius*(pow(r, intens) /  pow(radius, intens));
                                f = double ((int)rnew % radius) / r;
                         }
                         xo = (T32bit) ( origin + f*dx - x );
                         yo = (T32bit) ( origin + f*dy - y );
                         off[x] = xo*bpp + yo*imgnext;
                  }
                  else
                     if( hideBG[mode] )
                            off[x] = (border-y)*imgnext + (border-x)*bpp;
                     else
                            off[x] = 0;
              }
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::initialize ( ) [private]

Definition at line 188 of file science.cpp.

{
       KRandomSequence rnd;
       initLens();
       signed int ws = (signed int) (width() -  diam);
       signed int hs = (signed int) (height() - diam);

       x = (ws > 0) ? (rnd.getDouble() * ws ) : 0.0;
       y = (hs > 0) ? (rnd.getDouble() * hs ) : 0.0;

       xcoord = (int) x;
       ycoord = (int) y;

       switch( bpp ) {
              case 1 : applyLens = &KScienceSaver::applyLens8bpp;  break;
              case 2 : applyLens = &KScienceSaver::applyLens16bpp; break;
              case 3 : applyLens = &KScienceSaver::applyLens24bpp; break;
              case 4 : applyLens = &KScienceSaver::applyLens32bpp; break;
              default: myAssert( false, "unsupported colordepth "\
                                 "(only 8, 16, 24, 32 bpp supported)" );
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::initLens ( ) [private]

Definition at line 413 of file science.cpp.

{
       int min = (width() < height()) ? width() : height();
       border = 1 + SCI_MAX_MOVE;

       radius = (size[mode] * min) / 100;
       if( radius<<1 == min ) radius--;
       diam = radius << 1;
       myAssert( diam < min, "assertion violated: diam < min" );
       origin = radius + border;
       side  = origin << 1;

       d->buffer = XSubImage( d->xRootWin, 0, 0, side, side );
        myAssert( d->buffer != 0, "cannot allocate pixmap" );

       d->offset = (T32bit **) malloc( sizeof(T32bit *) * side );
       myAssert( d->offset != 0, "too few memory" );

       switch( mode ) {
              case MODE_WHIRL:     initWhirlLens();  break;
              case MODE_SPHERE:    initSphereLens(); break;
              case MODE_EXPONENTIAL:
              case MODE_CONTRACTION:      initExponentialLens(); break;
              case MODE_CURVATURE:    initCurvatureLens(); break;
              case MODE_WAVE:      initWaveLens(); break;
              default: myAssert( false, "internal error (wrong mode in initLens() )" );
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::initSphereLens ( ) [protected]

Definition at line 251 of file science.cpp.

{
       double dx, dy, r, xr, yr, phi, intens;
       T32bit *off;
       T32bit xo, yo;

       intens = 1.0 - double( intensity[mode] ) / 20.0;

       if( inverse[mode] )
              intens = -intens;

       for(int y = side-1; y >= 0; y--)
       {
              dy = y - origin;
              off = d->offset[y] = (T32bit *) malloc(sizeof(T32bit) * side);
              myAssert( off != 0, "too few memory" );
              for(int x = side-1; x >= 0; x--)
              {
                  dx = x - origin;
                  r = sqrt( dx*dx + dy*dy );

              if( r < radius )
              {
                     xr = (double) radius*cos(asin(dy/radius));
                     yr = (double) radius*cos(asin(dx/radius));
                     phi = (xr != 0.0) ? asin(dx/xr) : 0.0;
                     xo = (T32bit) (origin + intens*2.0*phi*xr / M_PI - x);
                     phi = (yr != 0.0) ? asin(dy/yr) : 0.0;
                     yo = (T32bit) (origin + intens*2.0*phi*yr / M_PI - y);
                     off[x] = xo*bpp + yo*imgnext;
              }
              else
                     if( hideBG[mode] )
                            off[x] = (border-y)*imgnext + (border-x)*bpp;
                     else
                            off[x] = 0;
              }
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::initWaveLens ( ) [protected]

Definition at line 372 of file science.cpp.

{
       double dx, dy, r, rnew, f, intens, k;
       T32bit *off;
       T32bit xo, yo;

       intens = (double) intensity[mode] + 1.0;
       k = (intensity[mode] % 2) ? -12.0 : 12.0;

       for(int y = side-1; y >= 0; y--)
       {
              dy = y - origin;
              off = d->offset[y] = (T32bit *) malloc(sizeof(T32bit) * side);
              myAssert( off != 0, "too few memory" );
              for(int x = side-1; x >= 0; x--)
              {
                  dx = x - origin;
                  r = sqrt( dx*dx + dy*dy );

                  if( r < radius )
                  {
                         if( r == 0.0 )
                                f = 0.0;
                         else
                         {
                                rnew = r - k * sin( M_PI * intens * r/(double)radius);
                                f = double ((int)rnew % radius) / r;
                         }
                         xo = (T32bit) ( origin + f*dx - x );
                         yo = (T32bit) ( origin + f*dy - y );
                         off[x] = xo*bpp + yo*imgnext;
                  }
                  else
                     if( hideBG[mode] )
                            off[x] = (border-y)*imgnext + (border-x)*bpp;
                     else
                            off[x] = 0;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::initWhirlLens ( ) [protected]

Definition at line 211 of file science.cpp.

{
       double dx, dy, r, phi, intens;
       T32bit *off;
       T32bit xo, yo;

       intens = double( intensity[mode] + 1) / 5.0;
       if( inverse[mode] )
              intens = -intens;

       for(int y = side-1; y >= 0; y--)
       {
              dy = y - origin;
              off = d->offset[y] = (T32bit *) malloc(sizeof(T32bit) * side);
              myAssert( off != 0, "too few memory" );
              for(int x = side-1; x >= 0; x--)
              {
                  dx = x - origin;
                  r = sqrt( dx*dx + dy*dy );

                  if( r < radius )
                  {
                         if ( dx == 0.0 )
                                phi = (dy > 0.0) ? M_PI_2 :-(M_PI_2);
                         else
                                phi = atan2( dy, dx );
                         phi +=  intens * ( radius - r ) / ( r+7.0 );
                         xo = (T32bit) ( origin + r*cos( phi ) - x );
                         yo = (T32bit) ( origin + r*sin( phi ) - y );
                         off[x] = xo*bpp + yo*imgnext;
                  }
                  else
                     if( hideBG[mode] )
                            off[x] = (border-y)*imgnext + (border-x)*bpp;
                     else
                            off[x] = 0;
              }
        }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::myAssert ( bool  term,
const char *  sMsg 
)

Definition at line 179 of file science.cpp.

{
       if( !term ) {
              fprintf(stderr, "Error in KScreensaver - mode Science: %s\n", eMsg);
              releaseLens();
              exit(-1);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::readSettings ( ) [private]

Definition at line 574 of file science.cpp.

{
    KConfigGroup group = KGlobal::config()->group("Settings");
        QString sMode;

       mode = group.readEntry( "ModeNr", SCI_DEFAULT_MODE );

       for(int i=0; i < MAX_MODES; i++)
       {
              sMode.setNum( i );
              group = KGlobal::config()->group( "Mode" + sMode );
              moveX[i]     = group.readEntry(  "MoveX",     SCI_DEFAULT_MOVEX);
              moveY[i]     = group.readEntry(  "MoveY",     SCI_DEFAULT_MOVEY);
              size[i]      = group.readEntry(  "Size",      SCI_DEFAULT_SIZE);
              speed[i]     = group.readEntry(  "Speed",     SCI_DEFAULT_SPEED);
              intensity[i] = group.readEntry(  "Intensity", SCI_DEFAULT_INTENSITY);
              inverse[i]   = group.readEntry( "Inverse",   SCI_DEFAULT_INVERSE);
              gravity[i]   = group.readEntry( "Gravity",   SCI_DEFAULT_GRAVITY);
              hideBG[i]    = group.readEntry( "HideBG",    SCI_DEFAULT_HIDE);
       }

       vx = copysign( moveX[mode], vx );
       vy = copysign( moveY[mode], vy );
}

Here is the caller graph for this function:

void KScienceSaver::releaseLens ( ) [private]

Definition at line 442 of file science.cpp.

{
       if( d->offset != 0 ) {
              for(int i=0; i<side; i++)
                     if( d->offset[i] != 0 ) free( d->offset[i] );
              free( d->offset );
              d->offset = 0;
       }
       if( d->buffer != 0 ) {
              XDestroyImage( d->buffer );
              d->buffer = 0;
       }
}

Here is the caller graph for this function:

void KScienceSaver::setGravity ( bool  b)

Definition at line 550 of file science.cpp.

{
       timer.stop();

       releaseLens();
       gravity[mode] = b;
       vy = copysign( moveY[mode], vy );
       initLens();

       timer.start( SCI_MAX_SPEED - speed[mode]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::setHideBG ( bool  b)

Definition at line 562 of file science.cpp.

{
       timer.stop();

       releaseLens();
       hideBG[mode] = b;
       initLens();
       do_refresh( QRect( 0, 0, width(), height() ) );

       timer.start( SCI_MAX_SPEED - speed[mode]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::setIntensity ( signed int  s)

Definition at line 528 of file science.cpp.

{
       timer.stop();

       releaseLens();
       intensity[mode] = i;
       initLens();

       timer.start( SCI_MAX_SPEED - speed[mode]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::setInverse ( bool  b)

Definition at line 539 of file science.cpp.

{
       timer.stop();

       releaseLens();
       inverse[mode] = b;
       initLens();

       timer.start( SCI_MAX_SPEED - speed[mode]);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::setMode ( int  mode)

Definition at line 456 of file science.cpp.

{
       timer.stop();

       releaseLens();
       int old = mode;
       mode = m;
       vx = copysign( moveX[mode], vx );
       vy = copysign( moveY[mode], vy );
       int dm = diam;
       initLens();
       if( hideBG[old] ^ hideBG[m] )
              do_refresh( QRect( 0, 0, width(), height() ) );
       else
              if( diam < dm )
              {
                     do_refresh( QRect( (int) x+diam, (int) y,      dm-diam, diam    ) );
                     do_refresh( QRect( (int) x,      (int) y+diam, dm,      dm-diam ) );
              }

       timer.start( SCI_MAX_SPEED - speed[mode] );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::setMove ( bool  s)

Definition at line 499 of file science.cpp.

{
       moveOn = s;
}

Here is the caller graph for this function:

void KScienceSaver::setMoveX ( signed int  s)

Definition at line 479 of file science.cpp.

{
       timer.stop();

       moveX[mode] = s;
       vx = copysign( moveX[mode], vx );

       timer.start( SCI_MAX_SPEED - speed[mode] );
}

Here is the caller graph for this function:

void KScienceSaver::setMoveY ( signed int  s)

Definition at line 489 of file science.cpp.

{
       timer.stop();

       moveY[mode] = s;
       vy = copysign( moveY[mode], vy );

       timer.start( SCI_MAX_SPEED - speed[mode] );
}

Here is the caller graph for this function:

void KScienceSaver::setSize ( signed int  s)

Definition at line 504 of file science.cpp.

{
       timer.stop();

       releaseLens();
       int dm = diam;
       size[mode] = s;
       initLens();
       if( diam < dm )
       {
              do_refresh( QRect( (int) x+diam, (int) y,      dm-diam, diam    ) );
              do_refresh( QRect( (int) x,      (int) y+diam, dm,      dm-diam ) );
       }

       timer.start( SCI_MAX_SPEED - speed[mode] );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void KScienceSaver::setSpeed ( signed int  s)

Definition at line 521 of file science.cpp.

{
       speed[mode] = s;

       timer.start( SCI_MAX_SPEED - speed[mode] );
}

Here is the caller graph for this function:

void KScienceSaver::slotTimeout ( ) [protected, slot]

Definition at line 621 of file science.cpp.

{
       if( grabPixmap ) {
              if( !QWidget::find(winId())->isActiveWindow() )
                     return;
              grabPreviewWidget();
              grabPixmap = false;
              initialize();
              if( hideBG[mode] )
                     do_refresh( QRect ( 0, 0, width(), height() ) );
       }

       signed int oldx = xcoord, oldy = ycoord;

       if( gravity[mode] ) {
              double h = double(y+1.0) / double(height()-diam);
              if( h > 1.0 ) h = 1.0;
              vy = sqrt( h ) * ( (vy > 0.0) ? moveY[mode] : -moveY[mode] );
       }
       myAssert( abs((int)rint(vy)) <= border, "assertion violated: vy <= border" );

       if( moveOn )
       {
              x += vx;
              y += vy;
       }

       if( x <= 0.0 ) {
              vx = -vx;
              x = 0.0;
       }
       if( int(x) + diam >= width()) {
              vx = -vx;
              myAssert( width()-diam > 0, "assertion violated: width-diam > 0" );
              x = (double) (width() - diam - 1);
       }
       if( y <= 0.0 ) {
              vy = -vy;
              y = 0.0;
       }
       if( int(y) + diam >= height() ) {
              vy = -vy;
              myAssert( height() - diam > 0, "assertion violated: height-diam > 0" );
              y = (double) (height() - diam - 1);
       }
       
       xcoord = (int) x ;
       ycoord = (int) y ;
       signed int dx = (signed int) xcoord - oldx;
       signed int dy = (signed int) ycoord - oldy;
       signed int xs, ys, xd, yd, w, h;

       if( dx > 0 ) {
              w = diam+dx;
              xd = oldx;
              xs = border-dx;
              if( dy > 0 ) {
                     h = diam+dy;
                     yd = oldy;
                     ys = border-dy;
              }
              else {
                     h = diam-dy;
                     yd = ycoord;
                     ys = border;
              }
       }
       else {
              w = diam-dx;
              xd = xcoord;
              xs = border;
              if( dy > 0 ) {
                     h = diam+dy;
                     yd = oldy;
                     ys = border-dy;
              } else {
                     h = diam-dy;
                     yd = ycoord;
                     ys = border;
              }
       }

       if(  xd + w >= width()  ) w = width()  - xd - 1;
       if(  yd + h >= height() ) h = height() - yd - 1;

//printf("%d: (dx: %3d, dy: %3d), diam: %3d, (xc: %3d, yc: %3d), (xs: %3d, ys: %3d), (xd: %3d, yd: %3d), (w: %3d, h: %3d)\n", mode, dx, dy, diam, xcoord, ycoord, xs, ys, xd, yd, w, h);
       myAssert( dx <= border && dy <=border, "assertion violated: dx or dy <= border");
       myAssert( xcoord >= 0 && ycoord >= 0, "assertion violated: xcoord, ycoord >= 0 ");
       myAssert( xd+w < width(), "assertion violated: xd+w < width" );
       myAssert( yd+h < height(), "assertion violated: yd+h < height" );

       if( hideBG[mode] )
              blackPixel( xcoord, ycoord );
       (this->*applyLens)(xs, ys, xd, yd, w, h);
       XPutImage( QX11Info::display(), winId(), d->gc, d->buffer, 0, 0, xd, yd, w, h );
       if( hideBG[mode] )
              blackPixelUndo( xcoord, ycoord );
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

void(KScienceSaver::* KScienceSaver::applyLens)(int xs, int ys, int xd, int yd, int w, int h) [private]

Definition at line 64 of file science.h.

char KScienceSaver::blackRestore[4] [protected]

Definition at line 101 of file science.h.

int KScienceSaver::border [protected]

Definition at line 99 of file science.h.

signed int KScienceSaver::bpp [protected]

Definition at line 98 of file science.h.

Definition at line 102 of file science.h.

int KScienceSaver::diam [protected]

Definition at line 99 of file science.h.

bool KScienceSaver::grabPixmap [protected]

Definition at line 86 of file science.h.

bool KScienceSaver::gravity[MAX_MODES] [protected]

Definition at line 89 of file science.h.

bool KScienceSaver::hideBG[MAX_MODES] [protected]

Definition at line 90 of file science.h.

int KScienceSaver::imgnext [protected]

Definition at line 100 of file science.h.

signed int KScienceSaver::intensity[MAX_MODES] [protected]

Definition at line 95 of file science.h.

bool KScienceSaver::inverse[MAX_MODES] [protected]

Definition at line 88 of file science.h.

int KScienceSaver::mode [protected]

Definition at line 87 of file science.h.

bool KScienceSaver::moveOn [protected]

Definition at line 84 of file science.h.

signed int KScienceSaver::moveX[MAX_MODES] [protected]

Definition at line 92 of file science.h.

signed int KScienceSaver::moveY[MAX_MODES] [protected]

Definition at line 93 of file science.h.

int KScienceSaver::origin [protected]

Definition at line 99 of file science.h.

int KScienceSaver::radius [protected]

Definition at line 99 of file science.h.

bool KScienceSaver::setup [protected]

Definition at line 85 of file science.h.

signed int KScienceSaver::side [protected]

Definition at line 98 of file science.h.

signed int KScienceSaver::size[MAX_MODES] [protected]

Definition at line 91 of file science.h.

signed int KScienceSaver::speed[MAX_MODES] [protected]

Definition at line 94 of file science.h.

QTimer KScienceSaver::timer [protected]

Definition at line 83 of file science.h.

double KScienceSaver::vx [protected]

Definition at line 97 of file science.h.

double KScienceSaver::vy [protected]

Definition at line 97 of file science.h.

double KScienceSaver::x [protected]

Definition at line 97 of file science.h.

int KScienceSaver::xcoord [protected]

Definition at line 96 of file science.h.

double KScienceSaver::y [protected]

Definition at line 97 of file science.h.

int KScienceSaver::ycoord [protected]

Definition at line 96 of file science.h.


The documentation for this class was generated from the following files: