321 //model->assignAt(action.position, action.newElement); |
321 //model->assignAt(action.position, action.newElement); |
322 }, |
322 }, |
323 }, action); |
323 }, action); |
324 } |
324 } |
325 |
325 |
|
326 QFont codeEditorFontFromSettings() |
|
327 { |
|
328 QFont font{}; |
|
329 if (setting<Setting::CodeEditorUseSystemFont>()) |
|
330 { |
|
331 font.setStyleHint(QFont::Monospace); |
|
332 } |
|
333 else |
|
334 { |
|
335 font.setFamily(setting<Setting::CodeEditorFontFamily>()); |
|
336 font.setPointSize(setting<Setting::CodeEditorFontSize>()); |
|
337 } |
|
338 return font; |
|
339 } |
|
340 |
|
341 constexpr glm::mat4 DEFAULT_GRID_MATRIX = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}}; |
|
342 |
326 int main(int argc, char *argv[]) |
343 int main(int argc, char *argv[]) |
327 { |
344 { |
328 doQtRegistrations(); |
345 doQtRegistrations(); |
329 QApplication app{argc, argv}; |
346 QApplication app{argc, argv}; |
330 QApplication::setWindowIcon(QIcon{":/icons/appicon.png"}); |
347 QApplication::setWindowIcon(QIcon{":/icons/appicon.png"}); |
375 if (model != nullptr) { |
392 if (model != nullptr) { |
376 ModelData* data = new ModelData(&documents); |
393 ModelData* data = new ModelData(&documents); |
377 data->tools = std::make_unique<EditTools>(); |
394 data->tools = std::make_unique<EditTools>(); |
378 data->canvas = std::make_unique<PartRenderer>(model, &documents, colorTable); |
395 data->canvas = std::make_unique<PartRenderer>(model, &documents, colorTable); |
379 data->axesLayer = std::make_unique<AxesLayer>(); |
396 data->axesLayer = std::make_unique<AxesLayer>(); |
380 constexpr glm::mat4 XZ = {{1, 0, 0, 0}, {0, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 1}}; |
|
381 data->gridLayer = std::make_unique<GridLayer>(); |
397 data->gridLayer = std::make_unique<GridLayer>(); |
382 data->gridLayer->setGridMatrix(XZ); |
398 data->gridLayer->setGridMatrix(DEFAULT_GRID_MATRIX); |
383 data->tools->setGridMatrix(XZ); |
399 data->tools->setGridMatrix(DEFAULT_GRID_MATRIX); |
384 data->model = model; |
400 data->model = model; |
385 data->canvas->addRenderLayer(data->axesLayer.get()); |
401 data->canvas->addRenderLayer(data->axesLayer.get()); |
386 data->canvas->setLayerEnabled(data->axesLayer.get(), setting<Setting::DrawAxes>()); |
402 data->canvas->setLayerEnabled(data->axesLayer.get(), setting<Setting::DrawAxes>()); |
387 data->canvas->addRenderLayer(data->gridLayer.get()); |
403 data->canvas->addRenderLayer(data->gridLayer.get()); |
388 data->canvas->addRenderLayer(data->tools.get()); |
404 data->canvas->addRenderLayer(data->tools.get()); |
667 if (modelSubWindow != nullptr) { |
683 if (modelSubWindow != nullptr) { |
668 if (ModelData* data = documents.findPayload<ModelData>(modelSubWindow->modelId)) { |
684 if (ModelData* data = documents.findPayload<ModelData>(modelSubWindow->modelId)) { |
669 checkEditingModeAction(data->tools->currentEditingMode()); |
685 checkEditingModeAction(data->tools->currentEditingMode()); |
670 mainWindow.modelEdit->setDocument(data->model); |
686 mainWindow.modelEdit->setDocument(data->model); |
671 mainWindow.modelEdit->setTextCursor(*data->textcursor); |
687 mainWindow.modelEdit->setTextCursor(*data->textcursor); |
|
688 mainWindow.modelEdit->setFont(codeEditorFontFromSettings()); |
672 } |
689 } |
673 } |
690 } |
674 else { |
691 else { |
675 checkEditingModeAction(EditingMode::SelectMode); |
692 checkEditingModeAction(EditingMode::SelectMode); |
676 } |
693 } |
716 if (ModelData* data = currentModelData(&mainWindow, &documents)) { |
733 if (ModelData* data = currentModelData(&mainWindow, &documents)) { |
717 documents.loadDependenciesForAllModels(libraries); |
734 documents.loadDependenciesForAllModels(libraries); |
718 data->canvas->update(); |
735 data->canvas->update(); |
719 } |
736 } |
720 }); |
737 }); |
|
738 QObject::connect( |
|
739 mainWindow.gridMatrix, |
|
740 &MatrixEditor::valueChanged, |
|
741 [&](const glm::mat4& newGridMatrix) |
|
742 { |
|
743 forEachModel(&documents, [&](const void*, const ModelData* data) |
|
744 { |
|
745 if (data->gridLayer != nullptr and data->tools != nullptr and data->canvas != nullptr) |
|
746 { |
|
747 data->gridLayer->setGridMatrix(newGridMatrix); |
|
748 data->tools->setGridMatrix(newGridMatrix); |
|
749 data->canvas->update(); |
|
750 } |
|
751 }); |
|
752 } |
|
753 ); |
|
754 mainWindow.gridMatrix->setValue(DEFAULT_GRID_MATRIX); |
721 mainWindow.tabifyDockWidget(mainWindow.messageLogDock, mainWindow.toolOptionsDock); |
755 mainWindow.tabifyDockWidget(mainWindow.messageLogDock, mainWindow.toolOptionsDock); |
722 mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>()); |
756 mainWindow.restoreGeometry(setting<Setting::MainWindowGeometry>()); |
723 mainWindow.restoreState(setting<Setting::MainWindowState>()); |
757 mainWindow.restoreState(setting<Setting::MainWindowState>()); |
724 // If a dock is made floating and the app is closed, the dock becomes invisible |
758 // If a dock is made floating and the app is closed, the dock becomes invisible |
725 // after the restoreState call. So we make them visible again here. |
759 // after the restoreState call. So we make them visible again here. |