Auto-Smooth & Force Length (Code available, looking for dev help)

Interactive OK… once I moved the Options groupbox. Also “(Hobby)” was just noise… nobody is going to know what it is or means. It’s also going to create issues with ambiguity in translations… is it a person named Hobby… or is it a hobby. Less is More.

Again Claude doesn’t seem to have a clue what to do with the UI forms. :roll_eyes:

Also we can’t have Claude changing code… for ex: we need to follow Allman style for braces with no single line blocks. All code blocks must be in braces.

No: It’s not the 70’s… we don’t need to save paper… thank you very much K&R

int index = ui->lineType_ComboBox->findData(LineTypeNone);
if (index != -1) ui->lineType_ComboBox->removeItem(index);

Yes:

int index = ui->lineType_ComboBox->findData(LineTypeNone);
if (index != -1)
{
    ui->lineType_ComboBox->removeItem(index);
}

This No: It’s mess to read. And again we’re not stuck in the 80’s and 80 char screens

connect(ui->comboBoxP1, &QComboBox::currentTextChanged,
        this, &DialogCubicBezier::PointNameChanged);
connect(ui->comboBoxP2, &QComboBox::currentTextChanged,
        this, &DialogCubicBezier::PointNameChanged);
connect(ui->comboBoxP3, &QComboBox::currentTextChanged,
        this, &DialogCubicBezier::PointNameChanged);
connect(ui->comboBoxP4, &QComboBox::currentTextChanged,
        this, &DialogCubicBezier::PointNameChanged);

This Yes:

connect(ui->comboBoxP1, &QComboBox::currentTextChanged, this, &DialogCubicBezier::PointNameChanged);
connect(ui->comboBoxP2, &QComboBox::currentTextChanged, this, &DialogCubicBezier::PointNameChanged);
connect(ui->comboBoxP3, &QComboBox::currentTextChanged, this, &DialogCubicBezier::PointNameChanged);
connect(ui->comboBoxP4, &QComboBox::currentTextChanged, this, &DialogCubicBezier::PointNameChanged);
3 Likes

OMG… Claude mangled the hell out of the DialogCubicBezier file… besides what I posted above, it deleted whole sections and members - specifically sp1()… that’s why the name isn’t being created.

Also it appears it added a bunch of uneccssary get functions for the CubicBezierTool so it’s got this:

instead of this:

The only thing that should have changed is handling and getting the new check boxes and length formula. That’s it.

Why was there a need to touch the enums? No new tool enums were added and if they are they are added at the end of the enum list.

3 Likes

The original dialog had this:

VCubicBezier DialogCubicBezier::GetSpline() const
{
    return spl;
}

which returns the whole spline including the 4 points… you pass spl and extract the points:

there is no need to have 4 separate get functions to return the points from the dialog.

On the other hand there does need to be a call back function for the Prop Editor for each point - for ex:

each

From my point of view it’s difficult to see what changes have been added, because the whole file has changed… most of which have nothing to do with adding the feature. By chance did this dialog get mixed up with the Interactive dialog?

3 Likes

@odrnorn

I got the update with the new schema. I haven’t built with it yet, but it look to all be correct. :slightly_smiling_face:

Just a few notes.

This 0.7.4 schema bump was easy… it’s just setting the new version number. On the other hand the feature I’m currently working on for the multisize feature changes the xml schema a lot… removing some elements, moving some to a different element, and adding new ones. A real fun one is renaming attributes as unlike elements there is no method to rename them. You have to loop and find them, save a copy of the value, delete the attribute, then add it back in with a new name with the value from the saved copy. A good case in study for conversions is the passmark → notches. :wink:

Something else to keep in mind… whenever new features are added (or removed) that chnage the schema there’s always the chance that another dev may also working on a new schema with the same version number, and it will certainly cause conflcts where one dev will have to change their schema - so be aware of that.

3 Likes

Found another minror bug… if the enforce length checkbox is unchecked when the dialog opens it’s not hiding the lengtht formula.

And another major bug with the Curve Fixed… the visualization does not match the curve:

And another major bug with Curve -Interactive. Unchecking the Enforce curve length does not restore the orginal curve.

And another… the Curve -Interactive. Apply button has no effect.

I have no idea how this is optimised?

3 Likes

Hi everyone, and especially @Douglas — thank you for the thorough review and honest feedback on the first attempt. You were right on pretty much every point.

Rather than patching the original branch, I started over from scratch on a clean develop base (Qt 6.5.3, matching upstream CI). Every issue Douglas identified has been addressed:

What changed since the first version:

  • Schema versioning done properly — new v0.7.4 schema with converter chain from v0.7.3, not patching the existing schema

  • No more mangled dialogs — the .ui forms are cleanly extended with a new Options GroupBox, nothing moved or deleted. Curve name, sp1(), all original members untouched

  • No unnecessary getter rewritesGetSpline() still returns the whole spline as before. Only the new attributes (autoSmooth, lengthMode, targetLength) got accessors

  • Allman braces throughout, no single-line blocks, no K&R-style wrapping

  • Copyright headers preserved — no files were mangled

  • Checkboxes → Dropdowns — as Douglas suggested, since the Property Editor has no checkbox plugin. Auto-Smooth (No/Yes) and Adjust Length (Off/Start/End/Both)

  • No more “Error” on empty formula — the curve length field defaults to the current arc length when no target is set

  • Visualization fixed — both the selection highlight and the dialog preview now show the computed curve, not the original. This was a deeper architectural fix (new setShowPoints() pattern that survives mouseMove refresh cycles)

  • Toggle preservation — switching Adjust Length to Off no longer destroys your value. Switch back and it’s still there

  • Reference counting bug fixed — pre-existing bug where Create() incremented P1 three times instead of P1/P2/P3/P4

