From 73f28b97317842650f95969f628ace3574966519 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Fri, 25 Mar 2016 14:45:49 +0600 Subject: [PATCH] Make normals and workplanes non-stylable. This does not seem to have any useful application, and it can result in odd misrenderings with some styles. --- src/draw.cpp | 19 +++++-------------- src/drawconstraint.cpp | 5 +++++ src/drawentity.cpp | 7 +++++++ src/sketch.h | 2 ++ src/style.cpp | 5 ++++- src/ui.h | 1 - 6 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/draw.cpp b/src/draw.cpp index 7a0961f..9652d55 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -19,15 +19,6 @@ bool GraphicsWindow::Selection::IsEmpty(void) { return true; } -bool GraphicsWindow::Selection::IsStylable(void) { - if(entity.v) return true; - if(constraint.v) { - Constraint *c = SK.GetConstraint(constraint); - if(c->type == Constraint::COMMENT) return true; - } - return false; -} - bool GraphicsWindow::Selection::HasEndpoints(void) { if(!entity.v) return false; Entity *e = SK.GetEntity(entity); @@ -257,12 +248,14 @@ void GraphicsWindow::GroupSelection(void) { (gs.n)++; Entity *e = SK.entity.FindById(s->entity); + + if(e->IsStylable()) gs.stylables++; + // A list of points, and a list of all entities that aren't points. if(e->IsPoint()) { gs.point[(gs.points)++] = s->entity; } else { gs.entity[(gs.entities)++] = s->entity; - (gs.stylables)++; } // And an auxiliary list of normals, including normals from @@ -305,10 +298,8 @@ void GraphicsWindow::GroupSelection(void) { if(s->constraint.v) { gs.constraint[(gs.constraints)++] = s->constraint; Constraint *c = SK.GetConstraint(s->constraint); - if(c->type == Constraint::COMMENT) { - (gs.stylables)++; - (gs.comments)++; - } + if(c->IsStylable()) gs.stylables++; + if(c->type == Constraint::COMMENT) gs.comments++; } } } diff --git a/src/drawconstraint.cpp b/src/drawconstraint.cpp index 96b614e..432b816 100644 --- a/src/drawconstraint.cpp +++ b/src/drawconstraint.cpp @@ -1117,3 +1117,8 @@ void Constraint::GetEdges(SEdgeList *sel) { dogd.sel = NULL; } +bool Constraint::IsStylable() { + if(type == COMMENT) return true; + return false; +} + diff --git a/src/drawentity.cpp b/src/drawentity.cpp index bbec8d2..ef2f72c 100644 --- a/src/drawentity.cpp +++ b/src/drawentity.cpp @@ -205,6 +205,13 @@ Vector Entity::GetReferencePos(void) { return dogd.refp; } +bool Entity::IsStylable() { + if(IsPoint()) return false; + if(IsWorkplane()) return false; + if(IsNormal()) return false; + return true; +} + bool Entity::IsVisible(void) { Group *g = SK.GetGroup(group); diff --git a/src/sketch.h b/src/sketch.h index 3e53087..144d7db 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -494,6 +494,7 @@ public: void LineDrawOrGetDistance(Vector a, Vector b, bool maybeFat=false); void DrawOrGetDistance(void); + bool IsStylable(); bool IsVisible(void); bool PointIsFromReferences(void); @@ -676,6 +677,7 @@ public: Vector GetReferencePos(void); void Draw(void); void GetEdges(SEdgeList *sel); + bool IsStylable(); void LineDrawOrGetDistance(Vector a, Vector b); void DrawOrGetDistance(Vector *labelPos); diff --git a/src/style.cpp b/src/style.cpp index 1bfd2cb..a86a017 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -148,6 +148,9 @@ void Style::AssignSelectionToStyle(uint32_t v) { int i; for(i = 0; i < SS.GW.gs.entities; i++) { hEntity he = SS.GW.gs.entity[i]; + Entity *e = SK.GetEntity(he); + if(!e->IsStylable()) continue; + if(!he.isFromRequest()) { showError = true; continue; @@ -161,7 +164,7 @@ void Style::AssignSelectionToStyle(uint32_t v) { for(i = 0; i < SS.GW.gs.constraints; i++) { hConstraint hc = SS.GW.gs.constraint[i]; Constraint *c = SK.GetConstraint(hc); - if(c->type != Constraint::COMMENT) continue; + if(!c->IsStylable()) continue; c->disp.style.v = v; } diff --git a/src/ui.h b/src/ui.h index 3e4cce8..fec523b 100644 --- a/src/ui.h +++ b/src/ui.h @@ -618,7 +618,6 @@ public: void Clear(void); bool IsEmpty(void); bool Equals(Selection *b); - bool IsStylable(void); bool HasEndpoints(void); }; Selection hover;