Mon, 04 Jul 2022 00:19:18 +0300
fix some issues like subfile references not showing up properly
src/documentmanager.cpp | file | annotate | diff | comparison | revisions | |
src/gl/partrenderer.cpp | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions | |
src/model.cpp | file | annotate | diff | comparison | revisions |
--- a/src/documentmanager.cpp Sun Jul 03 23:54:22 2022 +0300 +++ b/src/documentmanager.cpp Mon Jul 04 00:19:18 2022 +0300 @@ -335,6 +335,7 @@ QObject::connect(model, &Model::dataChanged, modelModified); QObject::connect(model, &Model::rowsInserted, modelModified); QObject::connect(model, &Model::rowsRemoved, modelModified); + QObject::connect(model, &Model::modelReset, modelModified); } } @@ -403,12 +404,17 @@ std::map<QString, QString>& missing) { bool repeat = true; + const auto olddeps = info->dependencies; info->dependencies.clear(); while (repeat) { repeat = false; const std::set<Dependency> dependencies = resolveReferencePaths(info, libraries); for (const Dependency& dep : dependencies) { - if (not info->dependencies.contains(dep.name) and not missing.contains(dep.path)) { + const ModelId* const idp = findInMap(olddeps, dep.name); + if (idp != nullptr) { + info->dependencies[dep.name] = *idp; + } + else if (not info->dependencies.contains(dep.name) and not missing.contains(dep.path)) { QString loadErrorString; QTextStream localErrorStream{&loadErrorString}; const std::optional<ModelId> modelIdOpt = documents->openModel( @@ -417,7 +423,7 @@ OpenType::AutomaticallyOpened); if (not modelIdOpt.has_value()) { const QString& errorMessage = QObject::tr("could not load '%1': %2") - .arg(dep.path, loadErrorString); + .arg(dep.path, loadErrorString); missing[dep.path] = errorMessage; } else {
--- a/src/gl/partrenderer.cpp Sun Jul 03 23:54:22 2022 +0300 +++ b/src/gl/partrenderer.cpp Mon Jul 04 00:19:18 2022 +0300 @@ -49,10 +49,11 @@ QSurfaceFormat surfaceFormat; surfaceFormat.setSamples(8); this->setFormat(surfaceFormat); - connect(model, &Model::rowsInserted, [&]{ - this->needBuild = true; - }); - connect(model, &Model::rowsRemoved, [&]{ this->needBuild = true; }); + const auto setNeedBuild = [&]{this->needBuild = true;}; + connect(model, &Model::rowsInserted, setNeedBuild); + connect(model, &Model::rowsRemoved, setNeedBuild); + connect(model, &Model::dataChanged, setNeedBuild); + connect(model, &Model::modelReset, setNeedBuild); const auto updateLayerMvpMatrix = [this]{ const glm::mat4 newMvpMatrix = this->projectionMatrix * this->viewMatrix * this->modelMatrix; for (RenderLayer* layer : this->activeRenderLayers) {
--- a/src/main.cpp Sun Jul 03 23:54:22 2022 +0300 +++ b/src/main.cpp Mon Jul 04 00:19:18 2022 +0300 @@ -333,6 +333,15 @@ } } +static QFont monospace() +{ + QFont font{"Monospace"}; + font.setStyleHint(QFont::TypeWriter); + font.setPointSize(10); + font.setFixedPitch(true); + return font; +} + constexpr bool sortModelIndexesByRow(const QModelIndex& a, const QModelIndex& b) { return a.row() < b.row(); @@ -429,11 +438,6 @@ MessageLog messageLog; Signal settingsChanged; ui.setupUi(&mainWindow); - QFont monospace{"Monospace"}; - monospace.setStyleHint(QFont::TypeWriter); - monospace.setPointSize(10); - monospace.setFixedPitch(true); - ui.modelEdit->setFont(monospace); ToolWidgets toolWidgets{ .circleToolOptions = new CircleToolOptionsWidget{&mainWindow}, .objectEditor = new ObjectEditor{&mainWindow}, @@ -526,6 +530,7 @@ ::save(*model, &stream); data->textbuffer = std::make_unique<QTextDocument>(); data->textbuffer->setPlainText(modeltext); + data->textbuffer->setDefaultFont(monospace()); data->textbuffer->setDocumentLayout(new QPlainTextDocumentLayout(data->textbuffer.get())); data->textcursor = std::make_unique<QTextCursor>(data->textbuffer.get()); documents.setModelPayload(modelId, data); @@ -776,6 +781,7 @@ QTextStream stream{&text}; Parser parser(stream); parser.parseBody(*data->model); + documents.loadDependenciesForAllModels(libraries); data->canvas->update(); } });