code format
This commit is contained in:
@@ -1,40 +1,41 @@
|
||||
/*
|
||||
QGL MaterialEditor
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
QGL MaterialEditor
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "material_editor.h"
|
||||
#include "ui_material_editor.h"
|
||||
|
||||
#include "glmaterial.h"
|
||||
#include "ui_material_editor.h"
|
||||
|
||||
|
||||
MaterialEditor::MaterialEditor(QWidget * parent): QWidget(parent) {
|
||||
ui = new Ui::MaterialEditor();
|
||||
ui->setupUi(this);
|
||||
ui->mapDiffuse ->configure(tr("Diffuse"), true);
|
||||
ui->mapNormal ->configure(tr("Normal"));
|
||||
ui->mapDiffuse->configure(tr("Diffuse"), true);
|
||||
ui->mapNormal->configure(tr("Normal"));
|
||||
ui->mapMetalness->configure(tr("Metalness"));
|
||||
ui->mapRoughness->configure(tr("Roughness"));
|
||||
ui->mapEmission ->configure(tr("Emission"), true);
|
||||
ui->mapRelief ->configure(tr("Relief"));
|
||||
ui->mapEmission->configure(tr("Emission"), true);
|
||||
ui->mapRelief->configure(tr("Relief"));
|
||||
ui->checkGlass->hide();
|
||||
ui->frameReflection->hide();
|
||||
ui->label_13->hide();
|
||||
mat = 0;
|
||||
active = true;
|
||||
mat = 0;
|
||||
active = true;
|
||||
ignore_next = 0;
|
||||
}
|
||||
|
||||
@@ -42,90 +43,94 @@ MaterialEditor::MaterialEditor(QWidget * parent): QWidget(parent) {
|
||||
void MaterialEditor::changeEvent(QEvent * e) {
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
ui->retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
case QEvent::LanguageChange: ui->retranslateUi(this); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MaterialEditor::materialChanged() {
|
||||
if (!active || !mat) return;
|
||||
ignore_next = 2;
|
||||
mat->_changed = true;
|
||||
mat->color_diffuse = ui->mapDiffuse ->color();
|
||||
ignore_next = 2;
|
||||
mat->_changed = true;
|
||||
mat->color_diffuse = ui->mapDiffuse->color();
|
||||
mat->color_emission = ui->mapEmission->color();
|
||||
mat->transparency = ui->spinTransparent->value();
|
||||
mat->reflectivity = ui->spinReflect->value();
|
||||
mat->iof = ui->spinIOF->value();
|
||||
mat->dispersion = ui->spinDispersion->value();
|
||||
mat->glass = ui->checkGlass->isChecked();
|
||||
//emit changed();
|
||||
mat->transparency = ui->spinTransparent->value();
|
||||
mat->reflectivity = ui->spinReflect->value();
|
||||
mat->iof = ui->spinIOF->value();
|
||||
mat->dispersion = ui->spinDispersion->value();
|
||||
mat->glass = ui->checkGlass->isChecked();
|
||||
// emit changed();
|
||||
}
|
||||
|
||||
|
||||
void MaterialEditor::setMaterial(Material * m) {
|
||||
if (ignore_next > 0) {
|
||||
//ignore_next = false;
|
||||
// ignore_next = false;
|
||||
return;
|
||||
}
|
||||
active = false;
|
||||
mat = m;
|
||||
mat = m;
|
||||
setEnabled(m);
|
||||
if (!mat) return;
|
||||
ui->mapDiffuse ->setColor(mat->color_diffuse );
|
||||
ui->mapDiffuse->setColor(mat->color_diffuse);
|
||||
ui->mapEmission->setColor(mat->color_emission);
|
||||
ui->spinTransparent->setValue(mat->transparency);
|
||||
ui->spinReflect->setValue(mat->reflectivity);
|
||||
ui->spinIOF->setValue(mat->iof);
|
||||
ui->spinDispersion->setValue(mat->dispersion);
|
||||
ui->checkGlass->setChecked(mat->glass);
|
||||
ui->mapDiffuse ->setMap(&(mat->map_diffuse ));
|
||||
ui->mapNormal ->setMap(&(mat->map_normal ));
|
||||
ui->mapDiffuse->setMap(&(mat->map_diffuse));
|
||||
ui->mapNormal->setMap(&(mat->map_normal));
|
||||
ui->mapMetalness->setMap(&(mat->map_metalness));
|
||||
ui->mapRoughness->setMap(&(mat->map_roughness));
|
||||
ui->mapEmission ->setMap(&(mat->map_emission ));
|
||||
ui->mapRelief ->setMap(&(mat->map_relief ));
|
||||
/*ui->lineReflFront->setProperty("GLpath", mat->map_reflection.path(0)); ui->lineReflFront->setText(QFileInfo(mat->map_reflection.path(0)).fileName());
|
||||
ui->lineReflBack->setProperty("GLpath", mat->map_reflection.path(1)); ui->lineReflBack->setText(QFileInfo(mat->map_reflection.path(1)).fileName());
|
||||
ui->lineReflLeft->setProperty("GLpath", mat->map_reflection.path(2)); ui->lineReflLeft->setText(QFileInfo(mat->map_reflection.path(2)).fileName());
|
||||
ui->lineReflRight->setProperty("GLpath", mat->map_reflection.path(3)); ui->lineReflRight->setText(QFileInfo(mat->map_reflection.path(3)).fileName());
|
||||
ui->lineReflTop->setProperty("GLpath", mat->map_reflection.path(4)); ui->lineReflTop->setText(QFileInfo(mat->map_reflection.path(4)).fileName());
|
||||
ui->lineReflBottom->setProperty("GLpath", mat->map_reflection.path(5)); ui->lineReflBottom->setText(QFileInfo(mat->map_reflection.path(5)).fileName());
|
||||
*/active = true;
|
||||
ui->mapEmission->setMap(&(mat->map_emission));
|
||||
ui->mapRelief->setMap(&(mat->map_relief));
|
||||
/*ui->lineReflFront->setProperty("GLpath", mat->map_reflection.path(0));
|
||||
ui->lineReflFront->setText(QFileInfo(mat->map_reflection.path(0)).fileName()); ui->lineReflBack->setProperty("GLpath",
|
||||
mat->map_reflection.path(1)); ui->lineReflBack->setText(QFileInfo(mat->map_reflection.path(1)).fileName());
|
||||
ui->lineReflLeft->setProperty("GLpath", mat->map_reflection.path(2));
|
||||
ui->lineReflLeft->setText(QFileInfo(mat->map_reflection.path(2)).fileName()); ui->lineReflRight->setProperty("GLpath",
|
||||
mat->map_reflection.path(3)); ui->lineReflRight->setText(QFileInfo(mat->map_reflection.path(3)).fileName());
|
||||
ui->lineReflTop->setProperty("GLpath", mat->map_reflection.path(4));
|
||||
ui->lineReflTop->setText(QFileInfo(mat->map_reflection.path(4)).fileName()); ui->lineReflBottom->setProperty("GLpath",
|
||||
mat->map_reflection.path(5)); ui->lineReflBottom->setText(QFileInfo(mat->map_reflection.path(5)).fileName());
|
||||
*/
|
||||
active = true;
|
||||
}
|
||||
|
||||
/*
|
||||
Material MaterialEditor::material() {
|
||||
Material m;
|
||||
mat->color_diffuse = ui->colorDiffuse ->color();
|
||||
mat->color_specular = ui->colorSpecular->color();
|
||||
mat->color_emission = ui->colorEmission->color();
|
||||
mat->transparency = ui->spinTransparent->value();
|
||||
mat->reflectivity = ui->spinReflect->value();
|
||||
mat->iof = ui->spinIOF->value();
|
||||
mat->dispersion = ui->spinDispersion->value();
|
||||
mat->glass = ui->checkGlass->isChecked();
|
||||
mat->map_diffuse = ui->mapDiffuse->map();
|
||||
mat->map_normal = ui->mapNormal->map();
|
||||
mat->map_specular = ui->mapSpecular->map();
|
||||
mat->map_roughness = ui->mapRoughness->map();
|
||||
mat->map_emission = ui->mapEmission->map();
|
||||
mat->map_relief = ui->mapRelief->map();
|
||||
mat->map_reflection.setPath(0, ui->lineReflFront->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(1, ui->lineReflBack->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(2, ui->lineReflLeft->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(3, ui->lineReflRight->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(4, ui->lineReflTop->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(5, ui->lineReflBottom->property("GLpath").toString());
|
||||
return m;
|
||||
Material m;
|
||||
mat->color_diffuse = ui->colorDiffuse ->color();
|
||||
mat->color_specular = ui->colorSpecular->color();
|
||||
mat->color_emission = ui->colorEmission->color();
|
||||
mat->transparency = ui->spinTransparent->value();
|
||||
mat->reflectivity = ui->spinReflect->value();
|
||||
mat->iof = ui->spinIOF->value();
|
||||
mat->dispersion = ui->spinDispersion->value();
|
||||
mat->glass = ui->checkGlass->isChecked();
|
||||
mat->map_diffuse = ui->mapDiffuse->map();
|
||||
mat->map_normal = ui->mapNormal->map();
|
||||
mat->map_specular = ui->mapSpecular->map();
|
||||
mat->map_roughness = ui->mapRoughness->map();
|
||||
mat->map_emission = ui->mapEmission->map();
|
||||
mat->map_relief = ui->mapRelief->map();
|
||||
mat->map_reflection.setPath(0, ui->lineReflFront->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(1, ui->lineReflBack->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(2, ui->lineReflLeft->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(3, ui->lineReflRight->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(4, ui->lineReflTop->property("GLpath").toString());
|
||||
mat->map_reflection.setPath(5, ui->lineReflBottom->property("GLpath").toString());
|
||||
return m;
|
||||
}
|
||||
*/
|
||||
|
||||
void MaterialEditor::on_buttonReflFrontSelect_clicked() {
|
||||
QString str = QFileDialog::getOpenFileName(this, "Select image", ui->lineReflFront->property("GLpath").toString(), "Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
QString str = QFileDialog::getOpenFileName(this,
|
||||
"Select image",
|
||||
ui->lineReflFront->property("GLpath").toString(),
|
||||
"Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
if (str.isEmpty()) return;
|
||||
ui->lineReflFront->setProperty("GLpath", str);
|
||||
ui->lineReflFront->setText(QFileInfo(str).fileName());
|
||||
@@ -134,7 +139,10 @@ void MaterialEditor::on_buttonReflFrontSelect_clicked() {
|
||||
|
||||
|
||||
void MaterialEditor::on_buttonReflBackSelect_clicked() {
|
||||
QString str = QFileDialog::getOpenFileName(this, "Select image", ui->lineReflBack->property("GLpath").toString(), "Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
QString str = QFileDialog::getOpenFileName(this,
|
||||
"Select image",
|
||||
ui->lineReflBack->property("GLpath").toString(),
|
||||
"Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
if (str.isEmpty()) return;
|
||||
ui->lineReflBack->setProperty("GLpath", str);
|
||||
ui->lineReflBack->setText(QFileInfo(str).fileName());
|
||||
@@ -143,7 +151,10 @@ void MaterialEditor::on_buttonReflBackSelect_clicked() {
|
||||
|
||||
|
||||
void MaterialEditor::on_buttonReflLeftSelect_clicked() {
|
||||
QString str = QFileDialog::getOpenFileName(this, "Select image", ui->lineReflLeft->property("GLpath").toString(), "Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
QString str = QFileDialog::getOpenFileName(this,
|
||||
"Select image",
|
||||
ui->lineReflLeft->property("GLpath").toString(),
|
||||
"Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
if (str.isEmpty()) return;
|
||||
ui->lineReflLeft->setProperty("GLpath", str);
|
||||
ui->lineReflLeft->setText(QFileInfo(str).fileName());
|
||||
@@ -152,7 +163,10 @@ void MaterialEditor::on_buttonReflLeftSelect_clicked() {
|
||||
|
||||
|
||||
void MaterialEditor::on_buttonReflRightSelect_clicked() {
|
||||
QString str = QFileDialog::getOpenFileName(this, "Select image", ui->lineReflRight->property("GLpath").toString(), "Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
QString str = QFileDialog::getOpenFileName(this,
|
||||
"Select image",
|
||||
ui->lineReflRight->property("GLpath").toString(),
|
||||
"Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
if (str.isEmpty()) return;
|
||||
ui->lineReflRight->setProperty("GLpath", str);
|
||||
ui->lineReflRight->setText(QFileInfo(str).fileName());
|
||||
@@ -161,7 +175,10 @@ void MaterialEditor::on_buttonReflRightSelect_clicked() {
|
||||
|
||||
|
||||
void MaterialEditor::on_buttonReflTopSelect_clicked() {
|
||||
QString str = QFileDialog::getOpenFileName(this, "Select image", ui->lineReflTop->property("GLpath").toString(), "Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
QString str = QFileDialog::getOpenFileName(this,
|
||||
"Select image",
|
||||
ui->lineReflTop->property("GLpath").toString(),
|
||||
"Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
if (str.isEmpty()) return;
|
||||
ui->lineReflTop->setProperty("GLpath", str);
|
||||
ui->lineReflTop->setText(QFileInfo(str).fileName());
|
||||
@@ -170,7 +187,10 @@ void MaterialEditor::on_buttonReflTopSelect_clicked() {
|
||||
|
||||
|
||||
void MaterialEditor::on_buttonReflBottomSelect_clicked() {
|
||||
QString str = QFileDialog::getOpenFileName(this, "Select image", ui->lineReflBottom->property("GLpath").toString(), "Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
QString str = QFileDialog::getOpenFileName(this,
|
||||
"Select image",
|
||||
ui->lineReflBottom->property("GLpath").toString(),
|
||||
"Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
|
||||
if (str.isEmpty()) return;
|
||||
ui->lineReflBottom->setProperty("GLpath", str);
|
||||
ui->lineReflBottom->setText(QFileInfo(str).fileName());
|
||||
|
||||
Reference in New Issue
Block a user