diff --git a/src/group.cpp b/src/group.cpp index 0f458045..438d5108 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -813,6 +813,12 @@ void Group::GenerateEquations(IdList *l) { AddEq(l, (EC(axis.z))->Minus(EP(6)), 5); #undef EC #undef EP + if(type == Type::HELIX) { + if(valB != 0.0) { + AddEq(l, Expr::From(h.param(7))->Times(Expr::From(PI))-> + Minus(Expr::From(h.param(3))->Times(Expr::From(valB))), 6); + } + } } else if(type == Type::EXTRUDE) { if(predef.entityB != Entity::FREE_IN_3D) { // The extrusion path is locked along a line, normal to the diff --git a/src/textscreens.cpp b/src/textscreens.cpp index 884d963d..ee6d90ea 100644 --- a/src/textscreens.cpp +++ b/src/textscreens.cpp @@ -299,6 +299,23 @@ void TextWindow::ScreenChangeGroupScale(int link, uint32_t v) { SS.TW.edit.meaning = Edit::GROUP_SCALE; SS.TW.edit.group.v = v; } +void TextWindow::ScreenChangeHelixPitch(int link, uint32_t v) { + Group *g = SK.GetGroup(SS.TW.shown.group); + double pitch = g->valB/SS.MmPerUnit(); + SS.TW.ShowEditControl(3, ssprintf("%.8f", pitch)); + SS.TW.edit.meaning = Edit::HELIX_PITCH; + SS.TW.edit.group.v = v; +} +void TextWindow::ScreenChangePitchOption(int link, uint32_t v) { + Group *g = SK.GetGroup(SS.TW.shown.group); + if(g->valB == 0.0) { + g->valB = SK.GetParam(g->h.param(7))->val * PI / + (SK.GetParam(g->h.param(3))->val); + } else { + g->valB = 0.0; + } + SS.GW.Invalidate(); +} void TextWindow::ScreenDeleteGroup(int link, uint32_t v) { SS.UndoRemember(); @@ -398,6 +415,26 @@ void TextWindow::ShowGroupInfo() { } Printf(false, ""); + if(g->type == Group::Type::HELIX) { + Printf(false, "%Ft pitch - length per turn%E"); + + if (fabs(g->valB) != 0.0) { + Printf(false, " %Ba %# %Fl%Ll%f%D[change]%E", + g->valB / SS.MmPerUnit(), + &TextWindow::ScreenChangeHelixPitch, g->h.v); + } else { + Printf(false, " %Ba %# %E", + SK.GetParam(g->h.param(7))->val * PI / + ( (SK.GetParam(g->h.param(3))->val) * SS.MmPerUnit() ), + &TextWindow::ScreenChangeHelixPitch, g->h.v); + } + Printf(false, " %Fd%f%LP%s fixed", + &TextWindow::ScreenChangePitchOption, + g->valB != 0 ? CHECK_TRUE : CHECK_FALSE); + + Printf(false, ""); // blank line + } + if(g->type == Group::Type::EXTRUDE || g->type == Group::Type::LATHE || g->type == Group::Type::REVOLVE || g->type == Group::Type::LINKED || g->type == Group::Type::HELIX) { @@ -789,6 +826,15 @@ void TextWindow::EditControlDone(std::string s) { } break; + case Edit::HELIX_PITCH: // stored in valB + if(Expr *e = Expr::From(s, /*popUpError=*/true)) { + double ev = e->Eval(); + Group *g = SK.GetGroup(edit.group); + g->valB = ev * SS.MmPerUnit(); + SS.MarkGroupDirty(g->h); + } + break; + case Edit::GROUP_COLOR: { Vector rgb; if(sscanf(s.c_str(), "%lf, %lf, %lf", &rgb.x, &rgb.y, &rgb.z)==3) { diff --git a/src/ui.h b/src/ui.h index 026d57de..359ad401 100644 --- a/src/ui.h +++ b/src/ui.h @@ -342,7 +342,9 @@ public: VIEW_PROJ_RIGHT = 702, VIEW_PROJ_UP = 703, // For tangent arc - TANGENT_ARC_RADIUS = 800 + TANGENT_ARC_RADIUS = 800, + // For helix pitch + HELIX_PITCH = 802 }; struct { bool showAgain; @@ -473,6 +475,8 @@ public: static void ScreenChangeExprA(int link, uint32_t v); static void ScreenChangeGroupName(int link, uint32_t v); static void ScreenChangeGroupScale(int link, uint32_t v); + static void ScreenChangeHelixPitch(int link, uint32_t v); + static void ScreenChangePitchOption(int link, uint32_t v); static void ScreenChangeLightDirection(int link, uint32_t v); static void ScreenChangeLightIntensity(int link, uint32_t v); static void ScreenChangeLightAmbient(int link, uint32_t v);