Exemple #1
0
const QString &map::getTableText(bool colour)
{
    QStringList tableTextList;
    double min = getZValues()->at(0);
    double max = getZValues()->at(getZValues()->length() - 1);
    double diff = max - min;

    int yAxisWidth = 0;
    if (axes[1]) {
        yAxisWidth = axes[1]->getWidth();
    }
    int xAxisWidth = axes[0]->getWidth();
    int valWidth = getWidth();
    if (xAxisWidth > valWidth) {
        valWidth = xAxisWidth;
    }
    if (isDTC()) {
        valWidth = 2 * getWordSize() + 2;
    }

    QString mapText = "<b>Map    " + formatHex(getAddress(), false, true) + ": " + label;
    if (units.length() != 0) {
        mapText += " (" + units + ")";
    }
    mapText += "</b>";
    tableTextList << mapText;

    if (!axes[0]->isFixed()) {
        QString axis1Text = "<b>X-Axis " + formatHex(axes[0]->getAddress(), false, true) + ": " + axes[0]->getLabel();
        if (axes[0]->getUnits().length() != 0) {
            axis1Text += " (" + axes[0]->getUnits() + ")";
        }
        axis1Text += "</b>";
        tableTextList << axis1Text;
    }
    if (axes[1]) {
        QString axis2Text = "<b>Y-Axis " + formatHex(axes[1]->getAddress(), false, true) + ": " + axes[1]->getLabel();
        if (axes[0]->getUnits().length() != 0) {
            axis2Text += " (" + axes[1]->getUnits() + ")";
        }
        axis2Text += "</b>";
        tableTextList << axis2Text;
    }
    tableTextList << "";

    QString xLabels;
    if (yAxisWidth > 0) {
        xLabels.fill(QChar(' '), yAxisWidth + 1);
    }
    for (int i = 0; i < getXDim(); i++) {
        xLabels += QString("%1 ").arg(axisValue(0, i), valWidth, 'f', axes[0]->getDecimalPoints(), QChar(' '));
    }
    xLabels = "<span style=\"text-decoration:underline; font-weight:bold;\">" + xLabels + "</span>";
    tableTextList << xLabels;

    for (int y = 0; y < getYDim(); y++) {
        QString row;
        if (axes[1]) {
            int dp = axes[1]->getDecimalPoints();
            row = QString("%1 ").arg(axisValue(1, y), yAxisWidth, 'f', dp, QChar(' '));
            row = "<span style=\"font-weight:bold\">" + row + "</span>";
        }

        for (int x = 0; x < getXDim(); x++) {
            int dp = getDecimalPoints();
            if (isDTC()) {
                int val = getValue(x,y);
                row += "0x" + QString("%1 ").arg(val, valWidth-2, 16, QChar('0')).toUpper();
            }
            else {
                double val = getValue(x, y);
                if (colour) {
                    double temp = val - min;
                    if (diff == 0) {
                        temp = 1.0;
                    }
                    else {
                        temp /= diff;
                    }
                    int red = 255*temp;
                    int green = 255-255*temp;
                    row += "<span style=\"background-color: rgb(" + QString::number(red) + "," + QString::number(green) + ",0);\">";
                }
                else {
                    row += "<span>";
                }

                row += QString("%1 </span>").arg(val, valWidth, 'f', dp, QChar(' '));
            }
        }
        tableTextList << row;
    }

    tableText = "<pre style=\"font-size:16px; color:black\">" + tableTextList.join("\n") + "</pre>";
    return tableText;
}
Exemple #2
0
void Picture::render(Pixel* pix)
{
//while(true){
    // Get BasicObjects
    BasicObject* obj = readObject( OBJ_FILE );

    double z[3];
    getZValues( FOV_FILE, z );

    //WNACI
    Matrix* wnd = AffineTransforms::windowingTransform(pix->getWidth(),
        pix->getHeight());
    Matrix* aspct = AffineTransforms::aspectRatio(pix->getWidth(),
        pix->getHeight(), z[0]);    // Matrix for aspect ratio.

    Vertex* eye = new Vertex( 0,0,0 );
    Matrix* camera = buildCamera( CMRA_FILE, eye );
    Matrix* normal = AffineTransforms::perspective( z[1], z[2] );

    Matrix* tmp = aspct->multiply(camera);
    delete camera;
    delete aspct;

    Matrix* tmp2 = normal->multiply( tmp );
    delete tmp;
    delete normal;

    Matrix* wnca = wnd->multiply(tmp2);
    delete tmp2;
    delete wnd;
    // END WNACI

    // Scene creation
    Scene* scene = new Scene(wnca);

    // Set up lighting
    double shading[8];
    getShadingInfo( SHADE_FILE, shading );

    Light* light = new Light();
    Vertex* light_loc = new Vertex( shading[0], shading[1], shading[2] );
    Color* light_clr = new Color( LGHT_CLR );
    
    light->setLocation( light_loc );
    light->setColor( light_clr );
    
    Color* amb = new Color( AMB_CLR );
    
    // Add objects to the scene.
    InstanceObject* sp = buildInstanceObject( TRS_FILE, obj );
    sp->setShininess( shading[7] );

    scene->addNode( sp );

    scene->render( pix, light, eye, amb, shading[6] );

    delete eye;
    delete amb;
    delete light;
    delete scene;
//}
}