code format
This commit is contained in:
@@ -1,33 +1,35 @@
|
||||
/*
|
||||
QGL ObjectEditor
|
||||
Ivan Pelipenko peri4ko@yandex.ru
|
||||
QGL ObjectEditor
|
||||
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 "object_editor.h"
|
||||
#include "ui_object_editor.h"
|
||||
|
||||
#include "qglview.h"
|
||||
#include <spinslider.h>
|
||||
#include "ui_object_editor.h"
|
||||
|
||||
#include <scroll_spin_box.h>
|
||||
#include <spinslider.h>
|
||||
|
||||
|
||||
ObjectEditor::ObjectEditor(QWidget * parent): QWidget(parent) {
|
||||
ui = new Ui::ObjectEditor();
|
||||
ui->setupUi(this);
|
||||
view = 0;
|
||||
active = true;
|
||||
view = 0;
|
||||
active = true;
|
||||
ignore_next = false;
|
||||
on_comboLightType_currentIndexChanged(0);
|
||||
ui->widgetMain->setEnabled(false);
|
||||
@@ -35,31 +37,27 @@ ObjectEditor::ObjectEditor(QWidget * parent): QWidget(parent) {
|
||||
ui->spinAimDist->hide();
|
||||
|
||||
QObjectList ol;
|
||||
ol << ui->spinPosX << ui->spinPosY << ui->spinPosZ <<
|
||||
ui->spinRotationX << ui->spinRotationY << ui->spinRotationZ <<
|
||||
ui->spinScaleX << ui->spinScaleY << ui->spinScaleZ;
|
||||
foreach (QObject * o, ol)
|
||||
ol << ui->spinPosX << ui->spinPosY << ui->spinPosZ << ui->spinRotationX << ui->spinRotationY << ui->spinRotationZ << ui->spinScaleX
|
||||
<< ui->spinScaleY << ui->spinScaleZ;
|
||||
foreach(QObject * o, ol)
|
||||
connect(o, SIGNAL(valueChanged(double)), this, SLOT(spinChanged(double)));
|
||||
|
||||
ol.clear();
|
||||
ol << ui->spinLightIntensity << ui->spinLightDecayConst << ui->spinLightDecayLinear <<
|
||||
ui->spinLightDecayQuadratic << ui->spinLightAngleStart << ui->spinLightAngleEnd <<
|
||||
ui->spinAimDist;
|
||||
foreach (QObject * o, ol)
|
||||
ol << ui->spinLightIntensity << ui->spinLightDecayConst << ui->spinLightDecayLinear << ui->spinLightDecayQuadratic
|
||||
<< ui->spinLightAngleStart << ui->spinLightAngleEnd << ui->spinAimDist;
|
||||
foreach(QObject * o, ol)
|
||||
connect(o, SIGNAL(valueChanged(double)), this, SLOT(spinLightChanged(double)));
|
||||
|
||||
ol.clear();
|
||||
ol << ui->spinCameraFOV << ui->spinCameraDepthStart << ui->spinCameraRoll << ui->spinAimDist;
|
||||
foreach (QObject * o, ol)
|
||||
foreach(QObject * o, ol)
|
||||
connect(o, SIGNAL(valueChanged(double)), this, SLOT(spinCameraChanged(double)));
|
||||
|
||||
ol.clear();
|
||||
ol << ui->checkVisible << ui->checkCastShadows << ui->checkReceiveShadows <<
|
||||
ui->checkAcceptLight << ui->checkAcceptFog <<
|
||||
ui->checkCameraMirrorX << ui->checkCameraMirrorY;
|
||||
foreach (QObject * o, ol)
|
||||
ol << ui->checkVisible << ui->checkCastShadows << ui->checkReceiveShadows << ui->checkAcceptLight << ui->checkAcceptFog
|
||||
<< ui->checkCameraMirrorX << ui->checkCameraMirrorY;
|
||||
foreach(QObject * o, ol)
|
||||
connect(o, SIGNAL(toggled(bool)), this, SLOT(checkChanged(bool)));
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -75,11 +73,8 @@ void ObjectEditor::assignQGLView(QGLView * v) {
|
||||
void ObjectEditor::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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,10 +97,10 @@ void ObjectEditor::selectionChanged() {
|
||||
return;
|
||||
}
|
||||
bool hl = !view->selectedLights().isEmpty(), hc = !view->selectedCameras().isEmpty();
|
||||
ui->groupLight ->setVisible(hl);
|
||||
ui->groupCamera ->setVisible(hc);
|
||||
ui->groupLight->setVisible(hl);
|
||||
ui->groupCamera->setVisible(hc);
|
||||
ui->labelAimDist->setVisible(hl || hc);
|
||||
ui->spinAimDist ->setVisible(hl || hc);
|
||||
ui->spinAimDist->setVisible(hl || hc);
|
||||
ui->labelTitle->setText(tr("[%1 objects]").arg(sol.size()));
|
||||
}
|
||||
|
||||
@@ -131,12 +126,12 @@ void ObjectEditor::setObject(ObjectBase * o) {
|
||||
bool is_l = o->type() == ObjectBase::glLight;
|
||||
bool is_c = o->type() == ObjectBase::glCamera;
|
||||
ui->labelAimDist->setVisible(is_l || is_c);
|
||||
ui->spinAimDist ->setVisible(is_l || is_c);
|
||||
ui->groupLight ->setVisible(is_l);
|
||||
ui->groupCamera ->setVisible(is_c);
|
||||
ui->spinAimDist->setVisible(is_l || is_c);
|
||||
ui->groupLight->setVisible(is_l);
|
||||
ui->groupCamera->setVisible(is_c);
|
||||
if (is_l) {
|
||||
Light * l = globject_cast<Light * >(o);
|
||||
//bool is_dir = l->light_type == Light::Directional, is_cone = l->light_type == Light::Cone;
|
||||
Light * l = globject_cast<Light *>(o);
|
||||
// bool is_dir = l->light_type == Light::Directional, is_cone = l->light_type == Light::Cone;
|
||||
ui->comboLightType->setCurrentIndex(l->light_type);
|
||||
ui->spinLightIntensity->setValue(l->intensity);
|
||||
ui->spinLightDecayConst->setValue(l->decay_const);
|
||||
@@ -148,7 +143,7 @@ void ObjectEditor::setObject(ObjectBase * o) {
|
||||
on_comboLightType_currentIndexChanged(ui->comboLightType->currentIndex());
|
||||
}
|
||||
if (is_c) {
|
||||
Camera * c = globject_cast<Camera * >(o);
|
||||
Camera * c = globject_cast<Camera *>(o);
|
||||
ui->checkCameraMirrorX->setChecked(c->isMirrorX());
|
||||
ui->checkCameraMirrorY->setChecked(c->isMirrorY());
|
||||
ui->spinCameraFOV->setValue(c->FOV());
|
||||
@@ -161,26 +156,24 @@ void ObjectEditor::setObject(ObjectBase * o) {
|
||||
|
||||
|
||||
void ObjectEditor::on_spinLightAngleStart_valueChanged(double v) {
|
||||
if (ui->spinLightAngleEnd->value() < v)
|
||||
ui->spinLightAngleEnd->setValue(v);
|
||||
if (ui->spinLightAngleEnd->value() < v) ui->spinLightAngleEnd->setValue(v);
|
||||
}
|
||||
|
||||
|
||||
void ObjectEditor::on_spinLightAngleEnd_valueChanged(double v) {
|
||||
if (ui->spinLightAngleStart->value() > v)
|
||||
ui->spinLightAngleStart->setValue(v);
|
||||
if (ui->spinLightAngleStart->value() > v) ui->spinLightAngleStart->setValue(v);
|
||||
}
|
||||
|
||||
|
||||
void ObjectEditor::on_comboLightType_currentIndexChanged(int index) {
|
||||
bool ang = (index == Light::Cone);
|
||||
ui->labelLightAngle ->setVisible(ang);
|
||||
ui->labelLightAngle->setVisible(ang);
|
||||
ui->labelLightAngleDash->setVisible(ang);
|
||||
ui->spinLightAngleStart->setVisible(ang);
|
||||
ui->spinLightAngleEnd ->setVisible(ang);
|
||||
ui->spinLightAngleEnd->setVisible(ang);
|
||||
if (!view || !active) return;
|
||||
QList<Light*> sll = view->selectedLights();
|
||||
foreach (Light * o, sll) {
|
||||
QList<Light *> sll = view->selectedLights();
|
||||
foreach(Light * o, sll) {
|
||||
o->light_type = (Light::Type)index;
|
||||
o->apply();
|
||||
}
|
||||
@@ -190,10 +183,10 @@ void ObjectEditor::on_comboLightType_currentIndexChanged(int index) {
|
||||
void ObjectEditor::on_buttonColor_colorChanged(const QColor & v) {
|
||||
if (!view || !active) return;
|
||||
ObjectBaseList sol = view->selectedObjects();
|
||||
foreach (ObjectBase * o, sol)
|
||||
foreach(ObjectBase * o, sol)
|
||||
o->setColor(v);
|
||||
QList<Light*> sll = view->selectedLights();
|
||||
foreach (Light * o, sll)
|
||||
QList<Light *> sll = view->selectedLights();
|
||||
foreach(Light * o, sll)
|
||||
o->apply();
|
||||
}
|
||||
|
||||
@@ -201,17 +194,17 @@ void ObjectEditor::on_buttonColor_colorChanged(const QColor & v) {
|
||||
void ObjectEditor::spinChanged(double v) {
|
||||
if (!view || !active) return;
|
||||
ObjectBaseList sol = view->selectedObjects(true);
|
||||
QObject * s = sender();
|
||||
foreach (ObjectBase * o, sol) {
|
||||
if (s == ui->spinPosX ) o->setPosX (v);
|
||||
if (s == ui->spinPosY ) o->setPosY (v);
|
||||
if (s == ui->spinPosZ ) o->setPosZ (v);
|
||||
QObject * s = sender();
|
||||
foreach(ObjectBase * o, sol) {
|
||||
if (s == ui->spinPosX) o->setPosX(v);
|
||||
if (s == ui->spinPosY) o->setPosY(v);
|
||||
if (s == ui->spinPosZ) o->setPosZ(v);
|
||||
if (s == ui->spinRotationX) o->setRotationX(v);
|
||||
if (s == ui->spinRotationY) o->setRotationY(v);
|
||||
if (s == ui->spinRotationZ) o->setRotationZ(v);
|
||||
if (s == ui->spinScaleX ) o->setScaleX (v);
|
||||
if (s == ui->spinScaleY ) o->setScaleY (v);
|
||||
if (s == ui->spinScaleZ ) o->setScaleZ (v);
|
||||
if (s == ui->spinScaleX) o->setScaleX(v);
|
||||
if (s == ui->spinScaleY) o->setScaleY(v);
|
||||
if (s == ui->spinScaleZ) o->setScaleZ(v);
|
||||
}
|
||||
ignore_next = true;
|
||||
}
|
||||
@@ -219,16 +212,16 @@ void ObjectEditor::spinChanged(double v) {
|
||||
|
||||
void ObjectEditor::spinLightChanged(double v) {
|
||||
if (!view || !active) return;
|
||||
QList<Light*> sll = view->selectedLights();
|
||||
QObject * s = sender();
|
||||
foreach (Light * o, sll) {
|
||||
if (s == ui->spinLightIntensity ) o->intensity = v;
|
||||
if (s == ui->spinLightDecayConst ) o->decay_const = v;
|
||||
if (s == ui->spinLightDecayLinear ) o->decay_linear = v;
|
||||
QList<Light *> sll = view->selectedLights();
|
||||
QObject * s = sender();
|
||||
foreach(Light * o, sll) {
|
||||
if (s == ui->spinLightIntensity) o->intensity = v;
|
||||
if (s == ui->spinLightDecayConst) o->decay_const = v;
|
||||
if (s == ui->spinLightDecayLinear) o->decay_linear = v;
|
||||
if (s == ui->spinLightDecayQuadratic) o->decay_quadratic = v;
|
||||
if (s == ui->spinLightAngleStart ) o->angle_start = v;
|
||||
if (s == ui->spinLightAngleEnd ) o->angle_end = v;
|
||||
if (s == ui->spinAimDist ) o->setDistance(v);
|
||||
if (s == ui->spinLightAngleStart) o->angle_start = v;
|
||||
if (s == ui->spinLightAngleEnd) o->angle_end = v;
|
||||
if (s == ui->spinAimDist) o->setDistance(v);
|
||||
o->apply();
|
||||
}
|
||||
ignore_next = true;
|
||||
@@ -237,13 +230,13 @@ void ObjectEditor::spinLightChanged(double v) {
|
||||
|
||||
void ObjectEditor::spinCameraChanged(double v) {
|
||||
if (!view || !active) return;
|
||||
QList<Camera*> scl = view->selectedCameras();
|
||||
QObject * s = sender();
|
||||
foreach (Camera * o, scl) {
|
||||
if (s == ui->spinCameraFOV ) o->setFOV (v);
|
||||
if (s == ui->spinCameraRoll ) o->setAngleRoll (v);
|
||||
QList<Camera *> scl = view->selectedCameras();
|
||||
QObject * s = sender();
|
||||
foreach(Camera * o, scl) {
|
||||
if (s == ui->spinCameraFOV) o->setFOV(v);
|
||||
if (s == ui->spinCameraRoll) o->setAngleRoll(v);
|
||||
if (s == ui->spinCameraDepthStart) o->setDepthStart(v);
|
||||
if (s == ui->spinAimDist ) o->setDistance (v);
|
||||
if (s == ui->spinAimDist) o->setDistance(v);
|
||||
}
|
||||
ignore_next = true;
|
||||
}
|
||||
@@ -251,18 +244,18 @@ void ObjectEditor::spinCameraChanged(double v) {
|
||||
|
||||
void ObjectEditor::checkChanged(bool v) {
|
||||
if (!view || !active) return;
|
||||
ObjectBaseList sol = view->selectedObjects();
|
||||
QList<Camera*> scl = view->selectedCameras();
|
||||
QObject * s = sender();
|
||||
foreach (ObjectBase * o, sol) {
|
||||
if (s == ui->checkVisible ) o->setVisible (v);
|
||||
if (s == ui->checkCastShadows ) o->setCastShadows (v);
|
||||
ObjectBaseList sol = view->selectedObjects();
|
||||
QList<Camera *> scl = view->selectedCameras();
|
||||
QObject * s = sender();
|
||||
foreach(ObjectBase * o, sol) {
|
||||
if (s == ui->checkVisible) o->setVisible(v);
|
||||
if (s == ui->checkCastShadows) o->setCastShadows(v);
|
||||
if (s == ui->checkReceiveShadows) o->setReceiveShadows(v);
|
||||
if (s == ui->checkAcceptLight ) o->setAcceptLight (v);
|
||||
if (s == ui->checkAcceptFog ) o->setAcceptFog (v);
|
||||
if (s == ui->checkAcceptLight) o->setAcceptLight(v);
|
||||
if (s == ui->checkAcceptFog) o->setAcceptFog(v);
|
||||
}
|
||||
foreach (Camera * o, scl) {
|
||||
if (s == ui->checkCameraMirrorX ) o->setMirrorX(v);
|
||||
if (s == ui->checkCameraMirrorY ) o->setMirrorY(v);
|
||||
foreach(Camera * o, scl) {
|
||||
if (s == ui->checkCameraMirrorX) o->setMirrorX(v);
|
||||
if (s == ui->checkCameraMirrorY) o->setMirrorY(v);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user