Skip to content

JSON send mode; ImageDisplay rotation, mirroring and scale mode - #13

Merged
txp666 merged 4 commits into
mainfrom
json-and-image
Nov 4, 2026
Merged

txp666 merged 4 commits into
mainfrom
json-and-image

Conversation

@txp666

@txp666 txp666 commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner
  • JSON send mode: a new commandMode "JSON" on the six command widgets (文本 / HEX / JSON / Modbus).
    • commandTemplate is a JSON template. Each {value} becomes the value as JSON: a value that is valid JSON (1, true, {"a":1}) is used as is, anything else is sent as an escaped string, input boxes included. For example, {"cmd":"setSpeed","value":{value}} with 75 sends {"cmd":"setSpeed","value":75}.
    • The template must be one valid JSON value, checked without the value (a {value} inside quotes is an error). A bad template is reported and nothing is sent.
    • Whitespace is removed, then commandJsonNewline is added (default 无).
  • ImageDisplay properties:
    • rotation (0–359°, clockwise about the centre; the box stays put and the picture shrinks to fit);
    • mirrorH / mirrorV;
    • scaleMode (适应 / 拉伸 / 原始大小).
  • Docs: 发送命令 and the ImageDisplay reference.
    • protocol.md gains a JSON mode section.

Checked:

  • The full suite passes (234). The only new tests are two shared golden-vector tests, also run by FluentHMI Studio: tests/data/json_command_vectors.json (78 cases) and tests/data/image_placement_vectors.json.
  • An exported app sent JSON over UDP from a button, a switch, a spin box, a line edit, a combo box and a \n line ending. The bytes matched FluentHMI Studio's exactly, and a bad template was rejected without sending.
  • Light and dark screenshots of the rotated, mirrored and scaled images in the canvas and the running app match FluentHMI Studio's.

🤖 Generated with Claude Code

txp666 and others added 4 commits November 4, 2026 20:54
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The image widget gets scaleMode (适应, 拉伸, 原始大小), rotation (0-359,
clockwise), mirrorH and mirrorV. The box never changes: the picture is
mirrored in its own frame, turned about the box centre and scaled so all
of it stays inside. It paints the original picture through a QTransform
instead of using ImageLabel, so it stays sharp at 2x and when zoomed.

ImageDisplay moves to app/core/image_runtime.py, shared by the designer,
the preview and exported apps. tests/data/image_placement_vectors.json
holds where the picture's corners land, the same file FluentHMI Studio is
checked against.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@txp666
txp666 merged commit 85b41fe into main Nov 4, 2026
6 checks passed
@txp666
txp666 deleted the json-and-image branch November 4, 2026 13:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant