Port EditGCodeDialog from PrusaSlicer (#3417)

This is a port of the EditGCodeDialog from PrusaSlicer 2.7.x. There were
a few changes made to make it a bit more functional. Also, it isn't
quite fully complete, but it should be in a very usable state.

General Changes:
- Implement UndoValueUIManager and EditValueUI in Field
- Implement EditGCodeDialog and add buttons to the tabs
- Other minor changes to accommodate the new classes

Differences from PrusaSlicer's Implementation:
- backported to wxWidgets 3.1.5 (reverse commit 8770c4b7 after updating
to 3.2.x)
- icons have been updated to use Orca colors
- improve the report that tells you if certain placeholders have not
been defined properly for the dialog. It now shows all issues at once
rather than having to fix then recompile to see the next issue.
- allow the use of the cmake option `ORCA_CHECK_GCODE_PLACEHOLDERS` to
toggle the above report since our workflow rarely uses debug mode.
- if a custom gcode value is not set when checking gcode placeholders, a
testing value is set. Custom gcode is not parsed if it is empty, and the
only way to check if the placeholders are all defined is by running the
placeholder operation on the custom gcode.
- some calls to `print.config()` in Gcode.cpp were changed to `m_config`
to support the above testing values feature (only m_config is modified
with the placeholders and `print.config()` would return an empty string)
- a macro has been added to quickly add a definition to
SlicingStatesConfigDefs with less boiler plate (it could technically be
used for any ConfigOptionDef, but that would hurt interoperability with
PS. I tried to not use the macro for too many PS defined definitions.)
- the presets are now also categorized by the page they are on in their
tab
<table>
<tr>
 <td>Prusa
 <td>Orca
<tr>
 <td>
<img
src="27cb4f48-d225-4563-9aeb-b2b461f8bff5"
/>
 <td>
<img
src="4fcd8cde-2427-4d1a-a0ed-1738b570b919"
/>
</table>

TODO:
- [x] Make sure all linux fixes have been applied
- [x] Finish adding "universal" gcode options
- [x] add search function to dataview (maybe?)
- [x] determine if any options are being left out of the preset
categories by getting options from Tab rather than Presets. If so,
consider adding outside of the groupings
This commit is contained in:
SoftFever 2024-01-24 19:56:18 +08:00 committed by GitHub
commit 5ff00fb48c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 2155 additions and 122 deletions

View file

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g id="b"><path d="m8.02,7.18h3.98v3.08c0,2.6-1.23,3.72-4.05,3.72s-3.95-1.12-3.95-3.68v-4.75c0-2.42,1.09-3.54,3.95-3.54s4.05,1,4.05,3.54h-2.12c0-1.11-.28-1.66-1.92-1.66-1.54,0-1.83.69-1.83,1.77v4.65c0,1.12.29,1.77,1.83,1.77s2.08-.65,2.08-1.82v-1.16h-2.02v-1.92Z" style="fill:#808080;"/></g></svg>

After

Width:  |  Height:  |  Size: 402 B

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="m13.6,5h-.6v3.5c0,.28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-2v3.5c0,.28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-2v3.5c0,.28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-2v3.5c0,.28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-.6c-.77,0-1.4.62-1.4,1.4v3.21c0,.77.62,1.4,1.4,1.4h11.21c.77,0,1.4-.62,1.4-1.4v-3.21c0-.77-.62-1.4-1.4-1.4Z" style="fill:#808080;"/></svg>

After

Width:  |  Height:  |  Size: 434 B

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path id="b" d="m8.54,4.31c-.53-.19-.81-.69-.73-1.32.08-.62.55-1.01,1.21-1.01.46,0,.82.21,1,.58.1.2.1.22.1.55,0,.43-.07.61-.31.87-.24.26-.46.35-.84.36-.21,0-.33,0-.43-.04Z" style="fill:#009688; isolation:isolate; opacity:1;"/><path id="c" d="m6.82,13.97c-.51-.14-.74-.4-.77-.86-.02-.28-.04-.15.57-3.12.22-1.07.44-2.13.48-2.34.13-.71.07-.77-.77-.81-.21-.01-.38-.03-.39-.04s0-.09.02-.18c.04-.18,0-.16.69-.31.62-.14,1.09-.19,1.63-.2.67,0,.9.07,1.13.36.09.11.09.13.09.41,0,.25-.06.57-.39,2.17-.78,3.74-.79,3.82-.68,3.99.03.04.08.1.12.13.12.08.47.14.8.14h.3s-.02.18-.02.18c-.01.1-.04.19-.05.2-.05.03-.88.2-1.24.26-.45.07-1.31.09-1.51.03h0Z" style="fill:#009688; isolation:isolate; opacity:1;"/><polyline points="14.5 3.5 14.5 1.5 12.5 1.5" style="fill:none; stroke:808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="3.5 1.5 1.5 1.5 1.5 3.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="1.5 12.5 1.5 14.5 3.5 14.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="12.5 14.5 14.5 14.5 14.5 12.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><circle cx="8" cy="8" r="2" style="fill:#808080;"/></svg>

After

Width:  |  Height:  |  Size: 162 B

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g id="b"><path d="m13.77,6.39c-.13-.47-.32-.92-.55-1.33l.43-1.3-1.41-1.41-1.3.43c-.42-.23-.86-.42-1.33-.55l-.61-1.23h-2l-.61,1.23c-.47.13-.92.31-1.33.55l-1.3-.43-1.42,1.41.43,1.3c-.23.41-.41.86-.54,1.33l-1.23.61v2l1.23.61c.13.47.32.92.55,1.33l-.43,1.3,1.41,1.41,1.3-.43c.42.23.86.42,1.33.55l.61,1.23h2l.61-1.23c.47-.13.92-.32,1.33-.55l1.3.43,1.41-1.41-.43-1.3c.23-.42.42-.86.55-1.33l1.23-.61v-2l-1.23-.61Zm-5.77,6.61c-2.76,0-5-2.24-5-5s2.24-5,5-5,5,2.24,5,5-2.24,5-5,5Z" style="fill:#808080;"/></g></svg>

After

Width:  |  Height:  |  Size: 610 B

View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><g id="b">
<path d="m13.77,6.39c-.13-.47-.32-.92-.55-1.33l.43-1.3-1.41-1.41-1.3.43c-.42-.23-.86-.42-1.33-.55l-.61-1.23h-2l-.61,1.23c-.47.13-.92.31-1.33.55l-1.3-.43-1.42,1.41.43,1.3c-.23.41-.41.86-.54,1.33l-1.23.61v2l1.23.61c.13.47.32.92.55,1.33l-.43,1.3,1.41,1.41,1.3-.43c.42.23.86.42,1.33.55l.61,1.23h2l.61-1.23c.47-.13.92-.32,1.33-.55l1.3.43,1.41-1.41-.43-1.3c.23-.42.42-.86.55-1.33l1.23-.61v-2l-1.23-.61Zm-5.77,6.61c-2.76,0-5-2.24-5-5s2.24-5,5-5,5,2.24,5,5-2.24,5-5,5Z" style="fill:#808080"/>
</g><circle cx="8" cy="8" r="2" style="fill:#009688; isolation:isolate; opacity:1;"/></svg>

After

Width:  |  Height:  |  Size: 694 B

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><rect x="1" y="7" width="2" height="6" rx="1" ry="1" style="fill:#009688;"/><rect x="5" y="2" width="2" height="11" rx="1" ry="1" style="fill:#009688;"/><rect x="9" y="3" width="2" height="10" rx="1" ry="1" style="fill:#009688;"/><rect x="13" y="5" width="2" height="8" rx="1" ry="1" style="fill:#009688;"/></svg>

After

Width:  |  Height:  |  Size: 418 B

View file

@ -0,0 +1,14 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_8076_36010)">
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.69269 2.49023C4.69269 1.29516 5.66149 0.326355 6.85657 0.326355C8.05165 0.326355 9.02044 1.29516 9.02044 2.49023V6.92898C9.96736 7.60117 10.5871 8.70725 10.5871 9.95952C10.5871 12.0108 8.92419 13.6737 6.87289 13.6737C4.8216 13.6737 3.15869 12.0108 3.15869 9.95952C3.15869 8.72168 3.76428 7.62665 4.69269 6.95241V2.49023ZM5.69269 7.51465V2.49023C5.69269 1.84744 6.21378 1.32635 6.85657 1.32635C7.49936 1.32635 8.02044 1.84744 8.02044 2.49023V7.49913C8.94588 7.9315 9.58709 8.87063 9.58709 9.95952C9.58709 11.4585 8.3719 12.6737 6.87289 12.6737C5.37388 12.6737 4.15869 11.4585 4.15869 9.95952C4.15869 8.88348 4.78486 7.95369 5.69269 7.51465Z" fill="#009688"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.186 2.49249C10.186 2.21635 10.4099 1.99249 10.686 1.99249H11.8258C12.1019 1.99249 12.3258 2.21635 12.3258 2.49249C12.3258 2.76863 12.1019 2.99249 11.8258 2.99249H10.686C10.4099 2.99249 10.186 2.76863 10.186 2.49249Z" fill="#009688"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.186 4.83203C10.186 4.55589 10.4099 4.33203 10.686 4.33203H11.8258C12.1019 4.33203 12.3258 4.55589 12.3258 4.83203C12.3258 5.10817 12.1019 5.33203 11.8258 5.33203H10.686C10.4099 5.33203 10.186 5.10817 10.186 4.83203Z" fill="#009688"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.87305 2.49249C7.14919 2.49249 7.37305 2.71635 7.37305 2.99249V9.22844C7.37305 9.50458 7.14919 9.72844 6.87305 9.72844C6.5969 9.72844 6.37305 9.50458 6.37305 9.22844L6.37305 2.99249C6.37305 2.71635 6.5969 2.49249 6.87305 2.49249Z" fill="#009688"/>
<path d="M8.24858 9.90249C8.24858 10.6622 7.63274 11.278 6.87307 11.278C6.1134 11.278 5.49756 10.6622 5.49756 9.90249C5.49756 9.14281 6.1134 8.52698 6.87307 8.52698C7.63274 8.52698 8.24858 9.14281 8.24858 9.90249Z" fill="#009688"/>
</g>
<defs>
<clipPath id="clip0_8076_36010">
<rect width="14" height="14" fill="white" transform="translate(0 14) rotate(-90)"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2.1 KiB

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="m9,8v3.14c0,.47-.45.86-1,.86h0c-.55,0-1-.38-1-.86v-3.14h2Z" style="fill:#009688;"/><circle cx="8" cy="6" r="1" style="fill:#009688;"/><polyline points="4.5 2.5 2.5 2.5 2.5 13.5 4.5 13.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="11.5 13.5 13.5 13.5 13.5 2.5 11.5 2.5" style="fill:none; stroke:#808080; stroke-linecap:round; stroke-miterlimit:10;"/></svg>

After

Width:  |  Height:  |  Size: 524 B

View file

@ -0,0 +1 @@
<?xml version="1.0" encoding="UTF-8"?><svg id="a" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><polyline points="4.5 2.5 2.5 2.5 2.5 13.5 4.5 13.5" style="fill:none; stroke:808080; stroke-linecap:round; stroke-miterlimit:10;"/><polyline points="11.5 13.5 13.5 13.5 13.5 2.5 11.5 2.5" style="fill:none; stroke:808080; stroke-linecap:round; stroke-miterlimit:10;"/><path d="m9,8v3.14c0,.47-.45.86-1,.86h0c-.55,0-1-.38-1-.86v-3.14h2Z" style="fill:#808080;"/><circle cx="8" cy="6" r="1" style="fill:#808080;"/></svg>

After

Width:  |  Height:  |  Size: 522 B