diff --git a/src/group.cpp b/src/group.cpp index 12afe21..73a437d 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 2ec0c68..430f1f5 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 4a1ffcc..a9a697a 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 863c89f..30f3775 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 a6d4523..68b8154 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