From 8c72982658d403c214ff7d66c857ca0b9b41b25f Mon Sep 17 00:00:00 2001 From: Wenzel Jakob Date: Sun, 27 Mar 2011 20:01:34 +0200 Subject: [PATCH] bugfixes --- doc/acknowledgements.tex | 1 + include/mitsuba/hw/gizmo.h | 9 ++-- src/libhw/gizmo.cpp | 10 ++--- src/libhw/glrenderer.cpp | 6 +-- src/libhw/gltexture.cpp | 18 ++++---- src/librender/preview.cpp | 8 +++- src/qtgui/acknowledgmentdlg.ui | 1 + src/qtgui/glwidget.cpp | 76 ++++++++++++++++++------------- src/qtgui/glwidget.h | 1 + src/qtgui/mainwindow.cpp | 26 ++++++++++- src/qtgui/mainwindow.h | 2 + src/qtgui/mainwindow.ui | 6 +++ src/qtgui/preview.cpp | 2 +- src/qtgui/sceneinfodlg.cpp | 42 +++++++++++++++++ src/qtgui/sceneinfodlg.h | 39 ++++++++++++++++ src/qtgui/sceneinfodlg.ui | 82 ++++++++++++++++++++++++++++++++++ 16 files changed, 275 insertions(+), 54 deletions(-) create mode 100644 src/qtgui/sceneinfodlg.cpp create mode 100644 src/qtgui/sceneinfodlg.h create mode 100644 src/qtgui/sceneinfodlg.ui diff --git a/doc/acknowledgements.tex b/doc/acknowledgements.tex index af01b2bc..3da069cd 100644 --- a/doc/acknowledgements.tex +++ b/doc/acknowledgements.tex @@ -11,6 +11,7 @@ Mitsuba makes heavy use of the following amazing libraries and tools: \item Qt 4 by Nokia \item OpenEXR by Industrial Light \& Magic \item Xerces-C+\!+ by the Apache Foundation +\item Eigen by Beno\^it Jacob and Ga\"el Guennebaud \item The Boost C+\!+ class library \item GLEW by Milan Ikits, Marcelo E. Magallon and Lev Povalahev \item Mersenne Twister by Makoto Matsumoto and Takuji Nishimura diff --git a/include/mitsuba/hw/gizmo.h b/include/mitsuba/hw/gizmo.h index 1c950093..504ca7ff 100644 --- a/include/mitsuba/hw/gizmo.h +++ b/include/mitsuba/hw/gizmo.h @@ -42,9 +42,12 @@ public: /// Check whether the gizmo is currently active inline bool isActive() const { return m_active; } - + + /// Check whether the drag starting point has been set + inline bool canDrag() const { return m_drag; } + /// Check whether the gizmo is currently used in a drag operation - inline bool isDragging() const { return m_drag; } + inline bool isDragging() const { return m_drag && (m_dragStart != m_dragEnd); } /// Check whether a certain ray intersects the gizmo inline void rayIntersect(const Ray &ray, Float &t) const { @@ -69,7 +72,7 @@ public: inline void reset() { m_active = m_drag = false; } /// Stop dragging - inline void stopDrag() { m_drag = false; } + inline void stopDrag() { m_dragStart = m_dragEnd; } /// Return the bounding sphere associated with the gizmo inline const BSphere &getBSphere() const { return m_bsphere; } diff --git a/src/libhw/gizmo.cpp b/src/libhw/gizmo.cpp index 72a77bb7..e0c6eba5 100644 --- a/src/libhw/gizmo.cpp +++ b/src/libhw/gizmo.cpp @@ -42,7 +42,6 @@ Transform Gizmo::getTransform() const { } void Gizmo::startDrag(const Ray &ray) { - m_drag = false; Float nearT, farT; if (!m_bsphere.rayIntersect(ray, nearT, farT) || (nearT < 0 && farT < 0)) { @@ -53,8 +52,8 @@ void Gizmo::startDrag(const Ray &ray) { } else { m_dragStart = ray(nearT); } - - m_active = true; + m_dragEnd = m_dragStart; + m_drag = true; } void Gizmo::dragTo(const Ray &ray, const Camera *camera) { @@ -71,7 +70,6 @@ void Gizmo::dragTo(const Ray &ray, const Camera *camera) { m_dragEnd = m_bsphere.center + normalize(closest - m_bsphere.center) * m_bsphere.radius; } - m_drag = true; } void Gizmo::draw(Renderer *renderer, const Camera *camera) { @@ -86,10 +84,12 @@ void Gizmo::draw(Renderer *renderer, const Camera *camera) { Float tcRadius = std::sqrt(length*length - radius*radius)*radius/length; Float tcDist = std::sqrt(radius*radius - tcRadius*tcRadius); + renderer->setDepthTest(false); renderer->drawCircle(m_bsphere.center - camToSphere * tcDist, camToSphere, tcRadius); + renderer->setDepthTest(true); - if (m_drag) { + if (m_drag && m_dragStart != m_dragEnd) { Spectrum color1, color2; color1.fromLinearRGB(0.7f, 0.7f, 1.0f); color2.fromLinearRGB(0.3f, 0.3f, 0.3f); diff --git a/src/libhw/glrenderer.cpp b/src/libhw/glrenderer.cpp index e1251aa0..5d2146de 100644 --- a/src/libhw/glrenderer.cpp +++ b/src/libhw/glrenderer.cpp @@ -39,11 +39,9 @@ GLEWContextStruct *glewGetContext() { MTS_NAMESPACE_BEGIN GLRenderer::GLRenderer(Session *session) - : Renderer(session) { -} + : Renderer(session) { } -GLRenderer::~GLRenderer() { -} +GLRenderer::~GLRenderer() { } void GLRenderer::init(Device *device, Renderer *other) { Renderer::init(device, other); diff --git a/src/libhw/gltexture.cpp b/src/libhw/gltexture.cpp index b3402d0b..72c3f5fc 100644 --- a/src/libhw/gltexture.cpp +++ b/src/libhw/gltexture.cpp @@ -216,7 +216,7 @@ void GLTexture::init() { Log(EError, "FBO Error: Unknown error status (0x%x)!", status); } - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, GL_NONE); } } @@ -478,7 +478,7 @@ Spectrum GLTexture::getPixel(int x, int y) const { glViewport(0, 0, m_size.x, m_size.y); glReadPixels(x, y, 1, 1, GL_RGB, GL_FLOAT, &pixels); glPopAttrib(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, GL_NONE); result.fromLinearRGB(pixels[0], pixels[1], pixels[2]); return result; @@ -488,7 +488,6 @@ Spectrum GLTexture::getPixel(int x, int y) const { void GLTexture::activateTarget() { Assert(m_fbType != ENone); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_fboId); - glPushAttrib(GL_VIEWPORT_BIT); glViewport(0, 0, m_size.x, m_size.y); } @@ -525,7 +524,7 @@ void GLTexture::setTargetRegion(const Point2i &offset, const Vector2i &size) { void GLTexture::releaseTarget() { Assert(m_fbType != ENone); glPopAttrib(); - glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); + glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, GL_NONE); if (isMipMapped()) m_needsUpdate = true; } @@ -541,10 +540,11 @@ void GLTexture::bind(int textureUnit, int textureIndex) const { } glEnable(m_glType); - if (textureIndex == 1 && m_fbType == EColorAndDepthBuffer) + if (textureIndex == 1 && m_fbType == EColorAndDepthBuffer) { glBindTexture(m_glType, m_depthId); - else + } else { glBindTexture(m_glType, m_id); + } if (isMipMapped() && m_needsUpdate) { glGenerateMipmapEXT(m_glType); @@ -616,9 +616,9 @@ void GLTexture::blit(GPUTexture *target, int what) const { glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, GL_NONE); } -void GLTexture::blit(GPUTexture *target, int what, const Point2i &sourceOffset, - const Vector2i &sourceSize, const Point2i &destOffset, - const Vector2i &destSize) const { +void GLTexture::blit(GPUTexture *target, int what, + const Point2i &sourceOffset, const Vector2i &sourceSize, + const Point2i &destOffset, const Vector2i &destSize) const { GLTexture *dest = static_cast(target); Assert(m_fbType != ENone && (dest == NULL || dest->m_fbType != ENone)); diff --git a/src/librender/preview.cpp b/src/librender/preview.cpp index 3f8d343d..83bbff39 100644 --- a/src/librender/preview.cpp +++ b/src/librender/preview.cpp @@ -265,7 +265,7 @@ void PreviewWorker::processCoherent(const WorkUnit *workUnit, WorkResult *workRe secRay4.dRcp[0].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[0].ps); secRay4.dRcp[1].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[1].ps); secRay4.dRcp[2].ps = _mm_div_ps(SSEConstants::one.ps, secRay4.d[2].ps); - + cosThetaLight.ps = _mm_sub_ps(_mm_setzero_ps(), _mm_add_ps(_mm_add_ps( _mm_mul_ps(nSecD[0].ps, lumDir[0]), @@ -291,6 +291,12 @@ void PreviewWorker::processCoherent(const WorkUnit *workUnit, WorkResult *workRe const Shape *shape = (*m_shapes)[its4.shapeIndex.i[idx]]; const BSDF *bsdf = shape->getBSDF(); + if (EXPECT_NOT_TAKEN(!bsdf)) { + memset(&emitted[idx], 0, sizeof(Spectrum)); + memset(&direct[idx], 0, sizeof(Spectrum)); + continue; + } + if (EXPECT_TAKEN(primIndex != KNoTriangleFlag)) { const TriMesh *mesh = static_cast(shape); const Triangle &t = mesh->getTriangles()[primIndex]; diff --git a/src/qtgui/acknowledgmentdlg.ui b/src/qtgui/acknowledgmentdlg.ui index c658f979..f9754f75 100644 --- a/src/qtgui/acknowledgmentdlg.ui +++ b/src/qtgui/acknowledgmentdlg.ui @@ -58,6 +58,7 @@ p, li { white-space: pre-wrap; } <ul style="-qt-list-indent: 1;"><li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://qt.nokia.com/products"><span style=" text-decoration: underline; color:#0000ff;">Qt 4</span></a> by Nokia</li> <li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.openexr.com/"><span style=" text-decoration: underline; color:#0000ff;">OpenEXR</span></a> by Industrial Light &amp; Magic</li> <li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://xerces.apache.org/xerces-c/"><span style=" text-decoration: underline; color:#0000ff;">Xerces-C++</span></a> by the Apache Foundation</li> +<li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://eigen.tuxfamily.org"><span style=" text-decoration: underline; color:#0000ff;">Eigen</span></a> by Benoît Jacob and Gaël Guennebaud</li> <li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">The <a href="http://www.boost.org/"><span style=" text-decoration: underline; color:#0000ff;">Boost</span></a> C++ class library</li> <li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://glew.sourceforge.net/"><span style=" text-decoration: underline; color:#0000ff;">GLEW</span></a> by Milan Ikits, Marcelo E. Magallon and Lev Povalahev</li> <li style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://sourceforge.net/projects/collada-dom/"><span style=" text-decoration: underline; color:#0000ff;">COLLADA DOM</span></a> by Sony Computer Entertainment</li> diff --git a/src/qtgui/glwidget.cpp b/src/qtgui/glwidget.cpp index febba8cb..fe61c056 100644 --- a/src/qtgui/glwidget.cpp +++ b/src/qtgui/glwidget.cpp @@ -68,6 +68,10 @@ GLWidget::GLWidget(QWidget *parent) : } GLWidget::~GLWidget() { + shutdown(); +} + +void GLWidget::shutdown() { if (m_preview) m_preview->quit(); } @@ -157,9 +161,9 @@ void GLWidget::initializeGL() { m_gammaTonemap->setSource(GPUProgram::EFragmentProgram, "#version 120\n" - "uniform sampler2D source;\n" + "uniform sampler2D colorSource, depthSource;\n" "uniform float invWhitePoint, invGamma;\n" - "uniform bool sRGB;\n" + "uniform bool sRGB, hasDepth;\n" "\n" "float toSRGB(float value) {\n" " if (value < 0.0031308)\n" @@ -168,11 +172,12 @@ void GLWidget::initializeGL() { "}\n" "\n" "void main() {\n" - " vec4 color = texture2D(source, gl_TexCoord[0].xy) * invWhitePoint;\n" + " vec4 color = texture2D(colorSource, gl_TexCoord[0].xy) * invWhitePoint;\n" " if (sRGB)\n" " gl_FragColor = vec4(toSRGB(color.r), toSRGB(color.g), toSRGB(color.b), 1);\n" " else\n" " gl_FragColor = vec4(pow(color.rgb, vec3(invGamma)), 1);\n" + " gl_FragDepth = hasDepth ? texture2D(depthSource, gl_TexCoord[0].xy).r : 0.5;\n" "}\n" ); @@ -185,9 +190,9 @@ void GLWidget::initializeGL() { m_reinhardTonemap->setSource(GPUProgram::EFragmentProgram, "#version 120\n" - "uniform sampler2D source;\n" + "uniform sampler2D colorSource, depthSource;\n" "uniform float key, invWpSqr, invGamma, multiplier;\n" - "uniform bool sRGB;\n" + "uniform bool sRGB, hasDepth;\n" "\n" "float toSRGB(float value) {\n" " if (value < 0.0031308)\n" @@ -204,7 +209,7 @@ void GLWidget::initializeGL() { " -0.969256, 1.875991, 0.041556,\n" " 0.055648, -0.204043, 1.057311);\n" "\n" - " vec4 color = texture2D(source, gl_TexCoord[0].xy)*multiplier;\n" + " vec4 color = texture2D(colorSource, gl_TexCoord[0].xy)*multiplier;\n" " vec3 xyz = rgb2xyz * color.rgb;\n" " float normalization = 1.0/(xyz.x + xyz.y + xyz.z);\n" " vec3 Yxy = vec3(xyz.x*normalization, xyz.y*normalization, xyz.y);\n" @@ -216,6 +221,7 @@ void GLWidget::initializeGL() { " gl_FragColor = vec4(toSRGB(color.r), toSRGB(color.g), toSRGB(color.b), 1);\n" " else\n" " gl_FragColor = vec4(pow(color.rgb, vec3(invGamma)), 1);\n" + " gl_FragDepth = hasDepth ? texture2D(depthSource, gl_TexCoord[0].xy).r : 0.5;\n" "}\n" ); @@ -573,15 +579,14 @@ void GLWidget::keyPressEvent(QKeyEvent *event) { case Qt::Key_Down: m_downKeyDown = true; break; case Qt::Key_A: { - if (m_context->selectionMode == ENothing) { - m_context->selectionMode = EScene; - m_gizmo->init(m_context->scene->getBSphere()); - } else { + if (m_context->selectionMode == EScene) { m_context->selectionMode = ENothing; m_gizmo->reset(); + } else { + m_context->selectionMode = EScene; + m_gizmo->init(m_context->scene->getBSphere()); } m_context->selectedShape = NULL; - updateGL(); } // break intentionally missing case Qt::Key_F: { @@ -653,7 +658,7 @@ void GLWidget::mouseMoveEvent(QMouseEvent *event) { bool didMove = false; if (m_navigationMode == EArcBall) { - if (event->buttons() & Qt::LeftButton) { + if (event->buttons() & Qt::LeftButton && m_gizmo->canDrag()) { Ray ray; Point2i offset = upperLeft(); Point2 sample = Point2(m_mousePos.x() - offset.x, m_mousePos.y() - offset.y); @@ -811,8 +816,12 @@ void GLWidget::mousePressEvent(QMouseEvent *event) { if (its.t < t) { SLog(EInfo, "Selected shape \"%s\"", its.shape->getName().c_str()); m_context->selectedShape = its.shape; - m_gizmo->init(its.shape->getAABB().getBSphere()); + BSphere bsphere = its.shape->getAABB().getBSphere(); + bool newSelection = (bsphere != m_gizmo->getBSphere()); + m_gizmo->init(bsphere); m_context->selectionMode = EShape; + if (newSelection) + return; } } else { if (t == std::numeric_limits::infinity()) { @@ -822,7 +831,7 @@ void GLWidget::mousePressEvent(QMouseEvent *event) { return; } } - + m_gizmo->startDrag(ray); m_storedViewTransform = camera->getViewTransform(); } @@ -856,7 +865,8 @@ void GLWidget::mouseReleaseEvent(QMouseEvent *event) { } void GLWidget::paintGL() { - m_renderer->setDepthTest(false); + m_renderer->setDepthTest(true); + m_renderer->setDepthMask(true); if (m_context == NULL) { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); m_renderer->clear(); @@ -866,7 +876,7 @@ void GLWidget::paintGL() { } else if (m_context != NULL) { Vector2i size; glClearColor(0.2f, 0.2f, 0.2f, 1.0f); - glClear(GL_COLOR_BUFFER_BIT); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); PreviewQueueEntry entry; GPUTexture *buffer = NULL; @@ -933,7 +943,12 @@ void GLWidget::paintGL() { size = Vector2i(m_framebuffer->getSize().x, m_framebuffer->getSize().y); buffer = m_framebuffer; + } else { + return; } + bool hasDepth = m_context->mode == EPreview + && (m_context->previewMethod == EOpenGL || + m_context->previewMethod == EOpenGLSinglePass); if (m_softwareFallback) { buffer->bind(); @@ -947,11 +962,15 @@ void GLWidget::paintGL() { if (m_context->mode == EPreview) invWhitePoint /= entry.vplSampleOffset; + if (hasDepth) + buffer->bind(1, 1); m_gammaTonemap->bind(); - m_gammaTonemap->setParameter("source", 0); + m_gammaTonemap->setParameter("colorSource", 0); + m_gammaTonemap->setParameter("depthSource", 1); m_gammaTonemap->setParameter("invWhitePoint", invWhitePoint); m_gammaTonemap->setParameter("invGamma", 1/m_context->gamma); m_gammaTonemap->setParameter("sRGB", m_context->srgb); + m_gammaTonemap->setParameter("hasDepth", hasDepth); m_renderer->blitTexture(buffer, m_context->mode == EPreview, !m_hScroll->isVisible(), !m_vScroll->isVisible(), -m_context->scrollOffset); @@ -1015,13 +1034,17 @@ void GLWidget::paintGL() { logLuminance = 1; } + if (hasDepth) + buffer->bind(1, 1); m_reinhardTonemap->bind(); - m_reinhardTonemap->setParameter("source", 0); + m_reinhardTonemap->setParameter("colorSource", 0); + m_reinhardTonemap->setParameter("depthSource", 1); m_reinhardTonemap->setParameter("key", m_context->reinhardKey/logLuminance); m_reinhardTonemap->setParameter("multiplier", multiplier); m_reinhardTonemap->setParameter("invWpSqr", std::pow((Float) 2, m_context->reinhardBurn)); m_reinhardTonemap->setParameter("invGamma", 1/m_context->gamma); m_reinhardTonemap->setParameter("sRGB", m_context->srgb); + m_reinhardTonemap->setParameter("hasDepth", hasDepth); m_renderer->blitTexture(buffer, m_context->mode == EPreview, !m_hScroll->isVisible(), !m_vScroll->isVisible(), -m_context->scrollOffset); @@ -1059,19 +1082,14 @@ void GLWidget::paintGL() { if (m_context->mode == EPreview) { const ProjectiveCamera *camera = static_cast (m_context->scene->getCamera()); - m_renderer->setCamera(camera); - - Point2i offset = upperLeft(true); - - buffer->blit(NULL, GPUTexture::EDepthBuffer, Point2i(0, 0), - size, offset, size); glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - + m_renderer->setCamera(camera); + glPushAttrib(GL_VIEWPORT_BIT); + Point2i offset = upperLeft(true); glViewport(offset.x, offset.y, size.x, size.y); - m_renderer->setDepthTest(true); m_renderer->setDepthMask(false); + m_renderer->setDepthTest(true); m_renderer->setBlendMode(Renderer::EBlendAdditive); - glDepthFunc(GL_LESS); if (m_context->showKDTree) { oglRenderKDTree(m_context->scene->getKDTree()); @@ -1085,9 +1103,7 @@ void GLWidget::paintGL() { m_gizmo->draw(m_renderer, camera); m_renderer->setBlendMode(Renderer::EBlendNone); - m_renderer->setDepthTest(false); - m_renderer->setDepthMask(true); - glViewport(viewport[0], viewport[1], viewport[2], viewport[3]); + glPopAttrib(); } } swapBuffers(); diff --git a/src/qtgui/glwidget.h b/src/qtgui/glwidget.h index fa464b8b..673a9db5 100644 --- a/src/qtgui/glwidget.h +++ b/src/qtgui/glwidget.h @@ -46,6 +46,7 @@ public: void resumePreview(); void refreshScene(); void resetPreview(); + void shutdown(); inline const RendererCapabilities *getRendererCapabilities() const { return m_renderer->getCapabilities(); } diff --git a/src/qtgui/mainwindow.cpp b/src/qtgui/mainwindow.cpp index ed2dee70..eaa8b503 100644 --- a/src/qtgui/mainwindow.cpp +++ b/src/qtgui/mainwindow.cpp @@ -21,6 +21,7 @@ #include "rendersettingsdlg.h" #include "previewsettingsdlg.h" #include "programsettingsdlg.h" +#include "sceneinfodlg.h" #include "sceneloader.h" #include "logwidget.h" #include "navdlg.h" @@ -496,6 +497,28 @@ void MainWindow::on_actionShowKDTree_triggered() { ui->glView->resetPreview(); } +void MainWindow::on_actionSceneDescription_triggered() { + int currentIndex = ui->tabBar->currentIndex(); + if (currentIndex == -1) + return; + SceneContext *context= m_context[currentIndex]; + SceneInformationDialog *dialog = new SceneInformationDialog(this, + context->scene); + QDesktopWidget *desktop = QApplication::desktop(); + dialog->move(QPoint((desktop->width() - dialog->width()) / 2, (desktop->height() - dialog->height())/2)); + connect(dialog, SIGNAL(finished(int)), this, SLOT(onSceneInformationClose(int))); + m_currentChild = dialog; + // prevent a tab drawing artifact on Qt/OSX + m_activeWindowHack = true; + dialog->show(); + qApp->processEvents(); + m_activeWindowHack = false; +} + +void MainWindow::onSceneInformationClose(int reason) { + m_currentChild = NULL; +} + void MainWindow::changeEvent(QEvent *e) { QMainWindow::changeEvent(e); switch (e->type()) { @@ -700,6 +723,7 @@ void MainWindow::updateUI() { ui->actionAdjustSize->setEnabled(hasTab); ui->actionShowKDTree->setEnabled(hasTab); ui->actionShowKDTree->setChecked(hasTab && context->showKDTree); + ui->actionSceneDescription->setEnabled(hasTab); #if !defined(__OSX__) ui->actionPreviewSettings->setEnabled(!fallback && hasTab); #else @@ -863,6 +887,7 @@ void MainWindow::closeEvent(QCloseEvent *event) { return; } } + ui->glView->shutdown(); QMainWindow::closeEvent(event); m_logWidget->hide(); Logger *logger = Thread::getThread()->getLogger(); @@ -1369,7 +1394,6 @@ void MainWindow::onSaveAsDialogClose(int reason) { QFileDialog *dialog = static_cast(sender()); m_currentChild = NULL; if (reason == QDialog::Accepted) { - m_currentChild = NULL; QString fileName = dialog->selectedFiles().value(0); settings.setValue("fileDialogState", dialog->saveState()); saveScene(this, context, fileName); diff --git a/src/qtgui/mainwindow.h b/src/qtgui/mainwindow.h index 49d1d52c..1f0736bf 100644 --- a/src/qtgui/mainwindow.h +++ b/src/qtgui/mainwindow.h @@ -127,6 +127,7 @@ private slots: void on_actionReportBug_triggered(); void on_actionFeedback_triggered(); void on_actionShowKDTree_triggered(); + void on_actionSceneDescription_triggered(); void on_tabBar_currentChanged(int index); bool on_tabBar_tabCloseRequested(int index); void on_tabBar_tabMoved(int from, int to); @@ -153,6 +154,7 @@ private slots: void onExportDialogClose(int reason); void onRenderSettingsClose(int reason); void onImportDialogClose(int reason); + void onSceneInformationClose(int reason); private: Ui::MainWindow *ui; diff --git a/src/qtgui/mainwindow.ui b/src/qtgui/mainwindow.ui index ac0af414..a827617f 100644 --- a/src/qtgui/mainwindow.ui +++ b/src/qtgui/mainwindow.ui @@ -151,6 +151,7 @@ Developer + @@ -467,6 +468,11 @@ Visualize kd-Tree + + + Describe Scene.. + + diff --git a/src/qtgui/preview.cpp b/src/qtgui/preview.cpp index 6a616d2a..d13b3d0a 100644 --- a/src/qtgui/preview.cpp +++ b/src/qtgui/preview.cpp @@ -325,7 +325,7 @@ void PreviewThread::run() { target.buffer->setFormat(GPUTexture::EFloat32RGB); target.buffer->setSize(size); target.buffer->setFilterType(GPUTexture::ENearest); - target.buffer->setFrameBufferType(GPUTexture::EColorBuffer); + target.buffer->setFrameBufferType(GPUTexture::EColorAndDepthBuffer); target.buffer->setMipMapped(false); target.buffer->init(); target.buffer->incRef(); diff --git a/src/qtgui/sceneinfodlg.cpp b/src/qtgui/sceneinfodlg.cpp new file mode 100644 index 00000000..cc1c865f --- /dev/null +++ b/src/qtgui/sceneinfodlg.cpp @@ -0,0 +1,42 @@ +/* + This file is part of Mitsuba, a physically based rendering system. + + Copyright (c) 2007-2010 by Wenzel Jakob and others. + + Mitsuba is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License Version 3 + as published by the Free Software Foundation. + + Mitsuba 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 . +*/ + +#include "ui_sceneinfodlg.h" +#include "sceneinfodlg.h" + +SceneInformationDialog::SceneInformationDialog(QWidget *parent, Scene *scene) : + QDialog(parent), + ui(new Ui::SceneInformationDialog) { + ui->setupUi(this); + ui->textEdit->setText(scene->toString().c_str()); +} + +SceneInformationDialog::~SceneInformationDialog() { + delete ui; +} + +void SceneInformationDialog::changeEvent(QEvent *e) { + QDialog::changeEvent(e); + switch (e->type()) { + case QEvent::LanguageChange: + ui->retranslateUi(this); + break; + default: + break; + } +} diff --git a/src/qtgui/sceneinfodlg.h b/src/qtgui/sceneinfodlg.h new file mode 100644 index 00000000..5ce1daa7 --- /dev/null +++ b/src/qtgui/sceneinfodlg.h @@ -0,0 +1,39 @@ +/* + This file is part of Mitsuba, a physically based rendering system. + + Copyright (c) 2007-2010 by Wenzel Jakob and others. + + Mitsuba is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License Version 3 + as published by the Free Software Foundation. + + Mitsuba 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 . +*/ + +#if !defined(__SCENEINFODLG_H) +#define __SCENEINFODLG_H + +#include "common.h" + +namespace Ui { + class SceneInformationDialog; +} + +class SceneInformationDialog : public QDialog { + Q_OBJECT +public: + SceneInformationDialog(QWidget *parent, Scene *scene); + ~SceneInformationDialog(); +protected: + void changeEvent(QEvent *e); +private: + Ui::SceneInformationDialog *ui; +}; + +#endif // __SCENEINFODLG_H diff --git a/src/qtgui/sceneinfodlg.ui b/src/qtgui/sceneinfodlg.ui new file mode 100644 index 00000000..7b43bbac --- /dev/null +++ b/src/qtgui/sceneinfodlg.ui @@ -0,0 +1,82 @@ + + + SceneInformationDialog + + + Qt::NonModal + + + + 0 + 0 + 676 + 534 + + + + Scene Information + + + + + + + + Qt::Horizontal + + + + 198 + 20 + + + + + + + + &Close + + + + + + + + + + Monospace + 8 + + + + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'Monospace'; font-size:8pt; font-weight:400; font-style:normal;"> +<p style="-qt-paragraph-type:empty; margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Ubuntu'; font-size:11pt;"></p></body></html> + + + + + + + + + pushButton + clicked() + SceneInformationDialog + accept() + + + 327 + 263 + + + 334 + 199 + + + + +