Thu, 11 Jan 2018 15:30:30 +0200
renderer rework
src/documentmanager.cpp | file | annotate | diff | comparison | revisions | |
src/documentmanager.h | file | annotate | diff | comparison | revisions | |
src/glCompiler.cpp | file | annotate | diff | comparison | revisions | |
src/glCompiler.h | file | annotate | diff | comparison | revisions | |
src/glRenderer.cpp | file | annotate | diff | comparison | revisions | |
src/ldDocument.cpp | file | annotate | diff | comparison | revisions | |
src/mainwindow.cpp | file | annotate | diff | comparison | revisions | |
src/mainwindow.h | file | annotate | diff | comparison | revisions | |
src/mainwindow.ui | file | annotate | diff | comparison | revisions |
--- a/src/documentmanager.cpp Thu Jan 11 15:09:44 2018 +0200 +++ b/src/documentmanager.cpp Thu Jan 11 15:30:30 2018 +0200 @@ -152,6 +152,8 @@ dl.checkIfFinished(); file->reloadAllSubfiles(); } + + emit documentLoaded(file); } LDDocument* DocumentManager::findDocumentByName(QString name)
--- a/src/documentmanager.h Thu Jan 11 15:09:44 2018 +0200 +++ b/src/documentmanager.h Thu Jan 11 15:30:30 2018 +0200 @@ -46,6 +46,9 @@ void openMainModel(QString path); bool preInline(LDDocument* doc, LDObjectList&, bool deep, bool renderinline); +signals: + void documentLoaded(LDDocument* document); + private: Documents m_documents; bool m_loadingMainFile; @@ -56,4 +59,4 @@ QString Basename(QString path); QString Dirname(QString path); -static const QStringList g_specialSubdirectories({ "s", "48", "8" }); \ No newline at end of file +static const QStringList g_specialSubdirectories({ "s", "48", "8" });
--- a/src/glCompiler.cpp Thu Jan 11 15:09:44 2018 +0200 +++ b/src/glCompiler.cpp Thu Jan 11 15:30:30 2018 +0200 @@ -107,14 +107,14 @@ QColor blend(QColor baseColor, QColor blendColor, double intensity) { - double red = baseColor.redF(); - red += blendColor.redF() * intensity; + double red = baseColor.red(); + red += blendColor.red() * intensity; red /= (intensity + 1.0); - double green = baseColor.greenF(); - green += blendColor.greenF() * intensity; + double green = baseColor.green(); + green += blendColor.green() * intensity; green /= (intensity + 1.0); - double blue = baseColor.blueF(); - blue += blendColor.blueF() * intensity; + double blue = baseColor.blue(); + blue += blendColor.blue() * intensity; blue /= (intensity + 1.0); return {int(round(red)), int(round(green)), int(round(blue))}; } @@ -221,13 +221,10 @@ } -void GLCompiler::compileDocument(LDDocument* document) +void GLCompiler::compileDocument() { - if (document) - { - for (LDObject* obj : document->objects()) - compileObject(obj); - } + for (LDObject* object : this->document->objects()) + compileObject(object); } @@ -245,9 +242,8 @@ // Compile anything that still awaits it compileStaged(); - if (not vboChanged[vbonum]) + if (vboChanged[vbonum]) { - print("Merging %1", vbonum); QVector<GLfloat> vbodata; for (auto it = objectInfo.begin(); it != objectInfo.end();) @@ -295,7 +291,6 @@ return; ObjectVBOInfo info; - info.isChanged = true; dropObjectInfo(obj); switch(obj->type())
--- a/src/glCompiler.h Thu Jan 11 15:09:44 2018 +0200 +++ b/src/glCompiler.h Thu Jan 11 15:30:30 2018 +0200 @@ -26,7 +26,7 @@ public: GLCompiler(LDDocument* document, class GLRenderer* renderer); ~GLCompiler(); - void compileDocument(LDDocument* document); + void compileDocument(); void dropObjectInfo(LDObject* obj); QColor getColorForPolygon(LDPolygon& poly, LDObject* topobj, ComplementVboType complement) const; QColor indexColorForID(int id) const; @@ -44,7 +44,7 @@ struct ObjectVBOInfo { QVector<GLfloat> data[NumVbos]; - bool isChanged = false; + bool isChanged = true; }; void compileStaged();
--- a/src/glRenderer.cpp Thu Jan 11 15:09:44 2018 +0200 +++ b/src/glRenderer.cpp Thu Jan 11 15:30:30 2018 +0200 @@ -113,6 +113,7 @@ } calcCameraIcons(); + m_compiler.compileDocument(); } // ============================================================================= @@ -354,7 +355,7 @@ { if (m_initialized) { - compiler()->compileDocument(currentDocument()); + compiler()->compileDocument(); refresh(); } }
--- a/src/ldDocument.cpp Thu Jan 11 15:09:44 2018 +0200 +++ b/src/ldDocument.cpp Thu Jan 11 15:30:30 2018 +0200 @@ -131,10 +131,6 @@ if (m_isCache) { m_isCache = false; - - // Cache files are not compiled by the GL renderer. Now that this file is open for editing, it needs to be - // compiled. - m_window->currentRenderer()->compiler()->compileDocument(this); m_window->updateDocumentList(); } }
--- a/src/mainwindow.cpp Thu Jan 11 15:09:44 2018 +0200 +++ b/src/mainwindow.cpp Thu Jan 11 15:30:30 2018 +0200 @@ -87,6 +87,10 @@ connect(ui.objectList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(objectListDoubleClicked(QListWidgetItem*))); connect(m_tabs, SIGNAL(currentChanged(int)), this, SLOT(tabSelected())); connect(m_tabs, SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); + connect( + m_documents, SIGNAL(documentLoaded(LDDocument*)), + this, SLOT(documentLoaded(LDDocument*)) + ); if (ActivePrimitiveScanner()) connect(ActivePrimitiveScanner(), SIGNAL(workDone()), this, SLOT(updatePrimitives())); @@ -1222,16 +1226,13 @@ connect(document->history(), SIGNAL(stepAdded()), this, SLOT(updateActions())); connect(document, SIGNAL(closed()), this, SLOT(documentClosed())); - GLRenderer* renderer = new GLRenderer {document, this}; - m_renderers[document] = renderer; - ui.rendererStack->addWidget(renderer); - if (not cache) { changeDocument(document); document->openForEditing(); } + documentLoaded(document); return document; } @@ -1262,7 +1263,6 @@ buildObjectList(); updateTitle(); ui.rendererStack->setCurrentWidget(m_renderers[document]); - print("Changed document to %1", document->getDisplayName()); } } @@ -1290,8 +1290,15 @@ return m_currentDocument->getSelection(); } -// --------------------------------------------------------------------------------------------------------------------- -// + +void MainWindow::documentLoaded(LDDocument* document) +{ + GLRenderer* renderer = new GLRenderer {document, this}; + m_renderers[document] = renderer; + ui.rendererStack->addWidget(renderer); +} + + void MainWindow::documentClosed() { LDDocument* document = qobject_cast<LDDocument*>(sender());
--- a/src/mainwindow.h Thu Jan 11 15:09:44 2018 +0200 +++ b/src/mainwindow.h Thu Jan 11 15:30:30 2018 +0200 @@ -158,6 +158,7 @@ void recentFileClicked(); void quickColorClicked(); void objectListDoubleClicked(QListWidgetItem* listitem); + void documentLoaded(LDDocument* document); void documentClosed(); };
--- a/src/mainwindow.ui Thu Jan 11 15:09:44 2018 +0200 +++ b/src/mainwindow.ui Thu Jan 11 15:30:30 2018 +0200 @@ -39,15 +39,12 @@ </item> <item> <widget class="QToolBox" name="toolBox"> - <property name="currentIndex"> - <number>1</number> - </property> <widget class="QWidget" name="pageDocument"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>465</width> + <width>310</width> <height>371</height> </rect> </property> @@ -179,7 +176,7 @@ <rect> <x>0</x> <y>0</y> - <width>465</width> + <width>310</width> <height>371</height> </rect> </property>