Skip to content

CATROID-1645 Replace peripheral-specific arc/go-through bricks with shared blue motion bricks#5192

Open
wslany wants to merge 8 commits intoCatrobat:developfrom
wslany:codex/CATROID-1645
Open

CATROID-1645 Replace peripheral-specific arc/go-through bricks with shared blue motion bricks#5192
wslany wants to merge 8 commits intoCatrobat:developfrom
wslany:codex/CATROID-1645

Conversation

@wslany
Copy link
Copy Markdown
Member

@wslany wslany commented Apr 9, 2026

Summary

This PR replaces the six unreleased peripheral-specific motion bricks

  • EmbroideryArcBrick
  • EmbroideryThroughBrick
  • LaserArcBrick
  • LaserThroughBrick
  • PlotArcBrick
  • PlotThroughBrick

with two shared blue motion bricks:

  • ArcBrick
  • GoThroughBrick

The new shared bricks work consistently for normal motion, pen, embroidery, laser cutting, and plotting. This removes a substantial amount of duplicated brick and layout code and keeps the motion behavior in one place.

Because the six old bricks have not been released publicly, there are no backward-compatibility or migration concerns for existing projects.

Ticket

What Changed

1. Unified arc and go-through into shared blue motion bricks

  • Renamed the previous plot-specific implementations into the shared blue bricks:
    • PlotArcBrick -> ArcBrick
    • LaserThroughBrick -> GoThroughBrick
  • Removed the dedicated embroidery / laser / plot arc and go-through brick classes and layouts.
  • Updated ActionFactory and the shared motion actions so the same motion logic is used across normal motion, pen, embroidery, plotting, and cutting.

2. Added the shared motion bricks to peripheral brick menus

The embroidery, laser cutter, and plotter menus now expose the shared blue motion bricks directly, since they are especially useful in those categories.

Added to those menus:

  • Place at
  • Set X to
  • Set Y to
  • Change X by
  • Change Y by
  • Move _ steps
  • Turn left
  • Turn right
  • Point in direction
  • Go in arc
  • Go through

3. Added numeric visual placement support

  • GoThroughBrick now supports the same visual-placement behavior for plain numeric coordinates that users expect from the other motion bricks.

4. Restored and generalized correct arc / go-through behavior

  • Restored the corrected arc behavior that had previously only been fixed for embroidery.
  • Ensured arc and go-through update direction and intermediate motion consistently across:
    • normal motion
    • pen
    • embroidery
    • plotter
    • laser cutter

Additional Fixes Included

While manually testing the branch, several follow-up bugs were found and fixed so that stage rendering and exported files stay aligned.

Export and rendering fixes

  • Fixed plot / laser export corruption caused by shared mutable geometry between live rendering and exported data.
  • Fixed SVG export so the Y axis matches the stage output.
  • Fixed DST export corruption for negative embroidery extents by correcting the DST header formatting and keeping the file header aligned to 512 bytes.

Live stage fixes

  • Fixed delayed live rendering for plot / cut lines where a later movement was required before the previous line segment became visible.
  • Fixed embroidery stage rendering so it respects the current stage projection and preserved-aspect-ratio mode.

Lifecycle / restart fixes

  • Fixed drawing-state reset behavior when restarting from stage and when leaving stage back to the IDE before running again.
  • Kept the branch aligned with the upstream CATROID-1640 fix and addressed the additional lifecycle paths discovered during manual testing.

Implementation Notes

  • Touched Java production files were rewritten to Kotlin where practical:
    • EmbroideryActor.java -> EmbroideryActor.kt
    • DSTHeader.java -> DSTHeader.kt

Main Files

Production

  • catroid/src/main/java/org/catrobat/catroid/content/ActionFactory.java
  • catroid/src/main/java/org/catrobat/catroid/content/Look.java
  • catroid/src/main/java/org/catrobat/catroid/content/actions/PlotArcAction.kt
  • catroid/src/main/java/org/catrobat/catroid/content/actions/PlotThroughAction.kt
  • catroid/src/main/java/org/catrobat/catroid/content/bricks/ArcBrick.kt
  • catroid/src/main/java/org/catrobat/catroid/content/bricks/GoThroughBrick.kt
  • catroid/src/main/java/org/catrobat/catroid/plot/Plot.kt
  • catroid/src/main/java/org/catrobat/catroid/plot/SVGPlotGenerator.kt
  • catroid/src/main/java/org/catrobat/catroid/stage/EmbroideryActor.kt
  • catroid/src/main/java/org/catrobat/catroid/stage/StageLifeCycleController.java
  • catroid/src/main/java/org/catrobat/catroid/embroidery/DSTHeader.kt
  • catroid/src/main/java/org/catrobat/catroid/ui/fragment/CategoryBricksFactory.kt

Layout / resources

  • catroid/src/main/res/layout/brick_arc.xml
  • catroid/src/main/res/layout/brick_go_through.xml
  • catroid/src/main/res/values/strings.xml

