Exemple #1
0
void LightDialog::lightChanged(int i) {
    disconnectControls();

    currLight = i;
    lightSpinBox->setValue(currLight);

    //load new light
    Light light = renderer->getLight(i);
    lightEnable->setChecked(light.isEnabled);

    Color a = light.ambient;
    Color d = light.diffuse;
    Color s = light.specular;
    Vector3f p = light.pos;

    ar->setValue(int(a.r*100)); ag->setValue(int(a.g*100)); ab->setValue(int(a.b*100));
    dr->setValue(int(d.r*100)); dg->setValue(int(d.g*100)); db->setValue(int(d.b*100));
    sr->setValue(int(s.r*100)); sg->setValue(int(s.g*100)); sb->setValue(int(s.b*100));

    px->setValue( int(p.x / LIGHT_MAX_X * 100) );
    py->setValue( int(p.y / LIGHT_MAX_Y * 100) );
    pz->setValue( int(p.z / LIGHT_MAX_Z * 100) );
    //px->setText(QString::number(p.x)); py->setText(QString::number(p.y)); pz->setText(QString::number(p.z));

    typeComboBox->setCurrentIndex((int)p.w);

    connectControls();
}
Exemple #2
0
LightDialog::LightDialog(Renderer *renderer, QWidget *parent) : QDialog(parent) {
    Ui_lightDialog::setupUi(this);

    lightSpinBox->setRange(0,NUM_LIGHTS-1);
    currLight = lightSpinBox->value();

    //QRegExpValidator *rgbValidator = new QRegExpValidator(QRegExp("^(-{0,1}[01]|-{0,1}[01]{0,1}\\.\\d{1,8})$"), this);

    /*ar->setValidator(rgbValidator);
    ag->setValidator(rgbValidator);
    ab->setValidator(rgbValidator);

    dr->setValidator(rgbValidator);
    dg->setValidator(rgbValidator);
    db->setValidator(rgbValidator);

    sr->setValidator(rgbValidator);
    sg->setValidator(rgbValidator);
    sb->setValidator(rgbValidator);*/

    /*QDoubleValidator *doubleValidator = new QDoubleValidator(this);
    px->setValidator(doubleValidator);
    py->setValidator(doubleValidator);
    pz->setValidator(doubleValidator);*/

    typeComboBox->addItem("Directional");
    typeComboBox->addItem("Positional");

    this->renderer = renderer;
    connectControls();
}
Exemple #3
0
void EMainWindow::changePainting(int index)
{
	if (index == -1) {												//	если удалили последнюю вкладку - обнуляем все
		_currentPainting = 0;
		_currentView = 0;
		return;
	}
	if (_tabs.size() <= index) return;
	if (_currentPainting)
		disconnectControls(_currentPainting);						//	отсоединяем контроллеры
	_currentPainting = _tabs[index].painting;						//	обновляем указатели
	_currentView = _tabs[index].view;
        connectControls(_currentPainting);							//	присоединяем контроллеры
}
Exemple #4
0
void EMainWindow::createPainting()
{
        EPainting *newPainting = new EPainting(this);				//	создаем объекты вида и сцены
	EGraphicsView *newView = new EGraphicsView(newPainting);
	QRectF sRect = newPainting->sceneRect();
	newView->setSceneRect(sRect.left() - 100, sRect.top() - 100,
						  sRect.width() + 200, sRect.height() + 200);

        setUpdatesEnabled(false);						//	создаем вкладку в TabWidget
	int tabIndex = _mainUi.tabWidget->addTab(newView, "");
	if (_mainUi.tabWidget->currentIndex() == tabIndex) {			//	на случай, если создается 1я вкладка
                connectControls(newPainting);					//	тогда фокус сразу же переключается на нее
		_currentPainting = newPainting;
		_currentView = newView;
	}
	setUpdatesEnabled(true);
        _mainUi.tabWidget->setTabText(tabIndex, tr("Untitled-%1").arg(tabIndex));

	if (_tabs.size() <= tabIndex) _tabs.resize(tabIndex + 1);		//	вносим указатели в _tabs
	_tabs[tabIndex] = TabStruct(tabIndex, newPainting, newView);

        _mainUi.tabWidget->setCurrentIndex(tabIndex);				//	делаем новую картину текущей
}