Wed, 15 Jun 2022 19:47:02 +0300
Add wireframe button
src/gl/common.h | file | annotate | diff | comparison | revisions | |
src/gl/partrenderer.cpp | file | annotate | diff | comparison | revisions | |
src/main.cpp | file | annotate | diff | comparison | revisions | |
src/mainwindow.ui | file | annotate | diff | comparison | revisions | |
src/settings.h | file | annotate | diff | comparison | revisions |
--- a/src/gl/common.h Wed Jun 15 13:05:53 2022 +0300 +++ b/src/gl/common.h Wed Jun 15 19:47:02 2022 +0300 @@ -93,8 +93,6 @@ { // Normal rendering style Normal, - // Render all polygons as lines - Wireframe, // Use green colour for front faces and red colour for back faces BfcRedGreen, // Use a different colour for each object @@ -133,6 +131,7 @@ GLfloat lineThickness = 2.0f; bool lineAntiAliasing = true; bool drawAxes = true; + bool wireframe = false; }; }
--- a/src/gl/partrenderer.cpp Wed Jun 15 13:05:53 2022 +0300 +++ b/src/gl/partrenderer.cpp Wed Jun 15 19:47:02 2022 +0300 @@ -189,6 +189,9 @@ this->renderVao(gl::ArrayClass::Quads); this->renderVao(gl::ArrayClass::Lines); }; + if (this->renderPreferences.wireframe and this->renderPreferences.style != gl::RenderStyle::PickScene) { + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + } switch (this->renderPreferences.style) { case gl::RenderStyle::Normal: @@ -223,13 +226,9 @@ this->setFragmentStyle(gl::FragmentStyle::Black); renderAllArrays(); break; - case gl::RenderStyle::Wireframe: - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); - this->setFragmentStyle(gl::FragmentStyle::Normal); - renderAllArrays(); - break; } glDisable(GL_POLYGON_OFFSET_FILL); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); }
--- a/src/main.cpp Wed Jun 15 13:05:53 2022 +0300 +++ b/src/main.cpp Wed Jun 15 19:47:02 2022 +0300 @@ -252,6 +252,7 @@ action->setChecked(renderPreferences->style == data.payload); } ui->actionDrawAxes->setChecked(renderPreferences->drawAxes); + ui->actionWireframe->setChecked(renderPreferences->wireframe); }; static gl::RenderPreferences loadRenderPreferences() @@ -264,6 +265,7 @@ .lineThickness = setting<Setting::LineThickness>(), .lineAntiAliasing = setting<Setting::LineAntiAliasing>(), .drawAxes = setting<Setting::DrawAxes>(), + .wireframe = setting<Setting::Wireframe>(), }; } @@ -342,6 +344,7 @@ setSetting<Setting::RecentFiles>(recentlyOpenedFiles); setSetting<Setting::RenderStyle>(renderPreferences.style); setSetting<Setting::DrawAxes>(renderPreferences.drawAxes); + setSetting<Setting::Wireframe>(renderPreferences.wireframe); libraries.storeToSettings(); }; const auto updateRecentlyOpenedDocumentsMenu = [&]{ @@ -562,6 +565,11 @@ saveSettings(); updateRenderPreferences(&ui, &renderPreferences, &documents); }); + QObject::connect(ui.actionWireframe, &QAction::triggered, [&](bool enabled){ + renderPreferences.wireframe = enabled; + saveSettings(); + updateRenderPreferences(&ui, &renderPreferences, &documents); + }); for (auto data : ::renderStyleButtons) { QAction* action = data.memberInstance(&ui); QObject::connect(action, &QAction::triggered, [&, data]{
--- a/src/mainwindow.ui Wed Jun 15 13:05:53 2022 +0300 +++ b/src/mainwindow.ui Wed Jun 15 19:47:02 2022 +0300 @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>800</width> + <width>729</width> <height>600</height> </rect> </property> @@ -38,7 +38,7 @@ <rect> <x>0</x> <y>0</y> - <width>800</width> + <width>729</width> <height>29</height> </rect> </property> @@ -70,6 +70,7 @@ <addaction name="actionRenderStyleBfc"/> <addaction name="actionRenderStyleRandom"/> <addaction name="actionRenderStylePickScene"/> + <addaction name="actionWireframe"/> <addaction name="separator"/> <addaction name="actionAdjustGridToView"/> <addaction name="actionDrawAxes"/> @@ -125,6 +126,7 @@ <addaction name="actionRenderStyleNormal"/> <addaction name="actionRenderStyleBfc"/> <addaction name="actionRenderStyleRandom"/> + <addaction name="actionWireframe"/> <addaction name="actionDrawAxes"/> </widget> <widget class="QToolBar" name="editToolBar"> @@ -401,6 +403,18 @@ <string>About Qt</string> </property> </action> + <action name="actionWireframe"> + <property name="checkable"> + <bool>true</bool> + </property> + <property name="icon"> + <iconset resource="../ldforge.qrc"> + <normaloff>:/icons/renderstyle-wireframe.png</normaloff>:/icons/renderstyle-wireframe.png</iconset> + </property> + <property name="text"> + <string>Wireframe</string> + </property> + </action> </widget> <resources> <include location="../ldforge.qrc"/>
--- a/src/settings.h Wed Jun 15 13:05:53 2022 +0300 +++ b/src/settings.h Wed Jun 15 19:47:02 2022 +0300 @@ -37,7 +37,7 @@ SETTING(LineThickness, 2.0f) SETTING(LineAntiAliasing, true) SETTING(RenderStyle, gl::RenderStyle::Normal) -SETTING(DrawWireframe, false) +SETTING(Wireframe, false) SETTING(DrawAxes, true) SETTING(MainWindowGeometry, QByteArray{}) SETTING(MainSplitterState, QByteArray{})