What’s new compared to the first version:

  • Adjust Length has per-handle control — Start / End / Both, instead of just on/off. This lets you constrain only one handle while the other stays free

  • Combined mode uses tension, not linear scaling — when both Auto-Smooth and Curve Length are active, the solver varies the Hobby tension parameter τ instead of stretching the finished handles. This keeps the natural curve shape at any target length

  • Both solvers use secant method — consistent, fast convergence

The PR is here: FashionFreedom/Seamly2D#1588

12 commits, 25 files, +2700/−33 lines. The diff is almost entirely additive — the only structural change to existing code is the Create() dispatch, which is documented in-code with a comment explaining why sequential application doesn’t work.

@Douglas — I’d appreciate your review when you have time. Happy to adjust anything that doesn’t fit.

2 Likes

I’ll take a look later after I get some sleeo. :slight_smile:

3 Likes

Hey @odrnorn

Feature looks and work much better :slight_smile: I like the additions and the use of the drop downs for the length mode. In an odd sort of way it makes the dialogs and Properties Editor more cohesive rather than one using checkboxes and the other dropdowns.

Anyhow I had a look and requested a few changes:

Several requests as per my comment on Github…

  • Hyphented text should be avoided… it can cause issues when translating. Also the labels do not match between the Dialogs and Properties editor. The dialogs use “Auto-Smooth” while the Editor uses “Smooth curve”. I suggest using "Smooth curve in both. “Auto” can be ambiguous when translating as it’s an abbreviation for “automatic” and can be confused an "automobile.

  • The fx buttons do not work in either of the dialogs.

  • While a curve length formula can be entered in the Propeties Editor, it does not show in the dialog.

    Screenshot 2026-06-22 194455

    And the length value in the dialog does not match.

    Screenshot 2026-06-22 194516

    If the curve length formula is edited in the Properties Editor, and pattern immediately saved the formula is saved. If the curve dialog is then opened and Ok pressed the formula is replaced by the length value and the formulas will not be saved.

    Other than that everything else seems to work ok.

Not going to worry with this PR, but in the future as far as naming conventions for any new code - All classes shoud be UpperCamelCase, while functions, methods and variables should be lowerCamelCase. Basically following Qt’s conventions here. Also avoid using single char variable names other than iterators like i, j, k.

For ex: “s” here says nothing about what the QPair is, and searching for “s” would be futile.

const QPair<qreal, qreal> s = VAbstractCubicBezier::SolveHobbyTension(
        static_cast<QPointF>(*p1), static_cast<QPointF>(*p4),
        calcAngle1, calcAngle2, targetPx, lengthMode);
    finalLength1 = s.first;
    finalLength2 = s.second;

A better name would be something like handle with handle.first and handle.second. That tells me that the lengths are handle lengths without having to read the comment. In other words code should be self documenting with minimal comments.

4 Likes

Thanks for the thorough review and the quick feedback :slight_smile: really appreciate you taking the time to test everything hands-on.

I’ve addressed all three points and pushed the fixes:

  1. Labels: Renamed “Auto-Smooth” to “Smooth curve” in both curve dialogs to match the Properties Editor. No more hyphenated text for the translators.

  2. fx buttons: Wired up the curve length formula button in both Curve Fixed and Curve Interactive dialogs — they now open the formula editor as expected.

  3. Formula sync: The dialog now properly loads the stored formula from the Properties Editor instead of replacing it with a numeric value. Opening the dialog and pressing OK no longer destroys the formula.

The commit is up on the PR: d977a70 — fix: address review feedback.

Also noted your naming convention guidance (lowerCamelCase, self-documenting variable names) — will keep that in mind going forward. I can also offer to go over my code and try to get it au pair.

Let me know if there’s anything else that needs adjusting!

3 Likes

Feature has been merged and should be in next weeks release.

3 Likes

Thank you very much, @Douglas & @odrnorn

This is an amazing upgrade to the software. I can’t wait for Monday :grin:

4 Likes

Finally got around to playing with this feature. Is there a way to use the smooth-adjusted length in a formula? Because when I’m wanting another measurement to match my curve, I want it to match my curve, & it doesn’t seem to when I use “Smooth curve”.

:unicorn:

2 Likes

I’ve also been playing with them. You can use a formula to the length of the previous curve. Both of those features only work on the length of the curve handles, so make sure that the angles are formulated.

Something that I’ve learnt, that may help… Always create the shorter curve 1st so that you can adjust the length of the longer curve’s curve handles to match the shorter curve, otherwise you just get a straight line. :grin:

3 Likes

I only played with the curves enough to test, but yes a length formula of anything less than the distance between the 2 points will just create a line. I also suspect that trying to match / adjust a curve length beyond a certain point is going to produce a curve that is not right… which is going to depend on the length you are trying to match. Trying to adjust a front neck line 3/4" to match a collar is not goinjg to produce a proper curve… where as maybe you could get away with 3/4" on the side seam of pants.

3 Likes