git-svn-id: svn://db.shs.com.ru/libs@626 a8b55f48-bf90-11e4-a774-851b48703e85

This commit is contained in:
2019-11-22 15:20:52 +00:00
parent 5e2b563d57
commit 09248aae34
128 changed files with 16038 additions and 0 deletions

View File

@@ -0,0 +1,107 @@
/*
QGLView
Copyright (C) 2019 Ivan Pelipenko peri4ko@yandex.ru
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this programap-> If not, see <http://www.gnu.org/licenses/>.
*/
#include "material_map_editor.h"
#include "ui_material_map_editor.h"
#include "glmaterial.h"
MaterialMapEditor::MaterialMapEditor(QWidget * parent): QWidget(parent) {
ui = new Ui::MaterialMapEditor();
ui->setupUi(this);
active = true;
}
void MaterialMapEditor::changeEvent(QEvent * e) {
QWidget::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void MaterialMapEditor::resizeEvent(QResizeEvent * e) {
ui->iconedLabel->setFixedWidth(ui->iconedLabel->height());
ui->iconedLabel->setIconSize(ui->iconedLabel->size());
}
void MaterialMapEditor::updateIcon() {
ui->iconedLabel->setIcon(QIcon(ui->linePath->property("GLpath").toString()));
}
void MaterialMapEditor::mapChanged() {
if (!active || !map) return;
map->color_amount = ui->sliderAmount->value();
map->color_offset = ui->sliderOffset->value();
map->bitmap_scale.setX(ui->spinScaleX->value());
map->bitmap_scale.setY(ui->spinScaleY->value());
emit changed();
}
void MaterialMapEditor::setMap(Map * m) {
active = false;
map = m;
setEnabled(m);
if (!map) return;
ui->sliderAmount->setValue(map->color_amount);
ui->sliderOffset->setValue(map->color_offset);
ui->spinScaleX->setValue(map->bitmap_scale.x());
ui->spinScaleY->setValue(map->bitmap_scale.y());
ui->linePath->setProperty("GLpath", map->bitmap_path); ui->linePath->setText(QFileInfo(map->bitmap_path).fileName());
updateIcon();
active = true;
}
/*
Map MaterialMapEditor::map() {
Map m;
map->color_amount = ui->sliderAmount->value();
map->color_offset = ui->sliderOffset->value();
map->bitmap_scale.setX(ui->spinScaleX->value());
map->bitmap_scale.setY(ui->spinScaleY->value());
map->bitmap_path = ui->linePath->property("GLpath").toString();
return m;
}
*/
void MaterialMapEditor::on_buttonSelect_clicked() {
QString str = QFileDialog::getOpenFileName(this, "Select image", ui->linePath->property("GLpath").toString(), "Images(*.bmp *.jpg *.jpeg *.png *.tif *.tiff *.tga);;All files(*)");
if (str.isEmpty()) return;
ui->linePath->setProperty("GLpath", str);
ui->linePath->setText(QFileInfo(str).fileName());
map->setBitmapPath(str);
updateIcon();
mapChanged();
}
void MaterialMapEditor::on_buttonClear_clicked() {
ui->linePath->setText("");
ui->linePath->setProperty("GLpath", "");
map->clearBitmap();
updateIcon();
mapChanged();
}