From 55e3162a05d4e942052a11a5c0b288ad3fd61cb2 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Sat, 2 Apr 2016 19:34:17 +0600 Subject: [PATCH] When creating a new group, use the color of last requested solid. --- src/group.cpp | 9 +++++++++ src/groupmesh.cpp | 11 +++++++++++ src/sketch.h | 1 + src/solvespace.cpp | 12 ++++++++++++ src/solvespace.h | 1 + 5 files changed, 34 insertions(+) diff --git a/src/group.cpp b/src/group.cpp index 12afe211..73a437d3 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -222,6 +222,15 @@ void Group::MenuGroup(int id) { default: oops(); } + + // Copy color from the previous mesh-contributing group. + if(g.IsMeshGroup() && SK.groupOrder.n > 0) { + Group *running = SK.GetRunningMeshGroup(); + if(running != NULL) { + g.color = running->color; + } + } + SS.GW.ClearSelection(); SS.UndoRemember(); diff --git a/src/groupmesh.cpp b/src/groupmesh.cpp index 2ec0c682..430f1f52 100644 --- a/src/groupmesh.cpp +++ b/src/groupmesh.cpp @@ -430,6 +430,17 @@ Group *Group::RunningMeshGroup(void) { } } +bool Group::IsMeshGroup() { + switch(type) { + case Group::EXTRUDE: + case Group::LATHE: + case Group::ROTATE: + case Group::TRANSLATE: + return true; + } + return false; +} + void Group::DrawDisplayItems(int t) { RgbaColor specColor; bool useSpecColor; diff --git a/src/sketch.h b/src/sketch.h index 4a1ffcc5..a9a697a9 100644 --- a/src/sketch.h +++ b/src/sketch.h @@ -243,6 +243,7 @@ public: // And the mesh stuff Group *PreviousGroup(void); Group *RunningMeshGroup(void); + bool IsMeshGroup(); void GenerateShellAndMesh(void); template void GenerateForStepAndRepeat(T *steps, T *outs); template void GenerateForBoolean(T *a, T *b, T *o, int how); diff --git a/src/solvespace.cpp b/src/solvespace.cpp index 863c89f6..30f37750 100644 --- a/src/solvespace.cpp +++ b/src/solvespace.cpp @@ -852,3 +852,15 @@ BBox Sketch::CalculateEntityBBox(bool includingInvisible) { } return box; } + +Group *Sketch::GetRunningMeshGroup() { + if(groupOrder.n < 1) return NULL; + Group *g = GetGroup(groupOrder.elem[groupOrder.n - 1]); + while(g != NULL) { + if(g->IsMeshGroup()) { + return g; + } + g = g->PreviousGroup(); + } + return NULL; +} diff --git a/src/solvespace.h b/src/solvespace.h index a6d4523c..68b81546 100644 --- a/src/solvespace.h +++ b/src/solvespace.h @@ -672,6 +672,7 @@ public: void Clear(void); BBox CalculateEntityBBox(bool includingInvisible); + Group *GetRunningMeshGroup(); }; #undef ENTITY #undef CONSTRAINT