Tests

  • catroid/src/test/java/org/catrobat/catroid/test/content/actions/EmbroideryArcActionTest.kt
  • catroid/src/test/java/org/catrobat/catroid/test/content/actions/PlotArcActionTest.kt
  • catroid/src/test/java/org/catrobat/catroid/test/content/actions/PlotThroughActionTest.kt
  • catroid/src/test/java/org/catrobat/catroid/test/content/bricks/GoThroughBrickTest.kt
  • catroid/src/test/java/org/catrobat/catroid/test/plot/PlotTest.kt
  • catroid/src/test/java/org/catrobat/catroid/test/embroidery/EmbroideryExportIsolationTest.kt
  • catroid/src/test/java/org/catrobat/catroid/test/embroidery/DSTHeaderTest.kt
  • catroid/src/test/java/org/catrobat/catroid/stage/EmbroideryActorProjectionTest.kt
  • catroid/src/test/java/org/catrobat/catroid/stage/StageLifeCycleControllerTest.kt
  • catroid/src/test/java/org/catrobat/catroid/test/ui/fragment/PeripheralMotionCategoryBricksTest.kt
  • catroid/src/androidTest/java/org/catrobat/catroid/test/content/bricks/BrickCategoryTest.java

Testing

Focused tests run during development included:

  • shared arc regression tests
  • shared go-through regression tests
  • visual placement regression tests
  • plot / laser export regression tests
  • SVG export regression tests
  • DST export isolation and header-alignment regression tests
  • stage lifecycle reset regression tests
  • embroidery stage projection regression tests
  • peripheral category menu regression tests

Concrete commands run included:

:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.test.content.actions.EmbroideryArcActionTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.test.content.actions.PlotArcActionTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.test.content.actions.PlotThroughActionTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.test.content.bricks.GoThroughBrickTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.test.plot.PlotTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.test.embroidery.EmbroideryExportIsolationTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.test.embroidery.DSTHeaderTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.stage.EmbroideryActorProjectionTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.stage.StageLifeCycleControllerTest
:catroid:testCatroidDebugUnitTest --tests org.catrobat.catroid.test.ui.fragment.PeripheralMotionCategoryBricksTest
:catroid:assembleCatroidDebugAndroidTest

Independent Embroidery Designer APKs were also built repeatedly for manual device testing while addressing the follow-up bugs.

Reviewer Notes

  • The core CATROID-1645 simplification is the replacement of six peripheral-specific bricks with two shared blue motion bricks.
  • This branch also contains the follow-up fixes needed to make stage behavior and exported SVG / DST output match manual testing results.
  • Since the old peripheral-specific bricks were unreleased, the simplification could be done directly without compatibility code.

Your checklist for this pull request

Please review the contributing guidelines and wiki pages of this repository.

  • Include the name of the Jira ticket in the PR’s title
  • Include a summary of the changes plus the relevant context
  • Choose the proper base branch (develop)
  • Confirm that the changes follow the project’s coding guidelines
  • Verify that the changes generate no compiler or linter warnings
  • Perform a self-review of the changes
  • Verify to commit no other files than the intentionally changed ones
  • Include reasonable and readable tests verifying the added or changed behavior
  • Confirm that new and existing unit tests pass locally
  • Check that the commits’ message style matches the project’s guideline
  • Stick to the project’s gitflow workflow
  • Verify that your changes do not have any conflicts with the base branch
  • After the PR, verify that all CI checks have passed
  • Post a message in the catroid-stage or catroid-ide Slack channel and ask for a code reviewer

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR consolidates previously peripheral-specific (unreleased) arc/go-through motion bricks into shared blue motion bricks (ArcBrick, GoThroughBrick), and updates motion/render/export/lifecycle code paths so arc and bezier “go through” behave consistently across normal motion, pen, embroidery, plotter, and laser cutter.

Changes:

  • Replace peripheral-specific arc/go-through bricks and layouts with shared motion equivalents, and wire them into the relevant brick categories.
  • Update arc/go-through actions to compute intermediate motion + direction consistently, including embroidery/plot implications.
  • Fix/verify export + live rendering alignment issues (plot queues, SVG Y inversion, DST header formatting) and add regression tests.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
