diff -r e81f4ad53efd -r 65b4741b302d src/main.cpp --- a/src/main.cpp Sat Apr 08 16:59:55 2023 +0300 +++ b/src/main.cpp Sat Apr 08 21:48:49 2023 +0300 @@ -323,6 +323,23 @@ }, action); } +QFont codeEditorFontFromSettings() +{ + QFont font{}; + if (setting()) + { + font.setStyleHint(QFont::Monospace); + } + else + { + font.setFamily(setting()); + font.setPointSize(setting()); + } + return font; +} + +constexpr glm::mat4 DEFAULT_GRID_MATRIX = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}}; + int main(int argc, char *argv[]) { doQtRegistrations(); @@ -377,10 +394,9 @@ data->tools = std::make_unique(); data->canvas = std::make_unique(model, &documents, colorTable); data->axesLayer = std::make_unique(); - constexpr glm::mat4 XZ = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}}; data->gridLayer = std::make_unique(); - data->gridLayer->setGridMatrix(XZ); - data->tools->setGridMatrix(XZ); + data->gridLayer->setGridMatrix(DEFAULT_GRID_MATRIX); + data->tools->setGridMatrix(DEFAULT_GRID_MATRIX); data->model = model; data->canvas->addRenderLayer(data->axesLayer.get()); data->canvas->setLayerEnabled(data->axesLayer.get(), setting()); @@ -669,6 +685,7 @@ checkEditingModeAction(data->tools->currentEditingMode()); mainWindow.modelEdit->setDocument(data->model); mainWindow.modelEdit->setTextCursor(*data->textcursor); + mainWindow.modelEdit->setFont(codeEditorFontFromSettings()); } } else { @@ -718,6 +735,23 @@ data->canvas->update(); } }); + QObject::connect( + mainWindow.gridMatrix, + &MatrixEditor::valueChanged, + [&](const glm::mat4& newGridMatrix) + { + forEachModel(&documents, [&](const void*, const ModelData* data) + { + if (data->gridLayer != nullptr and data->tools != nullptr and data->canvas != nullptr) + { + data->gridLayer->setGridMatrix(newGridMatrix); + data->tools->setGridMatrix(newGridMatrix); + data->canvas->update(); + } + }); + } + ); + mainWindow.gridMatrix->setValue(DEFAULT_GRID_MATRIX); mainWindow.tabifyDockWidget(mainWindow.messageLogDock, mainWindow.toolOptionsDock); mainWindow.restoreGeometry(setting()); mainWindow.restoreState(setting());