summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Rødal <sroedal@trolltech.com>2008-06-25 17:34:03 +0200
committerSamuel Rødal <sroedal@trolltech.com>2008-06-25 17:41:23 +0200
commit7f7c88303fd873815269732a29d022d6f731cb50 (patch)
treeb9f0a14d300f9f029c8c169576d0bfd59a11cb71
parent0d4112e01c674a5150e724ee7b49593299efbd9b (diff)
More cleanup.
-rw-r--r--openglscene.cpp24
-rw-r--r--openglscene.h2
2 files changed, 9 insertions, 17 deletions
diff --git a/openglscene.cpp b/openglscene.cpp
index bb69f31..06bcd0a 100644
--- a/openglscene.cpp
+++ b/openglscene.cpp
@@ -38,31 +38,25 @@ private:
Controls::Controls(OpenGLScene *scene)
: QDialog(0, Qt::CustomizeWindowHint | Qt::WindowTitleHint)
, m_scene(scene)
- , m_models(new QComboBox)
- , m_dir(QLatin1String("models"))
+ , m_dir(QLatin1String("models"), QLatin1String("*.obj"), QDir::Size | QDir::Reversed, QDir::Files)
{
QVBoxLayout *layout = new QVBoxLayout(this);
layout->addWidget(new QLabel(tr("Model:")));
- m_dir.setNameFilters(QStringList() << QLatin1String("*.obj"));
- m_models->addItems(m_dir.entryList());
+ m_models = new QComboBox;
connect(m_models, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(loadModel(const QString &)));
#ifndef QT_NO_CONCURRENT
connect(&m_modelLoader, SIGNAL(finished()), this, SLOT(modelLoaded()));
#endif
-
- if (m_models->count() > 0)
- loadModel(m_models->currentText());
+ m_models->addItems(m_dir.entryList());
layout->addWidget(m_models);
QCheckBox *wireframe = new QCheckBox(tr("Render as wireframe"));
- wireframe->setChecked(true);
connect(wireframe, SIGNAL(toggled(bool)), m_scene, SLOT(enableWireframe(bool)));
layout->addWidget(wireframe);
QCheckBox *normals = new QCheckBox(tr("Display normals vectors"));
- wireframe->setChecked(false);
connect(normals, SIGNAL(toggled(bool)), m_scene, SLOT(enableNormals(bool)));
layout->addWidget(normals);
@@ -72,8 +66,6 @@ Controls::Controls(OpenGLScene *scene)
connect(lightPosition, SIGNAL(valueChanged(int)), m_scene, SLOT(setLightPosition(int)));
layout->addWidget(lightPosition);
- m_scene->setLightPosition(lightPosition->value());
-
QPushButton *colorButton = new QPushButton(tr("Choose model color"));
connect(colorButton, SIGNAL(pressed()), this, SLOT(setModelColor()));
layout->addWidget(colorButton);
@@ -124,9 +116,10 @@ void Controls::setBackgroundColor()
}
OpenGLScene::OpenGLScene()
- : m_wireframeEnabled(true)
+ : m_wireframeEnabled(false)
, m_normalsEnabled(false)
, m_distance(1.4f)
+ , m_lightPosition(0.0f)
, m_modelColor(QColor::fromCmykF(0.40, 0.0, 1.0, 0.0))
, m_backgroundColor(QColor::fromCmykF(0.39, 0.39, 0.0, 0.0))
, m_model(new Model)
@@ -135,6 +128,7 @@ OpenGLScene::OpenGLScene()
{
Controls *controls = new Controls(this);
controls->setWindowOpacity(0.8);
+ controls->setWindowTitle(tr("Controls"));
QGraphicsProxyWidget *item = addWidget(controls);
const QPointF offset = item->boundingRect().topLeft();
@@ -166,7 +160,7 @@ void OpenGLScene::drawBackground(QPainter *painter, const QRectF &)
glPushMatrix();
glLoadIdentity();
- const float pos[] = { m_lightPos, 5, 2, 0 };
+ const float pos[] = { m_lightPosition, 5, 2, 0 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);
glColor4f(m_modelColor.redF(), m_modelColor.greenF(), m_modelColor.blueF(), 1.0f);
@@ -212,7 +206,7 @@ void OpenGLScene::enableNormals(bool enabled)
void OpenGLScene::setLightPosition(int pos)
{
- m_lightPos = pos * 0.05;
+ m_lightPosition = pos * 0.05;
update();
}
@@ -263,7 +257,6 @@ void OpenGLScene::mousePressEvent(QGraphicsSceneMouseEvent *event)
m_mouseEventTime = m_time.elapsed();
m_angularMomentum = m_accumulatedMomentum = Point3d();
-
event->accept();
}
@@ -275,7 +268,6 @@ void OpenGLScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
const int delta = m_time.elapsed() - m_mouseEventTime;
m_angularMomentum = m_accumulatedMomentum * (1000.0 / qMax(1, delta));
-
event->accept();
update();
}
diff --git a/openglscene.h b/openglscene.h
index c9283ab..c0d5c20 100644
--- a/openglscene.h
+++ b/openglscene.h
@@ -38,8 +38,8 @@ private:
bool m_wireframeEnabled;
bool m_normalsEnabled;
- float m_lightPos;
float m_distance;
+ float m_lightPosition;
QColor m_modelColor;
QColor m_backgroundColor;