Exemple #1
0
void testApp::doBoxGrid()
{

	clearBoxes();
	int w = imageWidth;
	int h = imageHeight;

	cvColorImage.setFromPixels(getKinectRGBPixels(), w, h);
	
	for(int i=0; i<w; i+=boxGridStep)
	{
		for(int j=0; j<h; j+=boxGridStep)
		{
			ImageBox rect;
			float boxSize = kinect.getDistanceAt(i, j);
			boxSize = ofMap(boxSize, 0, 600, 30, 2, true);
			//rect.setPhysics(3.0, 0.53, 0.1);
			rect.setPhysics(boxMass, boxBounce, boxFriction);
			cvColorImage.setROI(ofRectangle(i, j, boxSize, boxSize));
			ofImage boxImage;
			boxImage.setFromPixels(cvColorImage.getRoiPixels(), boxSize, boxSize, OF_IMAGE_COLOR, true);
			rect.setTexture(boxImage);
			cvColorImage.resetROI();
			rect.setup(myWorld, i, j, boxSize, boxSize);
			boxes.push_back(rect);
			

		}
	}
}
Exemple #2
0
void testApp::keyPressed (int key)
{
	switch (key)
	{
			
		case 'f':
		{
			doFingerFollow = !doFingerFollow;
			break;
		}
		case 'g':
		{
			forceGUIDraw = !forceGUIDraw;
			glClear(GL_COLOR_BUFFER_BIT);
			break;
		}
		case 'c':
		{
			//float r = ofRandom(4, 20);		// a random radius 4px - 20px
			ofxBox2dCircle circle;
			circle.setPhysics(3.0, 0.53, 0.1);
			int circleSize = kinect.getDistanceAt(mouseX, mouseY);
			circleSize = ofMap(circleSize, 0, 600, 1, 8, true);
			//kinect.getDistanceAt(mouseX, mouseY);
			cout << "circleSize" << circleSize <<endl;
			circle.setup(myWorld, mouseX, mouseY, circleSize);
			circles.push_back(circle);
			break;
		}
		case 'b':
		{
			doBoxGrid();
			break;
		}
		case 'x':
		{
			clearBoxes();
			break;
		}
		
	}
}
SAESpageWidget::SAESpageWidget(QWidget *parent) :
    QWidget(parent)
{
    /*create*/
    gridLayout = new QGridLayout(this);
    keygridLayout = new QGridLayout();
    inputTypeLayout = new QHBoxLayout();

    inputTypeL = new QLabel(tr("Input Type:"), this);
    binaryL = new QLabel(tr("Binary (16 digits)"), this);
    decimalL = new QLabel(tr("Integer (value <= 65535)"), this);
    hexL = new QLabel(tr("Hex (4 digits)"), this);

    binaryE = new QLineEdit(this);
    decimalE = new QLineEdit(this);
    hexE = new QLineEdit(this);

    inputTypeE = new QComboBox(this);
    keyBox = new QGroupBox(tr("Key (16 bit)"), this);
    inputL = new QGroupBox(this);
    outputL = new QGroupBox(this);

    inputLayout = new QHBoxLayout(inputL);
    outputLayout = new QHBoxLayout(outputL);

    inputE = new QPlainTextEdit(this);
    outputE = new QTextBrowser(this);

    clearButton = new QPushButton(tr("Clear"), this);
    convertButton = new QPushButton(this);

    QRegExp binRegExp("[01]{16}");                      //we use regular expressions to cleanse the input
    QRegExp hexRegExp("[0-9A-Fa-f]{4}");                //for some of the key fields!  Fr. Smolarski would
                                                        //be proud :P

    binaryValidator = new QRegExpValidator(binRegExp, this);    //the purpose of validators is to restrict
    decimalValidator = new QIntValidator(0, 65535, this);       //input in certain boxes to something
    hexValidator = new QRegExpValidator(hexRegExp, this);       //appropriate; i.e. if our input box
    inputValidator = new QRegExpValidator(this);                //needs a number, the QIntValidator
                                                                //prevents you from typing in anything else
    binaryE->setValidator(binaryValidator);
    decimalE->setValidator(decimalValidator);
    hexE->setValidator(hexValidator);


    /*lay out*/
    inputLayout->addWidget(inputE);
    outputLayout->addWidget(outputE);

    inputTypeLayout->addWidget(inputTypeL);
    inputTypeLayout->addWidget(inputTypeE);
    inputTypeLayout->addStretch();



    keygridLayout->addLayout(inputTypeLayout, 0, 0, 1, 4);
    keygridLayout->addWidget(binaryL, 1, 0, 1, 1);
    keygridLayout->setAlignment(binaryL, Qt::AlignRight);
    keygridLayout->addWidget(binaryE, 1, 1, 1, 3);

    keygridLayout->addWidget(decimalL, 2, 0, 1, 1);
    keygridLayout->setAlignment(decimalL, Qt::AlignRight);
    keygridLayout->addWidget(decimalE, 2, 1, 1, 3);

    keygridLayout->addWidget(hexL, 3, 0, 1, 1);
    keygridLayout->setAlignment(hexL, Qt::AlignRight);
    keygridLayout->addWidget(hexE, 3, 1, 1, 3);

    keygridLayout->setRowMinimumHeight(4, 50);

    keyBox->setLayout(keygridLayout);

    gridLayout->addWidget(keyBox, 0, 0, 4, 4);
    gridLayout->addWidget(inputL, 0, 4, 4, 8);
    gridLayout->addWidget(clearButton, 4, 8, 1, 2);
    gridLayout->addWidget(convertButton, 4, 10, 1, 2);
    gridLayout->addWidget(outputL, 6, 0, 3, 12);
    gridLayout->setRowMinimumHeight(5, 8);


    /*initialize*/
    inputTypeE->addItem(tr("Binary (Base 2)"));
    inputTypeE->addItem(tr("Integer (Base 10)"));
    inputTypeE->addItem(tr("Hex (Base 16)"));

    setCurrentKeyInput(0);

    /*signals&slots*/
    connect(inputTypeE, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentKeyInput(int)));
    connect(binaryE, SIGNAL(textEdited(QString)), this, SLOT(fillAndColorKeyInput(QString)));
    connect(decimalE, SIGNAL(textEdited(QString)), this, SLOT(fillAndColorKeyInput(QString)));
    connect(hexE, SIGNAL(textEdited(QString)), this, SLOT(fillAndColorKeyInput(QString)));
    connect(clearButton, SIGNAL(clicked()), this, SLOT(clearBoxes()));

}
SAESpageWidget::SAESpageWidget(QWidget *parent) :
    QWidget(parent)
{
    /*create*/
    gridLayout = new QGridLayout(this);
    keygridLayout = new QGridLayout();
    inputTypeLayout = new QHBoxLayout();

    inputTypeL = new QLabel(tr("Input Type:"), this);
    binaryL = new QLabel(tr("Binary (16 digits)"), this);
    decimalL = new QLabel(tr("Integer (value <= 65535)"), this);
    hexL = new QLabel(tr("Hex (4 digits)"), this);

    binaryE = new QLineEdit(this);
    decimalE = new QLineEdit(this);
    hexE = new QLineEdit(this);

    inputTypeE = new QComboBox(this);
    keyBox = new QGroupBox(tr("Key (16 bit)"), this);
    inputL = new QGroupBox(this);
    outputL = new QGroupBox(this);

    inputLayout = new QHBoxLayout(inputL);
    outputLayout = new QHBoxLayout(outputL);

    inputE = new QPlainTextEdit(this);
    outputE = new QTextBrowser(this);

    clearButton = new QPushButton(tr("Clear"), this);
    convertButton = new QPushButton(this);

    QRegExp binRegExp("[01]{16}");
    QRegExp hexRegExp("[0-9A-Fa-f]{4}");

    binaryValidator = new QRegExpValidator(binRegExp, this);
    decimalValidator = new QIntValidator(0, 65535, this);
    hexValidator = new QRegExpValidator(hexRegExp, this);
    inputValidator = new QRegExpValidator(this);

    binaryE->setValidator(binaryValidator);
    decimalE->setValidator(decimalValidator);
    hexE->setValidator(hexValidator);


    /*lay out*/
    inputLayout->addWidget(inputE);
    outputLayout->addWidget(outputE);

    inputTypeLayout->addWidget(inputTypeL);
    inputTypeLayout->addWidget(inputTypeE);
    inputTypeLayout->addStretch();



    keygridLayout->addLayout(inputTypeLayout, 0, 0, 1, 4);
    keygridLayout->addWidget(binaryL, 1, 0, 1, 1);
    keygridLayout->setAlignment(binaryL, Qt::AlignRight);
    keygridLayout->addWidget(binaryE, 1, 1, 1, 3);

    keygridLayout->addWidget(decimalL, 2, 0, 1, 1);
    keygridLayout->setAlignment(decimalL, Qt::AlignRight);
    keygridLayout->addWidget(decimalE, 2, 1, 1, 3);

    keygridLayout->addWidget(hexL, 3, 0, 1, 1);
    keygridLayout->setAlignment(hexL, Qt::AlignRight);
    keygridLayout->addWidget(hexE, 3, 1, 1, 3);

    keygridLayout->setRowMinimumHeight(4, 50);

    keyBox->setLayout(keygridLayout);

    gridLayout->addWidget(keyBox, 0, 0, 4, 4);
    gridLayout->addWidget(inputL, 0, 4, 4, 8);
    gridLayout->addWidget(clearButton, 4, 8, 1, 2);
    gridLayout->addWidget(convertButton, 4, 10, 1, 2);
    gridLayout->addWidget(outputL, 6, 0, 3, 12);
    gridLayout->setRowMinimumHeight(5, 8);


    /*initialize*/
    inputTypeE->addItem(tr("Binary (Base 2)"));
    inputTypeE->addItem(tr("Integer (Base 10)"));
    inputTypeE->addItem(tr("Hex (Base 16)"));

    setCurrentKeyInput(0);

    /*signals&slots*/
    connect(inputTypeE, SIGNAL(currentIndexChanged(int)), this, SLOT(setCurrentKeyInput(int)));
    connect(binaryE, SIGNAL(textEdited(QString)), this, SLOT(fillAndColorKeyInput(QString)));
    connect(decimalE, SIGNAL(textEdited(QString)), this, SLOT(fillAndColorKeyInput(QString)));
    connect(hexE, SIGNAL(textEdited(QString)), this, SLOT(fillAndColorKeyInput(QString)));
    connect(clearButton, SIGNAL(clicked()), this, SLOT(clearBoxes()));

}