1
git-svn-id: svn://db.shs.com.ru/libs@1 a8b55f48-bf90-11e4-a774-851b48703e85
This commit is contained in:
119
qglview/globject_editor.cpp
Normal file
119
qglview/globject_editor.cpp
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
QGLView
|
||||
Copyright (C) 2012 Ivan Pelipenko peri4ko@gmail.com
|
||||
|
||||
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 program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "globject_editor.h"
|
||||
|
||||
|
||||
GLObjectEditor::GLObjectEditor(QWidget * parent): QWidget(parent) {
|
||||
setupUi(this);
|
||||
active = true;
|
||||
object = 0;
|
||||
rmodes << GLObjectBase::View << GLObjectBase::Point << GLObjectBase::Line << GLObjectBase::Fill;
|
||||
groupLight->setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
void GLObjectEditor::changeEvent(QEvent * e) {
|
||||
return;
|
||||
QWidget::changeEvent(e);
|
||||
switch (e->type()) {
|
||||
case QEvent::LanguageChange:
|
||||
retranslateUi(this);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void GLObjectEditor::setObject(GLObjectBase * o) {
|
||||
object = o;
|
||||
if (object == 0) {
|
||||
groupLight->setEnabled(false);
|
||||
return;
|
||||
}
|
||||
active = false;
|
||||
spinPosX->setValue(object->posX());
|
||||
spinPosY->setValue(object->posY());
|
||||
spinPosZ->setValue(object->posZ());
|
||||
spinRotationX->setValue(object->rotationX());
|
||||
spinRotationY->setValue(object->rotationY());
|
||||
spinRotationZ->setValue(object->rotationZ());
|
||||
spinScaleX->setValue(object->scaleX());
|
||||
spinScaleY->setValue(object->scaleY());
|
||||
spinScaleZ->setValue(object->scaleZ());
|
||||
spinLineWidth->setValue(object->lineWidth());
|
||||
checkVisible->setChecked(object->isVisible());
|
||||
checkAcceptLight->setChecked(object->isAcceptLight());
|
||||
checkAcceptFog->setChecked(object->isAcceptFog());
|
||||
checkCastShadows->setChecked(object->isCastShadows());
|
||||
checkReceiveShadows->setChecked(object->isReceiveShadows());
|
||||
comboRenderMode->setCurrentIndex(rmodes.indexOf(object->renderMode()));
|
||||
groupLight->setEnabled(object->type() == GLObjectBase::Light);
|
||||
if (object->type() == GLObjectBase::Light) {
|
||||
Light * l = globject_cast<Light * >(object);
|
||||
//bool is_dir = l->light_type == Light::Directional, is_cone = l->light_type == Light::Cone;
|
||||
buttonLightColor->setColor(l->color());
|
||||
comboLightType->setCurrentIndex(l->light_type);
|
||||
spinLightIntensity->setValue(l->intensity);
|
||||
spinLightDecayConst->setValue(l->decay_const);
|
||||
spinLightDecayLinear->setValue(l->decay_linear);
|
||||
spinLightDecayQuadratic->setValue(l->decay_quadratic);
|
||||
spinLightAngleSpread->setValue(l->angle_spread);
|
||||
spinLightAngleDecayExp->setValue(l->angle_decay_exp);
|
||||
spinLightDirectionX->setValue(l->direction.x());
|
||||
spinLightDirectionY->setValue(l->direction.y());
|
||||
spinLightDirectionZ->setValue(l->direction.z());
|
||||
}
|
||||
active = true;
|
||||
}
|
||||
|
||||
|
||||
void GLObjectEditor::objectChanged() {
|
||||
if (!active || object == 0) return;
|
||||
object->setPosX(spinPosX->value());
|
||||
object->setPosY(spinPosY->value());
|
||||
object->setPosZ(spinPosZ->value());
|
||||
object->setRotationX(spinRotationX->value());
|
||||
object->setRotationY(spinRotationY->value());
|
||||
object->setRotationZ(spinRotationZ->value());
|
||||
object->setScaleX(spinScaleX->value());
|
||||
object->setScaleY(spinScaleY->value());
|
||||
object->setScaleZ(spinScaleZ->value());
|
||||
object->setLineWidth(spinLineWidth->value());
|
||||
object->setVisible(checkVisible->isChecked());
|
||||
object->setAcceptLight(checkAcceptLight->isChecked());
|
||||
object->setAcceptFog(checkAcceptFog->isChecked());
|
||||
object->setCastShadows(checkCastShadows->isChecked());
|
||||
object->setReceiveShadows(checkReceiveShadows->isChecked());
|
||||
object->setRenderMode((GLObjectBase::RenderMode)rmodes[comboRenderMode->currentIndex()]);
|
||||
if (object->type() == GLObjectBase::Light) {
|
||||
Light * l = globject_cast<Light * >(object);
|
||||
//bool is_dir = l->light_type == Light::Directional, is_cone = l->light_type == Light::Cone;
|
||||
l->setColor(buttonLightColor->color());
|
||||
l->light_type = (Light::Type)comboLightType->currentIndex();
|
||||
l->intensity = spinLightIntensity->value();
|
||||
l->decay_const = spinLightDecayConst->value();
|
||||
l->decay_linear = spinLightDecayLinear->value();
|
||||
l->decay_quadratic = spinLightDecayQuadratic->value();
|
||||
l->angle_spread = spinLightAngleSpread->value();
|
||||
l->angle_decay_exp = spinLightAngleDecayExp->value();
|
||||
l->direction = QVector3D(spinLightDirectionX->value(), spinLightDirectionY->value(), spinLightDirectionZ->value()).normalized();
|
||||
}
|
||||
emit changed();
|
||||
}
|
||||
Reference in New Issue
Block a user