Exemple #1
0
    void Interface :: onKeyDown(){

        keyboard.down = true;
        //fullscreen, etc (windowing controls)
        windowTransform();
                
        //stateTransform();
        switch(keyboard.code){
            case 'c':
                camera().reset(); 
                model().reset();
                break;
                
        }
                
        //Camera Controls			
        if (keyboard.alt) {	
            keyboardModelTransform(1.0, true);
        } else if (keyboard.shift){   
            keyboardCamTranslate(1.0, true);
        } else {                         
            keyboardCamSpin(1.0, true);
        }        
                
    }
MathMainWindow::MathMainWindow(shared_ptr<int> s, shared_ptr<double> sub, shared_ptr<double> sup, shared_ptr<string> f, shared_ptr<double> r, QWidget *parent)
: QWidget(parent), formulaline(f), resultline(r), subScript(sub), supScript(sup), isintegral(s)
{
	drawWindow = make_shared<draw>();
    QLabel *formulaLabel = new QLabel(tr("Formula:"));

    QLabel *resultLabel = new QLabel(tr("Result:"));
    resultline.setReadOnly(true);

	QLabel *subLabel = new QLabel(tr("sub:"));
	QLabel *supLabel = new QLabel(tr("sup:"));

	handWriteButton = new QPushButton(tr("&HandWrite"));
	startButton = new QPushButton(tr("&Start"));
	calcButton = new QPushButton(tr("&Calculate"));
    loadButton = new QPushButton(tr("&Load..."));
    submitButton = new QPushButton(tr("&Submit"));
    submitButton->setEnabled(false);

	calcButton->setToolTip(tr("Calculate the result of the formula you input"));
    loadButton->setToolTip(tr("Load a picture from a file"));
	

	connect(handWriteButton, SIGNAL(clicked()), this, SLOT(windowTransform()));
	connect(startButton, SIGNAL(clicked()), this, SLOT(start()));
	connect(calcButton, SIGNAL(clicked()), this, SLOT(calculate()));
    connect(loadButton, SIGNAL(clicked()), this, SLOT(loadFromFile()));
    connect(submitButton, SIGNAL(clicked()), this, SLOT(submitPicture()));

    QHBoxLayout *buttonLayout = new QHBoxLayout;
	buttonLayout->addWidget(startButton);
	buttonLayout->addWidget(calcButton);
    buttonLayout->addWidget(loadButton);
    //buttonLayout->addWidget(submitButton);
	buttonLayout->addWidget(handWriteButton);
    buttonLayout->addStretch(1);

	QHBoxLayout *integralLayout = new QHBoxLayout;
	integralLayout->addWidget(subLabel);
	integralLayout->addWidget(&subScript);
	integralLayout->addWidget(supLabel);
	integralLayout->addWidget(&supScript);
	integralLayout->addStretch(1);

	QHBoxLayout *resultLayout = new QHBoxLayout;
	resultLayout->addWidget(&resultline);
	resultLayout->addWidget(submitButton);

    QGridLayout *mainLayout = new QGridLayout;
    mainLayout->addWidget(formulaLabel, 0, 0);
    mainLayout->addWidget(&formulaline, 0, 1);
	mainLayout->addWidget(&isintegral, 1, 0);
	mainLayout->addLayout(integralLayout, 1, 1);
    mainLayout->addWidget(resultLabel, 2, 0);
	mainLayout->addLayout(resultLayout, 2, 1);
	mainLayout->addWidget(label, 0, 2, 4, 1);
	//mainLayout->addWidget(startButton, 3, 0);
    mainLayout->addLayout(buttonLayout, 3, 1);

    setLayout(mainLayout);
    setWindowTitle(tr("Math formula recognition"));

	QPixmap mp;
	mp.load("Resources/logo.jpg");;
	label->setPixmap(mp.scaledToHeight(150));
}