Back to index

kdeartwork  4.3.2
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
KLorenzSaver Class Reference

#include <lorenz.h>

Collaboration diagram for KLorenzSaver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 KLorenzSaver (WId id)
virtual ~KLorenzSaver ()
void setSpeed (int num)
void setEpoch (int num)
void setCRate (int num)
void setZRot (int num)
void setYRot (int num)
void setXRot (int num)
void updateMatrix ()
void newEpoch ()

Protected Member Functions

void paintEvent (QPaintEvent *)

Protected Attributes

QTimer timer

Private Member Functions

void readSettings ()

Private Attributes

double x
double y
double z
double t
double speed
double epoch
double zrot
double yrot
double xrot
double crate
int e
Matrix3Dmat

Detailed Description

Definition at line 22 of file lorenz.h.


Constructor & Destructor Documentation

Definition at line 483 of file lorenz.cpp.

                                   : KScreenSaver( id )
{
    readSettings();

    // Create a transform matrix with the parameters
    mat = new Matrix3D();
    updateMatrix();

    {
        QPalette palette;
        palette.setColor( backgroundRole(), Qt::black );
        setPalette( palette );
       setAutoFillBackground(true);
    }
    newEpoch();

    timer.start( 10 );
    connect( &timer, SIGNAL( timeout() ), SLOT( update() ) );
    show();
}

Here is the call graph for this function:

Definition at line 504 of file lorenz.cpp.

{
    delete mat;
    mat=0;
    timer.stop();
}

Member Function Documentation

Definition at line 569 of file lorenz.cpp.

{
    // Start at a random position, somewhere around the mean
    x = 0.95-25.0+50.0*KRandom::random() / (RAND_MAX+1.0);
    y = 0.97-25.0+50.0*KRandom::random() / (RAND_MAX+1.0);
    z = 23.6-25.0+50.0*KRandom::random() / (RAND_MAX+1.0);
    // start at some random 'time' as well to have different colors
    t = 10000.0*KRandom::random() / (RAND_MAX+1.0);
    e=0; // reset epoch counter
}

Here is the caller graph for this function:

void KLorenzSaver::paintEvent ( QPaintEvent *  ) [protected]

Definition at line 590 of file lorenz.cpp.

{
    setAttribute( Qt::WA_NoSystemBackground ); // Only after initial clear

    double kx, ky, kz, dx, dy, dz;
    const double h = 0.0001;
    const double tqh = h * 3.0 / 4.0;
    QPainter p(this);

    if ( !e )
        p.fillRect(rect(), p.background());

    QColormap cmap = QColormap::instance();
    for (int i=0; i<speed; i++) {
        // Runge-Kutta formula
        lorenz(x,y,z,dx,dy,dz);
        lorenz(x + tqh*dx, y + tqh*dy, z + tqh*dz, kx, ky, kz);
        x += h*(dx/3.0+2*kx/3.0);
        y += h*(dy/3.0+2*ky/3.0);
        z += h*(dz/3.0+2*kz/3.0);
        // Apply transform
        mat->transform(x,y,z,kx,ky,kz);
        // Choose a color
        p.setPen(
            cmap.pixel(QColor((int)(sin(t*crate/pi)*127+128),
                              (int)(sin(t*crate/(pi-1))*127+128),
                              (int)(sin(t*crate/(pi-2))*127+128))) );
        // Draw a point
        p.drawPoint( (int)(kx*width()*1.5/kz)+(int)(width()/2),
                     (int)(ky*height()*1.5/kz)+(int)(height()/2));
        t+=h;
    }
    if (++e>=epoch)
        newEpoch();
}

Here is the call graph for this function:

void KLorenzSaver::readSettings ( ) [private]

Definition at line 512 of file lorenz.cpp.

{
    KConfigGroup config(KGlobal::config(), "Settings");

    speed = config.readEntry( "Speed", DEFSPEED );
    epoch = config.readEntry( "Epoch", DEFEPOCH );
    zrot = config.readEntry( "ZRot", DEFZROT );
    yrot = config.readEntry( "YRot", DEFZROT );
    xrot = config.readEntry( "XRot", DEFZROT );

    int crate_num = config.readEntry( "Color Rate", DEFCOLOR );
    crate = (double)crate_num / (double)MAXCOLOR;
}

Here is the caller graph for this function:

void KLorenzSaver::setCRate ( int  num)

Definition at line 551 of file lorenz.cpp.

{
    crate = (double)num / (double)MAXCOLOR;
}

Here is the caller graph for this function:

void KLorenzSaver::setEpoch ( int  num)

Definition at line 531 of file lorenz.cpp.

{
    epoch = num;
}

Here is the caller graph for this function:

void KLorenzSaver::setSpeed ( int  num)

Definition at line 526 of file lorenz.cpp.

{
    speed = num;
}

Here is the caller graph for this function:

void KLorenzSaver::setXRot ( int  num)

Definition at line 546 of file lorenz.cpp.

{
    xrot = num;
}

Here is the caller graph for this function:

void KLorenzSaver::setYRot ( int  num)

Definition at line 541 of file lorenz.cpp.

{
    yrot = num;
}

Here is the caller graph for this function:

void KLorenzSaver::setZRot ( int  num)

Definition at line 536 of file lorenz.cpp.

{
    zrot = num;
}

Here is the caller graph for this function:

Definition at line 556 of file lorenz.cpp.

{
    // reset matrix
    mat->unit();
    // Remove the mean before the rotations...
    mat->translate(-0.95413, -0.96740, -23.60065);
    mat->rotZ(zrot);
    mat->rotY(yrot);
    mat->rotX(xrot);
    mat->translate(0, 0, 100);
    mat->proj(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

double KLorenzSaver::crate [private]

Definition at line 48 of file lorenz.h.

int KLorenzSaver::e [private]

Definition at line 49 of file lorenz.h.

double KLorenzSaver::epoch [private]

Definition at line 48 of file lorenz.h.

Definition at line 50 of file lorenz.h.

double KLorenzSaver::speed [private]

Definition at line 48 of file lorenz.h.

double KLorenzSaver::t [private]

Definition at line 47 of file lorenz.h.

QTimer KLorenzSaver::timer [protected]

Definition at line 41 of file lorenz.h.

double KLorenzSaver::x [private]

Definition at line 47 of file lorenz.h.

double KLorenzSaver::xrot [private]

Definition at line 48 of file lorenz.h.

double KLorenzSaver::y [private]

Definition at line 47 of file lorenz.h.

double KLorenzSaver::yrot [private]

Definition at line 48 of file lorenz.h.

double KLorenzSaver::z [private]

Definition at line 47 of file lorenz.h.

double KLorenzSaver::zrot [private]

Definition at line 48 of file lorenz.h.


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