Example #1
0
void Connector::setup(QLabel *ql, QLineEdit *le, QPushButton *mBtn, QPushButton *dBtn, Canvas *c) {
    status = ql;
    ipBox = le;
    modeBtn = mBtn;
    delayBtn = dBtn;
    canvas = c;
    connect(this, SIGNAL(addY()), canvas, SLOT(addY()));
    connect(this, SIGNAL(subY()), canvas, SLOT(subY()));
    connect(this, SIGNAL(addX()), canvas, SLOT(addX()));
    connect(this, SIGNAL(subX()), canvas, SLOT(subX()));
    connect(this, SIGNAL(paint()), canvas, SLOT(paintClicked()));
}
Example #2
0
void Connector::timesUp()
{
    QPair<int, int> next = cmdQ.dequeue();
    switch(next.first)
    {
    case CW:
        axis_number = next.second;
        canvas->rotateCW();
        break;
    case CCW:
        axis_number = next.second;
        canvas->rotateCCW();
        break;
    case ADDY:
        emit addY();
        break;
    case SUBY:
        emit subY();
        break;
    case ADDX:
        emit addX();
        break;
    case SUBX:
        emit subX();
        break;
    case PAINT:
        emit paint();
        break;
    default:
        qDebug() << "RECEIVE ERROR:" << next.first;
        break;
}
}
Example #3
0
void Connector::readCommands() {
    if (client)
    {
        qDebug() << "READ - NOT SERVER";
        return;
    }
    char buf[2] = {0};
    serverSock->read(buf, serverSock->bytesAvailable());
    int command = int(buf[0]);
    int axis = int(buf[1]);

    if (delay)
    {
        cmdQ.enqueue(qMakePair(command, axis));
        QTimer::singleShot(2000, this, SLOT(timesUp()));
    }
    else
    {
        switch(command)
        {
        case CW:
            axis_number = next.second;
            canvas->rotateCW();
            break;
        case CCW:
            axis_number = next.second;
            canvas->rotateCCW();
            break;
        case ADDY:
            emit addY();
            break;
        case SUBY:
            emit subY();
            break;
        case ADDX:
            emit addX();
            break;
        case SUBX:
            emit subX();
            break;
        case PAINT:
            emit paint();
            break;
        default:
            qDebug() << "RECEIVE ERROR:" << next.first;
            break;
        }
    }
}
Example #4
0
void CStarCamera::setViewportAngle(const FPoint &angles) {
	debug(DEBUG_DETAILED, "setViewportAngle %f %f", angles._x, angles._y);

	if (isLocked())
		return;

	if (_matrixRow == -1) {
		FPose subX(X_AXIS, angles._y);
		FPose subY(Y_AXIS, angles._x);
		FPose sub(subX, subY);
		proc22(sub);
	} else if (_matrixRow == 0) {
		FVector row1 = _matrix._row1;
		FPose subX(X_AXIS, angles._y);
		FPose subY(Y_AXIS, angles._x);
		FPose sub(subX, subY);

		FMatrix m1 = _viewport.getOrientation();
		FVector tempV1 = _viewport._position;
		FVector tempV2, tempV3, tempV4, tempV5, tempV6;
		tempV2._y = m1._row1._y * 100000.0;
		tempV2._z = m1._row1._z * 100000.0;
		tempV3._x = m1._row1._x * 100000.0 + tempV1._x;
		tempV4._x = tempV3._x;
		tempV3._y = tempV2._y + tempV1._y;
		tempV4._y = tempV3._y;
		tempV3._z = tempV2._z + tempV1._z;
		tempV4._z = tempV3._z;
		tempV2._x = m1._row2._x * 100000.0;
		tempV2._y = m1._row2._y * 100000.0;
		tempV2._z = m1._row2._z * 100000.0;
		tempV2._x = m1._row3._x * 100000.0;
		tempV2._y = m1._row3._y * 100000.0;
		tempV2._z = m1._row3._z * 100000.0;
		tempV2._x = tempV2._x + tempV1._x;
		tempV2._y = tempV2._y + tempV1._y;
		tempV2._z = tempV2._z + tempV1._z;
		tempV3._x = tempV2._x + tempV1._x;
		tempV3._y = tempV2._y + tempV1._y;
		tempV5._x = tempV2._x;
		tempV5._y = tempV2._y;
		tempV3._z = tempV2._z + tempV1._z;
		tempV5._z = tempV2._z;
		tempV6._x = tempV3._x;
		tempV6._y = tempV3._y;
		tempV6._z = tempV3._z;
		tempV1._x = tempV1._x - row1._x;
		tempV1._y = tempV1._y - row1._y;
		tempV1._z = tempV1._z - row1._z;
		tempV4._x = tempV3._x - row1._x;
		tempV4._y = tempV4._y - row1._y;
		tempV4._z = tempV4._z - row1._z;
		tempV5._x = tempV2._x - row1._x;

		tempV5._y = tempV5._y - row1._y;
		tempV5._z = tempV5._z - row1._z;
		tempV6._x = tempV3._x - row1._x;
		tempV6._y = tempV6._y - row1._y;
		tempV6._z = tempV6._z - row1._z;

		FVector modV1 = tempV1.fn5(sub);
		FVector modV2 = tempV4.fn5(sub);
		FVector modV3 = tempV5.fn5(sub);
		FVector modV4 = tempV6.fn5(sub);
		tempV1 = modV1;
		tempV4 = modV2;
		tempV5 = modV3;
		tempV4 = modV4;

		tempV2._x = tempV4._x - tempV1._x;
		tempV2._y = tempV4._y - tempV1._y;
		tempV2._z = tempV4._z - tempV1._z;
		tempV4._x = tempV2._x;
		tempV4._y = tempV2._y;
		tempV2._x = tempV5._x - tempV1._x;
		tempV4._z = tempV2._z;
		tempV5._x = tempV2._x;
		tempV2._y = tempV5._y - tempV1._y;
		tempV5._y = tempV2._y;
		tempV2._z = tempV5._z - tempV1._z;
		tempV5._z = tempV2._z;
		tempV2._x = tempV6._x - tempV1._x;
		tempV2._y = tempV6._y - tempV1._y;
		tempV2._z = tempV6._z - tempV1._z;
		tempV6 = tempV2;

		tempV4.normalize();
		tempV5.normalize();
		tempV6.normalize();
		tempV1 += row1;

		m1.set(tempV4, tempV5, tempV6);
		_viewport.setOrientation(m1);
		_viewport.setPosition(tempV1);
	} else if (_matrixRow == 1) {
		FVector tempV2;
		DMatrix m1, m2, sub;
		DVector mrow1, mrow2, mrow3;
		DVector tempV1, diffV, multV, multV2, tempV3, tempV4, tempV5, tempV6, tempV7;
		DVector tempV8, tempV9, tempV10, tempV11, tempV12;
		DVector tempV13, tempV14, tempV15, tempV16;

		DMatrix subX(0, _matrix._row1);
		DMatrix subY(Y_AXIS, angles._y);

		tempV1 = _matrix._row2 - _matrix._row1;
		diffV = tempV1;
		m1 = diffV.fn5();
		m1 = m1.fn4(subX);
		subX = m1.fn1();
		subX = subX.fn4(subY);

		FMatrix m3 = _viewport.getOrientation();
		tempV2 = _viewport._position;
		multV._x = m3._row1._x * 1000000.0;
		multV._y = m3._row1._y * 1000000.0;
		multV._z = m3._row1._z * 1000000.0;
		tempV3._x = tempV2._x;
		tempV3._y = tempV2._y;
		tempV3._z = tempV2._z;
		multV2._z = m3._row2._z * 1000000.0;

		tempV1._x = multV._x + tempV3._x;
		tempV1._y = multV._y + tempV3._y;
		tempV1._z = multV._z + tempV3._z;
		mrow3._z = 0.0;
		mrow3._y = 0.0;
		mrow3._x = 0.0;
		multV2._x = m3._row2._x * 1000000.0;
		multV2._y = m3._row2._y * 1000000.0;
		mrow1 = tempV1;
		multV = multV2 + tempV3;
		mrow2 = multV;

		tempV7._z = m3._row3._z * 1000000.0 + tempV3._z;
		tempV7._y = m3._row3._y * 1000000.0 + tempV3._y;
		tempV7._x = m3._row3._x * 1000000.0 + tempV3._x;

		mrow3 = tempV8;
		DVector *v = tempV3.fn1(tempV9, subX);
		tempV3 = *v;
		v = mrow1.fn1(tempV10, subX);
		mrow1 = *v;
		v = mrow2.fn1(tempV11, subX);
		mrow2 = *v;
		v = mrow3.fn1(tempV12, subX);
		mrow3 = *v;

		v = tempV3.fn1(tempV13, m1);
		tempV3 = *v;
		v = mrow1.fn1(tempV14, m1);
		mrow1 = *v;
		v = mrow2.fn1(tempV15, m1);
		mrow2 = *v;
		v = mrow3.fn1(tempV16, m1);
		mrow3 = *v;

		mrow1 -= tempV3;
		mrow2 -= tempV3;
		mrow3 -= tempV3;
		mrow1.normalize();
		mrow2.normalize();
		mrow3.normalize();
		tempV16 = tempV3;

		m3.set(mrow1, mrow2, mrow3);
		_viewport.setOrientation(m3);
		_viewport.setPosition(tempV16);
	}
}