コード例 #1
0
/*******************************************************************************
 * Initializes the dynamic parameter sliders.
 */
QWidget*
MainWindow::initDynamicParametersGroupBox(QWidget* parent)
{
	QGroupBox* group = new QGroupBox(tr("Dynamic Parameters"), parent);

	QGridLayout* layout = new QGridLayout(group);
	layout->setColumnStretch(0, 1);
	layout->setColumnStretch(1, 4);
	layout->setColumnStretch(2, 1);

	std::size_t i = 0;
	for ( ; i < dynamicParamInfoList.size(); ++i) {
		// Label.
		layout->addWidget(new QLabel(dynamicParamInfoList[i].name, group), i, 0);

		// Slider.
		dynamicParamSliderList_[i] = new ParameterSlider(i,
						configuration_->dynamicParamMinList[i], configuration_->dynamicParamMaxList[i],
						configuration_->dynamicParamList[i], group);
		layout->addWidget(dynamicParamSliderList_[i], i, 1);

		// Value.
		QString s;
		s.setNum(0.0);
		QLabel* valueLabel = new QLabel(s, group);
		layout->addWidget(valueLabel, i, 2);

		connect(dynamicParamSliderList_[i], SIGNAL(valueChanged(int, float)), this, SLOT(setDynamicParameter(int, float)));
		connect(dynamicParamSliderList_[i], SIGNAL(valueChanged(double)), valueLabel, SLOT(setNum(double)));
		valueLabel->setNum(dynamicParamSliderList_[i]->parameterValue());
	}

	// Stretch.
	layout->addWidget(new QWidget(group), i, 0, 1, 3);
	layout->setRowStretch(i, 1);

	return group;
}
コード例 #2
0
DeferredShading::DeferredShading(QWidget *parent, Qt::WFlags flags)
	: QMainWindow(parent, flags)
{
	ui.setupUi(this);

	// Layouts
	QHBoxLayout *mainLayout = new QHBoxLayout;
    QVBoxLayout *secondLayout = new QVBoxLayout;
	QHBoxLayout *thirdLayout = new QHBoxLayout;

	// Menus
	// File
	QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
	QAction *loadModelAct = new QAction(tr("&Load Model"), this);
	fileMenu->addAction(loadModelAct);
	// Render
	QMenu *renderMenu = menuBar()->addMenu(tr("&Render"));
	QAction *forwardRenderAct = new QAction(tr("&Forward"), this);
	QAction *forwardBlendRenderAct = new QAction(tr("&Forward(Blend)"), this);
	QAction *deferredRenderAct = new QAction(tr("&Deferred"), this);
	QAction *forwardPlusRenderAct = new QAction(tr("&Forward+"), this);
	QAction *forwardPlusCudaRenderAct = new QAction(tr("&Forward+(CUDA)"), this);
	QAction *positionRenderAct = new QAction(tr("&Position"), this);
	QAction *diffuseRenderAct = new QAction(tr("&Diffuse"), this);
	QAction *normalRenderAct = new QAction(tr("&Normal"), this);
	QAction *allRenderAct = new QAction(tr("&All"), this);
	QAction *depthRenderAct = new QAction(tr("&Depth"), this);
	QAction *gridRenderAct = new QAction(tr("&Lighting Grid"), this);
	renderMenu->addAction(forwardRenderAct);
	renderMenu->addAction(forwardBlendRenderAct);
	renderMenu->addAction(deferredRenderAct);
	renderMenu->addAction(forwardPlusRenderAct);
	renderMenu->addAction(forwardPlusCudaRenderAct);
	renderMenu->addSeparator();
	renderMenu->addAction(positionRenderAct);
	renderMenu->addAction(diffuseRenderAct);
	renderMenu->addAction(normalRenderAct);
	renderMenu->addAction(allRenderAct);
	renderMenu->addSeparator();
	renderMenu->addAction(depthRenderAct);
	renderMenu->addAction(gridRenderAct);

	// Validators
	QDoubleValidator *_doubleValidator = new QDoubleValidator(0.01,10.0,2);
	_doubleValidator->setNotation(QDoubleValidator::StandardNotation);
	QDoubleValidator *doubleValidator = new QDoubleValidator(0.01,10000.0,2);
	doubleValidator->setNotation(QDoubleValidator::StandardNotation);

	QIntValidator *intValidator = new QIntValidator(0,N_MAX_LIGHTS);
	QIntValidator *intValidator2 = new QIntValidator(0,4096);

	// Separators
	QFrame *line = new QFrame();
	line->setFrameShape(QFrame::VLine);
	QFrame *line2 = new QFrame();
	line2->setFrameShape(QFrame::VLine);
	QFrame *line3 = new QFrame();
	line3->setFrameShape(QFrame::VLine);
	QFrame *line4 = new QFrame();
	line4->setFrameShape(QFrame::VLine);

	// Camera Sensitivity
	QLabel *sensibilityLabel = new QLabel();
	sensibilityLabel->setText("Sensitivity: ");

	QLineEdit *cameraSensitivityIn = new QLineEdit();
	cameraSensitivityIn->setValidator(doubleValidator);
	cameraSensitivityIn->setText("0.1");

	// Camera Speed
	QLabel *speedLabel = new QLabel();
	speedLabel->setText("Speed: ");

	QLineEdit *cameraSpeedIn = new QLineEdit();
	cameraSpeedIn->setValidator(doubleValidator);
	cameraSpeedIn->setText("1.0");

	// Threshold (deferred only)
	QLabel *thresholdLabel = new QLabel();
	thresholdLabel->setText("Threshold: ");

	QLineEdit *thresholdIn = new QLineEdit();
	thresholdIn->setValidator(intValidator2);
	thresholdIn->setText("256");

	// Billboards
	//QLabel *billboardsLabel = new QLabel();
	//billboardsLabel->setText("Billboards: ");

	QCheckBox *billboardsCheckBox = new QCheckBox("Billboards:");
	billboardsCheckBox->setLayoutDirection(Qt::RightToLeft);
	billboardsCheckBox->setChecked(false);

	// Light bounding box scale
	QLabel *lightBBScaleLabel = new QLabel();
	lightBBScaleLabel->setText(" Bb scale: ");

	QLineEdit *lighBBScaleIn = new QLineEdit();
	lighBBScaleIn->setValidator(doubleValidator);
	lighBBScaleIn->setText("1.0");

	// Attenuation
	QLabel *attenuationLabel = new QLabel();
	attenuationLabel->setText("Attenuation: ");

	QLineEdit *constantAttIn = new QLineEdit();
	constantAttIn->setValidator(doubleValidator);
	constantAttIn->setText("1.0");

	QLineEdit *linearAttIn = new QLineEdit();
	linearAttIn->setValidator(doubleValidator);
	linearAttIn->setText("60.0");

	QLineEdit *expAttIn = new QLineEdit();
	expAttIn->setValidator(doubleValidator);
	expAttIn->setText("0.0");

	// Light intensity
	QLabel *lightIntesityLabel = new QLabel();
	lightIntesityLabel->setText("Intensity: ");

	QLineEdit *lighIntensityIn = new QLineEdit();
	lighIntensityIn->setValidator(doubleValidator);
	lighIntensityIn->setText("1.0");

	// Number of lights
	QLabel *nLightsLabel = new QLabel();
	nLightsLabel->setText("N: ");
	std::stringstream sstm;
	sstm << INITIAL_LIGHTS;
	std::string s = sstm.str();
	// QString::fromStdString desnt work on release
#ifdef NDEBUG
	nLights = "20";
#else
	nLights = QString::fromStdString(s);
#endif
	
	QLineEdit *nLightsIn = new QLineEdit();
	nLightsIn->setValidator(intValidator);
	nLightsIn->setText(nLights);

	QPushButton *genLightsButton = new QPushButton("Gen. Lights");

	// Render Mode
	QLabel *renderModeLabel = new QLabel();
	renderModeLabel->setText("Forward");
	renderModeLabel->setAlignment(Qt::AlignRight);

	// FPS
	QLabel *fpsLabelNum = new QLabel();
	fpsLabelNum->setNum(0);
	fpsLabelNum->setAlignment(Qt::AlignRight);
	fpsLabelNum->setMaximumHeight(20);

	QLabel *fpsLabel = new QLabel();
	fpsLabel->setText("FPS: ");
	fpsLabel->setAlignment(Qt::AlignRight);

	// GLWidget
    GLWidget *glWidget = new GLWidget;

	// Connect signals-slots
	connect(loadModelAct,SIGNAL(triggered()), this, SLOT(loadModelDia()));
	connect(this,SIGNAL(modelPathChange(std::string)), glWidget, SLOT(loadModel(std::string)));
	connect(forwardRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardRenderMode()));
	connect(forwardBlendRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardBlendRenderMode()));
	connect(forwardPlusRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardPlusRenderMode()));
	connect(forwardPlusCudaRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardPlusCudaRenderMode()));
	connect(deferredRenderAct,SIGNAL(triggered()), glWidget, SLOT(setDeferredRenderMode()));
	connect(positionRenderAct,SIGNAL(triggered()), glWidget, SLOT(setPositionRenderMode()));
	connect(diffuseRenderAct,SIGNAL(triggered()), glWidget, SLOT(setDiffuseRenderMode())); 
	connect(normalRenderAct,SIGNAL(triggered()), glWidget, SLOT(setNormalRenderMode()));
	connect(allRenderAct,SIGNAL(triggered()), glWidget, SLOT(setAllRenderMode()));
	connect(depthRenderAct,SIGNAL(triggered()), glWidget, SLOT(setDepthRenderMode()));
	connect(gridRenderAct,SIGNAL(triggered()), glWidget, SLOT(setForwardDebugRenderMode()));
	connect(this,SIGNAL(keyPressed(int)), glWidget, SLOT(addKey(int)));
	connect(this,SIGNAL(keyReleased(int)), glWidget, SLOT(removeKey(int)));
	connect(cameraSensitivityIn,SIGNAL(textChanged(QString)),glWidget,SLOT(modifyCameraSensitivity(QString)));
	connect(cameraSpeedIn,SIGNAL(textChanged(QString)),glWidget,SLOT(modifyCameraSpeed(QString)));
	connect(glWidget, SIGNAL(updateFPSSignal(int)), fpsLabelNum, SLOT(setNum(int)));
	connect(nLightsIn,SIGNAL(textChanged(QString)),this,SLOT(modifyNLights(QString)));
	connect(genLightsButton, SIGNAL(clicked()), this, SLOT(genLights()));
	connect(this, SIGNAL(glGenLights(int)), glWidget, SLOT(genLightning(int)));
	connect(billboardsCheckBox, SIGNAL(stateChanged(int)), glWidget, SLOT(enableBillboards(int)));
	connect(lighBBScaleIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyBoundingBoxScale(QString)));
	connect(lighIntensityIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyMaxIntensity(QString)));
	connect(glWidget, SIGNAL(updateLightIntensityIn(QString)), lighIntensityIn, SLOT(setText(QString)));
	connect(glWidget, SIGNAL(updateRenderMode(QString)), renderModeLabel, SLOT(setText(QString)));
	connect(thresholdIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyThreshold(QString)));
	connect(constantAttIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyConstantAttenuation(QString)));
	connect(linearAttIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyLinearAttenuation(QString)));
	connect(expAttIn, SIGNAL(textChanged(QString)), glWidget, SLOT(modifyExpAttenuation(QString)));

	// Set layout content
    mainLayout->addWidget(glWidget);

	thirdLayout->addWidget(sensibilityLabel);
	thirdLayout->addWidget(cameraSensitivityIn);
	thirdLayout->addWidget(speedLabel);
	thirdLayout->addWidget(cameraSpeedIn);
	thirdLayout->addWidget(line);
	thirdLayout->addWidget(thresholdLabel);
	thirdLayout->addWidget(thresholdIn);
	thirdLayout->addWidget(line2);
	thirdLayout->addWidget(billboardsCheckBox);
	thirdLayout->addWidget(lightBBScaleLabel);
	thirdLayout->addWidget(lighBBScaleIn);
	thirdLayout->addWidget(attenuationLabel);
	thirdLayout->addWidget(constantAttIn);
	thirdLayout->addWidget(linearAttIn);
	thirdLayout->addWidget(expAttIn);
	thirdLayout->addWidget(lightIntesityLabel);
	thirdLayout->addWidget(lighIntensityIn);
	thirdLayout->addWidget(nLightsLabel);
	thirdLayout->addWidget(nLightsIn);
	thirdLayout->addWidget(genLightsButton);
	thirdLayout->addWidget(line3);
	thirdLayout->addWidget(renderModeLabel);
	thirdLayout->addWidget(line4);
	thirdLayout->addWidget(fpsLabel);
	thirdLayout->addWidget(fpsLabelNum);

	secondLayout->addLayout(thirdLayout);
    secondLayout->addLayout(mainLayout);

	cameraSpeedIn->setFocus();

    setWindowTitle("Deferred Shading");
    ui.centralWidget->setLayout(secondLayout);
	setMinimumSize(1024,576);
}
コード例 #3
0
void firstPage::setUp_SpiralTable(){


    ////////////////////////////////////////////
    //          Set up spiral Table           //
    ////////////////////////////////////////////

    spiralTable=ui->spiralTable;
    spiralTable->verticalHeader()->setVisible(false);
    spiralTable->horizontalHeader()->setVisible(false);
    spiralTable->setShowGrid(false);

    //Format 1. Column
    for(int i = 0; i<spiralTable->rowCount() ; i++)
    {
        spiralTable->item(i,0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
    }


    //////////////////////////////////////////////////////////
    //      Put DoubleSpinBoxes in 2.Column of Table        //
    //////////////////////////////////////////////////////////

    for( int i = 0; i < spiralTable->rowCount(); i++ )
    {
        QDoubleSpinBox *spinBox = new QDoubleSpinBox();
        spinBox->setValue(0);
        spiralTable->setCellWidget( i, 1, spinBox );
    }

    static_cast<QSpinBox*>(spiralTable->cellWidget(0,1))->setMinimum(0);
    static_cast<QSpinBox*>(spiralTable->cellWidget(0,1))->setMaximum(maxA/2);

    static_cast<QSpinBox*>(spiralTable->cellWidget(1,1))->setMinimum(0);
    static_cast<QSpinBox*>(spiralTable->cellWidget(1,1))->setMaximum(maxA/2);

    static_cast<QSpinBox*>(spiralTable->cellWidget(2,1))->setMinimum(0);
    static_cast<QSpinBox*>(spiralTable->cellWidget(2,1))->setMaximum(10000);

    static_cast<QSpinBox*>(spiralTable->cellWidget(3,1))->setMinimum(0);
    static_cast<QSpinBox*>(spiralTable->cellWidget(3,1))->setMaximum(10000);

    static_cast<QSpinBox*>(spiralTable->cellWidget(4,1))->setMinimum(-1000);
    static_cast<QSpinBox*>(spiralTable->cellWidget(4,1))->setMaximum(1000);

    static_cast<QSpinBox*>(spiralTable->cellWidget(5,1))->setMinimum(-1000);
    static_cast<QSpinBox*>(spiralTable->cellWidget(5,1))->setMaximum(1000);

    static_cast<QSpinBox*>(spiralTable->cellWidget(6,1))->setMinimum(-1000);
    static_cast<QSpinBox*>(spiralTable->cellWidget(6,1))->setMaximum(1000);

    static_cast<QSpinBox*>(spiralTable->cellWidget(7,1))->setMinimum(0);
    static_cast<QSpinBox*>(spiralTable->cellWidget(7,1))->setMaximum(veloMax);


    ////////////////////////////////////////////////////////////////////////
    //      Load stored values and assign them in 3. and 2. Column        //
    ////////////////////////////////////////////////////////////////////////

    cout<<mSpiral.getStoredValuesPath()<<endl;
    QFile spiralFile(QString::fromStdString(mSpiral.getStoredValuesPath()));
    spiralFile.open(QIODevice::ReadOnly | QIODevice::Text);

    QTextStream inspiral(&spiralFile);
    for( int i = 0; i < spiralTable->rowCount(); i++ )
    {
        QLabel *label = new QLabel();

        double x = inspiral.readLine().toDouble();

        if((i==4)||(i==5)||(i==6)){
            x=(x/(2*pi))*360;
        }

        label->setNum(x);
        cout<<x<<endl;
        label->setAlignment(Qt::AlignVCenter);
        spiralTable->setCellWidget( i, 3, label );
        static_cast<QDoubleSpinBox*>(spiralTable->cellWidget(i,1))->setValue(x);
    }
    spiralFile.close();


    //make 1. Column unaccesible
    for(int i = 0;i<spiralTable->rowCount();i++){

        spiralTable->item(i,0)->setFlags(spiralTable->item(i,0)->flags() ^ Qt::ItemIsEditable);
        spiralTable->item(i,0)->setFlags(spiralTable->item(i,0)->flags() ^ Qt::ItemIsSelectable);
        spiralTable->item(i,0)->setFlags(spiralTable->item(i,0)->flags() ^ Qt::ItemIsUserCheckable);
        //spiralTable->item(i,0)->setFlags(spiralTable->item(i,0)->flags() ^ Qt::ItemIsEnabled);
    }


    spiralTable->setColumnWidth(2,cWidth);
    spiralTable->setTabKeyNavigation(false);

}
コード例 #4
0
void firstPage::setUp_LineTable(){

    lineTable=ui->lineTable;
    lineTable->verticalHeader()->setVisible(false);
    lineTable->horizontalHeader()->setVisible(false);
    lineTable->setShowGrid(false);

    //column 2 is only used as a spacer
    lineTable->setColumnWidth(2,cWidth);
    lineTable->setTabKeyNavigation(false);

    //////////////////////////////////////////
    //          Format 1. Column            //
    //////////////////////////////////////////

    for(int i = 0; i<lineTable->rowCount() ; i++)
    {
        lineTable->item(i,0)->setTextAlignment(Qt::AlignRight | Qt::AlignVCenter);
    }

    //make 1. Column unaccesible
    for(int i = 0;i<lineTable->rowCount();i++){

        lineTable->item(i,0)->setFlags(lineTable->item(i,0)->flags() ^ Qt::ItemIsEditable);
        lineTable->item(i,0)->setFlags(lineTable->item(i,0)->flags() ^ Qt::ItemIsSelectable);
        lineTable->item(i,0)->setFlags(lineTable->item(i,0)->flags() ^ Qt::ItemIsUserCheckable);
    }

    // http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/MAC/GREEK.TXT
    lineTable->item(1,0)->setText(QString(QChar(0x03C6))+" =");
    lineTable->item(2,0)->setText(QString(QChar(0x0398))+" =");


    //////////////////////////////////////////////////////////
    //      Put DoubleSpinBoxes in 2.Column of Table        //
    //////////////////////////////////////////////////////////
    for( int i = 0; i < lineTable->rowCount(); i++ )
    {

        if(i==3){
            QSpinBox *spinBox = new QSpinBox();
            spinBox->setValue(0);
            lineTable->setCellWidget( i, 1, spinBox );
        }else
        {

            QDoubleSpinBox *spinBox = new QDoubleSpinBox();
            spinBox->setValue(0);
            lineTable->setCellWidget( i, 1, spinBox );
        }
    }

    //Format SpinBoxes Manually

    static_cast<QSpinBox*>(lineTable->cellWidget(0,1))->setMinimum(0);
    static_cast<QSpinBox*>(lineTable->cellWidget(0,1))->setMaximum(maxA/2);

    static_cast<QSpinBox*>(lineTable->cellWidget(1,1))->setMinimum(-1000);
    static_cast<QSpinBox*>(lineTable->cellWidget(1,1))->setMaximum(1000);

    static_cast<QSpinBox*>(lineTable->cellWidget(2,1))->setMinimum(-1000);
    static_cast<QSpinBox*>(lineTable->cellWidget(2,1))->setMaximum(1000);

    static_cast<QSpinBox*>(lineTable->cellWidget(3,1))->setMinimum(1);
    static_cast<QSpinBox*>(lineTable->cellWidget(3,1))->setMaximum(1000);

    static_cast<QSpinBox*>(lineTable->cellWidget(4,1))->setMinimum(0);
    static_cast<QSpinBox*>(lineTable->cellWidget(4,1))->setMaximum(veloMax);

    ////////////////////////////////////////////////////////////////////////
    //      Load stored values and assign them in 3. and 2. Column        //
    ////////////////////////////////////////////////////////////////////////

    cout<<mLine.getStoredValuesPath()<<endl;
    QFile lineFile(QString::fromStdString(mLine.getStoredValuesPath()));
    lineFile.open(QIODevice::ReadOnly | QIODevice::Text);

    QTextStream inLine(&lineFile);
    for( int i = 0; i < lineTable->rowCount(); i++ )
    {
        if(i==3){
            QLabel *label = new QLabel();
            int x = inLine.readLine().toInt();
            label->setNum(x);
            cout<<x<<endl;
            label->setAlignment(Qt::AlignVCenter);
            lineTable->setCellWidget( i, 3, label );
            static_cast<QSpinBox*>(lineTable->cellWidget(i,1))->setValue(x);
        }else
        {
            QLabel *label = new QLabel();
            double x = inLine.readLine().toDouble();

            if((i==1)||(i==2)){
                x=(x/(2*pi))*360;
            }

            label->setNum(x);
            cout<<x<<endl;
            label->setAlignment(Qt::AlignVCenter);
            lineTable->setCellWidget( i, 3, label );
            static_cast<QDoubleSpinBox*>(lineTable->cellWidget(i,1))->setValue(x);
        }
    }
    lineFile.close();

}
コード例 #5
0
SliderDialog::SliderDialog(const char *caption, const char *msg,
                           int defaultval, int minval, int maxval)
    : QDialog(kapp->mainWidget(), caption, TRUE)
{
    setCaption(caption);
    QVBoxLayout *tl = new QVBoxLayout(this, 10, 10);
    QHBoxLayout *l1 = new QHBoxLayout;
    tl->addLayout(l1, 1);

    label = new QLabel(msg, this);
    label->setMinimumSize(label->sizeHint());
    l1->addWidget(label);

    lined = new QLineEdit(this);
    lined->setMinimumWidth(lined->sizeHint().width()/2);
    lined->setFixedHeight(lined->sizeHint().height());
    lined->setMaxLength(7);

    QString s;
    s.setNum(defaultval);
    lined->setText(s.data());
    lined->selectAll();
    lined->setFocus();
    l1->addWidget(lined, 1);

    QVBoxLayout *l2 = new QVBoxLayout;
    tl->addLayout(l2);
    slider = new KSlider(minval, maxval, 1, defaultval, KSlider::Horizontal,
                         this);
    slider->setTickInterval(10);
    slider->setFixedHeight(slider->sizeHint().height());
    slider->setMinimumWidth(200);
    connect(slider, SIGNAL(valueChanged(int)), this, SLOT(slider_change(int)));
    l2->addWidget(slider);

    QHBoxLayout *l21 = new QHBoxLayout;
    l2->addLayout(l21);

    // decorate slider
    QLabel *left = new QLabel(this);
    QLabel *mid = new QLabel(this);
    QLabel *right = new QLabel(this);
    left->setNum(minval);
    mid->setNum((minval + maxval) / 2);
    right->setNum(maxval);

    left->setFixedSize(left->sizeHint());
    mid->setFixedSize(mid->sizeHint());
    right->setFixedSize(right->sizeHint());
    l21->addWidget(left);
    l21->addStretch(1);
    l21->addWidget(mid);
    l21->addStretch(1);
    l21->addWidget(right);

    tl->addSpacing(10);

    KButtonBox *bbox = new KButtonBox(this);
    bbox->addStretch(1);
    ok = bbox->addButton(i18n("OK"));
    ok->setDefault(TRUE);
    connect(ok, SIGNAL(clicked()), SLOT(done_dialog()));

    cancel = bbox->addButton(i18n("Cancel"));
    connect(cancel, SIGNAL(clicked()), SLOT(reject()));
    bbox->layout();
    tl->addWidget(bbox);

    connect(lined, SIGNAL(returnPressed()), SLOT(done_dialog()));
    QAccel *acc = new QAccel(this);
    acc->connectItem(acc->insertItem(Key_Escape), this, SLOT(reject()));

    tl->freeze();
}
コード例 #6
0
bool QVideoCapture::open_settingsDialog()
{
    if (m_cvCapture.isOpened() && deviceFlag)
    {
        //DIALOG CONSTRUCTION//
        QDialog dialog;
        dialog.setFixedSize(256,320);
        dialog.setWindowTitle(tr("Camcorder settings"));

        QVBoxLayout toplevellayout;
        toplevellayout.setMargin(5);
        QTabWidget tabwidget;

        QWidget page1; // a widget for a cam general settings selection
        QHBoxLayout centralbox;
        centralbox.setMargin(5);
        QVBoxLayout sliders;
        sliders.setMargin(5);
        QVBoxLayout lineedits;
        lineedits.setMargin(5);
        QVBoxLayout names;
        names.setMargin(5);

        QSlider Sbrightness;
        Sbrightness.setOrientation(Qt::Horizontal);
        Sbrightness.setMinimum(MIN_BRIGHTNESS);
        Sbrightness.setMaximum(MAX_BRIGHTNESS);
        Sbrightness.setValue( (int)m_cvCapture.get(CV_CAP_PROP_BRIGHTNESS) );
        QLabel Lbrightness;
        Lbrightness.setNum( (int)m_cvCapture.get(CV_CAP_PROP_BRIGHTNESS) );
        connect(&Sbrightness, SIGNAL(valueChanged(int)), &Lbrightness, SLOT(setNum(int)));
        connect(&Sbrightness, SIGNAL(valueChanged(int)), this, SLOT(set_brightness(int)));
        connect(this, SIGNAL(set_default_brightness(int)), &Sbrightness, SLOT(setValue(int)));
        QLabel Nbrightness("Brightness:");

        QSlider Scontrast;
        Scontrast.setOrientation(Qt::Horizontal);
        Scontrast.setMinimum(MIN_CONTRAST);
        Scontrast.setMaximum(MAX_CONTRAST);
        Scontrast.setValue( (int)m_cvCapture.get(CV_CAP_PROP_CONTRAST) );
        QLabel Lcontrast;
        Lcontrast.setNum( (int)m_cvCapture.get(CV_CAP_PROP_CONTRAST) );
        connect(&Scontrast, SIGNAL(valueChanged(int)), &Lcontrast, SLOT(setNum(int)));
        connect(&Scontrast,SIGNAL(valueChanged(int)), this, SLOT(set_contrast(int)));
        connect(this, SIGNAL(set_default_contrast(int)), &Scontrast, SLOT(setValue(int)));
        QLabel Ncontrast("Contrast:");

        QSlider Ssaturation;
        Ssaturation.setOrientation(Qt::Horizontal);
        Ssaturation.setMinimum(MIN_SATURATION);
        Ssaturation.setMaximum(MAX_SATURATION);
        Ssaturation.setValue( (int)m_cvCapture.get(CV_CAP_PROP_SATURATION) );
        QLabel Lsaturation;
        Lsaturation.setNum( (int)m_cvCapture.get(CV_CAP_PROP_SATURATION) );
        connect(&Ssaturation, SIGNAL(valueChanged(int)), &Lsaturation, SLOT(setNum(int)));
        connect(&Ssaturation,SIGNAL(valueChanged(int)), this, SLOT(set_saturation(int)));
        connect(this, SIGNAL(set_default_saturation(int)), &Ssaturation, SLOT(setValue(int)));
        QLabel Nsaturation("Saturation:");

        QSlider SwhitebalanceU;
        SwhitebalanceU.setOrientation(Qt::Horizontal);
        SwhitebalanceU.setMinimum(MIN_WHITE_BALANCE);
        SwhitebalanceU.setMaximum(MAX_WHITE_BALANCE);
        SwhitebalanceU.setValue( (int)m_cvCapture.get(CV_CAP_PROP_WHITE_BALANCE_BLUE_U) );
        QLabel LwhitebalanceU;
        LwhitebalanceU.setNum( (int)m_cvCapture.get(CV_CAP_PROP_WHITE_BALANCE_BLUE_U) );
        connect(&SwhitebalanceU, SIGNAL(valueChanged(int)), &LwhitebalanceU, SLOT(setNum(int)));
        connect(&SwhitebalanceU,SIGNAL(valueChanged(int)), this, SLOT(set_white_balanceU(int)));
        connect(this, SIGNAL(set_default_white_balanceU(int)), &SwhitebalanceU, SLOT(setValue(int)));
        QLabel NwhitebalanceU("White_balanceU:");

        QSlider SwhitebalanceV;
        SwhitebalanceV.setOrientation(Qt::Horizontal);
        SwhitebalanceV.setMinimum(MIN_WHITE_BALANCE);
        SwhitebalanceV.setMaximum(MAX_WHITE_BALANCE);
        SwhitebalanceV.setValue( (int)m_cvCapture.get(CV_CAP_PROP_WHITE_BALANCE_RED_V) );
        QLabel LwhitebalanceV;
        LwhitebalanceV.setNum( (int)m_cvCapture.get(CV_CAP_PROP_WHITE_BALANCE_RED_V) );
        connect(&SwhitebalanceV, SIGNAL(valueChanged(int)), &LwhitebalanceV, SLOT(setNum(int)));
        connect(&SwhitebalanceV,SIGNAL(valueChanged(int)), this, SLOT(set_white_balanceV(int)));
        connect(this, SIGNAL(set_default_white_balanceV(int)), &SwhitebalanceV, SLOT(setValue(int)));
        QLabel NwhitebalanceV("White_balanceV:");

        sliders.addWidget(&Sbrightness);
        lineedits.addWidget(&Lbrightness, 2);
        names.addWidget(&Nbrightness, 1);

        sliders.addWidget(&Scontrast);
        lineedits.addWidget(&Lcontrast, 2);
        names.addWidget(&Ncontrast, 1);

        sliders.addWidget(&Ssaturation);
        lineedits.addWidget(&Lsaturation, 2);
        names.addWidget(&Nsaturation, 1);

        sliders.addWidget(&SwhitebalanceU);
        lineedits.addWidget(&LwhitebalanceU, 2);
        names.addWidget(&NwhitebalanceU, 1);

        sliders.addWidget(&SwhitebalanceV);
        lineedits.addWidget(&LwhitebalanceV, 2);
        names.addWidget(&NwhitebalanceV, 1);

        centralbox.addLayout(&names);
        centralbox.addLayout(&sliders);
        centralbox.addLayout(&lineedits);
        page1.setLayout( &centralbox );

        QWidget page2; // a widget for a cam gain/exposure selection
        QHBoxLayout centralbox2;
        centralbox2.setMargin(5);
        QVBoxLayout sliders2;
        sliders2.setMargin(5);
        QVBoxLayout lineedits2;
        lineedits2.setMargin(5);
        QVBoxLayout names2;
        names2.setMargin(5);

        QSlider Sgain;
        Sgain.setOrientation(Qt::Horizontal);
        Sgain.setMinimum(MIN_GAIN);
        Sgain.setMaximum(MAX_GAIN);
        Sgain.setValue( (int)m_cvCapture.get(CV_CAP_PROP_GAIN) );
        QLabel Lgain;
        Lgain.setNum( (int)m_cvCapture.get(CV_CAP_PROP_GAIN) );
        connect(&Sgain, SIGNAL(valueChanged(int)), &Lgain, SLOT(setNum(int)));
        connect(&Sgain,SIGNAL(valueChanged(int)), this, SLOT(set_gain(int)));
        connect(this, SIGNAL(set_default_gain(int)), &Sgain, SLOT(setValue(int)),Qt::DirectConnection);
        QLabel Ngain("Gain:");

        QSlider Sexposure;
        Sexposure.setOrientation(Qt::Horizontal);
        Sexposure.setMinimum(MIN_EXPOSURE);
        Sexposure.setMaximum(MAX_EXPOSURE);
        Sexposure.setValue( (int)m_cvCapture.get(CV_CAP_PROP_EXPOSURE) );
        QLabel Lexposure;
        Lexposure.setNum( (int)m_cvCapture.get(CV_CAP_PROP_EXPOSURE) );
        connect(&Sexposure, SIGNAL(valueChanged(int)), &Lexposure, SLOT(setNum(int)));
        connect(&Sexposure,SIGNAL(valueChanged(int)), this, SLOT(set_exposure(int)));
        connect(this, SIGNAL(set_default_exposure(int)), &Sexposure, SLOT(setValue(int)));
        QLabel Nexposure("Exposure:");

        sliders2.addWidget(&Sgain);
        lineedits2.addWidget(&Lgain, 2);
        names2.addWidget(&Ngain, 1);

        sliders2.addWidget(&Sexposure);
        lineedits2.addWidget(&Lexposure, 2);
        names2.addWidget(&Nexposure, 1);

        centralbox2.addLayout(&names2);
        centralbox2.addLayout(&sliders2);
        centralbox2.addLayout(&lineedits2);
        page2.setLayout( &centralbox2 );


        QHBoxLayout buttons;
        buttons.setMargin(5);
        QPushButton Baccept;
        Baccept.setText(tr("Accept"));
        connect(&Baccept, SIGNAL(clicked()), &dialog, SLOT(accept()));
        QPushButton Bcancel;
        Bcancel.setText(tr("Cancel"));
        connect(&Bcancel, SIGNAL(clicked()), &dialog, SLOT(reject()));
        QPushButton Bdefault;
        Bdefault.setText(tr("Default"));
        connect(&Bdefault, SIGNAL(clicked()), this, SLOT(set_default_settings()));
        buttons.addWidget(&Baccept);
        buttons.addWidget(&Bcancel);
        buttons.addWidget(&Bdefault);

        tabwidget.addTab(&page1, "Brightness/Contrast");
        tabwidget.addTab(&page2, "Gain/Exposure");
        toplevellayout.addWidget(&tabwidget);
        toplevellayout.addLayout(&buttons);
        dialog.setLayout(&toplevellayout);
        //DIALOG CONSTRUCTION END//
        dialog.exec();
        return true;
    }