catroid/src/main/java/org/catrobat/catroid/content/ActionFactory.java Switch plot-arc factory API to ArcBrick.Directions.
catroid/src/main/java/org/catrobat/catroid/content/Look.java Trigger running-stitch updates on position changes (respecting simultaneousMovementXY).
catroid/src/main/java/org/catrobat/catroid/content/actions/PlotArcAction.kt Rework arc path + direction updates using motion direction.
catroid/src/main/java/org/catrobat/catroid/content/actions/PlotThroughAction.kt Rework bezier “go through” to use doubles + update direction along the curve.
catroid/src/main/java/org/catrobat/catroid/content/bricks/ArcBrick.kt Rename/convert plot arc brick to shared motion ArcBrick + new layout ids.
catroid/src/main/java/org/catrobat/catroid/content/bricks/GoThroughBrick.kt Introduce shared motion GoThroughBrick with visual placement support.
catroid/src/main/java/org/catrobat/catroid/embroidery/DSTHeader.kt Kotlin rewrite + fixed-width header formatting for negative extents.
catroid/src/main/java/org/catrobat/catroid/plot/Plot.kt Prevent shared-mutable-point corruption between render queue and export data.
catroid/src/main/java/org/catrobat/catroid/plot/SVGPlotGenerator.kt Invert Y axis so SVG output matches stage coordinates.
catroid/src/main/java/org/catrobat/catroid/stage/EmbroideryActor.kt Kotlin rewrite; ensure ShapeRenderer uses batch projection/transform matrices.
catroid/src/main/java/org/catrobat/catroid/stage/StageLifeCycleController.java Reset sprite drawing state on stage destroy to ensure clean restarts.
catroid/src/main/java/org/catrobat/catroid/ui/fragment/CategoryBricksFactory.kt Add shared motion bricks to motion + peripheral categories via helper list.
catroid/src/main/res/layout/brick_arc.xml Shared motion arc brick layout (motion styling + ids).
catroid/src/main/res/layout/brick_go_through.xml Shared motion go-through layout (motion styling + ids).
catroid/src/main/res/values/strings.xml Add shared strings for arc/go-through brick UI text.
catroid/src/androidTest/java/org/catrobat/catroid/test/BricksHelpUrlTest.java Update help URL mappings to new shared bricks.
catroid/src/androidTest/java/org/catrobat/catroid/test/content/bricks/BrickCategoryTest.java Update expected category brick lists (motion/peripheral include shared bricks).
catroid/src/test/java/org/catrobat/catroid/stage/EmbroideryActorProjectionTest.kt Regression test for using batch matrices when rendering embroidery.
catroid/src/test/java/org/catrobat/catroid/stage/StageLifeCycleControllerTest.kt Regression test ensuring destroy resets pen/plot/stitch state for fresh starts.
catroid/src/test/java/org/catrobat/catroid/test/content/actions/EmbroideryArcActionTest.kt Regression tests for embroidery arc stitch output + direction behavior.
catroid/src/test/java/org/catrobat/catroid/test/content/actions/PlotArcActionTest.kt Regression tests for arc movement/direction normalization.
catroid/src/test/java/org/catrobat/catroid/test/content/actions/PlotThroughActionTest.kt Regression tests for bezier end direction + zig-zag stitch direction updates.
catroid/src/test/java/org/catrobat/catroid/test/content/bricks/GoThroughBrickTest.kt Verify GoThroughBrick implements visual placement defaults.
catroid/src/test/java/org/catrobat/catroid/test/content/sprite/LookTest.java Verify running-stitch updates are not duplicated for combined XY set.
catroid/src/test/java/org/catrobat/catroid/test/embroidery/DSTHeaderTest.kt Verify DST header alignment + negative extents formatting.
catroid/src/test/java/org/catrobat/catroid/test/embroidery/EmbroideryExportIsolationTest.kt Ensure export stream isn’t affected by mutations of rendered pattern list.
catroid/src/test/java/org/catrobat/catroid/test/plot/PlotTest.kt Tests for SVG Y inversion + render/export queue isolation + immediate rendering.
catroid/src/test/java/org/catrobat/catroid/test/ui/fragment/PeripheralMotionCategoryBricksTest.kt Verifies peripheral categories include requested shared motion bricks in order.
catroid/src/main/java/org/catrobat/catroid/content/bricks/EmbroideryArcBrick.kt Removed (replaced by shared ArcBrick).
catroid/src/main/java/org/catrobat/catroid/content/bricks/EmbroideryThroughBrick.kt Removed (replaced by shared GoThroughBrick).
catroid/src/main/java/org/catrobat/catroid/content/bricks/LaserArcBrick.kt Removed (replaced by shared ArcBrick).
catroid/src/main/java/org/catrobat/catroid/content/bricks/PlotThroughBrick.kt Removed (replaced by shared GoThroughBrick).
catroid/src/main/java/org/catrobat/catroid/embroidery/DSTHeader.java Removed (Kotlin rewrite).
catroid/src/main/java/org/catrobat/catroid/stage/EmbroideryActor.java Removed (Kotlin rewrite).
catroid/src/main/res/layout/brick_embroider_arc.xml Removed (replaced by shared motion brick_arc.xml).
catroid/src/main/res/layout/brick_embroidery_through.xml Removed (replaced by shared motion brick_go_through.xml).
catroid/src/main/res/layout/brick_laser_through.xml Removed (replaced by shared motion brick_go_through.xml).
catroid/src/main/res/layout/brick_plot_arc.xml Removed (replaced by shared motion brick_arc.xml).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wslany wslany marked this pull request as ready for review April 9, 2026 14:59
@wslany wslany requested a review from reichli April 9, 2026 15:00
@reichli reichli added XML Change Active Member Tickets that are assigned to members that are still currently active labels Apr 9, 2026
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Active Member Tickets that are assigned to members that are still currently active XML Change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants