From f99829376000f31a0c94aa67bb827c4cd50ebf91 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 14 Aug 2016 00:55:27 +0000 Subject: [PATCH] Allow displaying outlines without any other edges. As usual, what's displayed is what's exported. --- CHANGELOG.md | 9 ++++++--- src/export.cpp | 8 +++++--- src/graphicswin.cpp | 4 +++- src/groupmesh.cpp | 26 +++++++++++++------------- 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb3d0559..a64118ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,15 +8,18 @@ New export/import features: * Three.js: allow configuring projection for exported model, and initially use the current viewport projection. +New rendering features: + * The "Show/hide hidden lines" button is now a tri-state button that allows + showing all lines (on top of shaded mesh), stippling occluded lines + or not drawing them at all. + * The "Show/hide outlines" button is now independent from "Show/hide edges". + Other new features: * New command for measuring total length of selected entities, "Analyze → Measure Perimeter". * New link to match the on-screen size of the sketch with its actual size, "view → set to full scale". * When zooming to fit, constraints are also considered. - * The "Show/hide hidden lines" button is now a tri-state button that allows - showing all lines (on top of shaded mesh), stippling occluded lines - or not drawing them at all. 2.2 --- diff --git a/src/export.cpp b/src/export.cpp index 386d2621..ba6667f8 100644 --- a/src/export.cpp +++ b/src/export.cpp @@ -203,10 +203,12 @@ void SolveSpaceUI::ExportViewOrWireframeTo(const std::string &filename, bool exp } } - if(SS.GW.showEdges) { + if(SS.GW.showEdges || SS.GW.showOutlines) { Group *g = SK.GetGroup(SS.GW.activeGroup); g->GenerateDisplayItems(); - g->displayOutlines.ListTaggedInto(&edges, Style::SOLID_EDGE); + if(SS.GW.showEdges) { + g->displayOutlines.ListTaggedInto(&edges, Style::SOLID_EDGE); + } } if(SS.GW.showConstraints) { @@ -388,7 +390,7 @@ void SolveSpaceUI::ExportLinesAndMesh(SEdgeList *sel, SBezierList *sbl, SMesh *s // Generate the edges where a curved surface turns from front-facing // to back-facing. - if(SS.GW.showEdges) { + if(SS.GW.showEdges || SS.GW.showOutlines) { root->MakeCertainEdgesInto(sel, EdgeKind::TURNING, /*coplanarIsInter=*/false, NULL, NULL, GW.showOutlines ? Style::OUTLINE : Style::SOLID_EDGE); diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index 55af7bf9..d8b1a1d1 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -1076,7 +1076,9 @@ void GraphicsWindow::ToggleBool(bool *v) { // We might need to regenerate the mesh and edge list, since the edges // wouldn't have been generated if they were previously hidden. - if(showEdges) (SK.GetGroup(activeGroup))->displayDirty = true; + if(showEdges || showOutlines) { + SK.GetGroup(activeGroup)->displayDirty = true; + } SS.GenerateAll(); InvalidateGraphics(); diff --git a/src/groupmesh.cpp b/src/groupmesh.cpp index 599c5fa5..03164f32 100644 --- a/src/groupmesh.cpp +++ b/src/groupmesh.cpp @@ -378,7 +378,7 @@ void Group::GenerateDisplayItems() { displayMesh.MakeFromCopyOf(&(pg->displayMesh)); displayOutlines.Clear(); - if(SS.GW.showEdges) { + if(SS.GW.showEdges || SS.GW.showOutlines) { displayOutlines.MakeFromCopyOf(&pg->displayOutlines); } } else { @@ -398,7 +398,7 @@ void Group::GenerateDisplayItems() { displayOutlines.Clear(); - if(SS.GW.showEdges) { + if(SS.GW.showEdges || SS.GW.showOutlines) { if(runningMesh.l.n > 0) { // Triangle mesh only; no shell or emphasized edges. runningMesh.MakeOutlinesInto(&displayOutlines, EdgeKind::EMPHASIZED); @@ -528,17 +528,6 @@ void Group::Draw(Canvas *canvas) { DrawMesh(DrawMeshAs::DEFAULT, canvas); if(SS.GW.showEdges) { - if(SS.GW.showOutlines) { - Canvas::Stroke strokeOutline = {}; - strokeOutline.zIndex = 1; - strokeOutline.color = Style::Color(Style::OUTLINE); - strokeOutline.width = Style::Width(Style::OUTLINE); - Canvas::hStroke hcsOutline = canvas->GetStroke(strokeOutline); - - canvas->DrawOutlines(displayOutlines, hcsOutline, - Canvas::DrawOutlinesAs::CONTOUR_ONLY); - } - Canvas::Stroke strokeEdge = {}; strokeEdge.zIndex = 1; strokeEdge.color = Style::Color(Style::SOLID_EDGE); @@ -562,6 +551,17 @@ void Group::Draw(Canvas *canvas) { Canvas::DrawOutlinesAs::EMPHASIZED_AND_CONTOUR); } } + + if(SS.GW.showOutlines) { + Canvas::Stroke strokeOutline = {}; + strokeOutline.zIndex = 1; + strokeOutline.color = Style::Color(Style::OUTLINE); + strokeOutline.width = Style::Width(Style::OUTLINE); + Canvas::hStroke hcsOutline = canvas->GetStroke(strokeOutline); + + canvas->DrawOutlines(displayOutlines, hcsOutline, + Canvas::DrawOutlinesAs::CONTOUR_ONLY); + } } void Group::DrawPolyError(Canvas *canvas) {