--- a/src/main.cpp Tue Apr 11 20:27:04 2023 +0300 +++ b/src/main.cpp Tue Apr 11 22:39:18 2023 +0300 @@ -75,6 +75,7 @@ QStringList recentlyOpenedFiles; ColorTable colorTable; gl::RenderPreferences renderPreferences; + gl::build_preferences user_gl_build_preferences; MessageLog messageLog; ToolWidgets toolWidgets{ .circleToolOptions = new CircleToolOptionsWidget{&mainWindow}, @@ -176,12 +177,22 @@ }); } +static void rebuild_polygons_for_all_models(MainState* state) +{ + forEachModel(&state->documents, [](const void*, const ModelData* data){ + if (data->canvas != nullptr) { + data->canvas->build(); + data->canvas->update(); + } + }); +} + static void updateRenderPreferences(MainState* state) { forEachModel(&state->documents, [state](const void*, const ModelData* data){ if (data->canvas != nullptr) { - data->canvas->setRenderPreferences(state->renderPreferences); data->canvas->setLayerEnabled(data->axesLayer.get(), state->renderPreferences.drawAxes); + data->canvas->update(); } }); state->mainWindow.setRenderStyle(state->renderPreferences.style); @@ -189,12 +200,18 @@ state->mainWindow.actionWireframe->setChecked(state->renderPreferences.wireframe); } +static gl::build_preferences load_gl_build_preferences_from_settings() +{ + return gl::build_preferences{ + .mainColor = setting<Setting::MainColor>(), + .backgroundColor = setting<Setting::BackgroundColor>(), + }; +} + static gl::RenderPreferences loadRenderPreferences() { return gl::RenderPreferences{ .style = setting<Setting::RenderStyle>(), - .mainColor = setting<Setting::MainColor>(), - .backgroundColor = setting<Setting::BackgroundColor>(), .selectedColor = setting<Setting::SelectedColor>(), .lineThickness = setting<Setting::LineThickness>(), .lineAntiAliasing = setting<Setting::LineAntiAliasing>(), @@ -327,7 +344,8 @@ data->tools.get(), &EditTools::modelAction, std::bind(executeAction, model, std::placeholders::_1)); - data->canvas->setRenderPreferences(state->renderPreferences); + data->canvas->render_preferences = &state->renderPreferences; + data->canvas->build_preferences = &state->user_gl_build_preferences; QObject::connect( data->tools.get(), &EditTools::newStatusText, @@ -388,10 +406,12 @@ { state->recentlyOpenedFiles = setting<Setting::RecentFiles>(); state->renderPreferences = loadRenderPreferences(); + state->user_gl_build_preferences = load_gl_build_preferences_from_settings(); state->libraries.restoreFromSettings(); updateRecentlyOpenedDocumentsMenu(state); state->colorTable = loadColors(&state->libraries); updateRenderPreferences(state); + rebuild_polygons_for_all_models(state); state->mainWindow.mdiArea->setViewMode(setting<Setting::ViewMode>()); state->mainWindow.retranslateUi(&state->mainWindow); state->mainWindow.setToolButtonStyle(setting<Setting::ToolButtonStyle>()); @@ -731,7 +751,6 @@ } ); restoreSettings(&state); - updateRenderPreferences(&state); const int result = app.exec(); saveSettings(&state); return result;