mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-09-28 03:11:47 +00:00
Merge branch 'main' into feat/plugin-auditing
This commit is contained in:
@@ -17,7 +17,7 @@ cmake --build . --config %build_type% --target ALL_BUILD -- -m
|
||||
|
||||
## Testing
|
||||
|
||||
Catch2 framework. Tests in `tests/` directory.
|
||||
Catch2 framework. Tests in `tests/`; see [tests/AGENTS.md](tests/AGENTS.md) for where a new test belongs and the conventions to follow.
|
||||
|
||||
```bash
|
||||
cd build && ctest --output-on-failure # all tests
|
||||
@@ -30,6 +30,7 @@ ctest --test-dir ./tests/fff_print
|
||||
- C++17, selective C++20. PascalCase classes, snake_case functions/variables
|
||||
- `#pragma once` for headers. Smart pointers and RAII preferred
|
||||
- Parallelization via TBB — be mindful of shared state
|
||||
- Always use `SetSizerAndFit(sizer)` instead of `SetSizer(sizer)` on top level window. Unless `SetSizer` must be called before the full layout is built, call `sizer->SetSizeHints(window)` afterwards in this case.
|
||||
|
||||
## Key Entry Points
|
||||
|
||||
@@ -59,7 +60,31 @@ ctest --test-dir ./tests/fff_print
|
||||
|
||||
## Localization & translations
|
||||
|
||||
- Translation catalogs live in `localization/i18n/<lang>/OrcaSlicer_<lang>.po`.
|
||||
- When creating or reviewing translations, use the [Localization glossary](https://github.com/OrcaSlicer/OrcaSlicer_WIKI/blob/main/guides/localization_glossary.md) as the source of truth for recurring terms, so the same English term is always rendered the same way within a language and terms that must stay in English (brand/product names, acronyms, file formats, G-code, macros/variables) are not translated.
|
||||
- If a term's established translation changes, update both the affected `.po` files and the glossary so they stay in sync.
|
||||
- Only edit `msgstr` (never `msgid`); keep placeholders (`%s`, `%1%`, `\n`), context (`msgctxt`), and file encoding/line endings intact.
|
||||
Catalogs live in `localization/i18n/<lang>/OrcaSlicer_<lang>.po`; the template is `OrcaSlicer.pot`.
|
||||
See the [Localization guide](https://github.com/OrcaSlicer/OrcaSlicer_WIKI/blob/main/guides/localization_guide.md) for the human-facing version of these principles.
|
||||
|
||||
### Terminology
|
||||
|
||||
- Use the [Localization glossary](https://github.com/OrcaSlicer/OrcaSlicer_WIKI/blob/main/guides/localization_glossary.md) as the source of truth for recurring terms, so the same English term is always rendered the same way within a language, and terms that must stay in English (brand/product names, acronyms, materials, file formats, G-code tokens, macros/variables/identifiers) are not translated.
|
||||
- If a term's established translation changes, update both the affected `.po` files and the glossary (`localization_glossary.tsv`, then regenerate) so they stay in sync.
|
||||
- Translate the *meaning*, not the words. Check what the string actually controls before translating it — English reuses one word for different things. `Flow ratio` (multiplier), `Flow Rate` (throughput) and `Flow Dynamics` (pressure compensation) are three different terms; `extruder` may mean the toolhead, the feeder motor, or the nozzle depending on the string.
|
||||
- Reuse one template per recurring message shape (`Failed to connect to …`, `Are you sure you want to …?`), even where the English wording varies.
|
||||
|
||||
### Editing rules
|
||||
|
||||
- Only edit `msgstr` — **never** change `msgid`, and never "fix" wrong English in the translation alone. Report the source string instead.
|
||||
- Preserve exactly: placeholders (`%s`, `%d`, `%1%`, `%zu`, `%%`), every `\n` (count *and* position, including leading/trailing), leading/trailing spaces, HTML tags, `℃`, and the file's encoding and line endings.
|
||||
- **Never reorder positional arguments** in a `c-format` string. If the msgid is `%d` then `%s`, that order must hold — swapping them breaks at runtime.
|
||||
- `msgctxt` separates homonyms — always read it. `Back`/`Camera View` is the rear view of the 3D navigator, while `Back`/`Navigation` is the go-back button; `Top` exists in the *Alignment*, *Layers* and *Camera View* senses.
|
||||
- When a string needs disambiguating, add context in the source (`_L_CONTEXT`/`_u8L_CONTEXT`), don't work around it in the translation.
|
||||
- A literal `%` inside a string xgettext flagged `possible-c-format` will fail `msgfmt`. Fix it with a `// xgettext:no-c-format, no-boost-format` comment above the string in the source — do not mangle the translation or use `%%` in text that is never passed through printf.
|
||||
- Plural entries: read `nplurals` from the catalog's `Plural-Forms` header (it is **not** always 2 — ja/ko/zh/th/vi use 1, ru/cs/pl/lt use 3, uk uses 4). Each form must be genuinely inflected for its quantity; repeating one sentence across all forms is a bug in Slavic/Baltic languages, though it is correct for Turkish and Hungarian.
|
||||
- An entry whose `msgstr` equals its `msgid` is untranslated even though it is not empty; a plural entry with any empty form is likewise incomplete.
|
||||
- Mark machine-produced translations with an `# AI Translated` translator comment. Don't add it to a human translation you didn't actually rewrite.
|
||||
- Don't reflow or re-wrap unrelated entries — keep the diff limited to the strings you changed.
|
||||
|
||||
### Verifying
|
||||
|
||||
- `scripts/run_gettext.bat --full` (Windows) regenerates the template, merges every catalog and compiles the `.mo` files. It must exit 0.
|
||||
- Or check a single catalog with `msgfmt --check-format -o <out>.mo localization/i18n/<lang>/OrcaSlicer_<lang>.po`.
|
||||
- Fuzzy entries are not shown to users. If you correct one, clear its `fuzzy` flag, otherwise the fix never ships.
|
||||
|
||||
+1
-3
@@ -835,7 +835,7 @@ endif ()
|
||||
set(L10N_DIR "${SLIC3R_RESOURCES_DIR}/i18n")
|
||||
set(BBL_L18N_DIR "${CMAKE_CURRENT_SOURCE_DIR}/localization/i18n")
|
||||
add_custom_target(gettext_make_pot
|
||||
COMMAND xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_CTX:1,2c --keyword=_CTX_utf8:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost
|
||||
COMMAND xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_CONTEXT:1,2c --keyword=_u8L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost
|
||||
-f "${BBL_L18N_DIR}/list.txt"
|
||||
-o "${BBL_L18N_DIR}/OrcaSlicer.pot"
|
||||
COMMAND hintsToPot ${SLIC3R_RESOURCES_DIR} ${BBL_L18N_DIR}
|
||||
@@ -853,7 +853,6 @@ foreach(po_file ${BBL_L10N_PO_FILES})
|
||||
add_custom_command(
|
||||
TARGET gettext_merge_po_with_pot PRE_BUILD
|
||||
COMMAND msgmerge -N -o ${po_file} ${po_file} "${BBL_L18N_DIR}/OrcaSlicer.pot"
|
||||
DEPENDS ${po_file}
|
||||
)
|
||||
endforeach()
|
||||
add_custom_target(gettext_po_to_mo
|
||||
@@ -869,7 +868,6 @@ foreach(po_file ${BBL_L10N_PO_FILES})
|
||||
TARGET gettext_po_to_mo PRE_BUILD
|
||||
COMMAND msgfmt ARGS --check-format -o ${mo_file} ${po_file}
|
||||
#COMMAND msgfmt ARGS --check-compatibility -o ${mo_file} ${po_file}
|
||||
DEPENDS ${po_file}
|
||||
)
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
OrcaSlicer: an open source Next-Gen Slicing Software for Precision 3D Prints.
|
||||
Optimize your prints with ultra-fast slicing, intelligent support generation, and seamless printer compatibility—engineered for perfection.
|
||||
<h3>
|
||||
|
||||
# Official links and community
|
||||
|
||||
@@ -90,11 +89,22 @@ Visit our GitHub Releases page for the latest stable version of OrcaSlicer, reco
|
||||
🌙 **[Download the Latest Nightly Build](https://github.com/OrcaSlicer/OrcaSlicer/releases/tag/nightly-builds)**
|
||||
Explore the latest developments in OrcaSlicer with our nightly builds. Feedback on these versions is highly appreciated.
|
||||
|
||||
### Belt Printer Builds
|
||||
|
||||
The [nightly release](https://github.com/OrcaSlicer/OrcaSlicer/releases/tag/nightly-builds) ships **two parallel builds**: the standard build and a belt-printer build. Both are attached to the same release — tell them apart by the filename suffix:
|
||||
|
||||
- **Standard** — no suffix (e.g. `OrcaSlicer_Windows_Installer_x64_nightly.exe`)
|
||||
- **Belt** — `_belt` suffix (e.g. `OrcaSlicer_Windows_Installer_x64_nightly_belt.exe`)
|
||||
|
||||
The `_belt` builds add **experimental support for belt / conveyor (infinite-Z) printers**, where the model is sliced against a tilted belt surface instead of a flat horizontal bed. They include ready-to-use belt printer profiles, the full belt slicing pipeline (mesh rotation and G-code transforms), belt-aware support generation, and a tilted-bed preview.
|
||||
|
||||
> ⚠️ Belt printer support is under active development and is **not yet merged into `main`** — it currently ships only in these parallel `_belt` builds, produced from the [`belt-printer`](https://github.com/OrcaSlicer/OrcaSlicer/tree/belt-printer) branch. See tracking PR [#14394](https://github.com/OrcaSlicer/OrcaSlicer/pull/14394) and the original documentation in [#12998](https://github.com/OrcaSlicer/OrcaSlicer/pull/12998).
|
||||
|
||||
# How to install
|
||||
|
||||
## Windows
|
||||
|
||||
Download the **Windows Installer exe** for your preferred version from the [releases page](https://github.com/OrcaSlicer/OrcaSlicer/releases).
|
||||
Download the **Windows Installer exe** for your preferred version from the [releases page](https://github.com/OrcaSlicer/OrcaSlicer/releases). Both `x64` and `arm64` installers are published — pick the one matching your CPU.
|
||||
|
||||
- *For convenience there is also a portable build available.*
|
||||
<details>
|
||||
@@ -109,7 +119,7 @@ Download the **Windows Installer exe** for your preferred version from the [rel
|
||||
- This file may already be available on your computer if you've installed visual studio. Check the following location: `%VCINSTALLDIR%Redist\MSVC\v142`
|
||||
</details>
|
||||
|
||||
Windows Package Manager
|
||||
### Windows Package Manager
|
||||
|
||||
```shell
|
||||
winget install --id=SoftFever.OrcaSlicer -e
|
||||
@@ -117,7 +127,7 @@ winget install --id=SoftFever.OrcaSlicer -e
|
||||
|
||||
## Mac
|
||||
|
||||
1. Download the DMG for your computer: `arm64` version for Apple Silicon and `x86_64` for Intel CPU.
|
||||
1. Download the universal DMG, which runs on both Apple Silicon and Intel Macs.
|
||||
2. Drag OrcaSlicer.app to Application folder.
|
||||
3. *If you want to run a build from a PR, you also need to follow the instructions below:*
|
||||
|
||||
@@ -142,6 +152,14 @@ winget install --id=SoftFever.OrcaSlicer -e
|
||||

|
||||
</details>
|
||||
|
||||
### Homebrew Cask
|
||||
|
||||
```shell
|
||||
brew install --cask orcaslicer
|
||||
```
|
||||
|
||||
The [Homebrew cask](https://formulae.brew.sh/cask/orcaslicer) installs the official macOS DMG from [GitHub Releases](https://github.com/OrcaSlicer/OrcaSlicer/releases).
|
||||
|
||||
## Linux
|
||||
|
||||
### Flathub (Recommended)
|
||||
@@ -190,8 +208,8 @@ resolution: 0.1
|
||||
|
||||
# Supports
|
||||
|
||||
**OrcaSlicer** is an open-source project and I'm deeply grateful to all my sponsors and backers.
|
||||
Their generous support enables me to purchase filaments and other essential 3D printing materials for the project.
|
||||
**OrcaSlicer** is an open-source project, and we're deeply grateful to all our sponsors and backers.
|
||||
Their generous support helps fund filaments and other essential 3D printing materials for the project.
|
||||
Thank you! :)
|
||||
|
||||
## Sponsors
|
||||
@@ -215,7 +233,7 @@ Thank you! :)
|
||||
|
||||
**Ko-fi supporters** ☕: [Backers list](https://github.com/user-attachments/files/16147016/Supporters_638561417699952499.csv)
|
||||
|
||||
## Support me
|
||||
## Support the project
|
||||
|
||||
<a href="https://github.com/sponsors/SoftFever"><img src="https://img.shields.io/badge/GitHub%20Sponsors-30363D?style=flat&logo=GitHub-Sponsors&logoColor=EA4AAA" height="50"></a>
|
||||
<a href="https://ko-fi.com/G2G5IP3CP"><img src="https://img.shields.io/badge/Support_me_on_Ko--fi-FF5E5B?style=flat&logo=ko-fi&logoColor=white" height="50"></a>
|
||||
|
||||
@@ -128,6 +128,10 @@ cmake_minimum_required(VERSION 3.13)
|
||||
if(POLICY CMP0074)
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
endif()
|
||||
# Re-set after cmake_minimum_required above cleared it; use BoostConfig, not the removed FindBoost.
|
||||
if(POLICY CMP0167)
|
||||
cmake_policy(SET CMP0167 NEW)
|
||||
endif()
|
||||
|
||||
if(OpenVDB_FIND_QUIETLY)
|
||||
set (_quiet "QUIET")
|
||||
|
||||
Vendored
+2
@@ -423,6 +423,7 @@ endif ()
|
||||
include(OCCT/OCCT.cmake)
|
||||
include(OpenCV/OpenCV.cmake)
|
||||
include(python3/python3.cmake)
|
||||
include(wxInspector/wxInspector.cmake)
|
||||
|
||||
set(_dep_list
|
||||
dep_Boost
|
||||
@@ -446,6 +447,7 @@ set(_dep_list
|
||||
${EXPAT_PKG}
|
||||
dep_libnoise
|
||||
dep_python3
|
||||
dep_wxInspector
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
|
||||
Vendored
+13
@@ -0,0 +1,13 @@
|
||||
orcaslicer_add_cmake_project(
|
||||
wxInspector
|
||||
URL https://github.com/Noisyfox/wxInspector/archive/refs/tags/v1.0.0.zip
|
||||
URL_HASH SHA256=0ba163956f2d468b19a91b96c5aba66ee9610843ea41dda628ea44cdafde7db7
|
||||
DEPENDS ${WXWIDGETS_PKG}
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_CXX_FLAGS="-DwxDEBUG_LEVEL=0"
|
||||
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
add_debug_dep(dep_wxInspector)
|
||||
endif ()
|
||||
Vendored
+1
@@ -26,6 +26,7 @@ orcaslicer_add_cmake_project(
|
||||
GIT_REPOSITORY "https://github.com/SoftFever/Orca-deps-wxWidgets"
|
||||
GIT_TAG v3.3.2
|
||||
GIT_SHALLOW ON
|
||||
GIT_SUBMODULES 3rdparty/catch 3rdparty/pcre 3rdparty/libwebp
|
||||
DEPENDS ${PNG_PKG} ${ZLIB_PKG} ${EXPAT_PKG} ${JPEG_PKG}
|
||||
CMAKE_ARGS
|
||||
-DwxBUILD_PRECOMP=ON
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
# Move `wxInspectable` into `DPIAware` — Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Move `wxInspector::wxInspectable` from individual leaf classes into the common `DPIAware<P>` template so every DPIAware widget is automatically inspectable and gets the inspector keyboard shortcut.
|
||||
|
||||
**Architecture:** `DPIAware<P>` gains `wxInspector::wxInspectable` as a second base class and calls `SetupInspectorAccelerator(this)` in its constructor. `DPIDialog` and `MainFrame` drop their now-redundant `wxInspectable` inheritance and `SetupInspectorAccelerator` calls.
|
||||
|
||||
**Tech Stack:** C++17, wxWidgets, wxInspector
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- Build with `D:\VisualStudio\2026\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe`
|
||||
- Use `--config RelWithDebInfo` for all builds
|
||||
- Cross-platform: must compile on Windows, macOS, and Linux
|
||||
- Match existing code style: PascalCase classes, `#pragma once`
|
||||
- Do NOT commit files under `.superpowers/`
|
||||
- Do NOT commit `task.md`
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Move `wxInspectable` and `SetupInspectorAccelerator` into `DPIAware<P>`
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/slic3r/GUI/GUI_Utils.hpp:92` (DPIAware template — add wxInspectable base + SetupInspectorAccelerator call)
|
||||
- Modify: `src/slic3r/GUI/GUI_Utils.hpp:276` (DPIDialog — drop wxInspectable + SetupInspectorAccelerator)
|
||||
- Modify: `src/slic3r/GUI/MainFrame.hpp:96` (MainFrame — drop wxInspectable)
|
||||
- Modify: `src/slic3r/GUI/MainFrame.cpp:304` (MainFrame constructor — drop SetupInspectorAccelerator)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Nothing (standalone refactor)
|
||||
- Produces: All DPIAware widgets automatically inherit `wxInspector::wxInspectable` and get Ctrl+Shift+I accelerator
|
||||
|
||||
- [ ] **Step 1: Add `wxInspectable` to `DPIAware<P>` and call `SetupInspectorAccelerator`**
|
||||
|
||||
In `src/slic3r/GUI/GUI_Utils.hpp`, line 92, change the base class:
|
||||
|
||||
```cpp
|
||||
// Before:
|
||||
template<class P> class DPIAware : public P
|
||||
// After:
|
||||
template<class P> class DPIAware : public P, public wxInspector::wxInspectable
|
||||
```
|
||||
|
||||
In the constructor body of `DPIAware<P>`, after `this->CenterOnParent();` (currently line 110), add:
|
||||
|
||||
```cpp
|
||||
SetupInspectorAccelerator(this);
|
||||
```
|
||||
|
||||
(`<wx/inspector/inspector.h>` is already included at line 23.)
|
||||
|
||||
- [ ] **Step 2: Remove redundant `wxInspectable` and `SetupInspectorAccelerator` from `DPIDialog`**
|
||||
|
||||
In `src/slic3r/GUI/GUI_Utils.hpp`, line 276, change:
|
||||
|
||||
```cpp
|
||||
// Before:
|
||||
class DPIDialog : public DPIAware<wxDialog>, public wxInspector::wxInspectable
|
||||
// After:
|
||||
class DPIDialog : public DPIAware<wxDialog>
|
||||
```
|
||||
|
||||
In the `DPIDialog` constructor body, remove the `SetupInspectorAccelerator(this);` line (currently line 286). The rest of the constructor stays.
|
||||
|
||||
- [ ] **Step 3: Remove redundant `wxInspectable` from `MainFrame`**
|
||||
|
||||
In `src/slic3r/GUI/MainFrame.hpp`, line 96, change:
|
||||
|
||||
```cpp
|
||||
// Before:
|
||||
class MainFrame : public DPIFrame, public wxInspector::wxInspectable
|
||||
// After:
|
||||
class MainFrame : public DPIFrame
|
||||
```
|
||||
|
||||
`MainFrame` now gets `wxInspectable` through `DPIFrame` → `DPIAware<wxFrame>`.
|
||||
|
||||
- [ ] **Step 4: Remove redundant `SetupInspectorAccelerator` from `MainFrame` constructor**
|
||||
|
||||
In `src/slic3r/GUI/MainFrame.cpp`, line 304, remove the line:
|
||||
|
||||
```cpp
|
||||
SetupInspectorAccelerator(this);
|
||||
```
|
||||
|
||||
It is now called automatically by the `DPIAware<wxFrame>` constructor.
|
||||
|
||||
- [ ] **Step 5: Build to verify compilation**
|
||||
|
||||
```powershell
|
||||
$cmakePath = "D:\VisualStudio\2026\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
|
||||
& $cmakePath --build . --config RelWithDebInfo --target ALL_BUILD -- -m
|
||||
```
|
||||
|
||||
Expected: Build succeeds with zero new errors or warnings.
|
||||
|
||||
- [ ] **Step 6: Commit**
|
||||
|
||||
```bash
|
||||
git add src/slic3r/GUI/GUI_Utils.hpp src/slic3r/GUI/MainFrame.hpp src/slic3r/GUI/MainFrame.cpp
|
||||
git commit -m "refactor: move wxInspectable and SetupInspectorAccelerator into DPIAware
|
||||
|
||||
DPIAware<P> now inherits wxInspector::wxInspectable and calls
|
||||
SetupInspectorAccelerator in its constructor, making all DPIAware
|
||||
widgets automatically appear in the inspector tree with the
|
||||
Ctrl+Shift+I shortcut. Remove redundant wxInspectable inheritance
|
||||
and SetupInspectorAccelerator calls from DPIDialog and MainFrame.
|
||||
|
||||
Co-Authored-By: Claude <noreply@anthropic.com>"
|
||||
```
|
||||
@@ -0,0 +1,753 @@
|
||||
# wxInspector Plugins for OrcaSlicer — Implementation Plan
|
||||
|
||||
> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
|
||||
|
||||
**Goal:** Build two wxInspector plugins (DPIAware + CustomWidgets) that expose OrcaSlicer custom control properties in the inspector's property grid.
|
||||
|
||||
**Architecture:** Two plugins in a shared folder under `src/slic3r/Utils/wxInspectorPlugins/`. DPIAwarePlugin uses `dynamic_cast<DPIFrame*>/<DPIDialog*>` for detection; CustomWidgetsPlugin uses per-type `dynamic_cast`. Both registered as static singletons via a single inline function in `Registration.hpp`, called from `MainFrame` constructor.
|
||||
|
||||
**Tech Stack:** C++17, wxWidgets, wxInspector plugin API (`wx/inspector/plugin.h`, `wx/inspector/inspector.h`), OrcaSlicer custom widget headers
|
||||
|
||||
## Global Constraints
|
||||
|
||||
- Plugins placed under `src/slic3r/Utils/wxInspectorPlugins/`
|
||||
- Build with `D:\VisualStudio\2026\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe`
|
||||
- Minimal source changes: only trivial (one-line) getters/setters added to existing classes
|
||||
- Cross-platform: must compile on Windows, macOS, and Linux
|
||||
- Match existing code style: PascalCase classes, snake_case functions, `#pragma once`
|
||||
|
||||
---
|
||||
|
||||
### Task 1: Add getters/setters to existing Orca widget headers
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/slic3r/GUI/GUI_Utils.hpp` (DPIAware template — add 4 methods)
|
||||
- Modify: `src/slic3r/GUI/Widgets/Button.hpp` (add 3 getters)
|
||||
- Modify: `src/slic3r/GUI/Widgets/CheckBox.hpp` (add 1 getter)
|
||||
- Modify: `src/slic3r/GUI/Widgets/TextInput.hpp` (add 1 getter)
|
||||
- Modify: `src/slic3r/GUI/Widgets/LabeledStaticBox.hpp` (add 4 getter declarations)
|
||||
- Modify: `src/slic3r/GUI/Widgets/LabeledStaticBox.cpp` (add 4 getter implementations)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Nothing (prerequisite for all other tasks)
|
||||
- Produces:
|
||||
- `DPIAware<P>::set_scale_factor(float)`, `DPIAware<P>::set_prev_scale_factor(float)`, `DPIAware<P>::set_em_unit(int)`, `DPIAware<P>::force_rescale() const`
|
||||
- `Button::GetStyle()`, `Button::GetType()`, `Button::IsSelected()`
|
||||
- `CheckBox::IsHalfChecked()`
|
||||
- `TextInput::GetCornerRadius()`
|
||||
- `LabeledStaticBox::GetCornerRadius()`, `LabeledStaticBox::GetBorderWidth()`, `LabeledStaticBox::GetBorderColor()`, `LabeledStaticBox::GetScale()`
|
||||
|
||||
- [ ] **Step 1: Add DPIAware setters/getter in GUI_Utils.hpp**
|
||||
|
||||
After line 184 (`float prev_scale_factor() const { return m_prev_scale_factor; }`), add:
|
||||
|
||||
```cpp
|
||||
void set_scale_factor(float v) { m_scale_factor = v; }
|
||||
void set_prev_scale_factor(float v) { m_prev_scale_factor = v; }
|
||||
void set_em_unit(int v) { m_em_unit = v; }
|
||||
bool force_rescale() const { return m_force_rescale; }
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Add Button getters in Button.hpp**
|
||||
|
||||
After line 79 (`void SetSelected(bool selected = true) { m_selected = selected; }`), add:
|
||||
|
||||
```cpp
|
||||
ButtonStyle GetStyle() const { return m_style; }
|
||||
ButtonType GetType() const { return m_type; }
|
||||
bool IsSelected() const { return m_selected; }
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Add CheckBox getter in CheckBox.hpp**
|
||||
|
||||
After line 16 (`void SetHalfChecked(bool value = true);`), add:
|
||||
|
||||
```cpp
|
||||
bool IsHalfChecked() const { return m_half_checked; }
|
||||
```
|
||||
|
||||
- [ ] **Step 4: Add TextInput getter in TextInput.hpp**
|
||||
|
||||
After line 44 (`void SetCornerRadius(double radius);`), add:
|
||||
|
||||
```cpp
|
||||
int GetCornerRadius() const { return static_cast<int>(radius); }
|
||||
```
|
||||
|
||||
(Note: `radius` is inherited from `StaticBox` which has it as a protected `double` member.)
|
||||
|
||||
- [ ] **Step 5: Add LabeledStaticBox getter declarations in LabeledStaticBox.hpp**
|
||||
|
||||
After line 46 (`bool Enable(bool enable) override;`), add:
|
||||
|
||||
```cpp
|
||||
int GetCornerRadius() const { return m_radius; }
|
||||
int GetBorderWidth() const { return m_border_width; }
|
||||
StateColor GetBorderColor() const { return border_color; }
|
||||
float GetScale() const { return m_scale; }
|
||||
```
|
||||
|
||||
(Note: all of `m_radius`, `m_border_width`, `border_color`, `m_scale` are protected members, accessible to inline methods.)
|
||||
|
||||
- [ ] **Step 6: Commit**
|
||||
|
||||
```bash
|
||||
git add src/slic3r/GUI/GUI_Utils.hpp src/slic3r/GUI/Widgets/Button.hpp src/slic3r/GUI/Widgets/CheckBox.hpp src/slic3r/GUI/Widgets/TextInput.hpp src/slic3r/GUI/Widgets/LabeledStaticBox.hpp
|
||||
git commit -m "feat: add getters/setters for wxInspector plugin access
|
||||
|
||||
Add minimal public accessors to DPIAware (set_scale_factor,
|
||||
set_prev_scale_factor, set_em_unit, force_rescale), Button
|
||||
(GetStyle, GetType, IsSelected), CheckBox (IsHalfChecked),
|
||||
TextInput (GetCornerRadius), and LabeledStaticBox
|
||||
(GetCornerRadius, GetBorderWidth, GetBorderColor, GetScale)."
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 2: Create Registration helper header
|
||||
|
||||
**Files:**
|
||||
- Create: `src/slic3r/Utils/wxInspectorPlugins/Registration.hpp`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Nothing (forward-declares plugin classes)
|
||||
- Produces: `RegisterOrcaInspectorPlugins()`
|
||||
|
||||
- [ ] **Step 1: Create directory**
|
||||
|
||||
```bash
|
||||
mkdir -p src/slic3r/Utils/wxInspectorPlugins
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Write Registration.hpp**
|
||||
|
||||
```cpp
|
||||
#pragma once
|
||||
|
||||
namespace wxInspector {
|
||||
class wxInspectorPlugin;
|
||||
void RegisterPlugin(wxInspectorPlugin* plugin);
|
||||
}
|
||||
|
||||
// Forward declare our plugins
|
||||
class DPIAwarePlugin;
|
||||
class CustomWidgetsPlugin;
|
||||
|
||||
inline void RegisterOrcaInspectorPlugins()
|
||||
{
|
||||
static DPIAwarePlugin dpiaware;
|
||||
static CustomWidgetsPlugin customWidgets;
|
||||
wxInspector::RegisterPlugin(&dpiaware);
|
||||
wxInspector::RegisterPlugin(&customWidgets);
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add src/slic3r/Utils/wxInspectorPlugins/Registration.hpp
|
||||
git commit -m "feat: add wxInspector plugin registration helper
|
||||
|
||||
Add RegisterOrcaInspectorPlugins() inline function that creates
|
||||
and registers the DPIAwarePlugin and CustomWidgetsPlugin as
|
||||
static instances (matching wxInspector's built-in pattern)."
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 3: Create DPIAwarePlugin
|
||||
|
||||
**Files:**
|
||||
- Create: `src/slic3r/Utils/wxInspectorPlugins/DPIAwarePlugin.hpp`
|
||||
- Create: `src/slic3r/Utils/wxInspectorPlugins/DPIAwarePlugin.cpp`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Task 1 (DPIAware getters/setters), Task 2 (registration pattern)
|
||||
- Produces: `class DPIAwarePlugin : public wxInspector::wxInspectorPlugin`
|
||||
|
||||
- [ ] **Step 1: Write DPIAwarePlugin.hpp**
|
||||
|
||||
```cpp
|
||||
#pragma once
|
||||
|
||||
#include <wx/inspector/plugin.h>
|
||||
|
||||
class DPIAwarePlugin : public wxInspector::wxInspectorPlugin
|
||||
{
|
||||
public:
|
||||
wxString GetName() const override;
|
||||
|
||||
bool CanProvideProperties(wxClassInfo* info) override;
|
||||
|
||||
wxVector<wxInspector::PropertyDef> GetProperties(
|
||||
wxInspector::InspectableObject& obj) override;
|
||||
};
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Write DPIAwarePlugin.cpp**
|
||||
|
||||
```cpp
|
||||
#include "DPIAwarePlugin.hpp"
|
||||
|
||||
#include "slic3r/GUI/GUI_Utils.hpp" // DPIFrame, DPIDialog, DPIAware<P>
|
||||
|
||||
#include <wx/window.h>
|
||||
|
||||
namespace {
|
||||
|
||||
template<typename T>
|
||||
void addDPIProps(T* dpi, wxVector<wxInspector::PropertyDef>& props)
|
||||
{
|
||||
using namespace wxInspector;
|
||||
|
||||
props.push_back({"Scale Factor", "DPI Scaling", PropertyType::String,
|
||||
wxString::Format("%.2f", dpi->scale_factor()), false, {},
|
||||
[dpi]() { return wxString::Format("%.2f", dpi->scale_factor()); },
|
||||
[dpi](const wxString& v) {
|
||||
double val;
|
||||
if (wxSscanf(v, "%lf", &val) != 1) return false;
|
||||
dpi->set_scale_factor((float) val);
|
||||
return true;
|
||||
}});
|
||||
|
||||
props.push_back({"Prev Scale Factor", "DPI Scaling", PropertyType::String,
|
||||
wxString::Format("%.2f", dpi->prev_scale_factor()), false, {},
|
||||
[dpi]() { return wxString::Format("%.2f", dpi->prev_scale_factor()); },
|
||||
[dpi](const wxString& v) {
|
||||
double val;
|
||||
if (wxSscanf(v, "%lf", &val) != 1) return false;
|
||||
dpi->set_prev_scale_factor((float) val);
|
||||
return true;
|
||||
}});
|
||||
|
||||
props.push_back({"EM Unit", "DPI Scaling", PropertyType::Integer,
|
||||
wxString::Format("%d", dpi->em_unit()), false, {},
|
||||
[dpi]() { return wxString::Format("%d", dpi->em_unit()); },
|
||||
[dpi](const wxString& v) {
|
||||
long val;
|
||||
if (!v.ToLong(&val)) return false;
|
||||
dpi->set_em_unit((int) val);
|
||||
return true;
|
||||
}});
|
||||
|
||||
props.push_back({"Normal Font", "DPI Scaling", PropertyType::ReadOnly,
|
||||
dpi->normal_font().GetNativeFontInfoDesc(), true, {},
|
||||
[dpi]() { return dpi->normal_font().GetNativeFontInfoDesc(); },
|
||||
nullptr});
|
||||
|
||||
props.push_back({"Force Rescale", "DPI Scaling", PropertyType::Boolean,
|
||||
dpi->force_rescale() ? "true" : "false", true, {},
|
||||
[dpi]() { return dpi->force_rescale() ? "true" : "false"; },
|
||||
nullptr});
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
wxString DPIAwarePlugin::GetName() const
|
||||
{
|
||||
return "OrcaDPIAware";
|
||||
}
|
||||
|
||||
bool DPIAwarePlugin::CanProvideProperties(wxClassInfo* info)
|
||||
{
|
||||
return info->IsKindOf(CLASSINFO(wxWindow));
|
||||
}
|
||||
|
||||
wxVector<wxInspector::PropertyDef> DPIAwarePlugin::GetProperties(
|
||||
wxInspector::InspectableObject& obj)
|
||||
{
|
||||
wxVector<wxInspector::PropertyDef> props;
|
||||
wxWindow* win = obj.AsWindow();
|
||||
if (!win) return props;
|
||||
|
||||
if (auto* frame = dynamic_cast<DPIFrame*>(win)) {
|
||||
addDPIProps(frame, props);
|
||||
} else if (auto* dlg = dynamic_cast<DPIDialog*>(win)) {
|
||||
addDPIProps(dlg, props);
|
||||
}
|
||||
|
||||
return props;
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Commit**
|
||||
|
||||
```bash
|
||||
git add src/slic3r/Utils/wxInspectorPlugins/DPIAwarePlugin.hpp src/slic3r/Utils/wxInspectorPlugins/DPIAwarePlugin.cpp
|
||||
git commit -m "feat: add DPIAware wxInspector plugin
|
||||
|
||||
Exposes DPI scaling properties (scale_factor, prev_scale_factor,
|
||||
em_unit, normal_font, force_rescale) on DPIFrame and DPIDialog
|
||||
widgets. Uses dynamic_cast for detection and a template helper
|
||||
to capture the correct static type for lambda accessors."
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 4: Create CustomWidgetsPlugin
|
||||
|
||||
**Files:**
|
||||
- Create: `src/slic3r/Utils/wxInspectorPlugins/CustomWidgetsPlugin.hpp`
|
||||
- Create: `src/slic3r/Utils/wxInspectorPlugins/CustomWidgetsPlugin.cpp`
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Task 1 (all widget getters), Task 2 (registration pattern)
|
||||
- Produces: `class CustomWidgetsPlugin : public wxInspector::wxInspectorPlugin`
|
||||
|
||||
- [ ] **Step 1: Write CustomWidgetsPlugin.hpp**
|
||||
|
||||
```cpp
|
||||
#pragma once
|
||||
|
||||
#include <wx/inspector/plugin.h>
|
||||
|
||||
class CustomWidgetsPlugin : public wxInspector::wxInspectorPlugin
|
||||
{
|
||||
public:
|
||||
wxString GetName() const override;
|
||||
|
||||
bool CanProvideProperties(wxClassInfo* info) override;
|
||||
|
||||
wxVector<wxInspector::PropertyDef> GetProperties(
|
||||
wxInspector::InspectableObject& obj) override;
|
||||
|
||||
private:
|
||||
void addButtonProps(class Button* btn,
|
||||
wxVector<wxInspector::PropertyDef>& props);
|
||||
void addCheckBoxProps(class CheckBox* cb,
|
||||
wxVector<wxInspector::PropertyDef>& props);
|
||||
void addTextInputProps(class TextInput* ti,
|
||||
wxVector<wxInspector::PropertyDef>& props);
|
||||
void addSwitchButtonProps(class SwitchButton* sb,
|
||||
wxVector<wxInspector::PropertyDef>& props);
|
||||
void addProgressBarProps(class ProgressBar* pb,
|
||||
wxVector<wxInspector::PropertyDef>& props);
|
||||
void addLabelProps(class Label* lbl,
|
||||
wxVector<wxInspector::PropertyDef>& props);
|
||||
void addLabeledStaticBoxProps(class LabeledStaticBox* lsb,
|
||||
wxVector<wxInspector::PropertyDef>& props);
|
||||
};
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Write CustomWidgetsPlugin.cpp — includes and GetName/CanProvideProperties**
|
||||
|
||||
```cpp
|
||||
#include "CustomWidgetsPlugin.hpp"
|
||||
|
||||
#include "slic3r/GUI/Widgets/Button.hpp"
|
||||
#include "slic3r/GUI/Widgets/CheckBox.hpp"
|
||||
#include "slic3r/GUI/Widgets/TextInput.hpp"
|
||||
#include "slic3r/GUI/Widgets/SwitchButton.hpp"
|
||||
#include "slic3r/GUI/Widgets/ProgressBar.hpp"
|
||||
#include "slic3r/GUI/Widgets/Label.hpp"
|
||||
#include "slic3r/GUI/Widgets/LabeledStaticBox.hpp"
|
||||
|
||||
#include <wx/window.h>
|
||||
#include <wx/tglbtn.h>
|
||||
|
||||
wxString CustomWidgetsPlugin::GetName() const
|
||||
{
|
||||
return "OrcaCustomWidgets";
|
||||
}
|
||||
|
||||
bool CustomWidgetsPlugin::CanProvideProperties(wxClassInfo* info)
|
||||
{
|
||||
return info->IsKindOf(CLASSINFO(wxWindow));
|
||||
}
|
||||
|
||||
wxVector<wxInspector::PropertyDef> CustomWidgetsPlugin::GetProperties(
|
||||
wxInspector::InspectableObject& obj)
|
||||
{
|
||||
wxVector<wxInspector::PropertyDef> props;
|
||||
wxWindow* win = obj.AsWindow();
|
||||
if (!win) return props;
|
||||
|
||||
if (auto* btn = dynamic_cast<Button*>(win))
|
||||
addButtonProps(btn, props);
|
||||
if (auto* cb = dynamic_cast<CheckBox*>(win))
|
||||
addCheckBoxProps(cb, props);
|
||||
if (auto* ti = dynamic_cast<TextInput*>(win))
|
||||
addTextInputProps(ti, props);
|
||||
if (auto* sb = dynamic_cast<SwitchButton*>(win))
|
||||
addSwitchButtonProps(sb, props);
|
||||
if (auto* pb = dynamic_cast<ProgressBar*>(win))
|
||||
addProgressBarProps(pb, props);
|
||||
if (auto* lbl = dynamic_cast<Label*>(win))
|
||||
addLabelProps(lbl, props);
|
||||
if (auto* lsb = dynamic_cast<LabeledStaticBox*>(win))
|
||||
addLabeledStaticBoxProps(lsb, props);
|
||||
|
||||
return props;
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Write CustomWidgetsPlugin.cpp — addButtonProps**
|
||||
|
||||
```cpp
|
||||
void CustomWidgetsPlugin::addButtonProps(Button* btn,
|
||||
wxVector<wxInspector::PropertyDef>& props)
|
||||
{
|
||||
using namespace wxInspector;
|
||||
|
||||
wxVector<wxString> styleChoices;
|
||||
styleChoices.push_back("Regular");
|
||||
styleChoices.push_back("Confirm");
|
||||
styleChoices.push_back("Alert");
|
||||
styleChoices.push_back("Disabled");
|
||||
|
||||
auto styleToStr = [](ButtonStyle s) -> wxString {
|
||||
switch (s) {
|
||||
case ButtonStyle::Regular: return "Regular";
|
||||
case ButtonStyle::Confirm: return "Confirm";
|
||||
case ButtonStyle::Alert: return "Alert";
|
||||
case ButtonStyle::Disabled: return "Disabled";
|
||||
}
|
||||
return "Regular";
|
||||
};
|
||||
|
||||
props.push_back({"Button Style", "Orca Button", PropertyType::Choice,
|
||||
styleToStr(btn->GetStyle()), false, styleChoices,
|
||||
[btn, styleToStr]() { return styleToStr(btn->GetStyle()); },
|
||||
[btn](const wxString& v) {
|
||||
ButtonStyle s = ButtonStyle::Regular;
|
||||
if (v == "Confirm") s = ButtonStyle::Confirm;
|
||||
else if (v == "Alert") s = ButtonStyle::Alert;
|
||||
else if (v == "Disabled") s = ButtonStyle::Disabled;
|
||||
btn->SetStyle(s, btn->GetType());
|
||||
return true;
|
||||
}});
|
||||
|
||||
wxVector<wxString> typeChoices;
|
||||
typeChoices.push_back("Compact");
|
||||
typeChoices.push_back("Window");
|
||||
typeChoices.push_back("Choice");
|
||||
typeChoices.push_back("Parameter");
|
||||
typeChoices.push_back("Icon");
|
||||
typeChoices.push_back("Expanded");
|
||||
|
||||
auto typeToStr = [](ButtonType t) -> wxString {
|
||||
switch (t) {
|
||||
case ButtonType::Compact: return "Compact";
|
||||
case ButtonType::Window: return "Window";
|
||||
case ButtonType::Choice: return "Choice";
|
||||
case ButtonType::Parameter: return "Parameter";
|
||||
case ButtonType::Icon: return "Icon";
|
||||
case ButtonType::Expanded: return "Expanded";
|
||||
}
|
||||
return "Compact";
|
||||
};
|
||||
|
||||
props.push_back({"Button Type", "Orca Button", PropertyType::Choice,
|
||||
typeToStr(btn->GetType()), false, typeChoices,
|
||||
[btn, typeToStr]() { return typeToStr(btn->GetType()); },
|
||||
[btn](const wxString& v) {
|
||||
ButtonType t = ButtonType::Compact;
|
||||
if (v == "Window") t = ButtonType::Window;
|
||||
else if (v == "Choice") t = ButtonType::Choice;
|
||||
else if (v == "Parameter") t = ButtonType::Parameter;
|
||||
else if (v == "Icon") t = ButtonType::Icon;
|
||||
else if (v == "Expanded") t = ButtonType::Expanded;
|
||||
btn->SetStyle(btn->GetStyle(), t);
|
||||
return true;
|
||||
}});
|
||||
|
||||
props.push_back({"Selected", "Orca Button", PropertyType::Boolean,
|
||||
btn->IsSelected() ? "true" : "false", false, {},
|
||||
[btn]() { return btn->IsSelected() ? "true" : "false"; },
|
||||
[btn](const wxString& v) {
|
||||
btn->SetSelected(v == "true");
|
||||
btn->Refresh();
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 4: Write CustomWidgetsPlugin.cpp — addCheckBoxProps**
|
||||
|
||||
```cpp
|
||||
void CustomWidgetsPlugin::addCheckBoxProps(CheckBox* cb,
|
||||
wxVector<wxInspector::PropertyDef>& props)
|
||||
{
|
||||
using namespace wxInspector;
|
||||
|
||||
props.push_back({"Half Checked", "Orca CheckBox", PropertyType::Boolean,
|
||||
cb->IsHalfChecked() ? "true" : "false", false, {},
|
||||
[cb]() { return cb->IsHalfChecked() ? "true" : "false"; },
|
||||
[cb](const wxString& v) {
|
||||
cb->SetHalfChecked(v == "true");
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 5: Write CustomWidgetsPlugin.cpp — addTextInputProps**
|
||||
|
||||
```cpp
|
||||
void CustomWidgetsPlugin::addTextInputProps(TextInput* ti,
|
||||
wxVector<wxInspector::PropertyDef>& props)
|
||||
{
|
||||
using namespace wxInspector;
|
||||
|
||||
props.push_back({"Label", "Orca TextInput", PropertyType::String,
|
||||
ti->GetLabel(), false, {},
|
||||
[ti]() { return ti->GetLabel(); },
|
||||
[ti](const wxString& v) { ti->SetLabel(v); return true; }});
|
||||
|
||||
props.push_back({"Text Value", "Orca TextInput", PropertyType::String,
|
||||
ti->GetTextCtrl()->GetValue(), false, {},
|
||||
[ti]() { return ti->GetTextCtrl()->GetValue(); },
|
||||
[ti](const wxString& v) { ti->GetTextCtrl()->SetValue(v); return true; }});
|
||||
|
||||
props.push_back({"Corner Radius", "Orca TextInput", PropertyType::Integer,
|
||||
wxString::Format("%d", ti->GetCornerRadius()), false, {},
|
||||
[ti]() { return wxString::Format("%d", ti->GetCornerRadius()); },
|
||||
[ti](const wxString& v) {
|
||||
long val;
|
||||
if (!v.ToLong(&val)) return false;
|
||||
ti->SetCornerRadius((double) val);
|
||||
ti->Refresh();
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 6: Write CustomWidgetsPlugin.cpp — addSwitchButtonProps**
|
||||
|
||||
```cpp
|
||||
void CustomWidgetsPlugin::addSwitchButtonProps(SwitchButton* sb,
|
||||
wxVector<wxInspector::PropertyDef>& props)
|
||||
{
|
||||
using namespace wxInspector;
|
||||
|
||||
props.push_back({"Value", "Orca SwitchButton", PropertyType::Boolean,
|
||||
sb->GetValue() ? "true" : "false", false, {},
|
||||
[sb]() { return sb->GetValue() ? "true" : "false"; },
|
||||
[sb](const wxString& v) {
|
||||
sb->SetValue(v == "true");
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
```
|
||||
|
||||
(Note: `GetValue()` and `SetValue()` are inherited from `wxBitmapToggleButton` → `wxToggleButton`.)
|
||||
|
||||
- [ ] **Step 7: Write CustomWidgetsPlugin.cpp — addProgressBarProps**
|
||||
|
||||
```cpp
|
||||
void CustomWidgetsPlugin::addProgressBarProps(ProgressBar* pb,
|
||||
wxVector<wxInspector::PropertyDef>& props)
|
||||
{
|
||||
using namespace wxInspector;
|
||||
|
||||
props.push_back({"Proportion", "Orca ProgressBar", PropertyType::String,
|
||||
wxString::Format("%.2f", pb->m_proportion), false, {},
|
||||
[pb]() { return wxString::Format("%.2f", pb->m_proportion); },
|
||||
[pb](const wxString& v) {
|
||||
double val;
|
||||
if (wxSscanf(v, "%lf", &val) != 1) return false;
|
||||
pb->m_proportion = val;
|
||||
pb->Refresh();
|
||||
return true;
|
||||
}});
|
||||
|
||||
props.push_back({"Show Number", "Orca ProgressBar", PropertyType::Boolean,
|
||||
pb->m_shownumber ? "true" : "false", false, {},
|
||||
[pb]() { return pb->m_shownumber ? "true" : "false"; },
|
||||
[pb](const wxString& v) {
|
||||
pb->m_shownumber = (v == "true");
|
||||
pb->Refresh();
|
||||
return true;
|
||||
}});
|
||||
}
|
||||
```
|
||||
|
||||
(Note: `m_proportion` and `m_shownumber` are public members on `ProgressBar`.)
|
||||
|
||||
- [ ] **Step 8: Write CustomWidgetsPlugin.cpp — addLabelProps**
|
||||
|
||||
```cpp
|
||||
void CustomWidgetsPlugin::addLabelProps(Label* lbl,
|
||||
wxVector<wxInspector::PropertyDef>& props)
|
||||
{
|
||||
using namespace wxInspector;
|
||||
|
||||
bool isHyperlink = (lbl->GetWindowStyleFlag() & 0x0020) != 0; // LB_HYPERLINK
|
||||
|
||||
props.push_back({"Is Hyperlink", "Orca Label", PropertyType::Boolean,
|
||||
isHyperlink ? "true" : "false", true, {},
|
||||
[lbl]() {
|
||||
return (lbl->GetWindowStyleFlag() & 0x0020) ? "true" : "false";
|
||||
},
|
||||
nullptr});
|
||||
|
||||
props.push_back({"Font Point Size", "Orca Label", PropertyType::ReadOnly,
|
||||
wxString::Format("%d", lbl->GetFont().GetPointSize()), true, {},
|
||||
[lbl]() {
|
||||
return wxString::Format("%d", lbl->GetFont().GetPointSize());
|
||||
},
|
||||
nullptr});
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 9: Write CustomWidgetsPlugin.cpp — addLabeledStaticBoxProps**
|
||||
|
||||
```cpp
|
||||
void CustomWidgetsPlugin::addLabeledStaticBoxProps(LabeledStaticBox* lsb,
|
||||
wxVector<wxInspector::PropertyDef>& props)
|
||||
{
|
||||
using namespace wxInspector;
|
||||
|
||||
props.push_back({"Corner Radius", "LabeledStaticBox", PropertyType::Integer,
|
||||
wxString::Format("%d", lsb->GetCornerRadius()), false, {},
|
||||
[lsb]() { return wxString::Format("%d", lsb->GetCornerRadius()); },
|
||||
[lsb](const wxString& v) {
|
||||
long val;
|
||||
if (!v.ToLong(&val)) return false;
|
||||
lsb->SetCornerRadius((int) val);
|
||||
return true;
|
||||
}});
|
||||
|
||||
props.push_back({"Border Width", "LabeledStaticBox", PropertyType::Integer,
|
||||
wxString::Format("%d", lsb->GetBorderWidth()), false, {},
|
||||
[lsb]() { return wxString::Format("%d", lsb->GetBorderWidth()); },
|
||||
[lsb](const wxString& v) {
|
||||
long val;
|
||||
if (!v.ToLong(&val)) return false;
|
||||
lsb->SetBorderWidth((int) val);
|
||||
return true;
|
||||
}});
|
||||
|
||||
// Border Color: display as hex string
|
||||
wxColour bc = lsb->GetBorderColor().colorForStates(0);
|
||||
props.push_back({"Border Color", "LabeledStaticBox", PropertyType::String,
|
||||
bc.GetAsString(wxC2S_HTML_SYNTAX), false, {},
|
||||
[lsb]() {
|
||||
return lsb->GetBorderColor()
|
||||
.colorForStates(0)
|
||||
.GetAsString(wxC2S_HTML_SYNTAX);
|
||||
},
|
||||
[lsb](const wxString& v) {
|
||||
wxColour c(v);
|
||||
if (!c.IsOk()) return false;
|
||||
lsb->SetBorderColor(StateColor(c));
|
||||
return true;
|
||||
}});
|
||||
|
||||
props.push_back({"Scale", "LabeledStaticBox", PropertyType::ReadOnly,
|
||||
wxString::Format("%.2f", lsb->GetScale()), true, {},
|
||||
[lsb]() { return wxString::Format("%.2f", lsb->GetScale()); },
|
||||
nullptr});
|
||||
}
|
||||
```
|
||||
|
||||
- [ ] **Step 10: Commit**
|
||||
|
||||
```bash
|
||||
git add src/slic3r/Utils/wxInspectorPlugins/CustomWidgetsPlugin.hpp src/slic3r/Utils/wxInspectorPlugins/CustomWidgetsPlugin.cpp
|
||||
git commit -m "feat: add OrcaCustomWidgets wxInspector plugin
|
||||
|
||||
Exposes Orca-specific properties on 7 widget types:
|
||||
- Button: Style, Type, Selected
|
||||
- CheckBox: Half Checked
|
||||
- TextInput: Label, Text Value, Corner Radius
|
||||
- SwitchButton: Value
|
||||
- ProgressBar: Proportion, Show Number
|
||||
- Label: Is Hyperlink, Font Point Size
|
||||
- LabeledStaticBox: Corner Radius, Border Width, Border Color, Scale
|
||||
|
||||
Each widget type uses dynamic_cast for safe detection."
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 5: Wire plugins into MainFrame and CMakeLists
|
||||
|
||||
**Files:**
|
||||
- Modify: `src/slic3r/GUI/MainFrame.cpp` (add include + registration call)
|
||||
- Modify: `src/slic3r/CMakeLists.txt` (add 4 source files)
|
||||
|
||||
**Interfaces:**
|
||||
- Consumes: Tasks 1-4 (all plugins and registration helper)
|
||||
- Produces: Registered plugins available at runtime, buildable project
|
||||
|
||||
- [ ] **Step 1: Add include in MainFrame.cpp**
|
||||
|
||||
After the existing includes (around line 30, near the other Utils includes), add:
|
||||
|
||||
```cpp
|
||||
#include "slic3r/Utils/wxInspectorPlugins/Registration.hpp"
|
||||
```
|
||||
|
||||
- [ ] **Step 2: Add registration call in MainFrame constructor**
|
||||
|
||||
After `SetupInspectorAccelerator(this);` (currently line ~303), add:
|
||||
|
||||
```cpp
|
||||
RegisterOrcaInspectorPlugins();
|
||||
```
|
||||
|
||||
- [ ] **Step 3: Add source files to CMakeLists.txt**
|
||||
|
||||
Find the `SLIC3R_GUI_SOURCES` list in `src/slic3r/CMakeLists.txt`. After the existing `Utils/*.cpp` entries (around line 650-754), add:
|
||||
|
||||
```cmake
|
||||
Utils/wxInspectorPlugins/DPIAwarePlugin.hpp
|
||||
Utils/wxInspectorPlugins/DPIAwarePlugin.cpp
|
||||
Utils/wxInspectorPlugins/CustomWidgetsPlugin.hpp
|
||||
Utils/wxInspectorPlugins/CustomWidgetsPlugin.cpp
|
||||
Utils/wxInspectorPlugins/Registration.hpp
|
||||
```
|
||||
|
||||
(Note: Add all 5 files — 2 .hpp + 2 .cpp + 1 Registration.hpp. wxWidgets cmake needs headers listed too for the resource system.)
|
||||
|
||||
- [ ] **Step 4: Commit**
|
||||
|
||||
```bash
|
||||
git add src/slic3r/GUI/MainFrame.cpp src/slic3r/CMakeLists.txt
|
||||
git commit -m "feat: wire wxInspector plugins into MainFrame and build
|
||||
|
||||
- Call RegisterOrcaInspectorPlugins() after SetupInspectorAccelerator
|
||||
- Add all plugin source files to SLIC3R_GUI_SOURCES"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### Task 6: Build and verify
|
||||
|
||||
**Files:**
|
||||
- None modified (verification only)
|
||||
|
||||
- [ ] **Step 1: Configure the build**
|
||||
|
||||
```powershell
|
||||
$cmakePath = "D:\VisualStudio\2026\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
|
||||
& $cmakePath --build . --config Debug --target ALL_BUILD -- -m
|
||||
```
|
||||
|
||||
Expected: Build succeeds with zero errors and zero warnings from our new files.
|
||||
|
||||
- [ ] **Step 2: Fix any compilation errors**
|
||||
|
||||
If the build fails:
|
||||
- Check that `#include` paths resolve (the `slic3r/GUI/…` relative paths use `src/` as the include root — verify this is set up in CMake via `include_directories`)
|
||||
- Check that `ButtonStyle` and `ButtonType` enums are visible (they're defined in `Button.hpp`)
|
||||
- Check that `StateColor` constructor from `wxColour` is valid (it has `StateColor(wxColour const&)`)
|
||||
- Check that `LabeledStaticBox::GetBorderColor()` returns by value (StateColor copy is fine)
|
||||
- On macOS: static box margin removal call needs `#ifdef __WXOSX__` guard
|
||||
|
||||
- [ ] **Step 3: Launch OrcaSlicer and verify inspector**
|
||||
|
||||
Launch the built OrcaSlicer, press Ctrl+Shift+I to open the inspector:
|
||||
1. Select the MainFrame in the tree — verify "DPI Scaling" category appears with Scale Factor, Prev Scale Factor, EM Unit, Normal Font, Force Rescale
|
||||
2. Select an Orca Button — verify "Orca Button" category appears
|
||||
3. Select an Orca CheckBox — verify "Orca CheckBox" category appears
|
||||
4. Edit a property value (e.g., Scale Factor) — verify the setter applies correctly
|
||||
5. Select a LabeledStaticBox — verify corner radius, border width, border color, scale appear
|
||||
|
||||
- [ ] **Step 5: Commit (if fixes were needed) or mark complete**
|
||||
|
||||
```bash
|
||||
git status
|
||||
```
|
||||
|
||||
If clean: verification complete. If changes were made: `git add` and commit with fix message.
|
||||
@@ -0,0 +1,102 @@
|
||||
# Move `wxInspectable` into `DPIAware` — Design Spec
|
||||
|
||||
Date: 2026-07-23
|
||||
Branch: `dev/layout-inspector`
|
||||
|
||||
## Overview
|
||||
|
||||
Move the `wxInspector::wxInspectable` base class from individual leaf classes (`DPIDialog`, `MainFrame`) into the common `DPIAware<P>` template. This makes every DPIAware widget automatically visible in the inspector tree without requiring each subclass to opt in.
|
||||
|
||||
## Motivation
|
||||
|
||||
Currently, only `DPIDialog` and `MainFrame` explicitly inherit `wxInspectable`. `DPIFrame` (which `MainFrame` inherits from) does not — `MainFrame` adds it manually. This means:
|
||||
|
||||
- Any `DPIAware<T>` widget that isn't `DPIDialog` or `MainFrame` is invisible in the inspector tree
|
||||
- `DPIFrame` subclasses (`BaseTransparentDPIFrame`, `ImageDPIFrame`, `ModelMallDialog`, `MediaFileFrame`, `SecondaryCheckDialog`, `PrintErrorDialog`, etc.) don't appear
|
||||
- Adding a new DPIAware widget type requires remembering to also inherit `wxInspectable`
|
||||
|
||||
Moving `wxInspectable` to `DPIAware` fixes this for all current and future DPIAware widgets at once.
|
||||
|
||||
## Design
|
||||
|
||||
### Change 1: `GUI_Utils.hpp` — `DPIAware<P>`
|
||||
|
||||
Add `wxInspector::wxInspectable` as a second base class, and call `SetupInspectorAccelerator(this)` in the constructor (after `this->CenterOnParent()`):
|
||||
|
||||
```cpp
|
||||
// Before:
|
||||
template<class P> class DPIAware : public P
|
||||
|
||||
// After:
|
||||
template<class P> class DPIAware : public P, public wxInspector::wxInspectable
|
||||
```
|
||||
|
||||
Add in the constructor body (after `this->CenterOnParent()` at line 110):
|
||||
```cpp
|
||||
SetupInspectorAccelerator(this);
|
||||
```
|
||||
|
||||
This gives every `DPIAware<T>` widget both inspectability and the Ctrl+Shift+I keyboard shortcut automatically. `#include <wx/inspector/inspector.h>` is already present in the file.
|
||||
|
||||
### Change 2: `GUI_Utils.hpp` — `DPIDialog`
|
||||
|
||||
Remove the now-redundant `wxInspector::wxInspectable` and the `SetupInspectorAccelerator(this)` call:
|
||||
|
||||
```cpp
|
||||
// Before:
|
||||
class DPIDialog : public DPIAware<wxDialog>, public wxInspector::wxInspectable
|
||||
// ...
|
||||
SetupInspectorAccelerator(this);
|
||||
|
||||
// After:
|
||||
class DPIDialog : public DPIAware<wxDialog>
|
||||
// (SetupInspectorAccelerator call removed — now done in DPIAware constructor)
|
||||
```
|
||||
|
||||
`DPIDialog` gets `wxInspectable` and the accelerator through `DPIAware<wxDialog>` now.
|
||||
|
||||
### Change 3: `MainFrame.hpp` — `MainFrame`
|
||||
|
||||
Remove the now-redundant `wxInspector::wxInspectable`:
|
||||
|
||||
```cpp
|
||||
// Before:
|
||||
class MainFrame : public DPIFrame, public wxInspector::wxInspectable
|
||||
|
||||
// After:
|
||||
class MainFrame : public DPIFrame
|
||||
```
|
||||
|
||||
`MainFrame` gets `wxInspectable` through `DPIFrame` → `DPIAware<wxFrame>`.
|
||||
|
||||
### Change 4: `MainFrame.cpp` — `MainFrame` constructor
|
||||
|
||||
Remove the now-redundant `SetupInspectorAccelerator(this)` call (line 304). It will be called automatically by the `DPIAware` constructor.
|
||||
|
||||
## Impact
|
||||
|
||||
| Widget | Before | After |
|
||||
|--------|--------|-------|
|
||||
| `DPIDialog` subclasses (~80) | ✓ inspectable | ✓ inspectable (transitive) |
|
||||
| `MainFrame` | ✓ inspectable | ✓ inspectable (transitive) |
|
||||
| `DPIFrame` subclasses (8 others) | ✗ invisible | ✓ inspectable |
|
||||
| Future `DPIAware<T>` | ✗ invisible | ✓ inspectable |
|
||||
|
||||
## Files Modified
|
||||
|
||||
| File | Change |
|
||||
|------|--------|
|
||||
| `src/slic3r/GUI/GUI_Utils.hpp` | `DPIAware<P>` gains `wxInspector::wxInspectable` + `SetupInspectorAccelerator(this)` call; `DPIDialog` drops redundant `wxInspector::wxInspectable` and `SetupInspectorAccelerator(this)` |
|
||||
| `src/slic3r/GUI/MainFrame.hpp` | `MainFrame` drops redundant `wxInspector::wxInspectable` |
|
||||
| `src/slic3r/GUI/MainFrame.cpp` | Remove redundant `SetupInspectorAccelerator(this)` from MainFrame constructor |
|
||||
|
||||
## Non-Goals
|
||||
|
||||
- The `DPIAwarePlugin` detection logic (`dynamic_cast<DPIFrame*>` / `dynamic_cast<DPIDialog*>`) is unchanged
|
||||
- No new DPI properties — this is purely about tree visibility and accelerator setup
|
||||
|
||||
## Risk Assessment
|
||||
|
||||
- **Multiple inheritance**: `DPIAware<P>` already has a vtable (virtual destructor). Adding `wxInspectable` adds a second base but no additional data members. The `wxInspector::wxInspectable` class is expected to be a lightweight marker interface.
|
||||
- **Build**: No new includes needed; `<wx/inspector/inspector.h>` is already included in `GUI_Utils.hpp`.
|
||||
- **Cross-platform**: The change is standard C++ multiple inheritance — no platform-specific concerns.
|
||||
@@ -0,0 +1,244 @@
|
||||
# wxInspector Plugins for OrcaSlicer Custom Controls — Design Spec
|
||||
|
||||
Date: 2026-07-23
|
||||
Branch: `dev/layout-inspector`
|
||||
|
||||
## Overview
|
||||
|
||||
Create wxInspector plugins that expose OrcaSlicer's custom widget properties in the inspector's property grid. Without these plugins, the inspector shows only generic wxWidgets properties — missing all DPI-awareness data, custom styling, and Orca-specific control state.
|
||||
|
||||
## Goals
|
||||
|
||||
1. **DPIAware properties** — Inspect and update `scale_factor`, `prev_scale_factor`, `em_unit`, and `normal_font` on any DPIAware-derived widget
|
||||
2. **Custom widget properties** — Surface Orca-specific properties on `Button`, `CheckBox`, `TextInput`, `SwitchButton`, `ProgressBar`, `Label`, and `LabeledStaticBox`
|
||||
3. **Minimal source changes** — Only add trivial (one-line) getters/setters to existing classes; no architectural refactoring of Orca's widget hierarchy
|
||||
|
||||
## Non-Goals
|
||||
|
||||
- Custom inspector panels or AUI tabs (use the existing property grid and method invoker)
|
||||
- Python-plugin integration (this is C++ wxInspector, not Orca's Python plugin system)
|
||||
- Event logging customization (the built-in event logger already works)
|
||||
|
||||
## Architecture
|
||||
|
||||
### Two Plugins
|
||||
|
||||
| Plugin | Class | Files |
|
||||
|--------|-------|-------|
|
||||
| DPIAware plugin | `DPIAwarePlugin` | `DPIAwarePlugin.hpp`, `DPIAwarePlugin.cpp` |
|
||||
| Custom widgets plugin | `CustomWidgetsPlugin` | `CustomWidgetsPlugin.hpp`, `CustomWidgetsPlugin.cpp` |
|
||||
| Registration helper | inline function | `Registration.hpp` |
|
||||
|
||||
All files live under `src/slic3r/Utils/wxInspectorPlugins/`.
|
||||
|
||||
### Plugin Detection Strategy
|
||||
|
||||
**DPIAware plugin**: Uses `dynamic_cast<DPIFrame*>` and `dynamic_cast<DPIDialog*>` as detection gates. `DPIFrame` = `DPIAware<wxFrame>`, `DPIDialog` = `DPIAware<wxDialog>`. Since these are concrete typedefs, `dynamic_cast` works at runtime. This covers `MainFrame`, `SettingsDialog`, and all 8 calibration dialogs (which inherit `DPIDialog`).
|
||||
|
||||
**Custom widgets plugin**: Gates broadly on `CLASSINFO(wxWindow)`, then uses per-type `dynamic_cast` inside `GetProperties` to check each Orca-specific type. Only matching types append properties.
|
||||
|
||||
### Registration
|
||||
|
||||
A single `RegisterOrcaInspectorPlugins()` inline function in `Registration.hpp` creates both plugins as function-local statics (matching the wxInspector built-in provider pattern) and registers them via `wxInspector::RegisterPlugin()`.
|
||||
|
||||
Called once from `MainFrame::MainFrame()` after `SetupInspectorAccelerator(this)`.
|
||||
|
||||
### Why Separate Plugins?
|
||||
|
||||
- DPIAware is a C++ template concept (not a wxClassInfo-isKindOf check), so it needs its own detection logic
|
||||
- Custom widgets use standard wxClassInfo-based detection, matching the built-in provider pattern
|
||||
- Two focused files are easier to review and maintain than one monolithic plugin
|
||||
- Compile-time failure isolation: if a widget header changes, only one plugin breaks
|
||||
|
||||
## DPIAware Plugin — Property Specification
|
||||
|
||||
### Source Changes (GUI_Utils.hpp)
|
||||
|
||||
Four one-liner methods added to the `DPIAware<P>` template class (public section):
|
||||
|
||||
```cpp
|
||||
float scale_factor() const { return m_scale_factor; } // already exists
|
||||
float prev_scale_factor() const { return m_prev_scale_factor; } // already exists
|
||||
int em_unit() const { return m_em_unit; } // already exists
|
||||
void set_scale_factor(float v) { m_scale_factor = v; } // NEW
|
||||
void set_prev_scale_factor(float v) { m_prev_scale_factor = v; } // NEW
|
||||
void set_em_unit(int v) { m_em_unit = v; } // NEW
|
||||
bool force_rescale() const { return m_force_rescale; } // NEW
|
||||
// m_normal_font getter already exists: normal_font()
|
||||
```
|
||||
|
||||
### Detection
|
||||
|
||||
```cpp
|
||||
bool CanProvideProperties(wxClassInfo* info) override {
|
||||
// Gated in GetProperties via dynamic_cast on the window itself
|
||||
return info->IsKindOf(CLASSINFO(wxWindow));
|
||||
}
|
||||
```
|
||||
|
||||
In `GetProperties`:
|
||||
```cpp
|
||||
auto* win = obj.AsWindow();
|
||||
bool isDPI = dynamic_cast<DPIFrame*>(win) || dynamic_cast<DPIDialog*>(win);
|
||||
if (!isDPI) return props;
|
||||
```
|
||||
|
||||
### Property Table (category: "DPI Scaling")
|
||||
|
||||
| Name | Type | Editable | Getter | Setter |
|
||||
|------|------|----------|--------|--------|
|
||||
| Scale Factor | String (float) | Yes | `dpi->scale_factor()` | `dpi->set_scale_factor(v)` |
|
||||
| Prev Scale Factor | String (float) | Yes | `dpi->prev_scale_factor()` | `dpi->set_prev_scale_factor(v)` |
|
||||
| EM Unit | Integer | Yes | `dpi->em_unit()` | `dpi->set_em_unit(v)` |
|
||||
| Normal Font | ReadOnly | No | `dpi->normal_font().GetNativeFontInfoDesc()` | — |
|
||||
| Force Rescale | Boolean (ReadOnly) | No | `dpi->force_rescale()` | — |
|
||||
|
||||
**Note on setters**: The setters simply store values. They do NOT trigger a widget rescale/layout. To see the effect of a changed scale factor, use the inspector's Methods panel to call `Layout()` or resize the window — which triggers the DPI_CHANGED event path naturally.
|
||||
|
||||
## Custom Widgets Plugin — Property Specification
|
||||
|
||||
All properties are appended to the built-in wxWindow properties. Each widget type is independently detected via `dynamic_cast`.
|
||||
|
||||
### Detection gates (in `GetProperties`)
|
||||
|
||||
```cpp
|
||||
auto* win = obj.AsWindow();
|
||||
if (auto* btn = dynamic_cast<Button*>(win)) { addButtonProperties(btn, props); }
|
||||
if (auto* cb = dynamic_cast<CheckBox*>(win)) { addCheckBoxProperties(cb, props); }
|
||||
if (auto* ti = dynamic_cast<TextInput*>(win)) { addTextInputProperties(ti, props); }
|
||||
if (auto* sb = dynamic_cast<SwitchButton*>(win)) { addSwitchButtonProperties(sb, props); }
|
||||
if (auto* pb = dynamic_cast<ProgressBar*>(win)) { addProgressBarProperties(pb, props); }
|
||||
if (auto* lbl = dynamic_cast<Label*>(win)) { addLabelProperties(lbl, props); }
|
||||
if (auto* lsb = dynamic_cast<LabeledStaticBox*>(win)) { addLabeledStaticBoxProperties(lsb, props); }
|
||||
```
|
||||
|
||||
### Orca Button (`Button`) — category: "Orca Button"
|
||||
|
||||
| Name | Type | Editable | Getter | Setter |
|
||||
|------|------|----------|--------|--------|
|
||||
| Button Style | Choice | Yes | enum→string | string→enum |
|
||||
| Button Type | Choice | Yes | enum→string | string→enum |
|
||||
| Selected | Boolean | Yes | `m_selected` (needs getter) | `SetSelected(v)` |
|
||||
| Active Icon | ReadOnly | No | icon name string | — |
|
||||
| Inactive Icon | ReadOnly | No | icon name string | — |
|
||||
|
||||
Choices for Button Style: `Regular`, `Confirm`, `Alert`, `Disabled`
|
||||
Choices for Button Type: `Compact`, `Window`, `Choice`, `Parameter`, `Icon`, `Expanded`
|
||||
|
||||
**Source changes needed**: Button's `m_selected` is private. Add one-liner getter:
|
||||
```cpp
|
||||
bool IsSelected() const { return m_selected; }
|
||||
```
|
||||
|
||||
### Orca CheckBox (`CheckBox`) — category: "Orca CheckBox"
|
||||
|
||||
| Name | Type | Editable | Getter | Setter |
|
||||
|------|------|----------|--------|--------|
|
||||
| Half Checked | Boolean | Yes | `m_half_checked` (needs getter) | `SetHalfChecked(v)` |
|
||||
|
||||
**Source changes needed**: `m_half_checked` is private. Add one-liner getter:
|
||||
```cpp
|
||||
bool IsHalfChecked() const { return m_half_checked; }
|
||||
```
|
||||
|
||||
### Orca TextInput (`TextInput`) — category: "Orca TextInput"
|
||||
|
||||
| Name | Type | Editable | Getter | Setter |
|
||||
|------|------|----------|--------|--------|
|
||||
| Label | String | Yes | `GetLabel()` (inherited from wxWindow) | `SetLabel(v)` (exists) |
|
||||
| Text Value | String | Yes | `GetTextCtrl()->GetValue()` (GetTextCtrl is public) | `GetTextCtrl()->SetValue(v)` |
|
||||
| Corner Radius | Integer | Yes | `GetCornerRadius()` (NEW) | `SetCornerRadius(v)` (exists) |
|
||||
|
||||
**Source changes needed**: Add one getter to `TextInput`:
|
||||
```cpp
|
||||
int GetCornerRadius() const { return static_cast<int>(radius); }
|
||||
```
|
||||
(`radius` is inherited from StaticBox. `SetCornerRadius(double)` already exists. `GetTextCtrl()` is already public.)
|
||||
|
||||
### Orca SwitchButton (`SwitchButton`) — category: "Orca SwitchButton"
|
||||
|
||||
| Name | Type | Editable | Getter | Setter |
|
||||
|------|------|----------|--------|--------|
|
||||
| Value | Boolean | Yes | existing getter | existing setter |
|
||||
|
||||
### Orca ProgressBar (`ProgressBar`) — category: "Orca ProgressBar"
|
||||
|
||||
| Name | Type | Editable | Getter | Setter |
|
||||
|------|------|----------|--------|--------|
|
||||
| Proportion | Float (0-1) | Yes | `pb->m_proportion` (public member) | `pb->m_proportion = v` |
|
||||
| Show Number | Boolean | Yes | `pb->m_shownumber` (public member) | `pb->m_shownumber = v` |
|
||||
|
||||
**No source changes needed**: `m_proportion` and `m_shownumber` are already public members. `SetValue(int)` and `SetProgress(int)` already exist as public methods.
|
||||
|
||||
### Orca Label (`Label`) — category: "Orca Label"
|
||||
|
||||
| Name | Type | Editable | Getter | Setter |
|
||||
|------|------|----------|--------|--------|
|
||||
| Is Hyperlink | Boolean | No | existing flag check | — |
|
||||
| Font Size | ReadOnly | No | `GetFont().GetPointSize()` | — |
|
||||
|
||||
### LabeledStaticBox — category: "LabeledStaticBox"
|
||||
|
||||
| Name | Type | Editable | Getter | Setter |
|
||||
|------|------|----------|--------|--------|
|
||||
| Corner Radius | Integer | Yes | `GetCornerRadius()` (NEW) | `SetCornerRadius(v)` (exists) |
|
||||
| Border Width | Integer | Yes | `GetBorderWidth()` (NEW) | `SetBorderWidth(v)` (exists) |
|
||||
| Border Color | String (hex) | Yes | `GetBorderColor()` (NEW) | `SetBorderColor(v)` (exists) |
|
||||
| Scale | Float (ReadOnly) | No | `m_scale` (protected, needs getter) | — |
|
||||
|
||||
**Source changes needed**: Four one-liner getters added to `LabeledStaticBox`:
|
||||
```cpp
|
||||
int GetCornerRadius() const { return m_radius; }
|
||||
int GetBorderWidth() const { return m_border_width; }
|
||||
StateColor GetBorderColor() const { return border_color; }
|
||||
float GetScale() const { return m_scale; }
|
||||
```
|
||||
|
||||
## Files Modified (Existing Code)
|
||||
|
||||
| File | Changes |
|
||||
|------|---------|
|
||||
| `src/slic3r/GUI/GUI_Utils.hpp` | +4 methods in `DPIAware<P>`: `set_scale_factor()`, `set_prev_scale_factor()`, `set_em_unit()`, `force_rescale()` |
|
||||
| `src/slic3r/GUI/Widgets/LabeledStaticBox.hpp` | +4 getter declarations: `GetCornerRadius()`, `GetBorderWidth()`, `GetBorderColor()`, `GetScale()` |
|
||||
| `src/slic3r/GUI/Widgets/LabeledStaticBox.cpp` | +4 getter implementations |
|
||||
| `src/slic3r/GUI/Widgets/Button.hpp` | +1 getter: `IsSelected()` |
|
||||
| `src/slic3r/GUI/Widgets/CheckBox.hpp` | +1 getter: `IsHalfChecked()` |
|
||||
| `src/slic3r/GUI/Widgets/TextInput.hpp` | +1 getter: `GetCornerRadius()` |
|
||||
| `src/slic3r/GUI/Widgets/ProgressBar.hpp` | None (public members are used directly) |
|
||||
| `src/slic3r/GUI/MainFrame.cpp` | +1 `#include`, +1 call to `RegisterOrcaInspectorPlugins()` |
|
||||
| `src/slic3r/CMakeLists.txt` | +4 entries in `SLIC3R_GUI_SOURCES` (the .cpp plugin files) |
|
||||
|
||||
## Files Created
|
||||
|
||||
```
|
||||
src/slic3r/Utils/wxInspectorPlugins/
|
||||
├── DPIAwarePlugin.hpp
|
||||
├── DPIAwarePlugin.cpp
|
||||
├── CustomWidgetsPlugin.hpp
|
||||
├── CustomWidgetsPlugin.cpp
|
||||
└── Registration.hpp
|
||||
```
|
||||
|
||||
## Build & Linking
|
||||
|
||||
The `wxInspector` dependency is already wired:
|
||||
- `deps/wxInspector/wxInspector.cmake` fetches and builds wxInspector
|
||||
- `src/CMakeLists.txt` lines 92-93 link `wxInspector::wxInspector` into `wxWidgets_LIBRARIES`
|
||||
- The plugin files only need `#include <wx/inspector/plugin.h>` and `#include <wx/inspector/inspector.h>` — both available from the installed dependency
|
||||
|
||||
No new CMake dependencies needed. Only the new source files need listing in `SLIC3R_GUI_SOURCES`.
|
||||
|
||||
## Error Handling & Edge Cases
|
||||
|
||||
- **Stale pointers**: Plugin lambdas capture raw pointers, regenerated on every `GetProperties` call (matching wxInspector's built-in provider pattern). Pointers live only until the next tree selection.
|
||||
- **Widget destruction**: If a widget is destroyed while the inspector is showing its properties, `InspectableObject::IsValid()` returns false and properties are not displayed. The inspector won't show stale data.
|
||||
- **Invalid property values**: Setters use `sscanf` / `ToLong` with validation (matching built-in patterns). Bogus input is rejected — setter returns `false`, property grid shows error state.
|
||||
- **DPI drift**: Setting `scale_factor` without triggering rescale means displayed sizes don't match the new factor. This is acceptable — the inspector is a developer tool; operators know to call `Layout()` after making changes.
|
||||
- **Missing widget type**: If a `dynamic_cast` fails for all types, only built-in wxWindow properties are shown. No crash, no error — just reduced info.
|
||||
|
||||
## Future Work (Out of Scope)
|
||||
|
||||
- **StateColor visualization**: `StateColor` is a multi-value type (maps bitmask states to colors). A full solution would need a custom property editor (e.g., a table showing each state→color pair). Keep it simple for now.
|
||||
- **ScalableBitmap display**: Could show the bitmap as an inline thumbnail. Complex property editor work — deferred.
|
||||
- **More widget types**: `SwitchBoard`, `MultiSwitchButton`, `StepCtrl`, `FanControl`, `DropDown`, `ComboBox`, `AMS*` widgets could all benefit. Add as needed.
|
||||
- **Property refresh on tree selection**: Currently properties are static snapshots. A "refresh" button or auto-poll could keep values current for rapidly-changing widgets (progress bars, etc.). The built-in wxInspector already provides a tree-refresh button.
|
||||
@@ -8,7 +8,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-07-20 10:39-0300\n"
|
||||
"POT-Creation-Date: 2026-07-26 21:59-0300\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
@@ -552,6 +552,7 @@ msgstr ""
|
||||
msgid "Reset"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Enter"
|
||||
msgstr ""
|
||||
|
||||
@@ -877,6 +878,7 @@ msgstr ""
|
||||
msgid "Select all connectors"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Cut tool"
|
||||
msgid "Cut"
|
||||
msgstr ""
|
||||
|
||||
@@ -980,7 +982,7 @@ msgstr ""
|
||||
#, possible-boost-format
|
||||
msgid ""
|
||||
"Objects(%1%) have duplicated connectors. Some connectors may be missing in slicing result.\n"
|
||||
"Please report to PrusaSlicer team in which scenario this issue happened.\n"
|
||||
"Please report to the OrcaSlicer team in which scenario this issue happened.\n"
|
||||
"Thank you."
|
||||
msgstr ""
|
||||
|
||||
@@ -1732,12 +1734,14 @@ msgstr ""
|
||||
msgid "Select point"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
msgid "Restart selection"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Esc"
|
||||
msgstr ""
|
||||
|
||||
@@ -1838,6 +1842,7 @@ msgstr ""
|
||||
msgid "Leaving Measure gizmo"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Assembly tool"
|
||||
msgid "Assemble"
|
||||
msgstr ""
|
||||
|
||||
@@ -2348,6 +2353,9 @@ msgstr ""
|
||||
msgid "Import File"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
msgid "Choose files"
|
||||
msgstr ""
|
||||
|
||||
@@ -2466,12 +2474,14 @@ msgstr ""
|
||||
msgid "Show"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Del"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delete the selected object"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Backspace"
|
||||
msgstr ""
|
||||
|
||||
@@ -2659,6 +2669,9 @@ msgstr ""
|
||||
msgid "Restore to Meter"
|
||||
msgstr ""
|
||||
|
||||
msgid "Assemble"
|
||||
msgstr ""
|
||||
|
||||
msgid "Assemble the selected objects into an object with multiple parts"
|
||||
msgstr ""
|
||||
|
||||
@@ -3372,7 +3385,6 @@ msgstr ""
|
||||
msgid "Innerloop"
|
||||
msgstr ""
|
||||
|
||||
#. TRN To be shown in the main menu View->Top
|
||||
msgid "Top"
|
||||
msgstr ""
|
||||
|
||||
@@ -3403,6 +3415,7 @@ msgctxt "air_duct"
|
||||
msgid "Left(Aux)"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Hotend Heat Breaker Fan"
|
||||
msgid "Hotend"
|
||||
msgstr ""
|
||||
|
||||
@@ -4120,6 +4133,14 @@ msgstr ""
|
||||
msgid "Print with filament in AMS"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Nozzle position"
|
||||
msgid "Left"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Nozzle position"
|
||||
msgid "Right"
|
||||
msgstr ""
|
||||
|
||||
msgid "When the current material run out, the printer will continue to print in the following order."
|
||||
msgstr ""
|
||||
|
||||
@@ -5347,6 +5368,7 @@ msgstr ""
|
||||
msgid "Quality / Speed"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Mesh action"
|
||||
msgid "Smooth"
|
||||
msgstr ""
|
||||
|
||||
@@ -5447,10 +5469,24 @@ msgstr ""
|
||||
msgid "Align to Y axis"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Camera View"
|
||||
msgid "Front"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Camera View"
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
||||
#. TRN To be shown in the main menu View->Top
|
||||
msgctxt "Camera View"
|
||||
msgid "Top"
|
||||
msgstr ""
|
||||
|
||||
#. TRN To be shown in the main menu View->Bottom
|
||||
msgctxt "Camera View"
|
||||
msgid "Bottom"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Camera View"
|
||||
msgid "Left"
|
||||
msgstr ""
|
||||
@@ -5831,19 +5867,13 @@ msgstr ""
|
||||
msgid "Top View"
|
||||
msgstr ""
|
||||
|
||||
#. TRN To be shown in the main menu View->Bottom
|
||||
msgid "Bottom"
|
||||
msgstr ""
|
||||
|
||||
msgid "Bottom View"
|
||||
msgstr ""
|
||||
|
||||
msgid "Front"
|
||||
msgstr ""
|
||||
|
||||
msgid "Front View"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Camera View"
|
||||
msgid "Rear"
|
||||
msgstr ""
|
||||
|
||||
@@ -5955,6 +5985,9 @@ msgstr ""
|
||||
msgid "Redo"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cut"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cut selection to clipboard"
|
||||
msgstr ""
|
||||
|
||||
@@ -6054,6 +6087,10 @@ msgstr ""
|
||||
msgid "Preferences"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Menu"
|
||||
msgid "Edit"
|
||||
msgstr ""
|
||||
|
||||
msgid "View"
|
||||
msgstr ""
|
||||
|
||||
@@ -8615,6 +8652,15 @@ msgstr ""
|
||||
msgid "Displays current viewport FPS in the top-right corner."
|
||||
msgstr ""
|
||||
|
||||
msgid "G-code Preview"
|
||||
msgstr ""
|
||||
|
||||
msgid "Dim lower layers"
|
||||
msgstr ""
|
||||
|
||||
msgid "When scrubbing the layer slider in the sliced preview, render the layers below the current one darkened so that only the layer being viewed is shown at full brightness."
|
||||
msgstr ""
|
||||
|
||||
msgid "Login region"
|
||||
msgstr ""
|
||||
|
||||
@@ -8897,6 +8943,7 @@ msgstr ""
|
||||
msgid "The selected preset is null!"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Layer range"
|
||||
msgid "End"
|
||||
msgstr ""
|
||||
|
||||
@@ -9180,6 +9227,9 @@ msgstr ""
|
||||
msgid "The current printer does not support timelapse in Traditional Mode when printing By-Object."
|
||||
msgstr ""
|
||||
|
||||
msgid "I have checked the installed nozzle and want to print anyway."
|
||||
msgstr ""
|
||||
|
||||
msgid "Errors"
|
||||
msgstr ""
|
||||
|
||||
@@ -10804,24 +10854,28 @@ msgstr ""
|
||||
msgid "Select objects by rectangle"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Arrow Up"
|
||||
msgstr ""
|
||||
|
||||
msgid "Move selection 10mm in positive Y direction"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Arrow Down"
|
||||
msgstr ""
|
||||
|
||||
msgid "Move selection 10mm in negative Y direction"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Arrow Left"
|
||||
msgstr ""
|
||||
|
||||
msgid "Move selection 10mm in negative X direction"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Arrow Right"
|
||||
msgstr ""
|
||||
|
||||
@@ -10906,9 +10960,17 @@ msgstr ""
|
||||
msgid "Toggle printable for object/part"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Tab"
|
||||
msgstr ""
|
||||
|
||||
msgid "Switch between Prepare/Preview"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Space"
|
||||
msgstr ""
|
||||
|
||||
msgid "Open actions speed dial"
|
||||
msgstr ""
|
||||
|
||||
@@ -10966,9 +11028,17 @@ msgstr ""
|
||||
msgid "Move slider 5x faster"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Home"
|
||||
msgstr ""
|
||||
|
||||
msgid "Horizontal slider - Move to start position"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "End"
|
||||
msgstr ""
|
||||
|
||||
msgid "Horizontal slider - Move to last position"
|
||||
msgstr ""
|
||||
|
||||
@@ -14666,7 +14736,7 @@ msgstr ""
|
||||
msgid "Retract amount after wipe"
|
||||
msgstr ""
|
||||
|
||||
#, possible-c-format
|
||||
#, no-c-format, no-boost-format
|
||||
msgid ""
|
||||
"The length of fast retraction after wipe, relative to retraction length.\n"
|
||||
"The value will be clamped by 100% minus the retract amount before the wipe value."
|
||||
@@ -15098,6 +15168,9 @@ msgstr ""
|
||||
msgid "Traditional"
|
||||
msgstr ""
|
||||
|
||||
msgid "Smooth"
|
||||
msgstr ""
|
||||
|
||||
msgid "Farthest point timelapse"
|
||||
msgstr ""
|
||||
|
||||
@@ -16001,6 +16074,12 @@ msgstr ""
|
||||
msgid "Whether this printer supports fast purge mode with optimized temperature and multiplier."
|
||||
msgstr ""
|
||||
|
||||
msgid "Filament change"
|
||||
msgstr ""
|
||||
|
||||
msgid "The volume of material required to prime the extruder on the tower, excluding a hotend change."
|
||||
msgstr ""
|
||||
|
||||
msgid "The volume of material required to prime the extruder for a hotend change on the tower."
|
||||
msgstr ""
|
||||
|
||||
@@ -19049,15 +19128,15 @@ msgstr ""
|
||||
msgid "Show details"
|
||||
msgstr ""
|
||||
|
||||
msgid "Hide details"
|
||||
msgstr ""
|
||||
|
||||
msgid "Version to install:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Download and Install"
|
||||
msgstr ""
|
||||
|
||||
msgid "Skip for Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "A new version of the Bambu Network Plug-in is available."
|
||||
msgstr ""
|
||||
|
||||
@@ -19068,18 +19147,12 @@ msgstr ""
|
||||
msgid "Update to version:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Update Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "Remind Later"
|
||||
msgstr ""
|
||||
|
||||
msgid "Skip Version"
|
||||
msgstr ""
|
||||
|
||||
msgid "Don't Ask Again"
|
||||
msgstr ""
|
||||
|
||||
msgid "Update Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "(Latest)"
|
||||
msgstr ""
|
||||
|
||||
@@ -19095,9 +19168,6 @@ msgstr ""
|
||||
msgid "Restart Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "Restart Later"
|
||||
msgstr ""
|
||||
|
||||
msgid "NO RAMMING AT ALL"
|
||||
msgstr ""
|
||||
|
||||
|
||||
+2388
-1419
File diff suppressed because it is too large
Load Diff
+2284
-1384
File diff suppressed because it is too large
Load Diff
+1121
-916
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@ msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Orca Slicer\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2026-07-20 10:39-0300\n"
|
||||
"POT-Creation-Date: 2026-07-26 21:59-0300\n"
|
||||
"PO-Revision-Date: 2026-06-17 15:44-0300\n"
|
||||
"Last-Translator: Alexandre Folle de Menezes\n"
|
||||
"Language-Team: \n"
|
||||
@@ -548,6 +548,7 @@ msgstr ""
|
||||
msgid "Reset"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Enter"
|
||||
msgstr ""
|
||||
|
||||
@@ -873,6 +874,7 @@ msgstr ""
|
||||
msgid "Select all connectors"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Cut tool"
|
||||
msgid "Cut"
|
||||
msgstr ""
|
||||
|
||||
@@ -976,7 +978,7 @@ msgstr ""
|
||||
#, boost-format
|
||||
msgid ""
|
||||
"Objects(%1%) have duplicated connectors. Some connectors may be missing in slicing result.\n"
|
||||
"Please report to PrusaSlicer team in which scenario this issue happened.\n"
|
||||
"Please report to the OrcaSlicer team in which scenario this issue happened.\n"
|
||||
"Thank you."
|
||||
msgstr ""
|
||||
|
||||
@@ -1728,12 +1730,14 @@ msgstr ""
|
||||
msgid "Select point"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
msgid "Restart selection"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Esc"
|
||||
msgstr ""
|
||||
|
||||
@@ -1834,6 +1838,7 @@ msgstr ""
|
||||
msgid "Leaving Measure gizmo"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Assembly tool"
|
||||
msgid "Assemble"
|
||||
msgstr ""
|
||||
|
||||
@@ -2344,6 +2349,9 @@ msgstr ""
|
||||
msgid "Import File"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delete"
|
||||
msgstr ""
|
||||
|
||||
msgid "Choose files"
|
||||
msgstr ""
|
||||
|
||||
@@ -2462,12 +2470,14 @@ msgstr ""
|
||||
msgid "Show"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Del"
|
||||
msgstr ""
|
||||
|
||||
msgid "Delete the selected object"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Backspace"
|
||||
msgstr ""
|
||||
|
||||
@@ -2655,6 +2665,9 @@ msgstr ""
|
||||
msgid "Restore to Meter"
|
||||
msgstr ""
|
||||
|
||||
msgid "Assemble"
|
||||
msgstr ""
|
||||
|
||||
msgid "Assemble the selected objects into an object with multiple parts"
|
||||
msgstr ""
|
||||
|
||||
@@ -3368,7 +3381,6 @@ msgstr ""
|
||||
msgid "Innerloop"
|
||||
msgstr ""
|
||||
|
||||
#. TRN To be shown in the main menu View->Top
|
||||
msgid "Top"
|
||||
msgstr ""
|
||||
|
||||
@@ -3399,6 +3411,7 @@ msgctxt "air_duct"
|
||||
msgid "Left(Aux)"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Hotend Heat Breaker Fan"
|
||||
msgid "Hotend"
|
||||
msgstr ""
|
||||
|
||||
@@ -4116,6 +4129,14 @@ msgstr ""
|
||||
msgid "Print with filament in AMS"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Nozzle position"
|
||||
msgid "Left"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Nozzle position"
|
||||
msgid "Right"
|
||||
msgstr ""
|
||||
|
||||
msgid "When the current material run out, the printer will continue to print in the following order."
|
||||
msgstr ""
|
||||
|
||||
@@ -5343,6 +5364,7 @@ msgstr ""
|
||||
msgid "Quality / Speed"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Mesh action"
|
||||
msgid "Smooth"
|
||||
msgstr ""
|
||||
|
||||
@@ -5443,10 +5465,24 @@ msgstr ""
|
||||
msgid "Align to Y axis"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Camera View"
|
||||
msgid "Front"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Camera View"
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
||||
#. TRN To be shown in the main menu View->Top
|
||||
msgctxt "Camera View"
|
||||
msgid "Top"
|
||||
msgstr ""
|
||||
|
||||
#. TRN To be shown in the main menu View->Bottom
|
||||
msgctxt "Camera View"
|
||||
msgid "Bottom"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Camera View"
|
||||
msgid "Left"
|
||||
msgstr ""
|
||||
@@ -5827,19 +5863,13 @@ msgstr ""
|
||||
msgid "Top View"
|
||||
msgstr ""
|
||||
|
||||
#. TRN To be shown in the main menu View->Bottom
|
||||
msgid "Bottom"
|
||||
msgstr ""
|
||||
|
||||
msgid "Bottom View"
|
||||
msgstr ""
|
||||
|
||||
msgid "Front"
|
||||
msgstr ""
|
||||
|
||||
msgid "Front View"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Camera View"
|
||||
msgid "Rear"
|
||||
msgstr ""
|
||||
|
||||
@@ -5951,6 +5981,9 @@ msgstr ""
|
||||
msgid "Redo"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cut"
|
||||
msgstr ""
|
||||
|
||||
msgid "Cut selection to clipboard"
|
||||
msgstr ""
|
||||
|
||||
@@ -6050,6 +6083,10 @@ msgstr ""
|
||||
msgid "Preferences"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Menu"
|
||||
msgid "Edit"
|
||||
msgstr ""
|
||||
|
||||
msgid "View"
|
||||
msgstr ""
|
||||
|
||||
@@ -8611,6 +8648,15 @@ msgstr ""
|
||||
msgid "Displays current viewport FPS in the top-right corner."
|
||||
msgstr ""
|
||||
|
||||
msgid "G-code Preview"
|
||||
msgstr ""
|
||||
|
||||
msgid "Dim lower layers"
|
||||
msgstr ""
|
||||
|
||||
msgid "When scrubbing the layer slider in the sliced preview, render the layers below the current one darkened so that only the layer being viewed is shown at full brightness."
|
||||
msgstr ""
|
||||
|
||||
msgid "Login region"
|
||||
msgstr ""
|
||||
|
||||
@@ -8893,6 +8939,7 @@ msgstr ""
|
||||
msgid "The selected preset is null!"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Layer range"
|
||||
msgid "End"
|
||||
msgstr ""
|
||||
|
||||
@@ -9176,6 +9223,9 @@ msgstr ""
|
||||
msgid "The current printer does not support timelapse in Traditional Mode when printing By-Object."
|
||||
msgstr ""
|
||||
|
||||
msgid "I have checked the installed nozzle and want to print anyway."
|
||||
msgstr ""
|
||||
|
||||
msgid "Errors"
|
||||
msgstr ""
|
||||
|
||||
@@ -10800,24 +10850,28 @@ msgstr ""
|
||||
msgid "Select objects by rectangle"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Arrow Up"
|
||||
msgstr ""
|
||||
|
||||
msgid "Move selection 10mm in positive Y direction"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Arrow Down"
|
||||
msgstr ""
|
||||
|
||||
msgid "Move selection 10mm in negative Y direction"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Arrow Left"
|
||||
msgstr ""
|
||||
|
||||
msgid "Move selection 10mm in negative X direction"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Arrow Right"
|
||||
msgstr ""
|
||||
|
||||
@@ -10902,9 +10956,17 @@ msgstr ""
|
||||
msgid "Toggle printable for object/part"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Tab"
|
||||
msgstr ""
|
||||
|
||||
msgid "Switch between Prepare/Preview"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Space"
|
||||
msgstr ""
|
||||
|
||||
msgid "Open actions speed dial"
|
||||
msgstr ""
|
||||
|
||||
@@ -10962,9 +11024,17 @@ msgstr ""
|
||||
msgid "Move slider 5x faster"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "Home"
|
||||
msgstr ""
|
||||
|
||||
msgid "Horizontal slider - Move to start position"
|
||||
msgstr ""
|
||||
|
||||
msgctxt "Keyboard Shortcut"
|
||||
msgid "End"
|
||||
msgstr ""
|
||||
|
||||
msgid "Horizontal slider - Move to last position"
|
||||
msgstr ""
|
||||
|
||||
@@ -14662,7 +14732,7 @@ msgstr ""
|
||||
msgid "Retract amount after wipe"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
#, no-c-format, no-boost-format
|
||||
msgid ""
|
||||
"The length of fast retraction after wipe, relative to retraction length.\n"
|
||||
"The value will be clamped by 100% minus the retract amount before the wipe value."
|
||||
@@ -15094,6 +15164,9 @@ msgstr ""
|
||||
msgid "Traditional"
|
||||
msgstr ""
|
||||
|
||||
msgid "Smooth"
|
||||
msgstr ""
|
||||
|
||||
msgid "Farthest point timelapse"
|
||||
msgstr ""
|
||||
|
||||
@@ -15997,6 +16070,12 @@ msgstr ""
|
||||
msgid "Whether this printer supports fast purge mode with optimized temperature and multiplier."
|
||||
msgstr ""
|
||||
|
||||
msgid "Filament change"
|
||||
msgstr ""
|
||||
|
||||
msgid "The volume of material required to prime the extruder on the tower, excluding a hotend change."
|
||||
msgstr ""
|
||||
|
||||
msgid "The volume of material required to prime the extruder for a hotend change on the tower."
|
||||
msgstr ""
|
||||
|
||||
@@ -19045,15 +19124,15 @@ msgstr ""
|
||||
msgid "Show details"
|
||||
msgstr ""
|
||||
|
||||
msgid "Hide details"
|
||||
msgstr ""
|
||||
|
||||
msgid "Version to install:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Download and Install"
|
||||
msgstr ""
|
||||
|
||||
msgid "Skip for Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "A new version of the Bambu Network Plug-in is available."
|
||||
msgstr ""
|
||||
|
||||
@@ -19064,18 +19143,12 @@ msgstr ""
|
||||
msgid "Update to version:"
|
||||
msgstr ""
|
||||
|
||||
msgid "Update Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "Remind Later"
|
||||
msgstr ""
|
||||
|
||||
msgid "Skip Version"
|
||||
msgstr ""
|
||||
|
||||
msgid "Don't Ask Again"
|
||||
msgstr ""
|
||||
|
||||
msgid "Update Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "(Latest)"
|
||||
msgstr ""
|
||||
|
||||
@@ -19091,9 +19164,6 @@ msgstr ""
|
||||
msgid "Restart Now"
|
||||
msgstr ""
|
||||
|
||||
msgid "Restart Later"
|
||||
msgstr ""
|
||||
|
||||
msgid "NO RAMMING AT ALL"
|
||||
msgstr ""
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1775
-1162
File diff suppressed because it is too large
Load Diff
+1853
-1188
File diff suppressed because it is too large
Load Diff
+3412
-1658
File diff suppressed because it is too large
Load Diff
+2829
-1592
File diff suppressed because it is too large
Load Diff
+1037
-417
File diff suppressed because it is too large
Load Diff
+6525
-3150
File diff suppressed because it is too large
Load Diff
+3098
-1692
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+1247
-676
File diff suppressed because it is too large
Load Diff
+7140
-3412
File diff suppressed because it is too large
Load Diff
+1288
-521
File diff suppressed because it is too large
Load Diff
+2380
-1408
File diff suppressed because it is too large
Load Diff
+2561
-1443
File diff suppressed because it is too large
Load Diff
+4139
-2204
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+2003
-1735
File diff suppressed because it is too large
Load Diff
@@ -48,6 +48,7 @@
|
||||
<span id="statusText" class="status-text"></span>
|
||||
</footer>
|
||||
</main>
|
||||
<script src="../js/plugin-config-ui.js"></script>
|
||||
<script src="index.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -9,6 +9,12 @@ let selectedCapabilityType = "";
|
||||
let selectedHasPresetOverride = false;
|
||||
let selectedReadOnly = false;
|
||||
|
||||
// Whether the frame already holds the selected capability's custom UI (payloads are gated by
|
||||
// IsCurrentCapability and every selection change clears the view). Saving re-sends the whole
|
||||
// capability_config payload, and rebuilding the frame from it would reload the plugin's page under
|
||||
// the user's cursor, so a loaded frame gets the new values posted in instead.
|
||||
let customFrameLoaded = false;
|
||||
|
||||
function SafeJsonParse(text) {
|
||||
try {
|
||||
return JSON.parse(text);
|
||||
@@ -193,6 +199,7 @@ function ClearCapabilityConfigView() {
|
||||
if (custom) {
|
||||
custom.hidden = true;
|
||||
custom.removeAttribute("srcdoc");
|
||||
customFrameLoaded = false;
|
||||
}
|
||||
if (text)
|
||||
text.value = "";
|
||||
@@ -248,8 +255,14 @@ function ApplyCapabilityConfig(payload) {
|
||||
|
||||
if (html) {
|
||||
if (custom) {
|
||||
const context = OrcaConfigContext(payload, "preset");
|
||||
custom.hidden = false;
|
||||
custom.srcdoc = BuildCustomConfigDocument(html, config);
|
||||
if (customFrameLoaded && custom.contentWindow) {
|
||||
custom.contentWindow.postMessage({ __orca: "config", config: config, context: context }, "*");
|
||||
} else {
|
||||
customFrameLoaded = true;
|
||||
custom.srcdoc = BuildCustomConfigDocument(html, config, context);
|
||||
}
|
||||
}
|
||||
if (editor)
|
||||
editor.hidden = true;
|
||||
@@ -260,6 +273,7 @@ function ApplyCapabilityConfig(payload) {
|
||||
if (custom) {
|
||||
custom.hidden = true;
|
||||
custom.removeAttribute("srcdoc");
|
||||
customFrameLoaded = false;
|
||||
}
|
||||
if (editor)
|
||||
editor.hidden = false;
|
||||
@@ -354,39 +368,6 @@ function ApplyCapabilityConfigSaved(payload) {
|
||||
SetConfigValidation("");
|
||||
}
|
||||
|
||||
// The whole host surface a custom config UI gets: read the config, save one, drop the preset's
|
||||
// override, and be told when either lands. The frame is sandboxed into an opaque origin, so this
|
||||
// bridge is its only channel.
|
||||
function BuildCustomConfigDocument(html, config) {
|
||||
// Inlined into a <script>: a stored "</script>" would close the tag early, so escape "<" — the
|
||||
// literal stays valid JSON.
|
||||
const seed = JSON.stringify(config).replace(/</g, "\\u003c");
|
||||
const bridge = `<script>
|
||||
(function () {
|
||||
var handlers = [];
|
||||
var current = ${seed};
|
||||
window.orca = {
|
||||
getConfig: function () { return current; },
|
||||
saveConfig: function (cfg) { parent.postMessage({ __orca: "save", config: cfg }, "*"); },
|
||||
restoreDefaults: function () { parent.postMessage({ __orca: "restore" }, "*"); },
|
||||
onConfig: function (cb) {
|
||||
if (typeof cb !== "function") return;
|
||||
handlers.push(cb);
|
||||
try { cb(current); } catch (e) {}
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", function (event) {
|
||||
if (!event.data || event.data.__orca !== "config") return;
|
||||
current = event.data.config || {};
|
||||
handlers.forEach(function (handler) {
|
||||
try { handler(current); } catch (e) {}
|
||||
});
|
||||
});
|
||||
})();
|
||||
<\/script>`;
|
||||
return bridge + html;
|
||||
}
|
||||
|
||||
function OnCustomConfigMessage(event) {
|
||||
const custom = document.getElementById("configCustom");
|
||||
// Only the frame we created, and only while it is actually showing.
|
||||
@@ -432,6 +413,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
// OnCustomConfigMessage matches on the frame's contentWindow, not the origin ("null" when
|
||||
// sandboxed), and ignores anything else.
|
||||
window.addEventListener("message", OnCustomConfigMessage);
|
||||
OrcaWatchThemeForFrame("configCustom");
|
||||
|
||||
SendMessage("request_capabilities");
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<script type="text/javascript" src="../../data/text.js"></script>
|
||||
<script type="text/javascript" src="../js/globalapi.js"></script>
|
||||
<script type="text/javascript" src="../js/common.js"></script>
|
||||
<script src="../js/plugin-config-ui.js"></script>
|
||||
<script src="./index.js"></script>
|
||||
<script src="./plugin-sort.js"></script>
|
||||
<script src="../js/fuzzy-search.js"></script>
|
||||
|
||||
@@ -90,6 +90,7 @@ function OnInit() {
|
||||
// OnCustomConfigMessage matches on the frame's contentWindow, not the origin ("null" when
|
||||
// sandboxed), and ignores anything else.
|
||||
window.addEventListener("message", OnCustomConfigMessage);
|
||||
OrcaWatchThemeForFrame("configCustom");
|
||||
|
||||
document.addEventListener("click", (event) => {
|
||||
if (!event.target.closest(".ctx"))
|
||||
@@ -1077,7 +1078,7 @@ function ApplyCapabilityConfig(payload) {
|
||||
if (html) {
|
||||
if (custom) {
|
||||
custom.hidden = false;
|
||||
custom.srcdoc = BuildCustomConfigDocument(html, config);
|
||||
custom.srcdoc = BuildCustomConfigDocument(html, config, OrcaConfigContext(payload, "global"));
|
||||
}
|
||||
if (editor)
|
||||
editor.hidden = true;
|
||||
@@ -1178,39 +1179,6 @@ function ApplyCapabilityConfigSaved(payload) {
|
||||
SetConfigValidation("");
|
||||
}
|
||||
|
||||
// The whole host surface a custom config UI gets: read the config, save one, restore the plugin's
|
||||
// defaults, and be told when either lands. The frame is sandboxed into an opaque origin, so this
|
||||
// bridge is its only channel.
|
||||
function BuildCustomConfigDocument(html, config) {
|
||||
// Inlined into a <script>: a stored "</script>" would close the tag early, so escape "<" — the
|
||||
// literal stays valid JSON.
|
||||
const seed = JSON.stringify(config).replace(/</g, "\\u003c");
|
||||
const bridge = `<script>
|
||||
(function () {
|
||||
var handlers = [];
|
||||
var current = ${seed};
|
||||
window.orca = {
|
||||
getConfig: function () { return current; },
|
||||
saveConfig: function (cfg) { parent.postMessage({ __orca: "save", config: cfg }, "*"); },
|
||||
restoreDefaults: function () { parent.postMessage({ __orca: "restore" }, "*"); },
|
||||
onConfig: function (cb) {
|
||||
if (typeof cb !== "function") return;
|
||||
handlers.push(cb);
|
||||
try { cb(current); } catch (e) {}
|
||||
}
|
||||
};
|
||||
window.addEventListener("message", function (event) {
|
||||
if (!event.data || event.data.__orca !== "config") return;
|
||||
current = event.data.config || {};
|
||||
handlers.forEach(function (handler) {
|
||||
try { handler(current); } catch (e) {}
|
||||
});
|
||||
});
|
||||
})();
|
||||
<\/script>`;
|
||||
return bridge + html;
|
||||
}
|
||||
|
||||
function OnCustomConfigMessage(event) {
|
||||
const custom = document.getElementById("configCustom");
|
||||
// Only the frame we created, and only while it is actually showing.
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
// The host surface a plugin capability's custom configuration UI gets, shared by the Plugins dialog
|
||||
// and by a preset's plugin configuration dialog. Both sandbox the page into an opaque origin, so this
|
||||
// bridge is its only channel — and both must offer plugin authors the same one.
|
||||
|
||||
// The host theme (WebViewHostDialog::host_theme_vars_css) is injected as a ":root{--orca-*}" rule in
|
||||
// <style id="orca-host-theme-vars">, but only on the top-level page, so a sandboxed config UI never
|
||||
// sees it unless we hand it over. Relay that CSS verbatim instead of re-deriving it: C++ stays the
|
||||
// only place the contract is spelled out, and the host re-themes the style in place, so reading it
|
||||
// always yields the live theme.
|
||||
function OrcaThemeSnapshot() {
|
||||
const style = document.getElementById("orca-host-theme-vars");
|
||||
return {
|
||||
theme: document.documentElement.getAttribute("data-orca-theme") === "dark" ? "dark" : "light",
|
||||
css: style ? style.textContent : ""
|
||||
};
|
||||
}
|
||||
|
||||
// Inlined into a <script> or a JSON payload: a stored "</script>" would close the tag early, so
|
||||
// escape "<" — the literal stays valid JSON.
|
||||
function OrcaInlineJson(value) {
|
||||
return JSON.stringify(value).replace(/</g, "\\u003c");
|
||||
}
|
||||
|
||||
// What a custom UI can learn about the surface it is edited on, kept to what changes the page's own
|
||||
// behavior: "Restore defaults" writes the plugin's get_default_config() in the Plugins dialog but
|
||||
// drops the preset's override in a preset dialog, so a page needs the scope to label its own button.
|
||||
function OrcaConfigContext(payload, scope) {
|
||||
return {
|
||||
scope: scope,
|
||||
readOnly: payload ? payload.read_only === true : false,
|
||||
hasPresetOverride: payload ? payload.has_preset_override === true : false
|
||||
};
|
||||
}
|
||||
|
||||
// The whole host surface: read the config, save one, restore defaults, follow the theme, and be told
|
||||
// when any of it lands.
|
||||
function BuildCustomConfigDocument(html, config, context) {
|
||||
const theme = OrcaThemeSnapshot();
|
||||
const bridge = `<style id="orca-host-theme-vars"></style>
|
||||
<script>
|
||||
(function () {
|
||||
var handlers = [];
|
||||
var themeHandlers = [];
|
||||
var current = ${OrcaInlineJson(config === undefined ? {} : config)};
|
||||
var context = ${OrcaInlineJson(context || {})};
|
||||
var theme = ${OrcaInlineJson(theme)};
|
||||
|
||||
function applyTheme(next) {
|
||||
if (next && typeof next.css === "string") theme = next;
|
||||
var style = document.getElementById("orca-host-theme-vars");
|
||||
if (style) style.textContent = theme.css;
|
||||
if (document.documentElement) document.documentElement.setAttribute("data-orca-theme", theme.theme);
|
||||
themeHandlers.forEach(function (handler) {
|
||||
try { handler(theme.theme); } catch (e) {}
|
||||
});
|
||||
}
|
||||
|
||||
window.orca = {
|
||||
getConfig: function () { return current; },
|
||||
saveConfig: function (cfg) { parent.postMessage({ __orca: "save", config: cfg }, "*"); },
|
||||
restoreDefaults: function () { parent.postMessage({ __orca: "restore" }, "*"); },
|
||||
getContext: function () { return context; },
|
||||
onConfig: function (cb) {
|
||||
if (typeof cb !== "function") return;
|
||||
handlers.push(cb);
|
||||
try { cb(current); } catch (e) {}
|
||||
},
|
||||
onTheme: function (cb) {
|
||||
if (typeof cb !== "function") return;
|
||||
themeHandlers.push(cb);
|
||||
try { cb(theme.theme); } catch (e) {}
|
||||
}
|
||||
};
|
||||
|
||||
window.addEventListener("message", function (event) {
|
||||
if (!event.data) return;
|
||||
if (event.data.__orca === "theme") { applyTheme(event.data.theme); return; }
|
||||
if (event.data.__orca !== "config") return;
|
||||
current = event.data.config || {};
|
||||
if (event.data.context) context = event.data.context;
|
||||
handlers.forEach(function (handler) {
|
||||
try { handler(current); } catch (e) {}
|
||||
});
|
||||
});
|
||||
|
||||
applyTheme();
|
||||
})();
|
||||
<\/script>`;
|
||||
return bridge + html;
|
||||
}
|
||||
|
||||
// The host re-themes an open dialog in place (WebViewHostDialog::host_theme_apply_js), which a
|
||||
// sandboxed child frame never sees. Relay it so a custom UI follows a light/dark switch live.
|
||||
function OrcaWatchThemeForFrame(frameId) {
|
||||
const relay = () => {
|
||||
const frame = document.getElementById(frameId);
|
||||
if (!frame || frame.hidden || !frame.contentWindow)
|
||||
return;
|
||||
frame.contentWindow.postMessage({ __orca: "theme", theme: OrcaThemeSnapshot() }, "*");
|
||||
};
|
||||
new MutationObserver(relay).observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ["data-orca-theme"]
|
||||
});
|
||||
}
|
||||
+355
-145
@@ -3,18 +3,18 @@
|
||||
# dependencies = ["numpy"]
|
||||
#
|
||||
# [tool.orcaslicer.plugin]
|
||||
# name = "Orca Inspector Example"
|
||||
# name = "Orca Inspector"
|
||||
# description = "An interactive panel that browses the whole orca.host read-only API and demos every orca.host.ui facility."
|
||||
# author = "OrcaSlicer"
|
||||
# version = "0.0.1"
|
||||
# author = "SoftFever"
|
||||
# version = "0.0.3"
|
||||
# ///
|
||||
"""Orca Inspector — the worked example for `orca.host` and `orca.host.ui`.
|
||||
"""Orca Inspector — a guided tour of `orca.host` and `orca.host.ui`.
|
||||
|
||||
Run it from the Plugins dialog. It opens a NON-MODAL window (OrcaSlicer stays
|
||||
usable) with a sidebar of sections, each exercising one part of the API:
|
||||
|
||||
Overview plater state, scene statistics, current printer/process/filaments
|
||||
Presets every PresetCollection, preset flags, any preset's full config
|
||||
Presets every PresetCollection, filament slots, config viewer windows
|
||||
Config the complete merged full_config as a searchable table
|
||||
Model Model -> Object -> Volume/Instance tree with lazy mesh geometry
|
||||
Assembly objects grouped by module_name, per-instance assemble transforms
|
||||
@@ -32,9 +32,10 @@ and heavy mesh geometry (zero-copy numpy arrays, world-space math, the little
|
||||
point-cloud previews) only when you ask for it. "Refresh" drops the cache and
|
||||
refetches the visible section.
|
||||
|
||||
Style rules the page follows (see the plugin docs):
|
||||
- no hardcoded colors — only the host-injected --orca-* theme variables, so
|
||||
the panel matches light and dark mode automatically;
|
||||
Style rules the pages follow (see the plugin docs):
|
||||
- no hardcoded theme: BASE_CSS aliases the host-injected --orca-* variables
|
||||
(with fallbacks so the raw HTML previews in a plain browser) and styles the
|
||||
body and native controls from them — the host injects variables only;
|
||||
- self-contained HTML (inline CSS/JS, no external resources);
|
||||
- on_message runs on the UI thread, so long work (the progress demos) is
|
||||
offloaded to a thread and results are pushed back with win.post().
|
||||
@@ -45,6 +46,7 @@ transforms need bindings added in July 2026 — on older builds the panel shows
|
||||
what is missing instead of failing.
|
||||
"""
|
||||
|
||||
import json
|
||||
import re
|
||||
import threading
|
||||
import time
|
||||
@@ -125,6 +127,19 @@ def split_config_list(value):
|
||||
# --------------------------------------------------------------------------- #
|
||||
# section builders
|
||||
# --------------------------------------------------------------------------- #
|
||||
def filament_slots(bundle):
|
||||
"""One entry per filament slot: the mounted preset (current_filament_presets)
|
||||
plus its color and material from the merged config."""
|
||||
cfg = bundle.full_config_value
|
||||
colors = split_config_list(cfg("filament_colour"))
|
||||
types = split_config_list(cfg("filament_type"))
|
||||
return [{"slot": i + 1,
|
||||
"color": colors[i] if i < len(colors) else "",
|
||||
"material": types[i] if i < len(types) else "",
|
||||
"preset": preset_dict(preset) if preset else None}
|
||||
for i, preset in enumerate(bundle.current_filament_presets())]
|
||||
|
||||
|
||||
def build_overview():
|
||||
plater = orca.host.plater()
|
||||
model = orca.host.model()
|
||||
@@ -132,17 +147,7 @@ def build_overview():
|
||||
objects = model.objects()
|
||||
|
||||
cfg = bundle.full_config_value
|
||||
colors = split_config_list(cfg("filament_colour"))
|
||||
types = split_config_list(cfg("filament_type"))
|
||||
filaments = []
|
||||
for i, preset in enumerate(bundle.current_filament_presets()):
|
||||
filaments.append({
|
||||
"name": preset.name if preset else "<missing preset>",
|
||||
"color": colors[i] if i < len(colors) else "",
|
||||
"type": types[i] if i < len(types) else "",
|
||||
"is_system": bool(preset.is_system) if preset else False,
|
||||
"is_dirty": bool(preset.is_dirty) if preset else False,
|
||||
})
|
||||
filaments = filament_slots(bundle)
|
||||
|
||||
printer = bundle.current_printer_preset()
|
||||
process = bundle.current_process_preset()
|
||||
@@ -189,13 +194,12 @@ def build_overview():
|
||||
}
|
||||
|
||||
|
||||
# label -> how to reach the PresetCollection on the bundle
|
||||
# PresetCollection attribute -> label, in the order the Presets tab stacks its groups.
|
||||
# The bundle also exposes sla_prints/sla_materials, omitted as OrcaSlicer has no SLA.
|
||||
COLLECTIONS = [
|
||||
("prints", "Process"),
|
||||
("printers", "Printer"),
|
||||
("filaments", "Filament"),
|
||||
("sla_prints", "SLA print"),
|
||||
("sla_materials", "SLA material"),
|
||||
("prints", "Process"),
|
||||
]
|
||||
|
||||
|
||||
@@ -206,21 +210,25 @@ def build_presets():
|
||||
coll = getattr(bundle, attr)
|
||||
names = coll.preset_names()
|
||||
selected = coll.selected_preset()
|
||||
selected_name = coll.selected_preset_name()
|
||||
shown = names[:MAX_PRESET_NAMES]
|
||||
if selected_name and selected_name not in shown:
|
||||
shown.insert(0, selected_name) # the active preset stays pickable past the cap
|
||||
collections.append({
|
||||
"key": attr,
|
||||
"label": label,
|
||||
"size": coll.size(),
|
||||
"selected_name": coll.selected_preset_name(),
|
||||
"selected_name": selected_name,
|
||||
# selected = as saved on disk; edited = selected + unsaved modifications
|
||||
"selected": {"name": selected.name, "is_dirty": selected.is_dirty,
|
||||
"config_key_count": len(selected.config_keys())},
|
||||
"edited": preset_dict(coll.edited_preset()),
|
||||
"names": names[:MAX_PRESET_NAMES],
|
||||
"names": shown,
|
||||
"truncated": max(0, len(names) - MAX_PRESET_NAMES),
|
||||
})
|
||||
return {
|
||||
"collections": collections,
|
||||
"filament_names": bundle.current_filament_preset_names(),
|
||||
"filament_slots": filament_slots(bundle),
|
||||
}
|
||||
|
||||
|
||||
@@ -231,8 +239,7 @@ def build_preset_config(collection_key, name):
|
||||
preset = getattr(bundle, collection_key).find_preset(name)
|
||||
if preset is None:
|
||||
raise ValueError(f"preset {name!r} not found")
|
||||
return {"preset": preset_dict(preset),
|
||||
"rows": config_rows(preset.config_keys(), preset.config_value)}
|
||||
return config_rows(preset.config_keys(), preset.config_value)
|
||||
|
||||
|
||||
def build_config():
|
||||
@@ -467,102 +474,149 @@ SECTION_BUILDERS = {
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# the page — sidebar app, themed exclusively via the injected --orca-* vars
|
||||
# the pages — themed via BASE_CSS, which aliases the injected --orca-* vars
|
||||
# --------------------------------------------------------------------------- #
|
||||
# The host injects theme *variables* only (never element styles), so every page owns
|
||||
# its base look. The fallbacks keep the raw HTML previewable in a plain browser.
|
||||
BASE_CSS = r"""
|
||||
:root {
|
||||
--bg: var(--orca-bg, #ffffff);
|
||||
--fg: var(--orca-fg, #1f2429);
|
||||
--muted: var(--orca-muted, #6b7580);
|
||||
--border: var(--orca-border, #d9dee3);
|
||||
--accent: var(--orca-accent, #009688);
|
||||
--accent-fg: var(--orca-accent-fg, #ffffff);
|
||||
--ui: var(--orca-font, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif);
|
||||
--mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--bg: var(--orca-bg, #2b2d30);
|
||||
--fg: var(--orca-fg, #e4e6e8);
|
||||
--muted: var(--orca-muted, #9aa0a6);
|
||||
--border: var(--orca-border, #3d4043);
|
||||
}
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
body { margin:0; background:var(--bg); color:var(--fg); font:13px/1.45 var(--ui); }
|
||||
button { font:inherit; padding:4px 12px; cursor:pointer; border-radius:6px;
|
||||
background:var(--accent); color:var(--accent-fg); border:1px solid var(--accent); }
|
||||
button.secondary { background:transparent; color:var(--fg); border-color:var(--border); }
|
||||
button:disabled { opacity:.55; cursor:default; }
|
||||
input, select { font:inherit; color:var(--fg); background:var(--bg);
|
||||
border:1px solid var(--border); border-radius:6px; padding:4px 8px; }
|
||||
:focus-visible { outline:2px solid var(--accent); outline-offset:1px; }
|
||||
"""
|
||||
|
||||
# Identity hues for the preset collections, shared by the main page's group styling and
|
||||
# the config viewer window. Deliberately the same in light and dark mode: they say what a
|
||||
# card is, not what theme is on.
|
||||
HUES = {"printers": "#9a6ee8", "filaments": "#ee8f41", "prints": "#4e8df6"}
|
||||
HUE_CSS = "".join(f" .hue-{key} {{ --hue:{color}; }}\n" for key, color in HUES.items())
|
||||
|
||||
# The filterable key/value config table, shared by the Config tab and the viewer window.
|
||||
CFG_TABLE_CSS = r"""
|
||||
table.cfg { width:100%; border-collapse:collapse; font-size:12px; }
|
||||
table.cfg th { text-align:left; font-size:11px; letter-spacing:.07em;
|
||||
text-transform:uppercase; color:var(--muted); padding-bottom:4px; }
|
||||
table.cfg td:first-child { font-family:var(--mono); white-space:nowrap;
|
||||
vertical-align:top; }
|
||||
table.cfg td.val { font-family:var(--mono); white-space:pre-wrap; word-break:break-word; }
|
||||
td.val .more { color:var(--accent); cursor:pointer; }
|
||||
"""
|
||||
|
||||
PAGE = r"""<!DOCTYPE html>
|
||||
<html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<style>
|
||||
:root { --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
|
||||
* { box-sizing: border-box; }
|
||||
body { margin:0; height:100vh; display:flex; flex-direction:column; overflow:hidden; }
|
||||
<style>""" + BASE_CSS + r"""
|
||||
body { height:100vh; display:flex; flex-direction:column; overflow:hidden; }
|
||||
|
||||
header { flex:none; display:flex; align-items:center; gap:10px;
|
||||
padding:10px 16px; border-bottom:1px solid var(--orca-border); }
|
||||
padding:10px 16px; border-bottom:1px solid var(--border); }
|
||||
header h1 { font-size:15px; margin:0; }
|
||||
#stamp { flex:1; color:var(--orca-muted); font-size:12px; }
|
||||
button.secondary { background:transparent; color:var(--orca-fg);
|
||||
border-color:var(--orca-border); }
|
||||
#stamp { flex:1; color:var(--muted); font-size:12px; }
|
||||
button.small { padding:2px 10px; font-size:12px; }
|
||||
|
||||
main { flex:1; display:flex; min-height:0; }
|
||||
nav { flex:none; width:150px; padding:8px 0; overflow-y:auto;
|
||||
border-right:1px solid var(--orca-border); }
|
||||
border-right:1px solid var(--border); }
|
||||
nav .item { padding:8px 14px; cursor:pointer; user-select:none;
|
||||
color:var(--orca-muted); border-left:3px solid transparent; }
|
||||
nav .item:hover { color:var(--orca-fg); }
|
||||
nav .item.active { color:var(--orca-fg); font-weight:600;
|
||||
border-left-color:var(--orca-accent); }
|
||||
color:var(--muted); border-left:3px solid transparent; }
|
||||
nav .item:hover { color:var(--fg); }
|
||||
nav .item.active { color:var(--fg); font-weight:600;
|
||||
border-left-color:var(--accent); }
|
||||
nav .glyph { display:inline-block; width:1.5em; }
|
||||
#content { flex:1; overflow:auto; padding:14px 16px 28px; }
|
||||
|
||||
.tiles { display:grid; grid-template-columns:repeat(auto-fill,minmax(108px,1fr));
|
||||
gap:10px; margin-bottom:12px; }
|
||||
.tile { border:1px solid var(--orca-border); border-radius:8px; padding:10px 12px; }
|
||||
.tile { border:1px solid var(--border); border-radius:8px; padding:10px 12px; }
|
||||
.tile .v { font-size:20px; font-weight:600; font-variant-numeric:tabular-nums; }
|
||||
.tile .l { font-size:11px; color:var(--orca-muted); margin-top:2px; }
|
||||
.tile .l { font-size:11px; color:var(--muted); margin-top:2px; }
|
||||
|
||||
.cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(260px,1fr)); gap:12px; }
|
||||
.card { border:1px solid var(--orca-border); border-radius:8px;
|
||||
.card { border:1px solid var(--border); border-radius:8px;
|
||||
padding:12px 14px; min-width:0; }
|
||||
.card h3 { margin:0 0 8px; font-size:11px; letter-spacing:.07em;
|
||||
text-transform:uppercase; color:var(--orca-muted); }
|
||||
text-transform:uppercase; color:var(--muted); }
|
||||
.card.wide { grid-column:1 / -1; }
|
||||
""" + HUE_CSS + r""" .card.hued { border-top:3px solid var(--hue); }
|
||||
.dot { display:inline-block; width:9px; height:9px; border-radius:50%;
|
||||
background:var(--hue); margin-right:6px; }
|
||||
.pgroup { margin-bottom:18px; }
|
||||
.pgroup-head { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:8px; }
|
||||
.pgroup-head h2 { margin:0; font-size:12px; letter-spacing:.07em; text-transform:uppercase; }
|
||||
.pgroup-head select { flex:0 1 260px; min-width:120px; }
|
||||
.spacer { flex:1; }
|
||||
|
||||
.kv { display:grid; grid-template-columns:minmax(110px,max-content) 1fr;
|
||||
gap:3px 14px; font-size:12px; }
|
||||
.kv .k { color:var(--orca-muted); }
|
||||
.kv .k { color:var(--muted); }
|
||||
.kv .v { font-family:var(--mono); word-break:break-word; }
|
||||
|
||||
.badge { display:inline-block; border:1px solid var(--orca-border);
|
||||
color:var(--orca-muted); border-radius:999px; padding:1px 8px;
|
||||
.badge { display:inline-block; border:1px solid var(--border);
|
||||
color:var(--muted); border-radius:999px; padding:1px 8px;
|
||||
font-size:11px; margin:1px 3px 1px 0; white-space:nowrap; }
|
||||
.badge.on { background:var(--orca-accent); border-color:var(--orca-accent);
|
||||
color:var(--orca-accent-fg); }
|
||||
.badge.on { background:var(--accent); border-color:var(--accent);
|
||||
color:var(--accent-fg); }
|
||||
.swatch { display:inline-block; width:12px; height:12px; border-radius:3px;
|
||||
border:1px solid var(--orca-border); vertical-align:-2px; margin-right:5px; }
|
||||
border:1px solid var(--border); vertical-align:-2px; margin-right:5px; }
|
||||
|
||||
.toolbar { display:flex; gap:8px; align-items:center; margin-bottom:10px; }
|
||||
.toolbar input { flex:1; max-width:340px; }
|
||||
.count { color:var(--orca-muted); font-size:12px; }
|
||||
|
||||
table.cfg { width:100%; border-collapse:collapse; font-size:12px; }
|
||||
table.cfg td:first-child { font-family:var(--mono); white-space:nowrap;
|
||||
vertical-align:top; }
|
||||
table.cfg td.val { font-family:var(--mono); white-space:pre-wrap; word-break:break-word; }
|
||||
td.val .more { color:var(--orca-accent); cursor:pointer; }
|
||||
|
||||
.count { color:var(--muted); font-size:12px; }
|
||||
""" + CFG_TABLE_CSS + r"""
|
||||
.node { margin:1px 0; }
|
||||
.nhead { display:flex; align-items:center; gap:7px; padding:4px 8px;
|
||||
border-radius:6px; cursor:pointer; user-select:none; flex-wrap:wrap; }
|
||||
.nhead:hover { background:var(--orca-border); }
|
||||
.twist { width:1em; flex:none; color:var(--orca-muted); font-size:10px; }
|
||||
.nhead:hover { background:var(--border); }
|
||||
.twist { width:1em; flex:none; color:var(--muted); font-size:10px; }
|
||||
.nname { font-weight:600; }
|
||||
.nbody { display:none; margin-left:14px; padding:4px 0 4px 12px;
|
||||
border-left:1px dotted var(--orca-border); }
|
||||
border-left:1px dotted var(--border); }
|
||||
.node.open > .nhead .twist { transform:rotate(90deg); }
|
||||
.node.open > .nbody { display:block; }
|
||||
.subhead { margin:8px 0 4px; font-size:11px; letter-spacing:.07em;
|
||||
text-transform:uppercase; color:var(--orca-muted); }
|
||||
text-transform:uppercase; color:var(--muted); }
|
||||
|
||||
.banner { border:1px solid var(--orca-border); border-left:3px solid var(--orca-accent);
|
||||
.banner { border:1px solid var(--border); border-left:3px solid var(--accent);
|
||||
border-radius:6px; padding:9px 12px; margin-bottom:12px; font-size:12px; }
|
||||
.muted { color:var(--orca-muted); }
|
||||
.muted { color:var(--muted); }
|
||||
.mono { font-family:var(--mono); }
|
||||
|
||||
canvas.preview { width:100%; height:160px; border:1px solid var(--orca-border);
|
||||
canvas.preview { width:100%; height:160px; border:1px solid var(--border);
|
||||
border-radius:6px; }
|
||||
.previews { display:grid; grid-template-columns:1fr 1fr; gap:10px; margin-top:8px; }
|
||||
.previews .cap { font-size:11px; color:var(--orca-muted); text-align:center; margin-top:2px; }
|
||||
.previews .cap { font-size:11px; color:var(--muted); text-align:center; margin-top:2px; }
|
||||
|
||||
.log { font-family:var(--mono); font-size:12px; border:1px solid var(--orca-border);
|
||||
.log { font-family:var(--mono); font-size:12px; border:1px solid var(--border);
|
||||
border-radius:6px; padding:8px 10px; max-height:190px; overflow:auto; }
|
||||
.log div { padding:1px 0; }
|
||||
fieldset { border:1px solid var(--orca-border); border-radius:6px; margin:0 0 10px; }
|
||||
legend { color:var(--orca-muted); font-size:11px; padding:0 6px; }
|
||||
fieldset { border:1px solid var(--border); border-radius:6px; margin:0 0 10px; }
|
||||
legend { color:var(--muted); font-size:11px; padding:0 6px; }
|
||||
.frow { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin:6px 0; }
|
||||
label { font-size:12px; color:var(--orca-muted); }
|
||||
label { font-size:12px; color:var(--muted); }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@@ -588,7 +642,7 @@ const SECTIONS = [
|
||||
['assembly', '⬡', 'Assembly'],
|
||||
['uikit', '▣', 'UI Toolkit'],
|
||||
];
|
||||
const S = { current:'overview', cache:{}, busy:{}, colors:[], uiLog:[] };
|
||||
const S = { current:'overview', cache:{}, busy:{}, colors:[], uiLog:[], gen:0 };
|
||||
|
||||
const $ = id => document.getElementById(id);
|
||||
const esc = s => String(s == null ? '' : s)
|
||||
@@ -598,6 +652,9 @@ const deg = r => num(r * 180 / Math.PI, 1) + '°';
|
||||
const vec3 = (v, d=2) => v ? '(' + v.map(c => num(c, d)).join(', ') + ')' : '—';
|
||||
const yn = b => b ? 'yes' : 'no';
|
||||
const badge = (label, on) => '<span class="badge' + (on ? ' on' : '') + '">' + esc(label) + '</span>';
|
||||
// Colors land in a style attribute, so only literal hex colors pass through.
|
||||
const swatch = c => /^#[0-9a-f]{3,8}$/i.test(c || '')
|
||||
? '<span class="swatch" style="background:' + c + '"></span>' : '';
|
||||
const kv = rows => '<div class="kv">' + rows.map(([k, v]) =>
|
||||
'<div class="k">' + esc(k) + '</div><div class="v">' + v + '</div>').join('') + '</div>';
|
||||
const bboxRows = (label, bb) => bb ? [
|
||||
@@ -608,7 +665,8 @@ const bboxRows = (label, bb) => bb ? [
|
||||
/* ------------------------------------------------------- nav + fetching */
|
||||
function buildNav() {
|
||||
$('nav').innerHTML = SECTIONS.map(([key, glyph, label]) =>
|
||||
'<div class="item" id="nav-' + key + '" onclick="show(\'' + key + '\')">' +
|
||||
'<div class="item" id="nav-' + key + '" role="button" tabindex="0" ' +
|
||||
'onclick="show(\'' + key + '\')">' +
|
||||
'<span class="glyph">' + glyph + '</span>' + label + '</div>').join('');
|
||||
}
|
||||
function show(key) {
|
||||
@@ -622,9 +680,10 @@ function show(key) {
|
||||
function fetchSection(key) {
|
||||
S.busy[key] = true;
|
||||
$('content').innerHTML = '<p class="muted">Loading ' + esc(key) + '…</p>';
|
||||
orca.postMessage({ command:'fetch', section:key });
|
||||
orca.postMessage({ command:'fetch', section:key, gen:S.gen });
|
||||
}
|
||||
function refresh() {
|
||||
S.gen++; // replies to fetches from before this point are dropped
|
||||
S.cache = {};
|
||||
S.busy = {};
|
||||
show(S.current);
|
||||
@@ -660,13 +719,12 @@ function renderOverview(d) {
|
||||
[t.config_keys, 'config keys'],
|
||||
].map(([v, l]) => '<div class="tile"><div class="v">' + v + '</div><div class="l">' + l + '</div></div>').join('');
|
||||
|
||||
const filaments = d.setup.filaments.map((f, i) =>
|
||||
'<div style="margin:3px 0">' +
|
||||
(f.color ? '<span class="swatch" style="background:' + esc(f.color) + '"></span>' : '') +
|
||||
'<b>' + (i + 1) + '</b> ' + esc(f.name) +
|
||||
(f.type ? ' <span class="muted">' + esc(f.type) + '</span>' : '') +
|
||||
badge(f.is_system ? 'system' : 'user', f.is_system) +
|
||||
(f.is_dirty ? badge('modified', true) : '') +
|
||||
const filaments = d.setup.filaments.map(f =>
|
||||
'<div style="margin:3px 0">' + swatch(f.color) +
|
||||
'<b>' + f.slot + '</b> ' + esc(f.preset ? f.preset.name : '<missing preset>') +
|
||||
(f.material ? ' <span class="muted">' + esc(f.material) + '</span>' : '') +
|
||||
(f.preset ? badge(f.preset.is_system ? 'system' : 'user', f.preset.is_system) +
|
||||
(f.preset.is_dirty ? badge('modified', true) : '') : '') +
|
||||
'</div>').join('') || '<span class="muted">none</span>';
|
||||
|
||||
return '<div class="tiles">' + tiles + '</div><div class="cards">' +
|
||||
@@ -709,35 +767,65 @@ function presetBadges(p) {
|
||||
(p.is_visible ? '' : badge('hidden', false));
|
||||
}
|
||||
function renderPresets(d) {
|
||||
return '<div class="banner">Each card is one <span class="mono">host.PresetCollection</span>. ' +
|
||||
'“Edited” is the selected preset plus any unsaved changes. Pick any preset ' +
|
||||
'and load its complete config via <span class="mono">find_preset().config_value()</span>.</div>' +
|
||||
'<div class="cards">' + d.collections.map(c => {
|
||||
const p = c.edited;
|
||||
const options = c.names.map(n => // explicit value= so odd whitespace in names survives
|
||||
'<option value="' + esc(n) + '"' + (n === c.selected_name ? ' selected' : '') + '>' +
|
||||
const detailCard = g => {
|
||||
const p = g.edited;
|
||||
return '<div class="cards"><div class="card hued">' +
|
||||
'<div style="margin-bottom:6px"><b>' + esc(p.name) + '</b> ' + presetBadges(p) + '</div>' +
|
||||
kv([['label()', esc(p.label)], ['alias', esc(p.alias) || '—'],
|
||||
['type', esc(p.type)], ['bundle', esc(p.bundle_id) || '—'],
|
||||
['edited_preset()', p.config_key_count + ' keys' +
|
||||
(p.is_dirty ? ' · has unsaved changes' : ' · same as saved')],
|
||||
['selected_preset()', esc(g.selected.name) + ' · ' + g.selected.config_key_count + ' keys'],
|
||||
['file', '<span class="muted">' + esc(p.file) + '</span>']]) +
|
||||
'</div></div>';
|
||||
};
|
||||
const slotCard = (s, g) => {
|
||||
const p = s.preset;
|
||||
if (!p) return '<div class="card hued"><h3>Slot ' + s.slot + '</h3>' +
|
||||
'<p class="muted">no preset mounted</p></div>';
|
||||
return '<div class="card hued"><h3>Slot ' + s.slot + '</h3>' +
|
||||
'<div style="margin-bottom:6px">' + swatch(s.color) + '<b>' + esc(p.name) + '</b> ' +
|
||||
badge(p.is_system ? 'system' : 'user', p.is_system) +
|
||||
(p.is_dirty ? badge('modified', true) : '') +
|
||||
(p.name === g.selected_name ? badge('editing', true) : '') + '</div>' +
|
||||
kv([['material', esc(s.material) || '—'],
|
||||
['alias', esc(p.alias) || '—'],
|
||||
['config keys', p.config_key_count],
|
||||
['file', '<span class="muted">' + esc(p.file) + '</span>']]) +
|
||||
'<div class="frow" style="margin-top:8px"><button class="small secondary" ' +
|
||||
'data-act="pcfg" data-coll="filaments" data-name="' + esc(p.name) + '">View config</button></div>' +
|
||||
'</div>';
|
||||
};
|
||||
return '<div class="banner">Each group is one <span class="mono">host.PresetCollection</span>; ' +
|
||||
'the Filament group shows every slot from <span class="mono">current_filament_presets()</span>, ' +
|
||||
'and “editing” marks the preset open in its settings tab. Pick any preset in a group ' +
|
||||
'header — “View config” opens its complete config (via ' +
|
||||
'<span class="mono">find_preset().config_value()</span>) in its own window.</div>' +
|
||||
d.collections.map(g => {
|
||||
const options = g.names.map(n => // explicit value= so odd whitespace in names survives
|
||||
'<option value="' + esc(n) + '"' + (n === g.selected_name ? ' selected' : '') + '>' +
|
||||
esc(n) + '</option>').join('');
|
||||
return '<div class="card"><h3>' + esc(c.label) + ' · ' + c.size + ' presets</h3>' +
|
||||
'<div style="margin-bottom:6px"><b>' + esc(p.name) + '</b> ' + presetBadges(p) + '</div>' +
|
||||
kv([['label()', esc(p.label)], ['alias', esc(p.alias) || '—'],
|
||||
['type', esc(p.type)], ['bundle', esc(p.bundle_id) || '—'],
|
||||
['edited_preset()', p.config_key_count + ' keys' +
|
||||
(p.is_dirty ? ' · has unsaved changes' : ' · same as saved')],
|
||||
['selected_preset()', esc(c.selected.name) + ' · ' + c.selected.config_key_count + ' keys'],
|
||||
['file', '<span class="muted">' + esc(p.file) + '</span>']]) +
|
||||
'<div class="frow" style="margin-top:8px">' +
|
||||
'<select id="sel-' + c.key + '" style="flex:1;min-width:0">' + options + '</select>' +
|
||||
'<button class="small" data-act="pcfg" data-coll="' + c.key + '">View config</button>' +
|
||||
'</div>' +
|
||||
(c.truncated ? '<p class="muted">list capped, ' + c.truncated + ' more not shown</p>' : '') +
|
||||
'<div id="pcfg-' + c.key + '"></div></div>';
|
||||
}).join('') + '</div>';
|
||||
const cards = g.key === 'filaments'
|
||||
? '<div class="cards">' + (d.filament_slots.map(s => slotCard(s, g)).join('') ||
|
||||
'<p class="muted">no filament slots</p>') + '</div>'
|
||||
: detailCard(g);
|
||||
return '<div class="pgroup hue-' + g.key + '">' +
|
||||
'<div class="pgroup-head"><span class="dot"></span><h2>' + esc(g.label) + '</h2>' +
|
||||
'<span class="count">' + g.size + ' presets</span><span class="spacer"></span>' +
|
||||
'<select id="sel-' + g.key + '">' + options + '</select>' +
|
||||
'<button class="small" data-act="pcfg" data-coll="' + g.key + '">View config</button></div>' +
|
||||
cards +
|
||||
(g.truncated ? '<p class="muted">select capped, ' + g.truncated + ' more not listed</p>' : '') +
|
||||
// the config itself opens in a viewer window; this slot only shows failures
|
||||
'<div id="pcfg-' + g.key + '"></div></div>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function configTable(rows, id) {
|
||||
const body = rows.map(r => {
|
||||
const long = r.v.length > 160;
|
||||
const shown = long ? esc(r.v.slice(0, 160)) + '<span class="more" data-act="expand"> … show all</span>'
|
||||
const shown = long ? esc(r.v.slice(0, 160)) +
|
||||
'<span class="more" data-act="expand" role="button" tabindex="0"> … show all</span>'
|
||||
: esc(r.v);
|
||||
return '<tr data-k="' + esc(r.k.toLowerCase()) + '"><td>' + esc(r.k) + '</td>' +
|
||||
'<td class="val" data-full="' + esc(r.v) + '">' + shown + '</td></tr>';
|
||||
@@ -746,37 +834,36 @@ function configTable(rows, id) {
|
||||
}
|
||||
function renderConfig(d) {
|
||||
return '<div class="toolbar"><input id="cfg-search" placeholder="Filter ' + d.count +
|
||||
' keys…" oninput="filterConfig(this.value)">' +
|
||||
' keys…" oninput="filterTable(\'cfg-table\', this.value, \'cfg-count\')">' +
|
||||
'<span class="count" id="cfg-count">' + d.count + ' keys</span></div>' +
|
||||
'<div class="banner">The merged result of printer + process + filament presets — ' +
|
||||
'exactly what <span class="mono">preset_bundle().full_config_value(key)</span> returns for ' +
|
||||
'every key in <span class="mono">full_config_keys()</span>.</div>' +
|
||||
configTable(d.rows, 'cfg-table');
|
||||
}
|
||||
function filterConfig(q) {
|
||||
function filterTable(tableId, q, countId) {
|
||||
q = q.trim().toLowerCase();
|
||||
let visible = 0;
|
||||
document.querySelectorAll('#cfg-table tr[data-k]').forEach(tr => {
|
||||
document.querySelectorAll('#' + tableId + ' tr[data-k]').forEach(tr => {
|
||||
const hit = !q || tr.dataset.k.includes(q) ||
|
||||
tr.querySelector('.val').dataset.full.toLowerCase().includes(q);
|
||||
tr.style.display = hit ? '' : 'none';
|
||||
if (hit) visible++;
|
||||
});
|
||||
$('cfg-count').textContent = visible + ' keys';
|
||||
if (countId) $(countId).textContent = visible + ' keys';
|
||||
}
|
||||
|
||||
function extruderChip(id) {
|
||||
if (id == null || id < 1) return '<span class="badge">extruder —</span>';
|
||||
const color = S.colors[id - 1];
|
||||
return '<span class="badge">' + (color ? '<span class="swatch" style="background:' +
|
||||
esc(color) + '"></span>' : '') + 'extruder ' + id + '</span>';
|
||||
return '<span class="badge">' + swatch(S.colors[id - 1]) + 'extruder ' + id + '</span>';
|
||||
}
|
||||
const VOL_GLYPH = { ModelPart:'◆', NegativeVolume:'◇', ParameterModifier:'▨',
|
||||
SupportEnforcer:'▲', SupportBlocker:'▽' };
|
||||
|
||||
function node(head, body, open) {
|
||||
return '<div class="node' + (open ? ' open' : '') + '">' +
|
||||
'<div class="nhead" data-act="toggle"><span class="twist">▶</span>' + head + '</div>' +
|
||||
'<div class="nhead" data-act="toggle" role="button" tabindex="0" aria-expanded="' +
|
||||
!!open + '"><span class="twist">▶</span>' + head + '</div>' +
|
||||
'<div class="nbody">' + body + '</div></div>';
|
||||
}
|
||||
function paintedBadges(p) {
|
||||
@@ -969,7 +1056,7 @@ function drawPoints(canvas, pts, ax, ay) {
|
||||
PREVIEWS[canvas.id] = { pts, ax, ay };
|
||||
const scaleDpr = window.devicePixelRatio || 1;
|
||||
const w = canvas.clientWidth * scaleDpr, h = canvas.clientHeight * scaleDpr;
|
||||
if (!w || !h) return; // inside a collapsed node; repainted on toggle
|
||||
if (!w || !h) { delete canvas.dataset.painted; return; } // collapsed; repainted on toggle
|
||||
canvas.dataset.painted = '1';
|
||||
canvas.width = w; canvas.height = h;
|
||||
const ctx = canvas.getContext('2d');
|
||||
@@ -983,7 +1070,7 @@ function drawPoints(canvas, pts, ax, ay) {
|
||||
(h - 2 * pad) / Math.max(maxY - minY, 1e-6));
|
||||
const ox = (w - (maxX - minX) * scale) / 2, oy = (h - (maxY - minY) * scale) / 2;
|
||||
const style = getComputedStyle(document.body);
|
||||
ctx.strokeStyle = style.getPropertyValue('--orca-accent');
|
||||
ctx.strokeStyle = style.getPropertyValue('--accent');
|
||||
ctx.strokeRect(ox, oy, (maxX - minX) * scale, (maxY - minY) * scale);
|
||||
ctx.fillStyle = style.color;
|
||||
ctx.globalAlpha = 0.55;
|
||||
@@ -992,6 +1079,21 @@ function drawPoints(canvas, pts, ax, ay) {
|
||||
ctx.fillRect(ox + (p[ax] - minX) * scale - r / 2,
|
||||
h - oy - (p[ay] - minY) * scale - r / 2, r, r);
|
||||
}
|
||||
// A live theme switch re-stamps data-orca-theme and a resize leaves the bitmap at its
|
||||
// old size — both need every known preview repainted.
|
||||
function repaintPreviews() {
|
||||
document.querySelectorAll('canvas.preview').forEach(c => {
|
||||
const p = PREVIEWS[c.id];
|
||||
if (p) drawPoints(c, p.pts, p.ax, p.ay);
|
||||
});
|
||||
}
|
||||
new MutationObserver(repaintPreviews)
|
||||
.observe(document.documentElement, { attributes:true, attributeFilter:['data-orca-theme'] });
|
||||
let resizeTimer;
|
||||
window.addEventListener('resize', () => {
|
||||
clearTimeout(resizeTimer);
|
||||
resizeTimer = setTimeout(repaintPreviews, 150);
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------ UI toolkit */
|
||||
function renderUikit() {
|
||||
@@ -1052,6 +1154,7 @@ $('content').addEventListener('click', e => {
|
||||
if (act === 'toggle') {
|
||||
const node = t.parentElement;
|
||||
node.classList.toggle('open');
|
||||
t.setAttribute('aria-expanded', node.classList.contains('open'));
|
||||
// Repaint any preview whose canvas was hidden (zero-size) when its data arrived.
|
||||
node.querySelectorAll('canvas.preview').forEach(c => {
|
||||
const p = PREVIEWS[c.id];
|
||||
@@ -1062,9 +1165,10 @@ $('content').addEventListener('click', e => {
|
||||
t.textContent = 'Loading…';
|
||||
orca.postMessage({ command:'mesh', object:+t.dataset.o, volume:+t.dataset.v });
|
||||
} else if (act === 'pcfg') {
|
||||
const coll = t.dataset.coll;
|
||||
const coll = t.dataset.coll; // slot buttons carry their preset in data-name
|
||||
orca.postMessage({ command:'preset_config', collection:coll,
|
||||
name:$('sel-' + coll).value });
|
||||
name:t.dataset.name !== undefined ? t.dataset.name
|
||||
: $('sel-' + coll).value });
|
||||
} else if (act === 'expand') {
|
||||
const td = t.closest('td');
|
||||
td.textContent = td.dataset.full;
|
||||
@@ -1072,11 +1176,22 @@ $('content').addEventListener('click', e => {
|
||||
uiAction(t.dataset.ui);
|
||||
}
|
||||
});
|
||||
// Keyboard parity for the click-only elements (nav items, tree toggles, "show all").
|
||||
// Real form controls are skipped so they keep their native keys.
|
||||
document.addEventListener('keydown', e => {
|
||||
if (e.key !== 'Enter' && e.key !== ' ') return;
|
||||
if (/^(BUTTON|INPUT|SELECT|TEXTAREA)$/.test(e.target.tagName)) return;
|
||||
const t = e.target.closest('.item, [data-act]');
|
||||
if (!t) return;
|
||||
e.preventDefault();
|
||||
t.click();
|
||||
});
|
||||
|
||||
/* ------------------------------------------------------------- messages */
|
||||
orca.onMessage(msg => {
|
||||
if (!msg || !msg.command) return;
|
||||
if (msg.command === 'section') {
|
||||
if (msg.gen !== S.gen) return; // raced a Refresh; the refetch is in flight
|
||||
S.cache[msg.section] = msg;
|
||||
S.busy[msg.section] = false;
|
||||
stamp();
|
||||
@@ -1085,14 +1200,15 @@ orca.onMessage(msg => {
|
||||
const container = $('mesh-' + msg.object + '-' + msg.volume);
|
||||
if (!container) return;
|
||||
if (msg.ok) renderMeshDetail(container, msg.data);
|
||||
else container.innerHTML = '<span class="muted">⚠ ' + esc(msg.error) + '</span>';
|
||||
else container.innerHTML =
|
||||
'<button class="small secondary" data-act="mesh" data-o="' + msg.object +
|
||||
'" data-v="' + msg.volume + '">Retry</button> <span class="muted">⚠ ' +
|
||||
esc(msg.error) + '</span>';
|
||||
} else if (msg.command === 'preset_config') {
|
||||
// Success opened a viewer window; this slot only shows (or clears) failures.
|
||||
const container = $('pcfg-' + msg.collection);
|
||||
if (!container) return;
|
||||
container.innerHTML = msg.ok
|
||||
? '<div class="subhead">' + esc(msg.name) + ' · ' + msg.data.rows.length +
|
||||
' keys</div>' + configTable(msg.data.rows, 'pcfg-table-' + msg.collection)
|
||||
: '<span class="muted">⚠ ' + esc(msg.error) + '</span>';
|
||||
container.innerHTML = msg.ok ? '' : '<p class="muted">⚠ ' + esc(msg.error) + '</p>';
|
||||
} else if (msg.command === 'ui_result') {
|
||||
addLog(msg.ok ? '← ' + msg.action + ': ' + msg.result
|
||||
: '← ' + msg.action + ' failed: ' + msg.error);
|
||||
@@ -1110,28 +1226,33 @@ show('overview');
|
||||
# The modal page demoed from the UI Toolkit tab: create_window(style=WINDOW_MODAL)
|
||||
# keeps the handle alive for callbacks; orca.submit(payload) invokes on_submit.
|
||||
MODAL_PAGE = r"""<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8"></head>
|
||||
<body style="padding:18px">
|
||||
<h3 style="margin-top:0">Modal dialog</h3>
|
||||
<html lang="en"><head><meta charset="utf-8"><style>""" + BASE_CSS + r"""
|
||||
body { padding:18px; }
|
||||
h3 { margin-top:0; }
|
||||
input { width:100%; }
|
||||
</style></head>
|
||||
<body>
|
||||
<h3>Modal dialog</h3>
|
||||
<p>create_window(style=WINDOW_MODAL) keeps this page interactive until it submits or closes.</p>
|
||||
<p><input id="note" style="width:100%" value="hello from the modal"></p>
|
||||
<p><input id="note" value="hello from the modal"></p>
|
||||
<p style="text-align:right">
|
||||
<button style="background:transparent;color:var(--orca-fg);border-color:var(--orca-border)"
|
||||
onclick="orca.postMessage({live: document.getElementById('note').value})">Post while open</button>
|
||||
<button style="background:transparent;color:var(--orca-fg);border-color:var(--orca-border)"
|
||||
onclick="orca.close()">Cancel</button>
|
||||
<button class="secondary" onclick="orca.postMessage({live: document.getElementById('note').value})">Post while open</button>
|
||||
<button class="secondary" onclick="orca.close()">Cancel</button>
|
||||
<button onclick="orca.submit({note: document.getElementById('note').value})">Submit</button>
|
||||
</p>
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
CHILD_PAGE = r"""<!DOCTYPE html>
|
||||
<html><head><meta charset="utf-8"></head>
|
||||
<body style="padding:18px">
|
||||
<h3 style="margin-top:0">Child window</h3>
|
||||
<html lang="en"><head><meta charset="utf-8"><style>""" + BASE_CSS + r"""
|
||||
body { padding:18px; }
|
||||
h3 { margin-top:0; }
|
||||
</style></head>
|
||||
<body>
|
||||
<h3>Child window</h3>
|
||||
<p>Same create_window() API — one plugin, several windows.</p>
|
||||
<p><button onclick="orca.postMessage({command:'ping'})">Ping the plugin</button></p>
|
||||
<div id="log" style="color:var(--orca-muted)"></div>
|
||||
<div id="log" style="color:var(--muted)"></div>
|
||||
<script>
|
||||
var n = 0;
|
||||
orca.onMessage(function (msg) {
|
||||
@@ -1142,6 +1263,75 @@ CHILD_PAGE = r"""<!DOCTYPE html>
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
# The per-preset config viewer, opened by "View config" on the Presets tab. Its rows are
|
||||
# baked in as JSON at build time, so the window needs no bridge traffic and stays usable
|
||||
# side by side with the panel until closed.
|
||||
CONFIG_PAGE = r"""<!DOCTYPE html>
|
||||
<html lang="en"><head><meta charset="utf-8"><style>""" + BASE_CSS + CFG_TABLE_CSS + r"""
|
||||
body { padding:12px 16px 20px; border-top:3px solid var(--hue, var(--accent)); }
|
||||
.toolbar { display:flex; gap:8px; align-items:center; flex-wrap:wrap; margin-bottom:10px; }
|
||||
.toolbar h3 { margin:0; font-size:13px; }
|
||||
.toolbar input { flex:1; min-width:140px; }
|
||||
.dot { display:inline-block; width:9px; height:9px; border-radius:50%; flex:none;
|
||||
background:var(--hue, var(--accent)); }
|
||||
.count { color:var(--muted); font-size:12px; white-space:nowrap; }
|
||||
</style></head>
|
||||
<body>
|
||||
<div class="toolbar"><span class="dot"></span><h3 id="name"></h3>
|
||||
<span class="count" id="count"></span>
|
||||
<input id="q" placeholder="Filter keys…">
|
||||
<button class="secondary" onclick="orca.close()">Close</button></div>
|
||||
<div id="table"></div>
|
||||
<script>
|
||||
'use strict';
|
||||
const DATA = __DATA__;
|
||||
const $ = id => document.getElementById(id);
|
||||
const esc = s => String(s == null ? '' : s)
|
||||
.replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||||
if (DATA.hue) document.body.style.setProperty('--hue', DATA.hue);
|
||||
$('name').textContent = DATA.name;
|
||||
$('table').innerHTML = '<table class="cfg" id="t"><tr><th>key</th><th>value</th></tr>' +
|
||||
DATA.rows.map(r => {
|
||||
const long = r.v.length > 160;
|
||||
const shown = long ? esc(r.v.slice(0, 160)) +
|
||||
'<span class="more" role="button" tabindex="0"> … show all</span>' : esc(r.v);
|
||||
return '<tr data-k="' + esc(r.k.toLowerCase()) + '"><td>' + esc(r.k) + '</td>' +
|
||||
'<td class="val" data-full="' + esc(r.v) + '">' + shown + '</td></tr>';
|
||||
}).join('') + '</table>';
|
||||
function filter(q) {
|
||||
q = q.trim().toLowerCase();
|
||||
let visible = 0;
|
||||
document.querySelectorAll('#t tr[data-k]').forEach(tr => {
|
||||
const hit = !q || tr.dataset.k.includes(q) ||
|
||||
tr.querySelector('.val').dataset.full.toLowerCase().includes(q);
|
||||
tr.style.display = hit ? '' : 'none';
|
||||
if (hit) visible++;
|
||||
});
|
||||
$('count').textContent = visible + ' keys';
|
||||
}
|
||||
$('q').addEventListener('input', e => filter(e.target.value));
|
||||
$('table').addEventListener('click', e => {
|
||||
const t = e.target.closest('.more');
|
||||
if (t) { const td = t.closest('td'); td.textContent = td.dataset.full; }
|
||||
});
|
||||
document.addEventListener('keydown', e => {
|
||||
if ((e.key === 'Enter' || e.key === ' ') && e.target.classList.contains('more')) {
|
||||
e.preventDefault();
|
||||
e.target.click();
|
||||
}
|
||||
});
|
||||
filter('');
|
||||
</script>
|
||||
</body></html>
|
||||
"""
|
||||
|
||||
|
||||
def config_page(collection, name, rows):
|
||||
"""CONFIG_PAGE with one preset's rows baked in. `</` is escaped so a config
|
||||
value containing e.g. `</script>` cannot break out of the script block."""
|
||||
payload = json.dumps({"name": name, "hue": HUES.get(collection, ""), "rows": rows})
|
||||
return CONFIG_PAGE.replace("__DATA__", payload.replace("</", "<\\/"))
|
||||
|
||||
|
||||
# --------------------------------------------------------------------------- #
|
||||
# the plugin
|
||||
@@ -1150,6 +1340,7 @@ class OrcaInspectorPanel(orca.script.ScriptPluginCapabilityBase):
|
||||
win = None
|
||||
child = None
|
||||
modal = None
|
||||
cfgwin = None
|
||||
|
||||
def get_name(self):
|
||||
return "Orca Inspector"
|
||||
@@ -1166,6 +1357,9 @@ class OrcaInspectorPanel(orca.script.ScriptPluginCapabilityBase):
|
||||
if self.modal is not None:
|
||||
self.modal.close()
|
||||
self.modal = None
|
||||
if self.cfgwin is not None:
|
||||
self.cfgwin.close()
|
||||
self.cfgwin = None
|
||||
# Non-modal: returns immediately. The window is host-owned and lives on
|
||||
# after execute() returns; on_message keeps firing when the page posts.
|
||||
self.win = orca.host.ui.create_window(
|
||||
@@ -1184,11 +1378,11 @@ class OrcaInspectorPanel(orca.script.ScriptPluginCapabilityBase):
|
||||
msg = msg or {}
|
||||
command = msg.get("command")
|
||||
if command == "fetch":
|
||||
self.send_section(msg.get("section", ""))
|
||||
self.send_section(msg.get("section", ""), msg.get("gen"))
|
||||
elif command == "mesh":
|
||||
self.send_mesh(int(msg.get("object", -1)), int(msg.get("volume", -1)))
|
||||
self.send_mesh(msg.get("object", -1), msg.get("volume", -1))
|
||||
elif command == "preset_config":
|
||||
self.send_preset_config(msg.get("collection", ""), msg.get("name", ""))
|
||||
self.open_preset_config(msg.get("collection", ""), msg.get("name", ""))
|
||||
elif command == "ui":
|
||||
self.run_ui_action(msg)
|
||||
|
||||
@@ -1196,11 +1390,15 @@ class OrcaInspectorPanel(orca.script.ScriptPluginCapabilityBase):
|
||||
if self.child is not None:
|
||||
self.child.close()
|
||||
self.child = None
|
||||
if self.cfgwin is not None:
|
||||
self.cfgwin.close()
|
||||
self.cfgwin = None
|
||||
print("Orca Inspector closed")
|
||||
|
||||
def send_section(self, section):
|
||||
def send_section(self, section, gen=None):
|
||||
builder = SECTION_BUILDERS.get(section)
|
||||
reply = {"command": "section", "section": section}
|
||||
# gen echoes the page's refresh counter so a reply that raced a Refresh is dropped there.
|
||||
reply = {"command": "section", "section": section, "gen": gen}
|
||||
if builder is None:
|
||||
self.win.post({**reply, "ok": False, "error": f"unknown section {section!r}"})
|
||||
return
|
||||
@@ -1213,15 +1411,23 @@ class OrcaInspectorPanel(orca.script.ScriptPluginCapabilityBase):
|
||||
reply = {"command": "mesh", "object": object_index, "volume": volume_index}
|
||||
try:
|
||||
self.win.post({**reply, "ok": True,
|
||||
"data": build_mesh(object_index, volume_index)})
|
||||
"data": build_mesh(int(object_index), int(volume_index))})
|
||||
except Exception as exc:
|
||||
self.win.post({**reply, "ok": False, "error": str(exc)})
|
||||
|
||||
def send_preset_config(self, collection, name):
|
||||
def open_preset_config(self, collection, name):
|
||||
# One viewer at a time: a new pick replaces the previous window. The main page
|
||||
# only hears back about failures.
|
||||
reply = {"command": "preset_config", "collection": collection, "name": name}
|
||||
try:
|
||||
self.win.post({**reply, "ok": True,
|
||||
"data": build_preset_config(collection, name)})
|
||||
rows = build_preset_config(collection, name)
|
||||
if self.cfgwin is not None:
|
||||
self.cfgwin.close()
|
||||
self.cfgwin = orca.host.ui.create_window(
|
||||
title=f"Orca Inspector — {name}",
|
||||
html=config_page(collection, name, rows),
|
||||
width=520, height=640)
|
||||
self.win.post({**reply, "ok": True})
|
||||
except Exception as exc:
|
||||
self.win.post({**reply, "ok": False, "error": str(exc)})
|
||||
|
||||
@@ -1267,15 +1473,19 @@ class OrcaInspectorPanel(orca.script.ScriptPluginCapabilityBase):
|
||||
if self.child is not None and self.child.is_open():
|
||||
report("child already open")
|
||||
else:
|
||||
# Not `reply`: the close can also come from "child_close" later, so the
|
||||
# on_close payload is labelled neutrally.
|
||||
self.child = orca.host.ui.create_window(
|
||||
title="Orca Inspector — child", html=CHILD_PAGE,
|
||||
width=380, height=240, on_message=self.on_child_message,
|
||||
on_close=lambda: self.win.post(
|
||||
{**reply, "ok": True, "result": "child window closed"}))
|
||||
{"command": "ui_result", "action": "child",
|
||||
"ok": True, "result": "child window closed"}))
|
||||
report("child opened")
|
||||
elif action == "child_close":
|
||||
if self.child is not None:
|
||||
self.child.close()
|
||||
report("close requested") # the actual close is logged by on_close
|
||||
else:
|
||||
report("no child window")
|
||||
elif action == "child_state":
|
||||
@@ -0,0 +1,618 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.12"
|
||||
#
|
||||
# [tool.orcaslicer.plugin]
|
||||
# name = "Twistify"
|
||||
# description = "Twists, tapers, and wobbles every layer's slice polygons as a function of Z (demo)."
|
||||
# author = "SoftFever"
|
||||
# version = "0.03"
|
||||
# type = "slicing-pipeline"
|
||||
# ///
|
||||
"""Twistify -- twist/taper/wobble any model at slice time.
|
||||
|
||||
At Step.posSlice, every layer's sliced surfaces are transformed by a similarity
|
||||
about the object's bounding-box center as a function of Z -- edited IN PLACE
|
||||
through the host geometry classes (ExPolygon.rotate/scale/translate). Each
|
||||
surface is rotated about the center, then (if tapering) translated to the
|
||||
origin, uniformly scaled, and translated back, so the taper stays centered on
|
||||
the object instead of drifting toward the coordinate origin. An optional X
|
||||
wobble is applied last. After the per-region edits, layer.make_slices()
|
||||
re-derives the layer's merged islands so overhang/bridge/skirt/support stay
|
||||
coherent. The split slice loop runs make_perimeters() right after the hook, so
|
||||
the transform cascades into perimeters, infill, and the final G-code -- the
|
||||
preview corkscrews and the print keeps correct walls/infill/flow.
|
||||
|
||||
Because we edit geometry in place, surface types are preserved automatically
|
||||
(no per-surface type carry needed), and no numpy is required --
|
||||
rotate/scale/translate are host methods. Parameters come from self.get_config()
|
||||
(see _params below); the host seeds them from get_default_config() the first
|
||||
time the plugin loads. The first object layer is untouched (z_rel = 0), so bed
|
||||
adhesion is unaffected.
|
||||
|
||||
The plugin also ships its own configuration UI (has_config_ui/get_config_ui):
|
||||
a self-contained page the Plugins dialog renders instead of the JSON editor,
|
||||
drawing the transform it is about to apply as an isometric stack of layer
|
||||
outlines. It reaches the host only through the injected window.orca bridge --
|
||||
getConfig/saveConfig/restoreDefaults/getContext/onConfig/onTheme -- and styles
|
||||
itself from the --orca-* theme variables the host hands the frame, so it
|
||||
follows OrcaSlicer's light/dark theme.
|
||||
"""
|
||||
import math
|
||||
import json
|
||||
import orca
|
||||
|
||||
_DEFAULTS = {
|
||||
"twist_deg_per_mm": 1.0,
|
||||
"taper_per_mm": 0.0,
|
||||
"wobble_ampl_mm": 0.0,
|
||||
"wobble_period_mm": 20.0,
|
||||
"min_scale": 0.05,
|
||||
}
|
||||
|
||||
|
||||
def _params(self):
|
||||
try:
|
||||
src = json.loads(self.get_config())
|
||||
except (AttributeError, TypeError, ValueError):
|
||||
src = {}
|
||||
out = {}
|
||||
for key, default in _DEFAULTS.items():
|
||||
try:
|
||||
out[key] = float(src[key])
|
||||
except (KeyError, TypeError, ValueError):
|
||||
out[key] = default
|
||||
return out
|
||||
|
||||
|
||||
def _is_identity(p):
|
||||
return p["twist_deg_per_mm"] == 0.0 and p["taper_per_mm"] == 0.0 and p["wobble_ampl_mm"] == 0.0
|
||||
|
||||
|
||||
def _layer_params(z_rel, mm_to_scaled, p):
|
||||
"""(angle_rad, scale, x_offset_scaled) for one layer. Exact identity at z_rel == 0."""
|
||||
theta = math.radians(p["twist_deg_per_mm"] * z_rel)
|
||||
s = max(p["min_scale"], 1.0 + p["taper_per_mm"] * z_rel)
|
||||
ox = 0.0
|
||||
if p["wobble_ampl_mm"] != 0.0 and p["wobble_period_mm"] > 0.0:
|
||||
ox = p["wobble_ampl_mm"] * math.sin(2.0 * math.pi * z_rel / p["wobble_period_mm"]) * mm_to_scaled
|
||||
return theta, s, ox
|
||||
|
||||
|
||||
# The configuration page. Self-contained on purpose: it runs in an iframe sandboxed into an opaque
|
||||
# origin, so it has only the window.orca bridge and the --orca-* theme variables the host injects --
|
||||
# no network, no same-origin access, no shared stylesheet. get_config_ui() substitutes _DEFAULTS for
|
||||
# __ORCA_DEFAULTS__, so Python owns the values and the page adds only presentation.
|
||||
_CONFIG_UI = """
|
||||
<style>
|
||||
:root {
|
||||
--ink: var(--orca-fg, #1f2429);
|
||||
--paper: var(--orca-bg, #ffffff);
|
||||
--rule: var(--orca-border, #d9dee3);
|
||||
--quiet: var(--orca-muted, #6b7580);
|
||||
--live: var(--orca-accent, #009688);
|
||||
--live-ink: var(--orca-accent-fg, #ffffff);
|
||||
--ui: var(--orca-font, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
|
||||
--data: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
|
||||
}
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--ink: var(--orca-fg, #e4e6e8);
|
||||
--paper: var(--orca-bg, #2b2d30);
|
||||
--rule: var(--orca-border, #3d4043);
|
||||
--quiet: var(--orca-muted, #9aa0a6);
|
||||
}
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html, body { height: 100%; }
|
||||
body {
|
||||
margin: 0;
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font: 13px/1.45 var(--ui);
|
||||
}
|
||||
.panel { display: flex; flex-direction: column; height: 100%; }
|
||||
|
||||
.head {
|
||||
display: flex; align-items: baseline; gap: 10px;
|
||||
padding: 12px 16px 10px;
|
||||
border-bottom: 1px solid var(--rule);
|
||||
}
|
||||
.mark {
|
||||
font: 10px/1 var(--data); letter-spacing: .14em; text-transform: uppercase;
|
||||
color: var(--live);
|
||||
}
|
||||
.head-note { font-size: 11px; color: var(--quiet); }
|
||||
|
||||
/* The frame is as narrow as ~400px in a resized dialog and as wide as ~600px; below the
|
||||
breakpoint the drawing moves under the controls rather than squeezing both. */
|
||||
.work {
|
||||
flex: 1; min-height: 0; overflow: auto;
|
||||
display: grid; grid-template-columns: minmax(0, 1fr) 180px; gap: 16px;
|
||||
align-content: start; padding: 14px 16px;
|
||||
}
|
||||
@media (max-width: 470px) {
|
||||
.work { grid-template-columns: minmax(0, 1fr); }
|
||||
.plot { max-width: 210px; }
|
||||
}
|
||||
|
||||
.rows { display: flex; flex-direction: column; gap: 12px; }
|
||||
.row { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; }
|
||||
.row-label {
|
||||
grid-column: 1;
|
||||
font: 10px/1 var(--data); letter-spacing: .12em; text-transform: uppercase;
|
||||
color: var(--quiet);
|
||||
}
|
||||
.row-figure { grid-column: 2; display: flex; align-items: baseline; gap: 4px; }
|
||||
.row-figure input {
|
||||
/* No spinners: the rail is the coarse control, this is the exact one, and the arrows would
|
||||
steal the width the value needs. */
|
||||
-webkit-appearance: textfield; appearance: textfield;
|
||||
width: 76px; padding: 3px 6px; text-align: right;
|
||||
font: 13px/1.2 var(--data); font-variant-numeric: tabular-nums;
|
||||
color: var(--ink); background: transparent;
|
||||
border: 1px solid transparent; border-radius: 3px;
|
||||
}
|
||||
.row-figure input::-webkit-outer-spin-button,
|
||||
.row-figure input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
|
||||
.row-figure input:hover { border-color: var(--rule); }
|
||||
.row-figure input:focus { outline: none; border-color: var(--live); }
|
||||
.unit { font: 10px/1 var(--data); color: var(--quiet); min-width: 26px; }
|
||||
|
||||
/* The rail carries a detent at the value that means "no deformation", so neutral is a position
|
||||
you can feel for rather than a number you have to read. */
|
||||
.rail { grid-column: 1 / -1; position: relative; height: 16px; }
|
||||
.rail[data-detent]::before {
|
||||
content: ""; position: absolute; left: var(--detent); top: 3px;
|
||||
width: 1px; height: 10px; background: var(--rule);
|
||||
}
|
||||
.rail input {
|
||||
-webkit-appearance: none; appearance: none;
|
||||
position: relative; width: 100%; height: 16px; margin: 0; background: transparent;
|
||||
}
|
||||
.rail input::-webkit-slider-runnable-track { height: 2px; background: var(--rule); border-radius: 1px; }
|
||||
.rail input::-webkit-slider-thumb {
|
||||
-webkit-appearance: none; width: 11px; height: 11px; margin-top: -4.5px;
|
||||
border: none; border-radius: 50%; background: var(--live); cursor: grab;
|
||||
}
|
||||
.rail input:focus { outline: none; }
|
||||
.rail input:focus-visible { outline: 2px solid var(--live); outline-offset: 1px; border-radius: 3px; }
|
||||
.rail input:disabled::-webkit-slider-thumb { background: var(--quiet); cursor: default; }
|
||||
|
||||
.readout {
|
||||
margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--rule);
|
||||
font-size: 11px; color: var(--quiet); min-height: 32px;
|
||||
}
|
||||
.readout b { color: var(--ink); font-weight: 600; font-family: var(--data); font-variant-numeric: tabular-nums; }
|
||||
|
||||
.plot { margin: 0; display: flex; flex-direction: column; gap: 6px; }
|
||||
.plot svg { width: 100%; height: auto; display: block; }
|
||||
.plot figcaption { font: 10px/1.4 var(--data); color: var(--quiet); }
|
||||
/* SVG colours live here rather than in stroke="" attributes: var() is not reliable in a
|
||||
presentation attribute, and this way the drawing re-themes with the rest of the page. */
|
||||
.ring, .helix, .datum { fill: none; }
|
||||
.ring { stroke: var(--live); stroke-width: 1; }
|
||||
.helix { stroke: var(--live); stroke-width: 1; stroke-opacity: .5; stroke-dasharray: 2 2; }
|
||||
.datum { stroke: var(--quiet); stroke-width: 1; stroke-opacity: .7; }
|
||||
.tick { stroke: var(--rule); stroke-width: 1; }
|
||||
.plot text { fill: var(--quiet); font: 8px var(--data); }
|
||||
|
||||
.foot {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
padding: 10px 16px; border-top: 1px solid var(--rule);
|
||||
}
|
||||
.state { flex: 1; font-size: 11px; color: var(--quiet); }
|
||||
.state.dirty { color: var(--ink); }
|
||||
button {
|
||||
font: 12px/1 var(--ui); padding: 6px 14px; border-radius: 4px; cursor: pointer;
|
||||
border: 1px solid var(--rule); background: transparent; color: var(--ink);
|
||||
}
|
||||
button.go { border-color: var(--live); background: var(--live); color: var(--live-ink); }
|
||||
button:disabled { opacity: .45; cursor: default; }
|
||||
button:focus-visible { outline: 2px solid var(--live); outline-offset: 2px; }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
|
||||
</style>
|
||||
|
||||
<div class="panel">
|
||||
<header class="head">
|
||||
<span class="mark">Twistify</span>
|
||||
<span class="head-note">Applied to every layer as it is sliced</span>
|
||||
</header>
|
||||
|
||||
<div class="work">
|
||||
<div>
|
||||
<div class="rows" id="rows"></div>
|
||||
<p class="readout" id="readout"></p>
|
||||
</div>
|
||||
|
||||
<figure class="plot">
|
||||
<svg id="plot" viewBox="0 0 180 208" aria-hidden="true"></svg>
|
||||
<figcaption id="plotNote"></figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<footer class="foot">
|
||||
<span class="state" id="state"></span>
|
||||
<button type="button" id="restore">Restore defaults</button>
|
||||
<button type="button" id="save" class="go">Save</button>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var DEFAULTS = __ORCA_DEFAULTS__;
|
||||
|
||||
// Presentation only. `neutral` marks the value at which the control contributes no deformation;
|
||||
// rows without one (period, floor) are shape parameters, not amounts.
|
||||
var FIELDS = [
|
||||
{ key: "twist_deg_per_mm", label: "Twist", unit: "\\u00b0/mm", min: -20, max: 20, step: 0.1, dp: 1, neutral: 0,
|
||||
hint: "Rotation added per millimetre of height." },
|
||||
{ key: "taper_per_mm", label: "Taper", unit: "/mm", min: -0.05, max: 0.05, step: 0.001, dp: 3, neutral: 0,
|
||||
hint: "Scale added per millimetre. Negative narrows the model as it rises." },
|
||||
{ key: "wobble_ampl_mm", label: "Wobble", unit: "mm", min: 0, max: 10, step: 0.1, dp: 1, neutral: 0,
|
||||
hint: "How far each layer slides in X, from centre to peak." },
|
||||
{ key: "wobble_period_mm", label: "Wobble period", unit: "mm", min: 1, max: 120, step: 1, dp: 0,
|
||||
hint: "Height of one full wobble cycle." },
|
||||
{ key: "min_scale", label: "Scale floor", unit: "\\u00d7", min: 0.01, max: 1, step: 0.01, dp: 2,
|
||||
hint: "Taper never shrinks a layer past this, so a tall model cannot collapse." }
|
||||
];
|
||||
|
||||
// The preview simulates this much height. It never reads the real model, so the caption says so
|
||||
// rather than implying the drawing is to scale with the plate.
|
||||
var Z_SPAN = 40;
|
||||
var Z_STEP = 2;
|
||||
|
||||
var form = {};
|
||||
var stored = {};
|
||||
var context = (window.orca && window.orca.getContext) ? window.orca.getContext() : { scope: "global" };
|
||||
var savedNoteTimer = 0;
|
||||
|
||||
function num(value, fallback) {
|
||||
var n = parseFloat(value);
|
||||
return isFinite(n) ? n : fallback;
|
||||
}
|
||||
|
||||
function merged(config) {
|
||||
var out = {};
|
||||
Object.keys(DEFAULTS).forEach(function (key) {
|
||||
out[key] = num(config ? config[key] : undefined, DEFAULTS[key]);
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
function isDirty() {
|
||||
return Object.keys(DEFAULTS).some(function (key) { return form[key] !== stored[key]; });
|
||||
}
|
||||
|
||||
// --- the transform, exactly as _layer_params() applies it -------------------------------------
|
||||
|
||||
function layerAt(z) {
|
||||
var theta = form.twist_deg_per_mm * z * Math.PI / 180;
|
||||
var scale = Math.max(form.min_scale, 1 + form.taper_per_mm * z);
|
||||
var shift = 0;
|
||||
if (form.wobble_ampl_mm !== 0 && form.wobble_period_mm > 0)
|
||||
shift = form.wobble_ampl_mm * Math.sin(2 * Math.PI * z / form.wobble_period_mm);
|
||||
return { theta: theta, scale: scale, shift: shift };
|
||||
}
|
||||
|
||||
function deforms() {
|
||||
return form.twist_deg_per_mm !== 0 || form.taper_per_mm !== 0 || form.wobble_ampl_mm !== 0;
|
||||
}
|
||||
|
||||
// --- drawing ----------------------------------------------------------------------------------
|
||||
|
||||
var ISO_X = 0.866, ISO_Y = 0.5; // isometric: plan outlines stacked by height
|
||||
var ORIGIN_X = 108, ORIGIN_Y = 182; // the z = 0 outline's centre, in viewBox units
|
||||
var PLAN = 20; // half-width of the sample contour
|
||||
var Z_UNITS = 3.3; // viewBox units per millimetre of height
|
||||
var MM = 1.5; // viewBox units per millimetre of wobble travel
|
||||
var REACH = 62; // how far sideways the drawing may run before it is scaled down
|
||||
|
||||
// Plan-view corners of the layer at `z`, before projection.
|
||||
function planOutline(z) {
|
||||
var layer = layerAt(z);
|
||||
var half = PLAN * layer.scale;
|
||||
var cos = Math.cos(layer.theta), sin = Math.sin(layer.theta);
|
||||
return [[-half, -half], [half, -half], [half, half], [-half, half]].map(function (corner) {
|
||||
return [corner[0] * cos - corner[1] * sin + layer.shift * MM,
|
||||
corner[0] * sin + corner[1] * cos];
|
||||
});
|
||||
}
|
||||
|
||||
function points(plan, z, fit) {
|
||||
return plan.map(function (p) {
|
||||
var x = ORIGIN_X + (p[0] - p[1]) * ISO_X * fit;
|
||||
var y = ORIGIN_Y + (p[0] + p[1]) * ISO_Y * fit - z * Z_UNITS;
|
||||
return x.toFixed(1) + "," + y.toFixed(1);
|
||||
}).join(" ");
|
||||
}
|
||||
|
||||
function draw() {
|
||||
var svg = [];
|
||||
var layers = [];
|
||||
var reach = 0;
|
||||
for (var z = 0; z <= Z_SPAN + 0.001; z += Z_STEP) {
|
||||
var plan = planOutline(z);
|
||||
layers.push({ z: z, plan: plan });
|
||||
plan.forEach(function (p) { reach = Math.max(reach, Math.abs(p[0] - p[1]) * ISO_X); });
|
||||
}
|
||||
// A wide taper or a big wobble would run out of the frame, so scale down to fit rather than
|
||||
// clipping. Z keeps its scale, so the ruler stays true.
|
||||
var fit = reach > REACH ? REACH / reach : 1;
|
||||
|
||||
// Z ruler: the drawing is a height plot, so it gets an axis.
|
||||
for (var mark = 0; mark <= Z_SPAN; mark += 10) {
|
||||
var y = ORIGIN_Y - mark * Z_UNITS;
|
||||
svg.push('<line class="tick" x1="24" y1="' + y.toFixed(1) + '" x2="30" y2="' + y.toFixed(1) + '"/>');
|
||||
svg.push('<text x="20" y="' + (y + 3).toFixed(1) + '" text-anchor="end">' + mark + '</text>');
|
||||
}
|
||||
svg.push('<text x="30" y="' + (ORIGIN_Y - Z_SPAN * Z_UNITS - 11).toFixed(1) +
|
||||
'" text-anchor="end">mm</text>');
|
||||
|
||||
// The stack, faint at the bed and full strength at the top: the deformation grows with Z.
|
||||
var trace = [];
|
||||
layers.forEach(function (layer) {
|
||||
var ring = points(layer.plan, layer.z, fit);
|
||||
svg.push('<polygon class="ring" points="' + ring + '" stroke-opacity="' +
|
||||
(0.18 + 0.82 * layer.z / Z_SPAN).toFixed(2) + '"/>');
|
||||
trace.push(ring.split(" ")[1]);
|
||||
});
|
||||
|
||||
// One corner followed all the way up: on a twisted model, the helix the walls will run in.
|
||||
svg.push('<polyline class="helix" points="' + trace.join(" ") + '"/>');
|
||||
|
||||
// The datum: the first layer is never transformed, so it doubles as the reference outline.
|
||||
svg.push('<polygon class="datum" points="' + points(layers[0].plan, 0, fit) + '"/>');
|
||||
|
||||
document.getElementById("plot").innerHTML = svg.join("");
|
||||
document.getElementById("plotNote").textContent =
|
||||
deforms() ? "Sample contour, " + Z_SPAN + " mm of Z" : "Sample contour, undeformed";
|
||||
}
|
||||
|
||||
// --- readout ----------------------------------------------------------------------------------
|
||||
|
||||
function describe() {
|
||||
if (!deforms())
|
||||
return "No deformation. Twistify passes every layer through unchanged.";
|
||||
|
||||
var top = layerAt(Z_SPAN);
|
||||
var parts = [];
|
||||
if (form.twist_deg_per_mm !== 0)
|
||||
parts.push("<b>" + (form.twist_deg_per_mm * Z_SPAN).toFixed(0) + "\\u00b0</b> of rotation");
|
||||
if (form.taper_per_mm !== 0)
|
||||
parts.push("<b>" + top.scale.toFixed(2) + "\\u00d7</b> scale" +
|
||||
(top.scale === form.min_scale ? " (at the floor)" : ""));
|
||||
if (form.wobble_ampl_mm !== 0)
|
||||
parts.push("<b>\\u00b1" + form.wobble_ampl_mm.toFixed(1) + "</b> mm of wobble");
|
||||
return "At " + Z_SPAN + " mm above the first layer: " + parts.join(", ") + ".";
|
||||
}
|
||||
|
||||
function setReadout(html) { document.getElementById("readout").innerHTML = html; }
|
||||
|
||||
// Whatever the pointer or the keyboard is on explains itself; with neither, report the totals.
|
||||
function restoreReadout() {
|
||||
var id = document.activeElement ? document.activeElement.id : "";
|
||||
for (var i = 0; i < FIELDS.length; i++)
|
||||
if (id === "n-" + FIELDS[i].key || id === "r-" + FIELDS[i].key)
|
||||
return setReadout(FIELDS[i].hint);
|
||||
setReadout(describe());
|
||||
}
|
||||
|
||||
function refreshState() {
|
||||
var dirty = isDirty();
|
||||
document.getElementById("save").disabled = context.readOnly || !dirty;
|
||||
|
||||
if (savedNoteTimer)
|
||||
return; // the "Saved" note owns the line until it expires
|
||||
var state = document.getElementById("state");
|
||||
state.textContent = context.readOnly ? "This configuration is read-only."
|
||||
: dirty ? "Unsaved changes" : "";
|
||||
state.classList.toggle("dirty", dirty && !context.readOnly);
|
||||
}
|
||||
|
||||
function announce(message) {
|
||||
var state = document.getElementById("state");
|
||||
state.textContent = message;
|
||||
state.classList.remove("dirty");
|
||||
clearTimeout(savedNoteTimer);
|
||||
savedNoteTimer = setTimeout(function () { savedNoteTimer = 0; refreshState(); }, 2200);
|
||||
}
|
||||
|
||||
// --- controls ---------------------------------------------------------------------------------
|
||||
|
||||
function detent(field) {
|
||||
if (field.neutral === undefined) return "";
|
||||
return ((field.neutral - field.min) / (field.max - field.min) * 100).toFixed(2) + "%";
|
||||
}
|
||||
|
||||
function clamp(field, value) { return Math.min(field.max, Math.max(field.min, value)); }
|
||||
|
||||
// `echo` rewrites the number field with the clamped, formatted value. Off while the user is still
|
||||
// typing: "-" and "0.0" are valid partial input, and rewriting them mid-keystroke fights the
|
||||
// typist. The drawing still follows every keystroke.
|
||||
function apply(field, value, echo) {
|
||||
form[field.key] = clamp(field, value);
|
||||
if (echo)
|
||||
document.getElementById("n-" + field.key).value = form[field.key].toFixed(field.dp);
|
||||
document.getElementById("r-" + field.key).value = form[field.key];
|
||||
draw();
|
||||
// A control explains itself while you approach it, but once a value moves what matters is the
|
||||
// total it adds up to.
|
||||
setReadout(describe());
|
||||
refreshState();
|
||||
}
|
||||
|
||||
function buildRows() {
|
||||
var host = document.getElementById("rows");
|
||||
FIELDS.forEach(function (field) {
|
||||
var row = document.createElement("div");
|
||||
row.className = "row";
|
||||
// The number input is the labelled, keyboard-reachable control; the rail is the same value by
|
||||
// pointer, so it stays out of the tab order and the accessibility tree.
|
||||
row.innerHTML =
|
||||
'<label class="row-label" for="n-' + field.key + '">' + field.label + '</label>' +
|
||||
'<span class="row-figure">' +
|
||||
'<input id="n-' + field.key + '" type="number" step="' + field.step + '" ' +
|
||||
'min="' + field.min + '" max="' + field.max + '">' +
|
||||
'<span class="unit">' + field.unit + '</span>' +
|
||||
'</span>' +
|
||||
'<span class="rail"' + (field.neutral === undefined ? "" : ' data-detent style="--detent:' + detent(field) + '"') + '>' +
|
||||
'<input id="r-' + field.key + '" type="range" step="' + field.step + '" ' +
|
||||
'min="' + field.min + '" max="' + field.max + '" tabindex="-1" aria-hidden="true">' +
|
||||
'</span>';
|
||||
host.appendChild(row);
|
||||
|
||||
var number = row.querySelector("#n-" + field.key);
|
||||
var range = row.querySelector("#r-" + field.key);
|
||||
number.addEventListener("input", function () { apply(field, num(number.value, form[field.key]), false); });
|
||||
number.addEventListener("change", function () { apply(field, num(number.value, DEFAULTS[field.key]), true); });
|
||||
range.addEventListener("input", function () { apply(field, num(range.value, form[field.key]), true); });
|
||||
|
||||
[number, range].forEach(function (input) {
|
||||
input.addEventListener("focus", function () { setReadout(field.hint); });
|
||||
input.addEventListener("mouseenter", function () { setReadout(field.hint); });
|
||||
input.addEventListener("blur", restoreReadout);
|
||||
input.addEventListener("mouseleave", restoreReadout);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function load(config) {
|
||||
stored = merged(config);
|
||||
form = merged(config);
|
||||
FIELDS.forEach(function (field) {
|
||||
document.getElementById("n-" + field.key).value = form[field.key].toFixed(field.dp);
|
||||
document.getElementById("r-" + field.key).value = form[field.key];
|
||||
});
|
||||
draw();
|
||||
restoreReadout();
|
||||
refreshState();
|
||||
labelRestore();
|
||||
setInputsEnabled(!context.readOnly);
|
||||
}
|
||||
|
||||
// "Restore defaults" writes the plugin's own defaults globally, but in a preset it drops that
|
||||
// preset's override and falls back to the global configuration. Say which one the button does.
|
||||
function labelRestore() {
|
||||
var restore = document.getElementById("restore");
|
||||
var preset = context.scope === "preset";
|
||||
restore.textContent = preset ? "Use global settings" : "Restore defaults";
|
||||
restore.title = preset ? "Discard this preset's override and use the global configuration"
|
||||
: "Replace the saved configuration with Twistify's defaults";
|
||||
restore.disabled = context.readOnly || (preset && !context.hasPresetOverride);
|
||||
}
|
||||
|
||||
function setInputsEnabled(enabled) {
|
||||
FIELDS.forEach(function (field) {
|
||||
document.getElementById("n-" + field.key).disabled = !enabled;
|
||||
document.getElementById("r-" + field.key).disabled = !enabled;
|
||||
});
|
||||
}
|
||||
|
||||
buildRows();
|
||||
load(window.orca ? window.orca.getConfig() : {});
|
||||
|
||||
document.getElementById("save").addEventListener("click", function () {
|
||||
if (!window.orca) return;
|
||||
window.orca.saveConfig(form);
|
||||
});
|
||||
document.getElementById("restore").addEventListener("click", function () {
|
||||
if (window.orca) window.orca.restoreDefaults();
|
||||
});
|
||||
|
||||
if (window.orca && window.orca.onConfig) {
|
||||
var first = true;
|
||||
window.orca.onConfig(function (config) {
|
||||
// Fires once immediately (already handled above) and then on every host save: reload from
|
||||
// what was stored, never from what was typed.
|
||||
if (first) { first = false; return; }
|
||||
if (window.orca.getContext) context = window.orca.getContext();
|
||||
load(config);
|
||||
announce("Saved");
|
||||
});
|
||||
}
|
||||
// No theme handler needed: every colour on the page, the drawing included, resolves through the
|
||||
// --orca-* variables the host rewrites in place.
|
||||
})();
|
||||
</script>
|
||||
"""
|
||||
|
||||
|
||||
class Twistify(orca.slicing.SlicingPipelineCapabilityBase):
|
||||
def get_name(self):
|
||||
return "Twistify"
|
||||
|
||||
def get_default_config(self):
|
||||
return _DEFAULTS
|
||||
|
||||
def has_config_ui(self):
|
||||
return True
|
||||
|
||||
def get_config_ui(self):
|
||||
return _CONFIG_UI.replace("__ORCA_DEFAULTS__", json.dumps(_DEFAULTS))
|
||||
|
||||
def execute(self, ctx):
|
||||
if ctx.step != orca.slicing.Step.posSlice or ctx.object is None:
|
||||
return orca.ExecutionResult.success()
|
||||
|
||||
p = _params(self)
|
||||
if _is_identity(p):
|
||||
return orca.ExecutionResult.success("Twistify: identity parameters, nothing to do")
|
||||
|
||||
mm_to_scaled = 1.0 / orca.slicing.unscale(1)
|
||||
|
||||
layers = ctx.object.layers()
|
||||
if not layers:
|
||||
return orca.ExecutionResult.success("Twistify: object has no layers")
|
||||
|
||||
# Twist/taper axis = the object's bounding-box center (scaled coords, same frame
|
||||
# as the slice polygons), so each object on the plate transforms about its own
|
||||
# center. Keep the float center for translate-to-origin/back around scale(), and
|
||||
# a rounded-to-Point center for rotate() (which takes an integer Point).
|
||||
min_x, min_y, max_x, max_y = ctx.object.bounding_box()
|
||||
cx = (min_x + max_x) / 2.0
|
||||
cy = (min_y + max_y) / 2.0
|
||||
center = orca.host.Point(int(round(cx)), int(round(cy)))
|
||||
z0 = float(layers[0].print_z) # z_rel = 0 on the first layer -> footprint untouched
|
||||
|
||||
layers_touched = 0
|
||||
for layer in layers:
|
||||
if ctx.cancelled():
|
||||
break
|
||||
z_rel = float(layer.print_z) - z0
|
||||
theta, s, ox = _layer_params(z_rel, mm_to_scaled, p)
|
||||
if theta == 0.0 and s == 1.0 and ox == 0.0:
|
||||
continue # exact identity (always the first layer)
|
||||
|
||||
edited = False
|
||||
for region in layer.regions():
|
||||
for surface in region.slices.surfaces:
|
||||
ex = surface.expolygon
|
||||
ex.rotate(theta, center) # rotate about the object center (in place)
|
||||
if s != 1.0:
|
||||
# scale() scales about the coordinate ORIGIN, so re-center the
|
||||
# geometry on the origin first and translate back after, making
|
||||
# this a true similarity transform about the object's center.
|
||||
ex.translate(-cx, -cy)
|
||||
ex.scale(s)
|
||||
ex.translate(cx, cy)
|
||||
if ox != 0.0:
|
||||
ex.translate(ox, 0.0) # wobble in X
|
||||
edited = True
|
||||
if edited:
|
||||
# Re-derive the merged islands from the twisted region slices.
|
||||
layer.make_slices()
|
||||
layers_touched += 1
|
||||
|
||||
name = ctx.object.model_object().name or "object"
|
||||
return orca.ExecutionResult.success(
|
||||
f"Twistify: transformed {layers_touched} layer(s) of '{name}' "
|
||||
f"(twist {p['twist_deg_per_mm']} deg/mm, taper {p['taper_per_mm']}/mm, "
|
||||
f"wobble {p['wobble_ampl_mm']} mm)")
|
||||
|
||||
|
||||
@orca.plugin
|
||||
class TwistifyPackage(orca.base):
|
||||
def register_capabilities(self):
|
||||
orca.register_capability(Twistify)
|
||||
@@ -1,142 +0,0 @@
|
||||
# /// script
|
||||
# requires-python = ">=3.12"
|
||||
#
|
||||
# [tool.orcaslicer.plugin]
|
||||
# name = "Twistify"
|
||||
# description = "Twists, tapers, and wobbles every layer's slice polygons as a function of Z (demo)."
|
||||
# author = "OrcaSlicer"
|
||||
# version = "0.02"
|
||||
# type = "slicing-pipeline"
|
||||
# ///
|
||||
"""Twistify -- twist/taper/wobble any model at slice time.
|
||||
|
||||
At Step.posSlice, every layer's sliced surfaces are transformed by a similarity
|
||||
about the object's bounding-box center as a function of Z -- edited IN PLACE
|
||||
through the host geometry classes (ExPolygon.rotate/scale/translate). Each
|
||||
surface is rotated about the center, then (if tapering) translated to the
|
||||
origin, uniformly scaled, and translated back, so the taper stays centered on
|
||||
the object instead of drifting toward the coordinate origin. An optional X
|
||||
wobble is applied last. After the per-region edits, layer.make_slices()
|
||||
re-derives the layer's merged islands so overhang/bridge/skirt/support stay
|
||||
coherent. The split slice loop runs make_perimeters() right after the hook, so
|
||||
the transform cascades into perimeters, infill, and the final G-code -- the
|
||||
preview corkscrews and the print keeps correct walls/infill/flow.
|
||||
|
||||
Because we edit geometry in place, surface types are preserved automatically
|
||||
(no per-surface type carry needed), and no numpy is required --
|
||||
rotate/scale/translate are host methods. Parameters come from self.get_config()
|
||||
(see _params below), which the host seeds from get_default_config(). The first
|
||||
object layer is untouched (z_rel = 0), so bed adhesion is unaffected.
|
||||
"""
|
||||
import math
|
||||
import json
|
||||
import orca
|
||||
|
||||
_DEFAULTS = {
|
||||
"twist_deg_per_mm": 1.0,
|
||||
"taper_per_mm": 0.0,
|
||||
"wobble_ampl_mm": 0.0,
|
||||
"wobble_period_mm": 20.0,
|
||||
"min_scale": 0.05,
|
||||
}
|
||||
|
||||
|
||||
def _params(self):
|
||||
try:
|
||||
src = json.loads(self.get_config())
|
||||
except (AttributeError, TypeError):
|
||||
src = {}
|
||||
out = {}
|
||||
for key, default in _DEFAULTS.items():
|
||||
try:
|
||||
out[key] = float(src[key])
|
||||
except (KeyError, TypeError, ValueError):
|
||||
out[key] = default
|
||||
return out
|
||||
|
||||
|
||||
def _is_identity(p):
|
||||
return p["twist_deg_per_mm"] == 0.0 and p["taper_per_mm"] == 0.0 and p["wobble_ampl_mm"] == 0.0
|
||||
|
||||
|
||||
def _layer_params(z_rel, mm_to_scaled, p):
|
||||
"""(angle_rad, scale, x_offset_scaled) for one layer. Exact identity at z_rel == 0."""
|
||||
theta = math.radians(p["twist_deg_per_mm"] * z_rel)
|
||||
s = max(p["min_scale"], 1.0 + p["taper_per_mm"] * z_rel)
|
||||
ox = 0.0
|
||||
if p["wobble_ampl_mm"] != 0.0 and p["wobble_period_mm"] > 0.0:
|
||||
ox = p["wobble_ampl_mm"] * math.sin(2.0 * math.pi * z_rel / p["wobble_period_mm"]) * mm_to_scaled
|
||||
return theta, s, ox
|
||||
|
||||
|
||||
class Twistify(orca.slicing.SlicingPipelineCapabilityBase):
|
||||
def get_name(self):
|
||||
return "Twistify"
|
||||
|
||||
def get_default_config(self):
|
||||
return _DEFAULTS
|
||||
|
||||
def execute(self, ctx):
|
||||
if ctx.step != orca.slicing.Step.posSlice or ctx.object is None:
|
||||
return orca.ExecutionResult.success()
|
||||
|
||||
p = _params(self)
|
||||
if _is_identity(p):
|
||||
return orca.ExecutionResult.success("Twistify: identity parameters, nothing to do")
|
||||
|
||||
mm_to_scaled = 1.0 / orca.slicing.unscale(1)
|
||||
|
||||
layers = ctx.object.layers()
|
||||
if not layers:
|
||||
return orca.ExecutionResult.success("Twistify: object has no layers")
|
||||
|
||||
# Twist/taper axis = the object's bounding-box center (scaled coords, same frame
|
||||
# as the slice polygons), so each object on the plate transforms about its own
|
||||
# center. Keep the float center for translate-to-origin/back around scale(), and
|
||||
# a rounded-to-Point center for rotate() (which takes an integer Point).
|
||||
min_x, min_y, max_x, max_y = ctx.object.bounding_box()
|
||||
cx = (min_x + max_x) / 2.0
|
||||
cy = (min_y + max_y) / 2.0
|
||||
center = orca.host.Point(int(round(cx)), int(round(cy)))
|
||||
z0 = float(layers[0].print_z) # z_rel = 0 on the first layer -> footprint untouched
|
||||
|
||||
layers_touched = 0
|
||||
for layer in layers:
|
||||
if ctx.cancelled():
|
||||
break
|
||||
z_rel = float(layer.print_z) - z0
|
||||
theta, s, ox = _layer_params(z_rel, mm_to_scaled, p)
|
||||
if theta == 0.0 and s == 1.0 and ox == 0.0:
|
||||
continue # exact identity (always the first layer)
|
||||
|
||||
edited = False
|
||||
for region in layer.regions():
|
||||
for surface in region.slices.surfaces:
|
||||
ex = surface.expolygon
|
||||
ex.rotate(theta, center) # rotate about the object center (in place)
|
||||
if s != 1.0:
|
||||
# scale() scales about the coordinate ORIGIN, so re-center the
|
||||
# geometry on the origin first and translate back after, making
|
||||
# this a true similarity transform about the object's center.
|
||||
ex.translate(-cx, -cy)
|
||||
ex.scale(s)
|
||||
ex.translate(cx, cy)
|
||||
if ox != 0.0:
|
||||
ex.translate(ox, 0.0) # wobble in X
|
||||
edited = True
|
||||
if edited:
|
||||
# Re-derive the merged islands from the twisted region slices.
|
||||
layer.make_slices()
|
||||
layers_touched += 1
|
||||
|
||||
name = ctx.object.model_object().name or "object"
|
||||
return orca.ExecutionResult.success(
|
||||
f"Twistify: transformed {layers_touched} layer(s) of '{name}' "
|
||||
f"(twist {p['twist_deg_per_mm']} deg/mm, taper {p['taper_per_mm']}/mm, "
|
||||
f"wobble {p['wobble_ampl_mm']} mm)")
|
||||
|
||||
|
||||
@orca.plugin
|
||||
class TwistifyPackage(orca.base):
|
||||
def register_capabilities(self):
|
||||
orca.register_capability(Twistify)
|
||||
@@ -306,6 +306,12 @@ modules:
|
||||
sha256: c08bc65a81971c1dd5783182826503369466c7e67374d1646519adf05207b684
|
||||
dest: external-packages/python3
|
||||
|
||||
# wxInspector 1.0.0
|
||||
- type: file
|
||||
url: https://github.com/Noisyfox/wxInspector/archive/refs/tags/v1.0.0.zip
|
||||
sha256: 0ba163956f2d468b19a91b96c5aba66ee9610843ea41dda628ea44cdafde7db7
|
||||
dest: external-packages/wxInspector
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
# Fallback archives for deps normally provided by the GNOME SDK.
|
||||
# These are only used if find_package() fails to locate them.
|
||||
|
||||
@@ -23,7 +23,7 @@ if %FULL_MODE%==1 (
|
||||
call :prepareGettextList "%list_file%" "%filtered_list%" "%missing_list%"
|
||||
if "!has_sources!"=="1" (
|
||||
if not exist "%generated_i18n%" mkdir "%generated_i18n%"
|
||||
.\tools\xgettext.exe --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_CTX:1,2c --keyword=_CTX_utf8:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost --no-wrap -f "%filtered_list%" -o "%generated_pot%"
|
||||
.\tools\xgettext.exe --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_CONTEXT:1,2c --keyword=_u8L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost --no-wrap -f "%filtered_list%" -o "%generated_pot%"
|
||||
if errorlevel 1 (
|
||||
set "script_exit_code=1"
|
||||
) else (
|
||||
|
||||
@@ -85,7 +85,7 @@ if $FULL_MODE; then
|
||||
generated_pot_file="${generated_i18n_dir}/OrcaSlicer.pot"
|
||||
|
||||
mkdir -p "$generated_i18n_dir"
|
||||
xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_CTX:1,2c --keyword=_CTX_utf8:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost --no-wrap -f "$filtered_list" -o "$generated_pot_file"
|
||||
xgettext --keyword=L --keyword=_L --keyword=_u8L --keyword=L_CONTEXT:1,2c --keyword=_L_CONTEXT:1,2c --keyword=_u8L_CONTEXT:1,2c --keyword=_L_PLURAL:1,2 --add-comments=TRN --from-code=UTF-8 --no-location --debug --boost --no-wrap -f "$filtered_list" -o "$generated_pot_file"
|
||||
python3 scripts/HintsToPot.py ./resources "$generated_i18n_dir"
|
||||
|
||||
if [ -f "$pot_file" ] && files_equal_ignoring_pot_date "$pot_file" "$generated_pot_file"; then
|
||||
|
||||
+4
-4
@@ -88,6 +88,10 @@ if (SLIC3R_GUI)
|
||||
list(FILTER wxWidgets_LIBRARIES EXCLUDE REGEX OpenGL)
|
||||
|
||||
# list(REMOVE_ITEM wxWidgets_LIBRARIES oleacc)
|
||||
|
||||
find_package(wxInspector REQUIRED)
|
||||
list(APPEND wxWidgets_LIBRARIES "wxInspector::wxInspector")
|
||||
|
||||
message(STATUS "wx libs: ${wxWidgets_LIBRARIES}")
|
||||
|
||||
add_subdirectory(slic3r)
|
||||
@@ -283,10 +287,6 @@ else ()
|
||||
COMMAND ln -sf OrcaSlicer orca-slicer
|
||||
WORKING_DIRECTORY "$<TARGET_FILE_DIR:OrcaSlicer>"
|
||||
VERBATIM)
|
||||
else ()
|
||||
add_custom_command(TARGET OrcaSlicer POST_BUILD
|
||||
WORKING_DIRECTORY "$<TARGET_FILE_DIR:OrcaSlicer>"
|
||||
VERBATIM)
|
||||
endif ()
|
||||
if (XCODE)
|
||||
# Because of Debug/Release/etc. configurations (similar to MSVC) the slic3r binary is located in an extra level
|
||||
|
||||
+20
-3
@@ -24,6 +24,8 @@
|
||||
#include <iostream>
|
||||
#include <math.h>
|
||||
#include <csignal>
|
||||
#include <atomic>
|
||||
#include <new>
|
||||
|
||||
#if defined(__linux__) || defined(__LINUX__)
|
||||
#include <condition_variable>
|
||||
@@ -7608,6 +7610,9 @@ LONG WINAPI VectoredExceptionHandler(PEXCEPTION_POINTERS pExceptionInfo)
|
||||
}*/
|
||||
|
||||
#if defined(_MSC_VER) || defined(__MINGW32__)
|
||||
// Guards against a failed allocation inside the dump re-entering the new-handler.
|
||||
static std::atomic<bool> g_dump_in_progress{false};
|
||||
|
||||
extern "C" {
|
||||
__declspec(dllexport) int __stdcall orcaslicer_main(int argc, wchar_t **argv)
|
||||
{
|
||||
@@ -7626,10 +7631,22 @@ extern "C" {
|
||||
//AddVectoredExceptionHandler(1, CBaseException::UnhandledExceptionFilter);
|
||||
SET_DEFULTER_HANDLER();
|
||||
#endif
|
||||
// Dump before unwinding, while the stack still names what asked for the memory. Throwing
|
||||
// std::bad_alloc is standard-permitted here and is what reaches generic_exception_handle().
|
||||
std::set_new_handler([]() {
|
||||
int *a = nullptr;
|
||||
*a = 0;
|
||||
});
|
||||
if (!g_dump_in_progress.exchange(true)) {
|
||||
try {
|
||||
// A null EXCEPTION_POINTERS walks the calling thread as it stands.
|
||||
CBaseException base(GetCurrentProcess(), GetCurrentProcessId(), NULL, nullptr);
|
||||
base.ShowCallstack();
|
||||
} catch (...) {
|
||||
// A failed dump must not displace the std::bad_alloc owed to the caller.
|
||||
}
|
||||
// ObjParser recovers from std::bad_alloc, so let a later one dump again.
|
||||
g_dump_in_progress = false;
|
||||
}
|
||||
throw std::bad_alloc();
|
||||
});
|
||||
// Call the UTF8 main.
|
||||
return CLI().run(argc, argv_ptrs.data());
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ if (TARGET OpenVDB::openvdb)
|
||||
endif()
|
||||
|
||||
option(BUILD_SHARED_LIBS "Build shared libs" OFF)
|
||||
option(USE_SLIC3R_CONSOLE_LOG "Enable console logging in RelWithDebInfo builds" OFF)
|
||||
|
||||
set(lisbslic3r_sources
|
||||
AABBMesh.cpp
|
||||
@@ -247,6 +248,8 @@ set(lisbslic3r_sources
|
||||
GCode/Thumbnails.hpp
|
||||
GCode/ToolOrdering.cpp
|
||||
GCode/ToolOrdering.hpp
|
||||
GCode/OrderingStrategies.cpp
|
||||
GCode/OrderingStrategies.hpp
|
||||
GCode/WipeTower2.cpp
|
||||
GCode/WipeTower2.hpp
|
||||
GCode/WipeTower.cpp
|
||||
@@ -497,8 +500,12 @@ set(CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE ON CACHE BOOL "" FORCE)
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0011 NEW)
|
||||
# CGAL's config resets policies (cmake_minimum_required ...3.23), so a plain SET
|
||||
# can't reach it; the default opts its Boost lookup into BoostConfig (CMP0167).
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0167 NEW)
|
||||
find_package(CGAL REQUIRED)
|
||||
find_package(OpenCV REQUIRED core)
|
||||
unset(CMAKE_POLICY_DEFAULT_CMP0167)
|
||||
cmake_policy(POP)
|
||||
|
||||
add_library(libslic3r_cgal STATIC
|
||||
@@ -535,7 +542,9 @@ endif ()
|
||||
encoding_check(libslic3r)
|
||||
|
||||
target_compile_definitions(libslic3r PUBLIC -DUSE_TBB -DTBB_USE_CAPTURED_EXCEPTION=0)
|
||||
target_compile_definitions(libslic3r PRIVATE $<$<CONFIG:RelWithDebInfo>:SLIC3R_CONSOLE_LOG>)
|
||||
if (USE_SLIC3R_CONSOLE_LOG)
|
||||
target_compile_definitions(libslic3r PRIVATE $<$<CONFIG:RelWithDebInfo>:SLIC3R_CONSOLE_LOG>)
|
||||
endif()
|
||||
target_include_directories(libslic3r PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PUBLIC ${CMAKE_CURRENT_BINARY_DIR})
|
||||
target_include_directories(libslic3r SYSTEM PUBLIC ${EXPAT_INCLUDE_DIRS})
|
||||
|
||||
@@ -545,7 +554,7 @@ find_package(OpenCASCADE REQUIRED)
|
||||
target_include_directories(libslic3r SYSTEM PUBLIC ${OpenCASCADE_INCLUDE_DIR})
|
||||
|
||||
find_package(JPEG REQUIRED)
|
||||
find_package(draco REQUIRED)
|
||||
find_package(Draco REQUIRED)
|
||||
|
||||
set(OCCT_LIBS
|
||||
TKXDESTEP
|
||||
|
||||
@@ -57,6 +57,9 @@ double calculate_infill_rotation_angle(const PrintObject* object,
|
||||
if (template_string.empty()) {
|
||||
return Geometry::deg2rad(fixed_infill_angle);
|
||||
}
|
||||
// Convert the id to an index. Layer::id() counts the raft layers, object->layers() does not.
|
||||
const size_t first_object_layer_id = object->get_layer(0)->id();
|
||||
layer_id = layer_id > first_object_layer_id ? layer_id - first_object_layer_id : 0;
|
||||
double angle = 0.0;
|
||||
ConfigOptionFloats rotate_angles;
|
||||
const std::string search_string = "/NnZz$LlUuQq~^|#";
|
||||
@@ -75,6 +78,8 @@ double calculate_infill_rotation_angle(const PrintObject* object,
|
||||
double angle_start = 0;
|
||||
double limit_fill_z = object->get_layer(0)->bottom_z();
|
||||
double start_fill_z = limit_fill_z;
|
||||
// The raft height, or 0 without a raft.
|
||||
const double print_z_offset = object->slicing_parameters().object_print_z_min;
|
||||
bool _noop = false;
|
||||
auto fill_form = std::string::npos;
|
||||
bool _absolute = false;
|
||||
@@ -84,7 +89,8 @@ double calculate_infill_rotation_angle(const PrintObject* object,
|
||||
for (int i = 0; i <= layer_id; i++) {
|
||||
double fill_z = object->get_layer(i)->bottom_z();
|
||||
|
||||
if (limit_fill_z < object->get_layer(i)->slice_z) {
|
||||
// slice_z is measured from the bottom of the model, limit_fill_z from the build plate.
|
||||
if (limit_fill_z < object->get_layer(i)->slice_z + print_z_offset) {
|
||||
if (repeats) { // if repeats >0 then restore parameters for new iteration
|
||||
limit_fill_z += limit_fill_z - start_fill_z;
|
||||
start_fill_z = fill_z;
|
||||
|
||||
+236
-46
@@ -14,6 +14,7 @@
|
||||
#include "GCode/Thumbnails.hpp"
|
||||
#include "GCode/WipeTower.hpp"
|
||||
#include "ShortestPath.hpp"
|
||||
#include "GCode/OrderingStrategies.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "ClipperUtils.hpp"
|
||||
@@ -730,6 +731,42 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
|
||||
return temp_set_by_gcode;
|
||||
}
|
||||
|
||||
struct CustomGCodeMotionStateChanges
|
||||
{
|
||||
bool acceleration = false;
|
||||
bool jerk = false;
|
||||
};
|
||||
|
||||
static bool custom_gcode_line_has_xy_parameter(const std::string &raw)
|
||||
{
|
||||
const size_t comment_pos = raw.find(';');
|
||||
const std::string_view code(raw.data(), comment_pos == std::string::npos ? raw.size() : comment_pos);
|
||||
return code.find_first_of("XxYy") != std::string_view::npos;
|
||||
}
|
||||
|
||||
static CustomGCodeMotionStateChanges custom_gcode_motion_state_changes(const std::string &gcode)
|
||||
{
|
||||
CustomGCodeMotionStateChanges changes;
|
||||
GCodeReader parser;
|
||||
parser.parse_buffer(gcode, [&changes](GCodeReader &parser, const GCodeReader::GCodeLine &line) {
|
||||
const std::string_view cmd = line.cmd();
|
||||
if (boost::iequals(cmd, "M204") || boost::iequals(cmd, "M201") ||
|
||||
boost::iequals(cmd, "M202"))
|
||||
changes.acceleration = true;
|
||||
else if ((boost::iequals(cmd, "M205") || boost::iequals(cmd, "M207") || boost::iequals(cmd, "M566")) &&
|
||||
custom_gcode_line_has_xy_parameter(line.raw()))
|
||||
changes.jerk = true;
|
||||
else if (boost::iequals(cmd, "SET_VELOCITY_LIMIT")) {
|
||||
changes.acceleration |= boost::icontains(line.raw(), "ACCEL=");
|
||||
changes.jerk |= boost::icontains(line.raw(), "SQUARE_CORNER_VELOCITY=");
|
||||
}
|
||||
|
||||
if (changes.acceleration && changes.jerk)
|
||||
parser.quit_parsing();
|
||||
});
|
||||
return changes;
|
||||
}
|
||||
|
||||
// BBS
|
||||
// start_pos refers to the last position before the wipe_tower.
|
||||
// end_pos refers to the wipe tower's start_pos.
|
||||
@@ -2768,6 +2805,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
m_role_based_fan_marker_layer.fill(-1);
|
||||
|
||||
m_fan_mover.release();
|
||||
m_ordering_cache.clear();
|
||||
|
||||
m_writer.set_is_bbl_machine(is_bbl_printers);
|
||||
|
||||
@@ -3089,10 +3127,19 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
|
||||
// Therefore initialize the printing extruders from there.
|
||||
this->set_extruders(tool_ordering.all_extruders());
|
||||
print_object_instances_ordering =
|
||||
// By default, order object instances using a nearest neighbor search.
|
||||
print.config().print_order == PrintOrder::Default ? chain_print_object_instances(print)
|
||||
// By default, order object instances using nearest-neighbor chaining plus
|
||||
// 2-opt and crossing-removal post-processing.
|
||||
(print.config().print_order == PrintOrder::Default ? chain_print_object_instances(print)
|
||||
// Snake: serpentine row traversal + 2-opt
|
||||
: (print.config().print_order == PrintOrder::Snake ? chain_print_object_instances_snake(print)
|
||||
// Best of all: run every strategy, pick the shortest total path
|
||||
: (print.config().print_order == PrintOrder::BestOfStrategies ? chain_print_object_instances_best_of(print)
|
||||
// Otherwise same order as the object list
|
||||
: sort_object_instances_by_model_order(print);
|
||||
: sort_object_instances_by_model_order(print))));
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (initial_extruder_id == (unsigned int)-1) {
|
||||
// Nothing to print!
|
||||
@@ -4335,6 +4382,11 @@ PlaceholderParserIntegration &ppi = m_placeholder_parser_integration;
|
||||
ppi.update_from_gcodewriter(m_writer);
|
||||
std::string output = ppi.parser.process(templ, current_filament_id, config_override, &ppi.output_config, &ppi.context);
|
||||
ppi.validate_output_vector_variables();
|
||||
const CustomGCodeMotionStateChanges motion_state_changes = custom_gcode_motion_state_changes(output);
|
||||
if (motion_state_changes.acceleration)
|
||||
m_writer.invalidate_acceleration();
|
||||
if (motion_state_changes.jerk)
|
||||
m_writer.invalidate_jerk();
|
||||
|
||||
if (const std::vector<double> &pos = ppi.opt_position->values; ppi.position != pos) {
|
||||
// Update G-code writer.
|
||||
@@ -5478,7 +5530,9 @@ LayerResult GCode::process_layer(
|
||||
//Calibration Layer-specific GCode
|
||||
switch (print.calib_mode()) {
|
||||
case CalibMode::Calib_PA_Tower: {
|
||||
gcode += writer().set_pressure_advance(print.calib_params().start + static_cast<int>(print_z) * print.calib_params().step);
|
||||
gcode += writer().set_pressure_advance(this->interpolate_value_across_layers(static_cast<float>(print.calib_params().start),
|
||||
static_cast<float>(print.calib_params().end),
|
||||
static_cast<float>(print.calib_params().step)));
|
||||
break;
|
||||
}
|
||||
case CalibMode::Calib_Temp_Tower: {
|
||||
@@ -5486,7 +5540,12 @@ LayerResult GCode::process_layer(
|
||||
break;
|
||||
}
|
||||
case CalibMode::Calib_VFA_Tower: {
|
||||
auto _speed = print.calib_params().start + std::floor(print_z / 5.0) * print.calib_params().step;
|
||||
// Step the outer wall speed from start to end across the tower's layers. Plater::calib_VFA sizes the
|
||||
// geometry so each speed step spans one visual block (a fixed number of layers), so the layer-based
|
||||
// stepping stays aligned with the blocks regardless of nozzle size / layer height.
|
||||
float _speed = this->interpolate_value_across_layers(static_cast<float>(print.calib_params().start),
|
||||
static_cast<float>(print.calib_params().end),
|
||||
static_cast<float>(print.calib_params().step));
|
||||
m_calib_config.set_key_value("outer_wall_speed", new ConfigOptionFloatsNullable({std::round(_speed)}));
|
||||
break;
|
||||
}
|
||||
@@ -5640,10 +5699,17 @@ LayerResult GCode::process_layer(
|
||||
for (const auto &layer_to_print : layers) {
|
||||
if (layer_to_print.object_layer) {
|
||||
const auto& regions = layer_to_print.object_layer->regions();
|
||||
const bool enable_overhang_speed = std::any_of(regions.begin(), regions.end(), [this](const LayerRegion* r) {
|
||||
const bool has_extrusions = std::any_of(regions.begin(), regions.end(), [](const LayerRegion* r) {
|
||||
return r->has_extrusions();
|
||||
});
|
||||
const bool enable_overhang_speed = std::any_of(regions.begin(), regions.end(), [this](const LayerRegion* r) {
|
||||
return r->has_extrusions() && r->region().config().enable_overhang_speed.get_at(get_nozzle_config_index(m_writer.filament()->id()));
|
||||
});
|
||||
if (enable_overhang_speed) {
|
||||
const bool enable_overhang_fan = m_enable_cooling_markers && has_extrusions &&
|
||||
std::any_of(m_config.enable_overhang_bridge_fan.values.begin(),
|
||||
m_config.enable_overhang_bridge_fan.values.end(),
|
||||
[](unsigned char value) { return value != 0; });
|
||||
if (enable_overhang_speed || enable_overhang_fan) {
|
||||
m_extrusion_quality_estimator.prepare_for_new_layer(layer_to_print.original_object,
|
||||
layer_to_print.object_layer);
|
||||
}
|
||||
@@ -5911,41 +5977,128 @@ LayerResult GCode::process_layer(
|
||||
if (m_farthest_point_timelapse.enabled)
|
||||
compute_farthest_point(layers, most_used_extruder, support_filaments);
|
||||
|
||||
std::map<unsigned int, std::vector<InstanceToPrint>> filament_to_print_instances;
|
||||
// Per filament: instances to print, and the visit sequence over them. Island-level ordering
|
||||
// may visit an instance more than once per layer; otherwise one visit per instance.
|
||||
std::map<unsigned int, std::pair<std::vector<InstanceToPrint>, std::vector<InstanceVisit>>> filament_to_print_instances;
|
||||
{
|
||||
// Order individual islands rather than whole instances. Off for by-object sequencing,
|
||||
// sequential printing, and the explicit AsObjectList order, which tour whole instances.
|
||||
const bool island_level_ordering = print.config().print_sequence != PrintSequence::ByObject &&
|
||||
single_object_instance_idx == size_t(-1) &&
|
||||
print.config().print_order != PrintOrder::AsObjectList;
|
||||
for (unsigned int filament_id : layer_tools.extruders) {
|
||||
auto objects_by_extruder_it = by_extruder.find(filament_id);
|
||||
if (objects_by_extruder_it == by_extruder.end()) continue;
|
||||
|
||||
auto &filament_plan = filament_to_print_instances[filament_id];
|
||||
|
||||
if (!island_level_ordering) {
|
||||
// One visit per instance, printing all of its islands.
|
||||
filament_plan.first = sort_print_object_instances(objects_by_extruder_it->second, layers, ordering, single_object_instance_idx);
|
||||
filament_plan.second.reserve(filament_plan.first.size());
|
||||
for (size_t i = 0; i < filament_plan.first.size(); ++i)
|
||||
filament_plan.second.push_back({i, {}, true});
|
||||
continue;
|
||||
}
|
||||
|
||||
int plate_idx = print.get_plate_index();
|
||||
Point wt_pos(print.config().wipe_tower_x.get_at(plate_idx), print.config().wipe_tower_y.get_at(plate_idx));
|
||||
|
||||
// Build the instances and one tour node per non-empty island (a single node for
|
||||
// instances without chainable islands). Positions quantized to 1 mm so small
|
||||
// centroid drift between layers still hits the tour cache below.
|
||||
std::vector<GCode::ObjectByExtruder> &objects_by_extruder = objects_by_extruder_it->second;
|
||||
std::vector<const PrintObject *> print_objects;
|
||||
for (int obj_idx = 0; obj_idx < objects_by_extruder.size(); obj_idx++) {
|
||||
auto &object_by_extruder = objects_by_extruder[obj_idx];
|
||||
std::vector<InstanceToPrint> &instances = filament_plan.first;
|
||||
std::vector<IslandOrderNode> nodes;
|
||||
std::vector<size_t> node_instances;
|
||||
auto quantize_to_mm = [](const Point &pt) -> Point {
|
||||
const coord_t grid = coord_t(scale_(1.));
|
||||
// Round to the nearest 1 mm symmetrically (integer division truncates toward
|
||||
// zero, which would make the bucket straddling the origin twice as wide).
|
||||
auto q = [grid](coord_t v) -> coord_t {
|
||||
return ((v >= 0 ? v + grid / 2 : v - grid / 2) / grid) * grid;
|
||||
};
|
||||
return Point(q(pt.x()), q(pt.y()));
|
||||
};
|
||||
for (ObjectByExtruder &object_by_extruder : objects_by_extruder) {
|
||||
if (object_by_extruder.islands.empty() && (object_by_extruder.support == nullptr || object_by_extruder.support->empty())) continue;
|
||||
|
||||
print_objects.push_back(print.get_object(obj_idx));
|
||||
const size_t layer_id = &object_by_extruder - objects_by_extruder.data();
|
||||
const PrintObject *print_object = layers[layer_id].original_object;
|
||||
if (print_object == nullptr)
|
||||
continue;
|
||||
const Layer *obj_layer = layers[layer_id].object_layer;
|
||||
std::vector<ObjectByExtruder::Island> &islands = object_by_extruder.islands;
|
||||
const bool islands_chainable = obj_layer != nullptr && islands.size() == obj_layer->lslices.size() + 1;
|
||||
for (size_t instance_id = 0; instance_id < print_object->instances().size(); ++instance_id) {
|
||||
const size_t instance_idx = instances.size();
|
||||
instances.emplace_back(object_by_extruder, layer_id, *print_object, instance_id,
|
||||
print_object->instances()[instance_id].model_instance->get_labeled_id());
|
||||
const Point &shift = print_object->instances()[instance_id].shift;
|
||||
const size_t first_node = nodes.size();
|
||||
if (islands_chainable)
|
||||
for (size_t i = 0; i + 1 < islands.size(); ++i)
|
||||
if (!islands[i].by_region.empty()) {
|
||||
nodes.push_back({print_object->id(), instance_id, i,
|
||||
quantize_to_mm(obj_layer->lslices[i].contour.centroid() + shift)});
|
||||
node_instances.emplace_back(instance_idx);
|
||||
}
|
||||
if (nodes.size() == first_node) {
|
||||
// No chainable islands: tour the whole instance as one stop.
|
||||
nodes.push_back({print_object->id(), instance_id, size_t(-1), quantize_to_mm(shift)});
|
||||
node_instances.emplace_back(instance_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<const PrintInstance *> new_ordering = chain_print_object_instances(print_objects, &wt_pos);
|
||||
std::reverse(new_ordering.begin(), new_ordering.end());
|
||||
// Reuse the cached tour while this filament's island layout is unchanged.
|
||||
auto &cache_entry = m_ordering_cache[filament_id];
|
||||
if (!(cache_entry.first == nodes)) {
|
||||
cache_entry.first = nodes;
|
||||
Points node_points;
|
||||
node_points.reserve(nodes.size());
|
||||
for (const IslandOrderNode &node : nodes)
|
||||
node_points.emplace_back(node.pos);
|
||||
std::vector<size_t> tour = order_points_with_strategy(node_points, print.config().print_order, &wt_pos);
|
||||
// Chained starting near the wipe tower, reversed so the layer ends near it.
|
||||
std::reverse(tour.begin(), tour.end());
|
||||
|
||||
if (print.config().print_sequence == PrintSequence::ByObject) {
|
||||
filament_to_print_instances[filament_id] = sort_print_object_instances(objects_by_extruder_it->second, layers, ordering, single_object_instance_idx);
|
||||
} else {
|
||||
|
||||
// PrintSequence::ByLayer to use global ordering ( per object ordering ) if intra-layer order PrintOrder::AsObjectList is specified while keeping behaviour of PrintSequence::ByLayer
|
||||
const std::vector<const PrintInstance*>* ordering_for_filament = (print.config().print_order == PrintOrder::AsObjectList && ordering != nullptr) ? ordering: &new_ordering;
|
||||
filament_to_print_instances[filament_id] = sort_print_object_instances(objects_by_extruder_it->second, layers, ordering_for_filament, single_object_instance_idx);
|
||||
// Group consecutive tour stops of the same instance into visits.
|
||||
std::vector<InstanceVisit> visits;
|
||||
std::vector<bool> instance_seen(instances.size(), false);
|
||||
std::vector<int> last_visit_of_instance(instances.size(), -1);
|
||||
for (size_t node_idx : tour) {
|
||||
const size_t instance_idx = node_instances[node_idx];
|
||||
if (visits.empty() || visits.back().instance_idx != instance_idx) {
|
||||
visits.push_back({instance_idx, {}, !instance_seen[instance_idx]});
|
||||
instance_seen[instance_idx] = true;
|
||||
}
|
||||
if (nodes[node_idx].island_idx != size_t(-1))
|
||||
visits.back().islands.emplace_back(nodes[node_idx].island_idx);
|
||||
last_visit_of_instance[instance_idx] = int(visits.size()) - 1;
|
||||
}
|
||||
// The trailing catch-all island has no geometry to chain by; append it to the
|
||||
// instance's last visit.
|
||||
for (size_t i = 0; i < instances.size(); ++i) {
|
||||
if (last_visit_of_instance[i] < 0)
|
||||
continue;
|
||||
InstanceVisit &last_visit = visits[size_t(last_visit_of_instance[i])];
|
||||
if (last_visit.islands.empty())
|
||||
// A visit without explicit islands already prints everything.
|
||||
continue;
|
||||
std::vector<ObjectByExtruder::Island> &islands = instances[i].object_by_extruder.islands;
|
||||
if (!islands.back().by_region.empty())
|
||||
last_visit.islands.emplace_back(islands.size() - 1);
|
||||
}
|
||||
cache_entry.second = std::move(visits);
|
||||
}
|
||||
filament_plan.second = cache_entry.second;
|
||||
}
|
||||
}
|
||||
|
||||
std::set<size_t> layer_object_label_ids;
|
||||
for (auto iter = filament_to_print_instances.begin(); iter != filament_to_print_instances.end(); ++iter) {
|
||||
for (const InstanceToPrint &instance : iter->second) {
|
||||
for (const InstanceToPrint &instance : iter->second.first) {
|
||||
layer_object_label_ids.insert(instance.label_object_id);
|
||||
}
|
||||
}
|
||||
@@ -6015,7 +6168,7 @@ LayerResult GCode::process_layer(
|
||||
|
||||
if (print.config().print_sequence == PrintSequence::ByLayer && m_enable_exclude_object && print.config().support_object_skip_flush.value) {
|
||||
std::vector<size_t> filament_instances_id;
|
||||
for (InstanceToPrint &instance : filament_to_print_instances[extruder_id]) filament_instances_id.emplace_back(instance.label_object_id);
|
||||
for (InstanceToPrint &instance : filament_to_print_instances[extruder_id].first) filament_instances_id.emplace_back(instance.label_object_id);
|
||||
m_filament_instances_code = _encode_label_ids_to_base64(filament_instances_id);
|
||||
}
|
||||
|
||||
@@ -6096,7 +6249,9 @@ LayerResult GCode::process_layer(
|
||||
if (layer_tools.has_wipe_tower && m_wipe_tower)
|
||||
m_last_processor_extrusion_role = erWipeTower;
|
||||
|
||||
std::vector<InstanceToPrint> &instances_to_print = filament_to_print_instances[extruder_id];
|
||||
auto &filament_plan = filament_to_print_instances[extruder_id];
|
||||
std::vector<InstanceToPrint> &instances_to_print = filament_plan.first;
|
||||
const std::vector<InstanceVisit> &instance_visits = filament_plan.second;
|
||||
|
||||
// We are almost ready to print. However, we must go through all the objects twice to print the overridden extrusions first (infill/perimeter wiping feature):
|
||||
std::vector<ObjectByExtruder::Island::Region> by_region_per_copy_cache;
|
||||
@@ -6104,10 +6259,11 @@ LayerResult GCode::process_layer(
|
||||
if (is_anything_overridden && print_wipe_extrusions == 0)
|
||||
gcode+="; PURGING FINISHED\n";
|
||||
|
||||
for (InstanceToPrint &instance_to_print : instances_to_print) {
|
||||
for (const InstanceVisit &visit : instance_visits) {
|
||||
InstanceToPrint &instance_to_print = instances_to_print[visit.instance_idx];
|
||||
const auto& inst = instance_to_print.print_object.instances()[instance_to_print.instance_id];
|
||||
const LayerToPrint &layer_to_print = layers[instance_to_print.layer_id];
|
||||
if (print_wipe_extrusions == (is_anything_overridden ? 1 : 0)) {
|
||||
if (visit.first_visit && print_wipe_extrusions == (is_anything_overridden ? 1 : 0)) {
|
||||
gcode += generate_object_skirt_group(print, instance_to_print.print_object, instance_to_print.instance_id, layer_tools, layer, extruder_id);
|
||||
gcode += generate_object_brim(print, instance_to_print.print_object, instance_to_print.instance_id, first_layer);
|
||||
}
|
||||
@@ -6160,7 +6316,7 @@ LayerResult GCode::process_layer(
|
||||
m_avoid_crossing_perimeters.use_external_mp_once();
|
||||
m_last_obj_copy = this_object_copy;
|
||||
this->set_origin(unscale(offset));
|
||||
if (instance_to_print.object_by_extruder.support != nullptr) {
|
||||
if (visit.first_visit && instance_to_print.object_by_extruder.support != nullptr) {
|
||||
m_layer = layers[instance_to_print.layer_id].support_layer;
|
||||
m_object_layer_over_raft = false;
|
||||
|
||||
@@ -6194,9 +6350,42 @@ LayerResult GCode::process_layer(
|
||||
m_layer = layer_to_print.layer();
|
||||
m_object_layer_over_raft = object_layer_over_raft;
|
||||
}
|
||||
//FIXME order islands?
|
||||
// Sequential tool path ordering of multiple parts within the same object, aka. perimeter tracking (#5511)
|
||||
for (ObjectByExtruder::Island &island : instance_to_print.object_by_extruder.islands) {
|
||||
// Island print order. Use the islands the tour assigned to this visit; if none,
|
||||
// chain all islands nearest-neighbor from the current nozzle position (last_pos(),
|
||||
// in this instance's frame after set_origin() above). Empty islands are skipped;
|
||||
// the trailing catch-all island has no centroid to chain by and always goes last.
|
||||
std::vector<ObjectByExtruder::Island> &islands = instance_to_print.object_by_extruder.islands;
|
||||
std::vector<size_t> island_order = visit.islands;
|
||||
if (island_order.empty()) {
|
||||
island_order.reserve(islands.size());
|
||||
if (layer_to_print.object_layer != nullptr && islands.size() == layer_to_print.object_layer->lslices.size() + 1) {
|
||||
for (size_t i = 0; i + 1 < islands.size(); ++i)
|
||||
if (!islands[i].by_region.empty())
|
||||
island_order.emplace_back(i);
|
||||
if (island_order.size() > 1) {
|
||||
Points island_centroids;
|
||||
island_centroids.reserve(island_order.size());
|
||||
for (size_t i : island_order)
|
||||
island_centroids.emplace_back(layer_to_print.object_layer->lslices[i].contour.centroid());
|
||||
const Point start_near = this->last_pos();
|
||||
std::vector<size_t> chain = chain_points(island_centroids, this->last_pos_defined() ? &start_near : nullptr);
|
||||
std::vector<size_t> ordered;
|
||||
ordered.reserve(island_order.size());
|
||||
for (size_t k : chain)
|
||||
ordered.emplace_back(island_order[k]);
|
||||
island_order = std::move(ordered);
|
||||
}
|
||||
if (!islands.back().by_region.empty())
|
||||
island_order.emplace_back(islands.size() - 1);
|
||||
} else {
|
||||
// Unexpected islands layout, keep the stored order.
|
||||
for (size_t i = 0; i < islands.size(); ++i)
|
||||
island_order.emplace_back(i);
|
||||
}
|
||||
}
|
||||
for (size_t island_idx : island_order) {
|
||||
ObjectByExtruder::Island &island = islands[island_idx];
|
||||
const auto& by_region_specific = is_anything_overridden ? island.by_region_per_copy(by_region_per_copy_cache, static_cast<unsigned int>(instance_to_print.instance_id), extruder_id, print_wipe_extrusions != 0) : island.by_region;
|
||||
// When starting a new object, use the external motion planner for the first travel move.
|
||||
const Point& offset = instance_to_print.print_object.instances()[instance_to_print.instance_id].shift;
|
||||
@@ -7482,7 +7671,10 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||
bool variable_speed = false;
|
||||
std::vector<ProcessedPoint> new_points {};
|
||||
|
||||
if (NOZZLE_CONFIG(enable_overhang_speed) && !this->on_first_layer() && !object_layer_over_raft() &&
|
||||
const bool need_overhang_detection = NOZZLE_CONFIG(enable_overhang_speed) ||
|
||||
(FILAMENT_CONFIG(enable_overhang_bridge_fan) && m_enable_cooling_markers);
|
||||
|
||||
if (need_overhang_detection && !this->on_first_layer() && !object_layer_over_raft() &&
|
||||
(is_bridge(path.role()) || is_perimeter(path.role()))) {
|
||||
bool is_external = is_external_perimeter(path.role());
|
||||
double ref_speed = is_external ? NOZZLE_CONFIG(outer_wall_speed) : NOZZLE_CONFIG(inner_wall_speed);
|
||||
@@ -7541,6 +7733,11 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
|
||||
}
|
||||
variable_speed = std::any_of(new_points.begin(), new_points.end(),
|
||||
[speed](const ProcessedPoint &p) { return fabs(double(p.speed) - speed) > 1; }); // Ignore small speed variations (under 1mm/sec)
|
||||
if (!NOZZLE_CONFIG(enable_overhang_speed) && FILAMENT_CONFIG(enable_overhang_bridge_fan) && m_enable_cooling_markers) {
|
||||
for (ProcessedPoint &point : new_points)
|
||||
point.speed = speed;
|
||||
variable_speed = new_points.size() > 1;
|
||||
}
|
||||
}
|
||||
|
||||
double F = speed * 60; // convert mm/sec to mm/min
|
||||
@@ -8153,29 +8350,22 @@ std::string GCode::extrusion_role_to_string_for_parser(const ExtrusionRole & rol
|
||||
}
|
||||
|
||||
// Calculate the interpolated value for the current layer between start_value and end_value.
|
||||
// Step will create equal layers steps from first to last value.
|
||||
// Step > 0 splits the range into equal-width bands from first to last value (both inclusive).
|
||||
// Step = 0 means gradual interpolation finishing at last value.
|
||||
float GCode::interpolate_value_across_layers(float start_value, float end_value, float step) const
|
||||
{
|
||||
if (m_layer_index <= 1) {
|
||||
return start_value;
|
||||
}
|
||||
else {
|
||||
bool use_steps = step > 0.f;
|
||||
if (use_steps) {
|
||||
if (start_value > end_value) {
|
||||
start_value += step;
|
||||
} else {
|
||||
end_value += step;
|
||||
}
|
||||
}
|
||||
float ratio = m_layer_index / (m_layer_count - 1.f);
|
||||
float value = start_value + ratio * (end_value - start_value);
|
||||
if (use_steps) {
|
||||
value = trunc(value / step) * step;
|
||||
}
|
||||
return value;
|
||||
const float ratio = m_layer_index / (m_layer_count - 1.f);
|
||||
if (step > 0.f) {
|
||||
// Discrete equal-width bands. band is clamped to the last band so the result can't overshoot the range:
|
||||
// at the top layer ratio * n_bands == n_bands, which would otherwise index one band past the end.
|
||||
const int n_bands = std::lround(std::abs(end_value - start_value) / step) + 1;
|
||||
const int band = std::min(n_bands - 1, static_cast<int>(ratio * n_bands));
|
||||
return start_value + (end_value >= start_value ? 1.f : -1.f) * band * step;
|
||||
}
|
||||
return start_value + ratio * (end_value - start_value);
|
||||
}
|
||||
|
||||
std::string encodeBase64(uint64_t value)
|
||||
|
||||
@@ -539,6 +539,40 @@ private:
|
||||
// Cache for custom seam enforcers/blockers for each layer.
|
||||
SeamPlacer m_seam_placer;
|
||||
|
||||
// One stop of the island-level tour: consecutive islands of a single instance. An instance
|
||||
// can have several visits per layer when its islands are toured non-consecutively.
|
||||
struct InstanceVisit
|
||||
{
|
||||
// Index into the per-filament InstanceToPrint vector.
|
||||
size_t instance_idx;
|
||||
// Islands to print, in order (indices into ObjectByExtruder::islands). Empty: print all
|
||||
// islands, ordered at extrusion time.
|
||||
std::vector<size_t> islands;
|
||||
// First visit of this instance this layer; skirt, brim and support are emitted here.
|
||||
bool first_visit;
|
||||
};
|
||||
|
||||
// One node of the island-level tour, also used as cache key: identity plus quantized position.
|
||||
struct IslandOrderNode
|
||||
{
|
||||
ObjectID object_id;
|
||||
size_t instance_id;
|
||||
// Index into ObjectByExtruder::islands, or size_t(-1) for an instance without chainable
|
||||
// islands (e.g. support only), which is toured as a single stop.
|
||||
size_t island_idx;
|
||||
// Island centroid in G-code coordinates, quantized to 1 mm for cache stability.
|
||||
Point pos;
|
||||
bool operator==(const IslandOrderNode &rhs) const {
|
||||
return object_id == rhs.object_id && instance_id == rhs.instance_id &&
|
||||
island_idx == rhs.island_idx && pos == rhs.pos;
|
||||
}
|
||||
};
|
||||
|
||||
// Cache the per-filament island tour to avoid recomputing while the layer's island layout is
|
||||
// unchanged. Key: filament_id. Value: {nodes the tour was computed from, resulting visits}.
|
||||
std::map<unsigned int, std::pair<std::vector<IslandOrderNode>, std::vector<InstanceVisit>>>
|
||||
m_ordering_cache;
|
||||
|
||||
ExtrusionQualityEstimator m_extrusion_quality_estimator;
|
||||
|
||||
|
||||
|
||||
@@ -844,7 +844,10 @@ std::string CoolingBuffer::apply_layer_cooldown(
|
||||
ironing_fan_control = false; // ORCA: Add support for ironing fan speed control
|
||||
ironing_fan_speed = 0; // ORCA: Add support for ironing fan speed control
|
||||
}
|
||||
if (fan_speed_new != m_fan_speed) {
|
||||
// A tool change may keep the same configured base fan speed while the physical fan is
|
||||
// still running at the previous filament's overhang speed. Restore the base speed before
|
||||
// emitting G-code for the new tool in that case.
|
||||
if (fan_speed_new != m_fan_speed || (immediately_apply && m_current_fan_speed != fan_speed_new)) {
|
||||
m_fan_speed = fan_speed_new;
|
||||
m_current_fan_speed = fan_speed_new;
|
||||
if (immediately_apply)
|
||||
@@ -1040,8 +1043,10 @@ std::string CoolingBuffer::apply_layer_cooldown(
|
||||
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, m_current_fan_speed, part_cooling_fan_min_pwm);
|
||||
fan_speed_change_requests[CoolingLine::TYPE_FORCE_RESUME_FAN] = false;
|
||||
}
|
||||
else
|
||||
else {
|
||||
new_gcode += GCodeWriter::set_fan(m_config.gcode_flavor, m_fan_speed, part_cooling_fan_min_pwm);
|
||||
m_current_fan_speed = m_fan_speed;
|
||||
}
|
||||
need_set_fan = false;
|
||||
}
|
||||
pos = line_end;
|
||||
|
||||
@@ -614,6 +614,8 @@ void GCodeProcessor::TimeMachine::calculate_time(GCodeProcessorResult& result, P
|
||||
float leftover = 0.0f;
|
||||
for (size_t i = additional_buffer_idx; i < additional_buffer.size(); ++i)
|
||||
leftover += additional_buffer[i].second;
|
||||
BOOST_LOG_TRIVIAL(debug) << "calculate_time(is_final): leftover=" << leftover
|
||||
<< "s from " << (additional_buffer.size() - additional_buffer_idx) << " items";
|
||||
time += double(leftover);
|
||||
gcode_time.cache += leftover;
|
||||
} else {
|
||||
@@ -3492,6 +3494,7 @@ void GCodeProcessor::reset()
|
||||
m_extruder_blocks.clear();
|
||||
m_machine_start_gcode_end_line_id = (unsigned int) (-1);
|
||||
m_machine_end_gcode_start_line_id = (unsigned int) (-1);
|
||||
m_skip_end_gcode_delays = false;
|
||||
m_remaining_volume = std::vector<float>(MAXIMUM_EXTRUDER_NUMBER, 0.f);
|
||||
|
||||
m_line_id = 0;
|
||||
@@ -4219,6 +4222,14 @@ void GCodeProcessor::process_tags(const std::string_view comment, bool producers
|
||||
return;
|
||||
}
|
||||
|
||||
// End gcode marker: skip post-print M400 S/P dwells after this point so the M73 estimate reports
|
||||
// print-completion time, not post-print filtration/cooldown. BBS drops the same remainder in
|
||||
// calculate_time(is_final).
|
||||
if (comment == Machine_End_GCode_Start_Tag) {
|
||||
m_skip_end_gcode_delays = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Orca: Integrate filament consumption for purging performed to an external device and controlled via macros
|
||||
// (eg. Happy Hare) in the filament consumption stats.
|
||||
if (boost::starts_with(comment, GCodeProcessor::External_Purge_Tag)) {
|
||||
@@ -6401,6 +6412,10 @@ void GCodeProcessor::process_M400(const GCodeReader::GCodeLine& line)
|
||||
float value_p = 0.0;
|
||||
if (line.has_value('S', value_s) || line.has_value('P', value_p)) {
|
||||
value_s += value_p * 0.001;
|
||||
// Skip post-print end-gcode dwells so they don't inflate the M73 estimate (see
|
||||
// m_skip_end_gcode_delays). Only omits dwell time — no state is updated here.
|
||||
if (m_skip_end_gcode_delays)
|
||||
return;
|
||||
simulate_st_synchronize(value_s);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1109,6 +1109,10 @@ class Print;
|
||||
std::vector<ExtruderPreHeating::ExtruderUsageBlcok> m_extruder_blocks;
|
||||
unsigned int m_machine_start_gcode_end_line_id{ (unsigned int) (-1) };
|
||||
unsigned int m_machine_end_gcode_start_line_id{ (unsigned int) (-1) };
|
||||
// Set when the MACHINE_END_GCODE_START tag is seen during the streaming parse; tells
|
||||
// process_M400 to skip post-print end-gcode dwells (air purification, timelapse, sound)
|
||||
// so they don't inflate the M73 estimate. BBS excludes them in calculate_time(is_final).
|
||||
bool m_skip_end_gcode_delays{ false };
|
||||
// Tracks, during the stream, which filament sits in each physical nozzle and which nozzle each
|
||||
// extruder currently carries. Written by both branches of the two-arg process_filament_change
|
||||
// (the fallback branch does occupancy bookkeeping only); read by the richer change-time model
|
||||
|
||||
@@ -0,0 +1,435 @@
|
||||
// Print-object ordering strategies: implementation.
|
||||
// Consolidates TSP post-processing, Snake, and Best-of-Strategies.
|
||||
|
||||
#include "OrderingStrategies.hpp"
|
||||
#include "../Geometry.hpp"
|
||||
#include "../ShortestPath.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <limits>
|
||||
#include <numeric>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
/* ====================================================================
|
||||
* TSP post-processing utilities
|
||||
* ==================================================================== */
|
||||
|
||||
bool tsp_2opt_improve(std::vector<size_t>& path, const Points& centers, int max_passes)
|
||||
{
|
||||
size_t pn = path.size();
|
||||
if (pn <= 2) return false;
|
||||
|
||||
// Pre-compute edge lengths once per pass to avoid redundant norm() calls.
|
||||
auto recompute_edges = [&]() {
|
||||
std::vector<double> el(pn);
|
||||
for (size_t i = 0; i < pn; ++i) {
|
||||
size_t ni = (i + 1) % pn;
|
||||
el[i] = (centers[path[i]].cast<double>() - centers[path[ni]].cast<double>()).norm();
|
||||
}
|
||||
return el;
|
||||
};
|
||||
std::vector<double> el = recompute_edges();
|
||||
|
||||
// Pre-compute squared edge lengths for early rejection in the inner loop.
|
||||
auto recompute_edges_sq = [&]() {
|
||||
std::vector<double> elsq(pn);
|
||||
for (size_t i = 0; i < pn; ++i) {
|
||||
size_t ni = (i + 1) % pn;
|
||||
elsq[i] = (centers[path[i]].cast<double>() - centers[path[ni]].cast<double>()).squaredNorm();
|
||||
}
|
||||
return elsq;
|
||||
};
|
||||
std::vector<double> elsq = recompute_edges_sq();
|
||||
|
||||
bool improved = false;
|
||||
for (int pass = 0; max_passes <= 0 || pass < max_passes; ++pass) {
|
||||
size_t best_i = pn, best_j = pn;
|
||||
double best_gain = 0;
|
||||
|
||||
for (size_t i = 0; i < pn; ++i) {
|
||||
const Vec2d& pi = centers[path[i]].cast<double>();
|
||||
const Vec2d& p_in = centers[path[(i + 1) % pn]].cast<double>();
|
||||
double d_i = el[i];
|
||||
double d_i_sq = elsq[i];
|
||||
|
||||
for (size_t j = i + 2; j < pn; ++j) {
|
||||
size_t j_next = (j + 1) % pn;
|
||||
// Skip the swap that would reverse the entire cycle (removes both
|
||||
// edges (0,1) and (pn-1,0), equivalent to traversing the cycle backwards).
|
||||
if (i == 0 && j_next == 0) continue;
|
||||
|
||||
const Vec2d& pj = centers[path[j]].cast<double>();
|
||||
const Vec2d& p_jn = centers[path[j_next]].cast<double>();
|
||||
double d_j = el[j];
|
||||
|
||||
// Early rejection using squared distances (avoids 2 sqrt calls).
|
||||
double new_a_sq = (pj - pi).squaredNorm();
|
||||
double new_b_sq = (p_jn - p_in).squaredNorm();
|
||||
if (new_a_sq >= d_i_sq && new_b_sq >= elsq[j]) continue;
|
||||
|
||||
double new_a = std::sqrt(new_a_sq);
|
||||
double new_b = std::sqrt(new_b_sq);
|
||||
double gain = d_i + d_j - new_a - new_b;
|
||||
|
||||
if (gain > best_gain) {
|
||||
best_gain = gain;
|
||||
best_i = i; best_j = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (best_i == pn) break;
|
||||
improved = true;
|
||||
// Reverse the best swap segment
|
||||
std::reverse(path.begin() + best_i + 1, path.begin() + best_j + 1);
|
||||
|
||||
// Recompute edge lengths after reversal
|
||||
el = recompute_edges();
|
||||
elsq = recompute_edges_sq();
|
||||
}
|
||||
return improved;
|
||||
}
|
||||
|
||||
// Fast bounding-box overlap test (rejects most non-intersecting pairs).
|
||||
static inline bool bboxes_overlap(const Point& a, const Point& b, const Point& c, const Point& d)
|
||||
{
|
||||
return !(std::max(a.x(), b.x()) < std::min(c.x(), d.x()) ||
|
||||
std::max(c.x(), d.x()) < std::min(a.x(), b.x()) ||
|
||||
std::max(a.y(), b.y()) < std::min(c.y(), d.y()) ||
|
||||
std::max(c.y(), d.y()) < std::min(a.y(), b.y()));
|
||||
}
|
||||
|
||||
bool tsp_remove_crossings(std::vector<size_t>& path, const Points& centers)
|
||||
{
|
||||
size_t pn = path.size();
|
||||
if (pn <= 3) return false;
|
||||
|
||||
// Treat path as a cycle: include the closing edge (pn-1 -> 0), consistent with the other
|
||||
// TSP helpers (2-opt, closing-edge rotation) that operate on the full cycle.
|
||||
size_t n_edges = pn;
|
||||
|
||||
// Scan for first crossing; returns {i, j} or {npos, npos} if none.
|
||||
auto find_crossing = [&]() -> std::pair<size_t, size_t> {
|
||||
for (size_t i = 0; i < n_edges; ++i) {
|
||||
const Point& ai = centers[path[i]];
|
||||
const Point& bi = centers[path[(i + 1) % pn]];
|
||||
|
||||
for (size_t j = i + 2; j < n_edges; ++j) {
|
||||
// Skip the (0, pn-1) pair: edges (0,1) and (pn-1,0) share node 0.
|
||||
if (i == 0 && j == pn - 1) continue;
|
||||
|
||||
const Point& aj = centers[path[j]];
|
||||
const Point& bj = centers[path[(j + 1) % pn]];
|
||||
|
||||
if (!bboxes_overlap(ai, bi, aj, bj)) continue;
|
||||
if (Geometry::segments_intersect(ai, bi, aj, bj))
|
||||
return {i, j};
|
||||
}
|
||||
}
|
||||
return {std::numeric_limits<size_t>::max(), std::numeric_limits<size_t>::max()};
|
||||
};
|
||||
|
||||
// Process crossings one at a time: find first, reverse it, restart scan.
|
||||
// Cap iterations to prevent infinite loops on collinear/overlapping segments.
|
||||
int max_iters = static_cast<int>(pn * pn);
|
||||
bool improved = false;
|
||||
while (max_iters-- > 0) {
|
||||
auto [ci, cj] = find_crossing();
|
||||
if (ci == std::numeric_limits<size_t>::max()) break;
|
||||
improved = true;
|
||||
std::reverse(path.begin() + ci + 1, path.begin() + cj + 1);
|
||||
}
|
||||
return improved;
|
||||
}
|
||||
|
||||
void tsp_rotate_minimize_closing(std::vector<size_t>& path, const Points& centers)
|
||||
{
|
||||
size_t pn = path.size();
|
||||
size_t best_start = 0;
|
||||
double best_closing2 = std::numeric_limits<double>::max();
|
||||
for (size_t start = 0; start < pn; ++start) {
|
||||
size_t last = (start + pn - 1) % pn;
|
||||
double d2 = (centers[path[start]].cast<double>() - centers[path[last]].cast<double>()).squaredNorm();
|
||||
if (d2 < best_closing2) { best_closing2 = d2; best_start = start; }
|
||||
}
|
||||
std::rotate(path.begin(), path.begin() + best_start, path.end());
|
||||
}
|
||||
|
||||
/* ====================================================================
|
||||
* Snake ordering
|
||||
* ==================================================================== */
|
||||
|
||||
struct SnakeRow { double avg_y; std::vector<size_t> indices; };
|
||||
|
||||
// --- Row threshold computation ---
|
||||
// Extract unique Y values and use the median gap between them to determine
|
||||
// the row threshold.
|
||||
static double compute_row_threshold(const std::vector<double>& sorted_ys,
|
||||
double y_min, double y_max,
|
||||
size_t n,
|
||||
double fraction_of_y_range,
|
||||
double min_threshold_um)
|
||||
{
|
||||
constexpr double MIN_GAP_FILTER = 1.0; // ignore sub-micron gaps (coord_t = 1/100mm)
|
||||
|
||||
// Extract unique Y values
|
||||
std::vector<double> unique_ys;
|
||||
unique_ys.reserve(sorted_ys.size());
|
||||
unique_ys.push_back(sorted_ys[0]);
|
||||
for (size_t i = 1; i < sorted_ys.size(); ++i) {
|
||||
if (sorted_ys[i] - sorted_ys[i - 1] > MIN_GAP_FILTER)
|
||||
unique_ys.push_back(sorted_ys[i]);
|
||||
}
|
||||
|
||||
double fallback_threshold = (y_max - y_min) * fraction_of_y_range;
|
||||
if (unique_ys.size() <= 1) {
|
||||
return std::max(fallback_threshold, min_threshold_um);
|
||||
}
|
||||
|
||||
// Compute gaps between consecutive unique Y values
|
||||
std::vector<double> gaps;
|
||||
gaps.reserve(unique_ys.size() - 1);
|
||||
for (size_t i = 1; i < unique_ys.size(); ++i)
|
||||
gaps.push_back(unique_ys[i] - unique_ys[i - 1]);
|
||||
|
||||
if (gaps.empty()) {
|
||||
return std::max(fallback_threshold, min_threshold_um);
|
||||
}
|
||||
|
||||
// Sort gaps to find the median
|
||||
std::sort(gaps.begin(), gaps.end());
|
||||
double median_gap = gaps[gaps.size() / 2];
|
||||
double min_gap = gaps.front();
|
||||
|
||||
// Threshold: half the gap between consecutive unique Y values.
|
||||
double threshold = (median_gap < min_gap * 1.5) ? min_gap * 0.5 : median_gap * 0.5;
|
||||
|
||||
bool has_row_structure;
|
||||
if (unique_ys.size() * 2 <= n) {
|
||||
has_row_structure = true;
|
||||
} else {
|
||||
// Single-column or sparse: uniform gaps indicate a deliberate grid
|
||||
double max_gap = *std::max_element(gaps.begin(), gaps.end());
|
||||
has_row_structure = (max_gap < min_gap * 2.0);
|
||||
}
|
||||
|
||||
if (has_row_structure) {
|
||||
// For grid-like data, use the gap-based threshold directly.
|
||||
return threshold;
|
||||
}
|
||||
|
||||
return std::max(fallback_threshold, min_threshold_um);
|
||||
}
|
||||
|
||||
// --- Row grouping ---
|
||||
// Bin points into rows by quantising Y / threshold
|
||||
static std::vector<SnakeRow> group_into_rows(const Points& centers, double row_threshold)
|
||||
{
|
||||
size_t n = centers.size();
|
||||
std::unordered_map<int64_t, std::vector<size_t>> row_map;
|
||||
for (size_t i = 0; i < n; ++i) {
|
||||
int64_t y_key = static_cast<int64_t>(std::floor(static_cast<double>(centers[i].y()) / row_threshold));
|
||||
row_map[y_key].push_back(i);
|
||||
}
|
||||
|
||||
std::vector<SnakeRow> rows;
|
||||
rows.reserve(row_map.size());
|
||||
for (auto& [key, indices] : row_map) {
|
||||
double avg_y = std::accumulate(indices.begin(), indices.end(), 0.0,
|
||||
[&](double acc, size_t idx) { return acc + static_cast<double>(centers[idx].y()); })
|
||||
/ indices.size();
|
||||
rows.push_back({avg_y, std::move(indices)});
|
||||
}
|
||||
|
||||
std::sort(rows.begin(), rows.end(),
|
||||
[](const SnakeRow& a, const SnakeRow& b) { return a.avg_y < b.avg_y; });
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
// Sort each row by X and greedily pick the direction (left->right or right->left)
|
||||
// that minimises the transition distance from the previous row's endpoint.
|
||||
static std::vector<size_t> build_serpentine_path(const Points& centers,
|
||||
std::vector<SnakeRow>& rows)
|
||||
{
|
||||
std::vector<size_t> path;
|
||||
path.reserve(centers.size());
|
||||
|
||||
for (size_t ri = 0; ri < rows.size(); ++ri) {
|
||||
auto& row = rows[ri].indices;
|
||||
std::sort(row.begin(), row.end(),
|
||||
[&](size_t a, size_t b) { return centers[a].x() < centers[b].x(); });
|
||||
|
||||
if (ri == 0) {
|
||||
path.insert(path.end(), row.begin(), row.end());
|
||||
} else {
|
||||
const Point& prev_end = centers[path.back()];
|
||||
double dist_to_left = (prev_end.cast<double>() - centers[row.front()].cast<double>()).squaredNorm();
|
||||
double dist_to_right = (prev_end.cast<double>() - centers[row.back()].cast<double>()).squaredNorm();
|
||||
|
||||
if (dist_to_left <= dist_to_right)
|
||||
path.insert(path.end(), row.begin(), row.end());
|
||||
else
|
||||
path.insert(path.end(), row.rbegin(), row.rend());
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
// Row-based serpentine traversal: detect rows, bin points, snake through them.
|
||||
static std::vector<size_t> row_serpentine_path(const Points& centers,
|
||||
double fraction_of_y_range = 0.02,
|
||||
double min_threshold_um = 1e4)
|
||||
{
|
||||
if (centers.empty()) return {};
|
||||
|
||||
size_t n = centers.size();
|
||||
|
||||
// Collect and sort Y coordinates.
|
||||
std::vector<double> sorted_ys;
|
||||
sorted_ys.reserve(n);
|
||||
for (const auto& p : centers) sorted_ys.push_back(static_cast<double>(p.y()));
|
||||
std::sort(sorted_ys.begin(), sorted_ys.end());
|
||||
|
||||
auto [ymin, ymax] = std::minmax_element(sorted_ys.begin(), sorted_ys.end());
|
||||
double y_min = *ymin, y_max = *ymax;
|
||||
|
||||
double row_threshold = compute_row_threshold(sorted_ys, y_min, y_max, n,
|
||||
fraction_of_y_range, min_threshold_um);
|
||||
|
||||
auto rows = group_into_rows(centers, row_threshold);
|
||||
return build_serpentine_path(centers, rows);
|
||||
}
|
||||
|
||||
std::vector<size_t> snake_core(const Points& centers)
|
||||
{
|
||||
if (centers.empty()) return {};
|
||||
|
||||
std::vector<size_t> path = row_serpentine_path(centers);
|
||||
|
||||
for (int iter = 0; iter < 3; ++iter) {
|
||||
bool improved = tsp_2opt_improve(path, centers);
|
||||
improved |= tsp_remove_crossings(path, centers);
|
||||
if (!improved) break;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
std::vector<const PrintInstance*> chain_print_object_instances_snake(const std::vector<const PrintObject*>& print_objects, const Point* start_near)
|
||||
{
|
||||
return chain_instances_with_core(print_objects, start_near, snake_core);
|
||||
}
|
||||
|
||||
std::vector<const PrintInstance*> chain_print_object_instances_snake(const Print& print)
|
||||
{
|
||||
return chain_print_object_instances_snake(print.objects().vector(), nullptr);
|
||||
}
|
||||
|
||||
/* ====================================================================
|
||||
* Best-of-strategies meta-strategy
|
||||
* ==================================================================== */
|
||||
|
||||
std::vector<const PrintInstance*> chain_print_object_instances_best_of(const std::vector<const PrintObject*>& print_objects, const Point* start_near)
|
||||
{
|
||||
if (print_objects.empty())
|
||||
return {};
|
||||
|
||||
// Run all strategies.
|
||||
std::vector<std::vector<const PrintInstance*>> candidates;
|
||||
candidates.push_back(chain_print_object_instances(print_objects, start_near));
|
||||
candidates.push_back(chain_print_object_instances_snake(print_objects, start_near));
|
||||
|
||||
// Compute metrics for each candidate.
|
||||
struct Candidate { double total_len; double max_edge; };
|
||||
std::vector<Candidate> metrics;
|
||||
metrics.reserve(candidates.size());
|
||||
|
||||
for (size_t i = 0; i < candidates.size(); ++i) {
|
||||
double total = 0.0;
|
||||
double mx = 0.0;
|
||||
for (size_t j = 0; j < candidates[i].size(); ++j) {
|
||||
size_t k = (j + 1) % candidates[i].size();
|
||||
double d = (candidates[i][j]->shift.cast<double>() - candidates[i][k]->shift.cast<double>()).norm();
|
||||
total += d;
|
||||
if (d > mx) mx = d;
|
||||
}
|
||||
metrics.push_back({total, mx});
|
||||
}
|
||||
|
||||
// Pick shortest total path; tiebreak on smallest max edge.
|
||||
auto best_it = std::min_element(metrics.begin(), metrics.end(),
|
||||
[](const Candidate& a, const Candidate& b) {
|
||||
return a.total_len < b.total_len ||
|
||||
(a.total_len == b.total_len && a.max_edge < b.max_edge);
|
||||
});
|
||||
size_t best = static_cast<size_t>(std::distance(metrics.begin(), best_it));
|
||||
|
||||
return candidates[best];
|
||||
}
|
||||
|
||||
std::vector<const PrintInstance*> chain_print_object_instances_best_of(const Print& print)
|
||||
{
|
||||
return chain_print_object_instances_best_of(print.objects().vector(), nullptr);
|
||||
}
|
||||
|
||||
/* ====================================================================
|
||||
* Island-level ordering entry point
|
||||
* ==================================================================== */
|
||||
|
||||
std::vector<size_t> order_points_with_strategy(const Points& points, PrintOrder print_order, const Point* start_near)
|
||||
{
|
||||
if (points.empty())
|
||||
return {};
|
||||
|
||||
if (print_order != PrintOrder::Snake && print_order != PrintOrder::BestOfStrategies)
|
||||
// Nearest neighbor + post-processing; honours start_near natively.
|
||||
return chain_points_with_postprocessing(points, start_near);
|
||||
|
||||
auto run_snake = [&points, start_near]() {
|
||||
std::vector<size_t> path = snake_core(points);
|
||||
if (start_near != nullptr && !path.empty()) {
|
||||
// Start the cycle at the point closest to start_near.
|
||||
size_t best_start = 0;
|
||||
double best_d2 = std::numeric_limits<double>::max();
|
||||
for (size_t k = 0; k < points.size(); ++k) {
|
||||
double d2 = (points[k].cast<double>() - start_near->cast<double>()).squaredNorm();
|
||||
if (d2 < best_d2) { best_d2 = d2; best_start = k; }
|
||||
}
|
||||
auto it = std::find(path.begin(), path.end(), best_start);
|
||||
if (it != path.begin() && it != path.end())
|
||||
std::rotate(path.begin(), it, path.end());
|
||||
} else {
|
||||
tsp_rotate_minimize_closing(path, points);
|
||||
}
|
||||
return path;
|
||||
};
|
||||
|
||||
if (print_order == PrintOrder::Snake)
|
||||
return run_snake();
|
||||
|
||||
// Best-of: pick the shortest total cycle; tiebreak on smallest max edge.
|
||||
std::vector<std::vector<size_t>> candidates;
|
||||
candidates.emplace_back(chain_points_with_postprocessing(points, start_near));
|
||||
candidates.emplace_back(run_snake());
|
||||
|
||||
size_t best = 0;
|
||||
double best_len = std::numeric_limits<double>::max();
|
||||
double best_edge = std::numeric_limits<double>::max();
|
||||
for (size_t i = 0; i < candidates.size(); ++i) {
|
||||
double len = tsp_cycle_path_length(candidates[i], points);
|
||||
double edge = tsp_max_edge_length(candidates[i], points);
|
||||
if (len < best_len || (len == best_len && edge < best_edge)) {
|
||||
best_len = len; best_edge = edge; best = i;
|
||||
}
|
||||
}
|
||||
return candidates[best];
|
||||
}
|
||||
|
||||
} // namespace Slic3r
|
||||
@@ -0,0 +1,148 @@
|
||||
// Print-object ordering strategies and shared TSP post-processing utilities.
|
||||
|
||||
#ifndef slic3r_OrderingStrategies_hpp_
|
||||
#define slic3r_OrderingStrategies_hpp_
|
||||
|
||||
#include "../libslic3r.h"
|
||||
#include "../Point.hpp"
|
||||
|
||||
#ifndef SLIC3R_TEST_HARNESS
|
||||
#include "../Print.hpp"
|
||||
#endif
|
||||
|
||||
#include <algorithm>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
// --- Path improvement (operate on index vectors into `centers`) ---
|
||||
|
||||
// 2-opt improvement: reverses segments that reduce total cycle path length.
|
||||
// Returns true if any improvement was made.
|
||||
bool tsp_2opt_improve(std::vector<size_t>& path, const Points& centers, int max_passes = 10);
|
||||
|
||||
// Crossing removal: reverse any segment pair whose edges geometrically cross.
|
||||
// Returns true if any crossing was removed.
|
||||
bool tsp_remove_crossings(std::vector<size_t>& path, const Points& centers);
|
||||
|
||||
// Rotate the cycle so the closing edge (last -> first) is minimized.
|
||||
void tsp_rotate_minimize_closing(std::vector<size_t>& path, const Points& centers);
|
||||
|
||||
// Total Euclidean path length of a cycle (including closing edge).
|
||||
inline double tsp_cycle_path_length(const std::vector<size_t>& path, const Points& centers)
|
||||
{
|
||||
if (path.size() < 2) return 0.0;
|
||||
double total = 0.0;
|
||||
for (size_t i = 0; i < path.size(); ++i) {
|
||||
size_t next = (i + 1) % path.size();
|
||||
total += (centers[path[i]].cast<double>() - centers[path[next]].cast<double>()).norm();
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
// Maximum edge length of a cycle (including closing edge).
|
||||
inline double tsp_max_edge_length(const std::vector<size_t>& path, const Points& centers)
|
||||
{
|
||||
if (path.size() < 2) return 0.0;
|
||||
double mx = 0.0;
|
||||
for (size_t i = 0; i < path.size(); ++i) {
|
||||
size_t next = (i + 1) % path.size();
|
||||
double d = (centers[path[i]].cast<double>() - centers[path[next]].cast<double>()).norm();
|
||||
if (d > mx) mx = d;
|
||||
}
|
||||
return mx;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifndef SLIC3R_TEST_HARNESS
|
||||
|
||||
// --- Wrapper boilerplate ---
|
||||
|
||||
// Collect instance centers from PrintObjects, optionally pre-rotate to honour
|
||||
// start_near, call a core algorithm, and map the result back to PrintInstance*.
|
||||
template<typename CoreFn>
|
||||
std::vector<const PrintInstance*> chain_instances_with_core(
|
||||
const std::vector<const PrintObject*>& print_objects,
|
||||
const Point* start_near,
|
||||
CoreFn&& core_fn)
|
||||
{
|
||||
Points instance_centers;
|
||||
std::vector<std::pair<size_t, size_t>> instances;
|
||||
for (size_t i = 0; i < print_objects.size(); ++i) {
|
||||
const PrintObject& object = *print_objects[i];
|
||||
for (size_t j = 0; j < object.instances().size(); ++j) {
|
||||
instance_centers.emplace_back(object.instances()[j].shift);
|
||||
instances.emplace_back(i, j);
|
||||
}
|
||||
}
|
||||
|
||||
if (instance_centers.empty()) return {};
|
||||
|
||||
// If start_near is provided, pre-rotate so closest point is first.
|
||||
if (start_near != nullptr) {
|
||||
size_t best_start = 0;
|
||||
double best_d2 = std::numeric_limits<double>::max();
|
||||
for (size_t k = 0; k < instance_centers.size(); ++k) {
|
||||
double d2 = (instance_centers[k].cast<double>() - start_near->cast<double>()).squaredNorm();
|
||||
if (d2 < best_d2) { best_d2 = d2; best_start = k; }
|
||||
}
|
||||
std::rotate(instance_centers.begin(), instance_centers.begin() + best_start, instance_centers.end());
|
||||
std::rotate(instances.begin(), instances.begin() + best_start, instances.end());
|
||||
}
|
||||
|
||||
auto path = core_fn(instance_centers);
|
||||
|
||||
// Rotate the cycle so the first element is the best starting point.
|
||||
// When start_near is provided, pick the point closest to it (preserving
|
||||
// the pre-rotation). Otherwise minimise the closing edge.
|
||||
if (start_near != nullptr && !path.empty()) {
|
||||
// Pre-rotation already put the closest point at index 0.
|
||||
// Find where index 0 appears in the path and rotate it to the front.
|
||||
auto it = std::find(path.begin(), path.end(), size_t(0));
|
||||
if (it != path.begin())
|
||||
std::rotate(path.begin(), it, path.end());
|
||||
} else {
|
||||
tsp_rotate_minimize_closing(path, instance_centers);
|
||||
}
|
||||
|
||||
std::vector<const PrintInstance*> out;
|
||||
out.reserve(path.size());
|
||||
for (size_t step : path) {
|
||||
out.emplace_back(&print_objects[instances[step].first]->instances()[instances[step].second]);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // SLIC3R_TEST_HARNESS
|
||||
|
||||
// --- Core algorithms (operate on raw Points, return index permutations) ---
|
||||
|
||||
// Snake ordering: row grouping + serpentine traversal + post-processing.
|
||||
std::vector<size_t> snake_core(const Points& centers);
|
||||
|
||||
#ifndef SLIC3R_TEST_HARNESS
|
||||
|
||||
// --- Production wrappers ---
|
||||
|
||||
// Snake ordering.
|
||||
std::vector<const PrintInstance*> chain_print_object_instances_snake(const std::vector<const PrintObject*>& print_objects, const Point* start_near);
|
||||
std::vector<const PrintInstance*> chain_print_object_instances_snake(const Print& print);
|
||||
|
||||
// Best-of-strategies: run all strategies and return the shortest result.
|
||||
// Primary: shortest total path; secondary tiebreaker: smallest max edge.
|
||||
std::vector<const PrintInstance*> chain_print_object_instances_best_of(const std::vector<const PrintObject*>& print_objects, const Point* start_near);
|
||||
std::vector<const PrintInstance*> chain_print_object_instances_best_of(const Print& print);
|
||||
|
||||
// Order raw points with the selected strategy, returning an index permutation. Island-level
|
||||
// counterpart of the chain_print_object_instances_* helpers. The returned cycle starts at the
|
||||
// point closest to start_near; orders without a dedicated strategy use nearest-neighbor chaining.
|
||||
std::vector<size_t> order_points_with_strategy(const Points& points, PrintOrder print_order, const Point* start_near);
|
||||
|
||||
#endif // SLIC3R_TEST_HARNESS
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
#endif /* slic3r_OrderingStrategies_hpp_ */
|
||||
@@ -1091,6 +1091,16 @@ namespace Slic3r
|
||||
if (layer + 1 < layer_filaments.size()) next_lf = layer_filaments[layer + 1];
|
||||
std::vector<unsigned int> filament_used_next_layer = collect_filaments_in_groups<unsigned int>(filament_sets, next_lf);
|
||||
|
||||
// Enable inter-layer forecast: when choosing filament ordering for current layer,
|
||||
// also consider next layer's filament set to minimize inter-layer transition flush.
|
||||
// solve_extruder_order_with_forcast() tries all permutations of curr+next layer
|
||||
// and picks the ordering that minimizes total flush across both layers.
|
||||
// This avoids expensive inter-layer transitions (e.g. ending layer with F2 when
|
||||
// next layer starts with F3, costing flush[F2→F3], instead of ending with F3
|
||||
// which gives flush[F3→F3]=0). Limited to ≤5 filaments due to O(N!×M!) complexity.
|
||||
// The per-nozzle base reorder does not use the inter-layer forecast. This function drives
|
||||
// BBL multi-extruder grouping cost and H2C ordering, so keeping it false avoids perturbing
|
||||
// existing H2D/H2C output.
|
||||
bool use_forcast = false;
|
||||
float tmp_cost = 0;
|
||||
std::vector<unsigned int> sequence;
|
||||
|
||||
@@ -1609,6 +1609,64 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config)
|
||||
if (max_vol_speed!= 0.f)
|
||||
m_filpar[idx].max_e_speed = (max_vol_speed / filament_area());
|
||||
|
||||
// Vortek H2C: carousel-specific ramming, precool, and reverse travel parameters
|
||||
{
|
||||
// Ramming speed: .first = extruder change, .second = nozzle change (carousel)
|
||||
// Use the dedicated ramming volumetric speed, falling back to max_vol_speed only when
|
||||
// the setting is nil/-1.
|
||||
float ramming_vol_speed = float(config.filament_ramming_volumetric_speed.get_at(idx));
|
||||
if (config.filament_ramming_volumetric_speed.is_nil(idx) || is_approx(config.filament_ramming_volumetric_speed.get_at(idx), -1.))
|
||||
ramming_vol_speed = max_vol_speed;
|
||||
m_filpar[idx].max_e_ramming_speed.first = (ramming_vol_speed / filament_area());
|
||||
|
||||
float ramming_vol_speed_nc = float(config.filament_ramming_volumetric_speed_nc.get_at(idx));
|
||||
if (config.filament_ramming_volumetric_speed_nc.is_nil(idx) || is_approx(config.filament_ramming_volumetric_speed_nc.get_at(idx), -1.))
|
||||
ramming_vol_speed_nc = max_vol_speed;
|
||||
m_filpar[idx].max_e_ramming_speed.second = (ramming_vol_speed_nc / filament_area());
|
||||
}
|
||||
{
|
||||
// Precool target temp: .first = extruder change, .second = nozzle change (carousel)
|
||||
// Precool is only active when enable_pre_heating is on; otherwise no precool temp/timing is
|
||||
// applied and the downstream precool_t stays 0, matching printers with pre-heating disabled.
|
||||
m_filpar[idx].precool_target_temp = {0, 0};
|
||||
if (config.enable_pre_heating.value) {
|
||||
if (!config.filament_pre_cooling_temperature.is_nil(idx) && config.filament_pre_cooling_temperature.get_at(idx) != 0)
|
||||
m_filpar[idx].precool_target_temp.first = config.filament_pre_cooling_temperature.get_at(idx);
|
||||
if (!config.filament_pre_cooling_temperature_nc.is_nil(idx) && config.filament_pre_cooling_temperature_nc.get_at(idx) != 0)
|
||||
m_filpar[idx].precool_target_temp.second = config.filament_pre_cooling_temperature_nc.get_at(idx);
|
||||
}
|
||||
}
|
||||
{
|
||||
// Precool timing: (nozzle_temp - precool_temp) / hotend_cooling_rate
|
||||
int extruder_count = m_is_multi_extruder ? 2 : 1; // H2C = 2 extruders
|
||||
float nozzle_temp = float(config.nozzle_temperature.is_nil(idx) ? 0 : config.nozzle_temperature.get_at(idx));
|
||||
float nozzle_temp_fl = float(config.nozzle_temperature_initial_layer.is_nil(idx) ? nozzle_temp : config.nozzle_temperature_initial_layer.get_at(idx));
|
||||
m_filpar[idx].precool_t.first.resize(extruder_count, 0.f);
|
||||
m_filpar[idx].precool_t.second.resize(extruder_count, 0.f);
|
||||
m_filpar[idx].precool_t_first_layer.first.resize(extruder_count, 0.f);
|
||||
m_filpar[idx].precool_t_first_layer.second.resize(extruder_count, 0.f);
|
||||
std::vector<double> cooling_rates = config.hotend_cooling_rate.values;
|
||||
for (int i = 0; i < extruder_count && i < (int)cooling_rates.size(); i++) {
|
||||
if (cooling_rates[i] < EPSILON) continue;
|
||||
if (m_filpar[idx].precool_target_temp.first != 0) {
|
||||
m_filpar[idx].precool_t.first[i] = std::max(0.f, nozzle_temp - float(m_filpar[idx].precool_target_temp.first)) / float(cooling_rates[i]);
|
||||
m_filpar[idx].precool_t_first_layer.first[i] = std::max(0.f, nozzle_temp_fl - float(m_filpar[idx].precool_target_temp.first)) / float(cooling_rates[i]);
|
||||
}
|
||||
if (m_filpar[idx].precool_target_temp.second != 0) {
|
||||
m_filpar[idx].precool_t.second[i] = std::max(0.f, nozzle_temp - float(m_filpar[idx].precool_target_temp.second)) / float(cooling_rates[i]);
|
||||
m_filpar[idx].precool_t_first_layer.second[i] = std::max(0.f, nozzle_temp_fl - float(m_filpar[idx].precool_target_temp.second)) / float(cooling_rates[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
// Ramming travel time: .first = extruder change, .second = nozzle change (carousel)
|
||||
m_filpar[idx].ramming_travel_time = {0.f, 0.f};
|
||||
if (!config.filament_ramming_travel_time.is_nil(idx))
|
||||
m_filpar[idx].ramming_travel_time.first = float(config.filament_ramming_travel_time.get_at(idx));
|
||||
if (!config.filament_ramming_travel_time_nc.is_nil(idx))
|
||||
m_filpar[idx].ramming_travel_time.second = float(config.filament_ramming_travel_time_nc.get_at(idx));
|
||||
}
|
||||
|
||||
m_perimeter_width = nozzle_diameter * Width_To_Nozzle_Ratio; // all extruders are now assumed to have the same diameter
|
||||
m_nozzle_change_perimeter_width = 2*m_perimeter_width;
|
||||
// BBS: remove useless config
|
||||
@@ -1893,7 +1951,7 @@ WipeTower::NozzleChangeResult WipeTower::nozzle_change(int old_filament_id, int
|
||||
.set_initial_tool(m_current_tool)
|
||||
.set_extrusion_flow(m_extrusion_flow)
|
||||
.set_y_shift(m_y_shift + (new_filament_id != (unsigned int) (-1) && (m_current_shape == SHAPE_REVERSED) ? m_layer_info->depth - m_layer_info->toolchanges_depth() : 0.f))
|
||||
.append("; Nozzle change start\n");
|
||||
.append(format_nozzle_change_tag(true, old_filament_id, new_filament_id));
|
||||
|
||||
box_coordinates cleaning_box(Vec2f(m_perimeter_width, m_perimeter_width), m_wipe_tower_width - 2 * m_perimeter_width,
|
||||
(new_filament_id != (unsigned int) (-1) ? wipe_depth + m_depth_traversed - m_perimeter_width : m_wipe_tower_depth - m_perimeter_width));
|
||||
@@ -1969,7 +2027,7 @@ WipeTower::NozzleChangeResult WipeTower::nozzle_change(int old_filament_id, int
|
||||
}
|
||||
}
|
||||
|
||||
writer.append("; Nozzle change end\n");
|
||||
writer.append(format_nozzle_change_tag(false, old_filament_id, new_filament_id));
|
||||
|
||||
result.start_pos = writer.start_pos_rotated();
|
||||
result.end_pos = writer.pos();
|
||||
@@ -2546,6 +2604,19 @@ void WipeTower::plan_toolchange(float z_par, float layer_height_par, unsigned in
|
||||
nozzle_change_depth = nozzle_change_line_count * m_nozzle_change_perimeter_width;
|
||||
depth += nozzle_change_depth;
|
||||
}
|
||||
if (nozzle_change_depth == 0
|
||||
&& !m_filament_nozzle_map.empty()
|
||||
&& old_tool < m_filament_nozzle_map.size() && new_tool < m_filament_nozzle_map.size()
|
||||
&& m_filament_nozzle_map[old_tool] != m_filament_nozzle_map[new_tool]) {
|
||||
double e_flow = nozzle_change_extrusion_flow(layer_height_par);
|
||||
double length = m_filaments_change_length[old_tool] / e_flow;
|
||||
int nozzle_change_line_count = length / (m_wipe_tower_width - 2*m_nozzle_change_perimeter_width) + 1;
|
||||
if (has_tpu_filament())
|
||||
nozzle_change_depth = m_tpu_fixed_spacing * nozzle_change_line_count * m_nozzle_change_perimeter_width;
|
||||
else
|
||||
nozzle_change_depth = nozzle_change_line_count * m_nozzle_change_perimeter_width;
|
||||
depth += nozzle_change_depth;
|
||||
}
|
||||
WipeTowerInfo::ToolChange tool_change = WipeTowerInfo::ToolChange(old_tool, new_tool, depth, 0.f, 0.f, wipe_volume, length_to_extrude, purge_volume);
|
||||
tool_change.nozzle_change_depth = nozzle_change_depth;
|
||||
m_plan.back().tool_changes.push_back(tool_change);
|
||||
@@ -2695,6 +2766,13 @@ bool WipeTower::is_petg_filament(int filament_id) const
|
||||
return m_filpar[filament_id].material == "PETG";
|
||||
}
|
||||
|
||||
bool WipeTower::is_need_reverse_travel(int filament_id, bool extruder_change) const
|
||||
{
|
||||
if (extruder_change)
|
||||
return m_filpar[filament_id].ramming_travel_time.first > EPSILON;
|
||||
return m_filpar[filament_id].ramming_travel_time.second > EPSILON;
|
||||
}
|
||||
|
||||
// BBS: consider both soluable and support properties
|
||||
// Return index of first toolchange that switches to non-soluble and non-support extruder
|
||||
// ot -1 if there is no such toolchange.
|
||||
@@ -2819,6 +2897,13 @@ WipeTower::ToolChangeResult WipeTower::tool_change_new(size_t new_tool, bool sol
|
||||
&& is_valid_last_layer(m_current_tool, m_cur_layer_id, m_z_pos)) {
|
||||
m_nozzle_change_result = nozzle_change_new(m_current_tool, new_tool, solid_nozzlechange);
|
||||
}
|
||||
if (m_nozzle_change_result.gcode.empty()
|
||||
&& !m_filament_nozzle_map.empty()
|
||||
&& m_current_tool < m_filament_nozzle_map.size() && new_tool < m_filament_nozzle_map.size()
|
||||
&& m_filament_nozzle_map[m_current_tool] != m_filament_nozzle_map[new_tool]
|
||||
&& is_valid_last_layer(m_current_tool, m_cur_layer_id, m_z_pos)) {
|
||||
m_nozzle_change_result = nozzle_change_new(m_current_tool, new_tool, solid_nozzlechange);
|
||||
}
|
||||
|
||||
size_t old_tool = m_current_tool;
|
||||
float wipe_depth = 0.f;
|
||||
@@ -2983,20 +3068,40 @@ WipeTower::NozzleChangeResult WipeTower::nozzle_change_new(int old_filament_id,
|
||||
}
|
||||
|
||||
float nz_extrusion_flow = nozzle_change_extrusion_flow(m_layer_height);
|
||||
float nozzle_change_speed = 60.0f * m_filpar[m_current_tool].max_e_speed / nz_extrusion_flow;
|
||||
nozzle_change_speed = solid_infill ? 40.f * 60.f : nozzle_change_speed;//If the contact layers belong to different categories, then reduce the speed.
|
||||
bool extruder_change = !is_in_same_extruder(old_filament_id, new_filament_id);
|
||||
float max_e_ramming = extruder_change
|
||||
? m_filpar[m_current_tool].max_e_ramming_speed.first
|
||||
: m_filpar[m_current_tool].max_e_ramming_speed.second;
|
||||
if (max_e_ramming < EPSILON) max_e_ramming = m_filpar[m_current_tool].max_e_speed; // fallback
|
||||
float nozzle_change_speed = 60.0f * max_e_ramming / nz_extrusion_flow;
|
||||
nozzle_change_speed = solid_infill ? 40.f * 60.f : nozzle_change_speed;
|
||||
|
||||
if (is_tpu_filament(m_current_tool)) {
|
||||
nozzle_change_speed *= 0.25;
|
||||
}
|
||||
float bridge_speed = std::min(60.0f * m_filpar[m_current_tool].max_e_speed / nozzle_change_extrusion_flow(0.2), nozzle_change_speed); // limit the bridge speed by add flow
|
||||
float bridge_speed = std::min(60.0f * max_e_ramming / nozzle_change_extrusion_flow(0.2), nozzle_change_speed);
|
||||
|
||||
WipeTowerWriter writer(m_layer_height, m_nozzle_change_perimeter_width, m_gcode_flavor, m_filpar);
|
||||
writer.set_extrusion_flow(nz_extrusion_flow)
|
||||
.set_z(m_z_pos)
|
||||
.set_initial_tool(m_current_tool)
|
||||
.set_y_shift(m_y_shift + (new_filament_id != (unsigned int) (-1) && (m_current_shape == SHAPE_REVERSED) ? m_layer_info->depth - m_layer_info->toolchanges_depth() : 0.f))
|
||||
.append("; Nozzle change start\n");
|
||||
.append(format_nozzle_change_tag(true, old_filament_id, new_filament_id));
|
||||
|
||||
if (!extruder_change && m_is_multiple_nozzle) {
|
||||
writer.append("M632 S" + std::to_string(new_filament_id) + " M N\n");
|
||||
// Use m_physical_extruder_map for heater index (matches format_line_M104 in add_M104_by_requirement)
|
||||
if (m_filpar[m_current_tool].precool_target_temp.second != 0) {
|
||||
int logical_ext = m_filament_map.empty() ? 0 : m_filament_map[m_current_tool] - 1;
|
||||
int phys_ext = (logical_ext >= 0 && logical_ext < (int)m_physical_extruder_map.size())
|
||||
? m_physical_extruder_map[logical_ext] : logical_ext;
|
||||
writer.append("M400\n");
|
||||
writer.append("M104 T" + std::to_string(phys_ext) + " S" +
|
||||
std::to_string(m_filpar[m_current_tool].precool_target_temp.second) + " N0\n");
|
||||
writer.append("M106 S255\n");
|
||||
}
|
||||
writer.append("M633\n");
|
||||
}
|
||||
|
||||
WipeTowerBlock* block = get_block_by_category(m_filpar[old_filament_id].category, false);
|
||||
if (!block) {
|
||||
@@ -3021,6 +3126,23 @@ WipeTower::NozzleChangeResult WipeTower::nozzle_change_new(int old_filament_id,
|
||||
dy = solid_infill ? m_nozzle_change_perimeter_width : dy;
|
||||
nozzle_change_line_count = solid_infill ? std::numeric_limits<int>::max() : nozzle_change_line_count;
|
||||
m_left_to_right = true;
|
||||
|
||||
if (extruder_change) {
|
||||
float ramming_length = nozzle_change_line_count * (xr - xl);
|
||||
int extruder_id = m_filament_map.empty() ? 0 : m_filament_map[m_current_tool] - 1;
|
||||
float precool_t = (extruder_id >= 0 && extruder_id < (int)m_filpar[m_current_tool].precool_t.first.size())
|
||||
? m_filpar[m_current_tool].precool_t.first[extruder_id] : 0.f;
|
||||
float precool_t_fl = (extruder_id >= 0 && extruder_id < (int)m_filpar[m_current_tool].precool_t_first_layer.first.size())
|
||||
? m_filpar[m_current_tool].precool_t_first_layer.first[extruder_id] : 0.f;
|
||||
float per_cooling_max_speed = nozzle_change_speed;
|
||||
if (is_first_layer() && precool_t_fl > EPSILON)
|
||||
per_cooling_max_speed = ramming_length / precool_t_fl * 60.f;
|
||||
else if (precool_t > EPSILON)
|
||||
per_cooling_max_speed = ramming_length / precool_t * 60.f;
|
||||
if (nozzle_change_speed > per_cooling_max_speed) nozzle_change_speed = per_cooling_max_speed;
|
||||
if (bridge_speed > per_cooling_max_speed) bridge_speed = per_cooling_max_speed;
|
||||
}
|
||||
|
||||
int real_nozzle_change_line_count = 0;
|
||||
bool need_change_flow = false;
|
||||
for (int i = 0; true; ++i) {
|
||||
@@ -3053,9 +3175,40 @@ WipeTower::NozzleChangeResult WipeTower::nozzle_change_new(int old_filament_id,
|
||||
block->last_nozzle_change_id = old_filament_id;
|
||||
|
||||
NozzleChangeResult result;
|
||||
if (is_tpu_filament(m_current_tool)) {
|
||||
if (!extruder_change && m_is_multiple_nozzle) {
|
||||
writer.append("M632 S" + std::to_string(new_filament_id) + " M N\n");
|
||||
}
|
||||
|
||||
if (is_need_reverse_travel(m_current_tool, extruder_change)) {
|
||||
bool left_to_right = !m_left_to_right;
|
||||
int tpu_line_count = (real_nozzle_change_line_count + 2 - 1) / 2; // nozzle_change_line_count / 2 round up
|
||||
int tpu_line_count = real_nozzle_change_line_count;
|
||||
float reverse_speed = nozzle_change_speed * 2; // reverse travel runs at double the nozzle-change speed
|
||||
float rt_time = extruder_change ? m_filpar[m_current_tool].ramming_travel_time.first
|
||||
: m_filpar[m_current_tool].ramming_travel_time.second;
|
||||
float need_reverse_travel_dis = rt_time * reverse_speed / 60.f;
|
||||
float real_travel_dis = tpu_line_count * (xr - xl - 2 * m_perimeter_width);
|
||||
if (real_travel_dis < need_reverse_travel_dis)
|
||||
reverse_speed *= real_travel_dis / need_reverse_travel_dis;
|
||||
writer.travel(writer.x(), writer.y() + dy/2);
|
||||
|
||||
for (int i = 0; true; ++i) {
|
||||
need_reverse_travel_dis -= (xr - xl - 2 * m_perimeter_width);
|
||||
float offset_dis = 0.f;
|
||||
if (need_reverse_travel_dis < 0)
|
||||
offset_dis = -need_reverse_travel_dis;
|
||||
if (left_to_right)
|
||||
writer.travel(xr - m_perimeter_width - offset_dis, writer.y(), reverse_speed);
|
||||
else
|
||||
writer.travel(xl + m_perimeter_width + offset_dis, writer.y(), reverse_speed);
|
||||
if (need_reverse_travel_dis < EPSILON) break;
|
||||
if (i == tpu_line_count - 1)
|
||||
break;
|
||||
writer.travel(writer.x(), writer.y() - dy);
|
||||
left_to_right = !left_to_right;
|
||||
}
|
||||
} else if (is_tpu_filament(m_current_tool)) {
|
||||
bool left_to_right = !m_left_to_right;
|
||||
int tpu_line_count = (real_nozzle_change_line_count + 2 - 1) / 2;
|
||||
nozzle_change_speed *= 2;
|
||||
writer.travel(writer.x(), writer.y() - m_nozzle_change_perimeter_width);
|
||||
|
||||
@@ -3080,12 +3233,15 @@ WipeTower::NozzleChangeResult WipeTower::nozzle_change_new(int old_filament_id,
|
||||
}
|
||||
}
|
||||
|
||||
writer.append("; Nozzle change end\n");
|
||||
if (!extruder_change && m_is_multiple_nozzle) writer.append("M633\n");
|
||||
|
||||
writer.append(format_nozzle_change_tag(false, old_filament_id, new_filament_id));
|
||||
|
||||
result.start_pos = writer.start_pos_rotated();
|
||||
result.origin_start_pos = initial_position;
|
||||
result.end_pos = writer.pos_rotated();
|
||||
result.gcode = writer.gcode();
|
||||
result.is_extruder_change = extruder_change;
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3506,29 +3662,26 @@ void WipeTower::toolchange_wipe_new(WipeTowerWriter &writer, const box_coordinat
|
||||
// Emit the arriving-hotend pre-heat inside the M632/M633 nozzle-change barrier. `M632 S<tool>[ H<nozzle>]
|
||||
// M N` opens the barrier (M = firmware nozzle-change flag, N = slicer generated), the M104 sets the
|
||||
// arriving hotend temp, and `M633` closes it. H2C's grouping is static (no dynamic nozzle map), so the
|
||||
// H<nozzle> field is omitted (a dynamic nozzle map would supply a real nozzle id, a static map -1 => no
|
||||
// H<nozzle> field is omitted (a dynamic nozzle map would supply a real nozzle id, a static map -1 =>no
|
||||
// H). The counterproductive fan-on (M106 S255) used for departing-tool cooldown is intentionally
|
||||
// omitted, since this is a pre-HEAT of the arriving tool. The whole helper is only ever called from
|
||||
// add_M104_by_requirement, which is gated on m_is_multiple_nozzle (extruder_max_nozzle_count>1) => H2C
|
||||
// only; every other printer's wipe tower is untouched. The M632 M-flag is itself a firmware barrier, so
|
||||
// a preceding M400 wait is subsumed.
|
||||
// only; every other printer's wipe tower is untouched.
|
||||
// BBS: extruder change preheat uses M400 + M104 WITHOUT M632/M633 barrier.
|
||||
// M632 barriers are only for carousel nozzle changes (emitted in nozzle_change_new/ramming).
|
||||
auto format_line_M104 = [this](int target_temp, int target_extruder = -1, bool wait_for_moves = true, const std::string &comment = "") {
|
||||
std::string buffer;
|
||||
buffer += "M632 S" + std::to_string(m_current_tool) + " M N\n";
|
||||
if (wait_for_moves)
|
||||
buffer += "M400\n";
|
||||
buffer += "M104";
|
||||
if (target_extruder != -1 && target_extruder < (int) m_physical_extruder_map.size())
|
||||
buffer += (" T" + std::to_string(m_physical_extruder_map[target_extruder]));
|
||||
buffer += " S" + std::to_string(target_temp) + " N0"; // N0 means the gcode is generated by the slicer
|
||||
if (!comment.empty()) buffer += " ;" + comment;
|
||||
buffer += '\n';
|
||||
buffer += "M633\n";
|
||||
(void) wait_for_moves; // the M632 M-flag barrier replaces the former M400 wait
|
||||
return buffer;
|
||||
};
|
||||
// Suppress the pre-heat M104 on the first layer and on solid (contact) toolchanges (should_heating).
|
||||
// m_is_multiple_nozzle folds in the H2C gate so single-nozzle output is untouched.
|
||||
// Orca: the arriving extruder id is resolved as m_filament_map[tool]-1 (layer-static) because Orca's
|
||||
// wipe tower is extruder-level rather than tracking a per-layer nozzle map.
|
||||
// m_is_multiple_nozzle gate needed because Orca calls toolchange_wipe_new for ALL printers (BBS has it H2C-only).
|
||||
bool should_heating = m_is_multiple_nozzle && m_filpar[m_current_tool].filament_cooling_before_tower > EPSILON &&
|
||||
!solid_tool_toolchange && !is_first_layer();
|
||||
auto add_M104_by_requirement = [&writer, &format_line_M104, &should_heating, this]() {
|
||||
@@ -3710,6 +3863,18 @@ bool WipeTower::is_in_same_extruder(int filament_id_1, int filament_id_2)
|
||||
return m_filament_map[filament_id_1] == m_filament_map[filament_id_2];
|
||||
}
|
||||
|
||||
std::string WipeTower::format_nozzle_change_tag(bool start, int old_filament_id, int new_filament_id) const
|
||||
{
|
||||
const std::string &tag = start ? GCodeProcessor::Nozzle_Change_Start_Tag : GCodeProcessor::Nozzle_Change_End_Tag;
|
||||
int old_nozzle = (old_filament_id >= 0 && old_filament_id < (int)m_filament_nozzle_map.size())
|
||||
? m_filament_nozzle_map[old_filament_id] : -1;
|
||||
int new_nozzle = (new_filament_id >= 0 && new_filament_id < (int)m_filament_nozzle_map.size())
|
||||
? m_filament_nozzle_map[new_filament_id] : -1;
|
||||
char buff[96];
|
||||
snprintf(buff, sizeof(buff), ";%s OF%d NF%d ON%d NN%d\n", tag.c_str(), old_filament_id, new_filament_id, old_nozzle, new_nozzle);
|
||||
return std::string(buff);
|
||||
}
|
||||
|
||||
// Per-extruder printable-height clamp: is an extruder still allowed to print on this wipe-tower layer,
|
||||
// or is it its final layer above the extruder's printable height?
|
||||
// Orca: the arriving extruder id is resolved as m_filament_map[tool]-1 (1-based map, layer-static),
|
||||
@@ -3908,6 +4073,19 @@ void WipeTower::plan_tower_new()
|
||||
nozzle_change_depth = nozzle_change_line_count * m_nozzle_change_perimeter_width;
|
||||
depth += nozzle_change_depth;
|
||||
}
|
||||
if (nozzle_change_depth == 0
|
||||
&& !m_filament_nozzle_map.empty()
|
||||
&& toolchange.old_tool < (int)m_filament_nozzle_map.size() && toolchange.new_tool < (int)m_filament_nozzle_map.size()
|
||||
&& m_filament_nozzle_map[toolchange.old_tool] != m_filament_nozzle_map[toolchange.new_tool]) {
|
||||
double e_flow = nozzle_change_extrusion_flow(m_plan[idx].height);
|
||||
double length = m_filaments_change_length[toolchange.old_tool] / e_flow;
|
||||
int nozzle_change_line_count = length / (m_wipe_tower_width - 2*m_nozzle_change_perimeter_width) + 1;
|
||||
if (has_tpu_filament())
|
||||
nozzle_change_depth = m_tpu_fixed_spacing * nozzle_change_line_count * m_nozzle_change_perimeter_width;
|
||||
else
|
||||
nozzle_change_depth = nozzle_change_line_count * m_nozzle_change_perimeter_width;
|
||||
depth += nozzle_change_depth;
|
||||
}
|
||||
toolchange.nozzle_change_depth = nozzle_change_depth;
|
||||
toolchange.required_depth = depth;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
Vec2f origin_start_pos; // not rotated
|
||||
|
||||
std::vector<Vec2f> wipe_path;
|
||||
bool is_extruder_change{true};
|
||||
};
|
||||
|
||||
struct ToolChangeResult
|
||||
@@ -309,6 +310,8 @@ public:
|
||||
int get_number_of_toolchanges() const { return m_num_tool_changes; }
|
||||
|
||||
void set_filament_map(const std::vector<int> &filament_map) { m_filament_map = filament_map; }
|
||||
// Vortek H2C: filament_id → physical nozzle_id for carousel rotation detection
|
||||
void set_filament_nozzle_map(const std::vector<int> &nozzle_map) { m_filament_nozzle_map = nozzle_map; }
|
||||
|
||||
void set_has_tpu_filament(bool has_tpu) { m_has_tpu_filament = has_tpu; }
|
||||
bool has_tpu_filament() const { return m_has_tpu_filament; }
|
||||
@@ -356,6 +359,12 @@ public:
|
||||
// Distance (in mm of filament) that a hotend is allowed to pre-cool before the
|
||||
// tower is reached; drives the prime-tower heating-during-wipe model (multi-nozzle only).
|
||||
float filament_cooling_before_tower = 0.f;
|
||||
// .first = extruder change, .second = nozzle change (carousel)
|
||||
std::pair<float,float> max_e_ramming_speed{0.f, 0.f};
|
||||
std::pair<float,float> ramming_travel_time{0.f, 0.f};
|
||||
std::pair<int,int> precool_target_temp{0, 0};
|
||||
std::pair<std::vector<float>,std::vector<float>> precool_t;
|
||||
std::pair<std::vector<float>,std::vector<float>> precool_t_first_layer;
|
||||
};
|
||||
|
||||
|
||||
@@ -395,6 +404,8 @@ public:
|
||||
void add_depth_to_block(int filament_id, int filament_adhesiveness_category, float depth, bool is_nozzle_change = false);
|
||||
int get_filament_category(int filament_id);
|
||||
bool is_in_same_extruder(int filament_id_1, int filament_id_2);
|
||||
// Vortek H2C: format BBS-compatible NOZZLE_CHANGE_START/END tag with OF/NF/ON/NN payload
|
||||
std::string format_nozzle_change_tag(bool start, int old_filament_id, int new_filament_id) const;
|
||||
void reset_block_status();
|
||||
int get_wall_filament_for_all_layer();
|
||||
// for generate new wipe tower
|
||||
@@ -453,6 +464,7 @@ private:
|
||||
size_t m_cur_layer_id;
|
||||
NozzleChangeResult m_nozzle_change_result;
|
||||
std::vector<int> m_filament_map;
|
||||
std::vector<int> m_filament_nozzle_map; // Vortek H2C: filament_id → physical nozzle_id
|
||||
bool m_has_tpu_filament{false};
|
||||
bool m_is_multi_extruder{false};
|
||||
bool m_use_gap_wall{false};
|
||||
@@ -555,6 +567,7 @@ private:
|
||||
|
||||
bool is_tpu_filament(int filament_id) const;
|
||||
bool is_petg_filament(int filament_id) const;
|
||||
bool is_need_reverse_travel(int filament_id, bool extruder_change) const;
|
||||
|
||||
// BBS
|
||||
box_coordinates align_perimeter(const box_coordinates& perimeter_box);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "CustomGCode.hpp"
|
||||
#include "I18N.hpp"
|
||||
#include "PrintConfig.hpp"
|
||||
#include "ClipperUtils.hpp"
|
||||
#include "Line.hpp"
|
||||
#include <algorithm>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
@@ -99,9 +101,87 @@ void GCodeWriter::apply_print_config(const PrintConfig &print_config)
|
||||
m_max_jerk_z = LIMITS(machine_max_jerk_z);
|
||||
m_max_jerk_e = LIMITS(machine_max_jerk_e);
|
||||
m_resolution = print_config.resolution.value;
|
||||
|
||||
#undef LIMITS
|
||||
#undef LIMITS_UINT
|
||||
// Orca: capture the printable area(s) so a spiral lift can be skipped when its
|
||||
// circle would leave the boundary and collide with the print limits. Full polygons
|
||||
// are stored (not a bounding box) so the check stays correct for non-rectangular
|
||||
// beds, and per-extruder areas are kept so printers with different boundaries per
|
||||
// extruder use the right limit for whichever extruder is active.
|
||||
auto to_scaled_polygon = [](const Pointfs &pts) {
|
||||
Polygon poly;
|
||||
poly.points.reserve(pts.size());
|
||||
for (const Vec2d &p : pts)
|
||||
poly.points.emplace_back(coord_t(scale_(p.x())), coord_t(scale_(p.y())));
|
||||
poly.make_counter_clockwise();
|
||||
return poly;
|
||||
};
|
||||
|
||||
m_bed_printable_area.points.clear();
|
||||
m_extruder_printable_areas.clear();
|
||||
|
||||
if (print_config.printable_area.values.size() >= 3)
|
||||
m_bed_printable_area = to_scaled_polygon(print_config.printable_area.values);
|
||||
|
||||
const std::vector<Pointfs> &extruder_areas = print_config.extruder_printable_area.values;
|
||||
if (!extruder_areas.empty()) {
|
||||
m_extruder_printable_areas.resize(extruder_areas.size());
|
||||
for (size_t i = 0; i < extruder_areas.size(); ++i) {
|
||||
if (extruder_areas[i].size() < 3) {
|
||||
// No dedicated area for this extruder: it can reach the whole bed.
|
||||
m_extruder_printable_areas[i] = m_bed_printable_area;
|
||||
continue;
|
||||
}
|
||||
Polygon extruder_poly = to_scaled_polygon(extruder_areas[i]);
|
||||
if (m_bed_printable_area.points.size() < 3) {
|
||||
m_extruder_printable_areas[i] = std::move(extruder_poly);
|
||||
continue;
|
||||
}
|
||||
// The reachable area is the extruder area clipped to the bed. Bed shapes are
|
||||
// convex in practice, so keep the largest resulting contour.
|
||||
Polygons clipped = intersection(extruder_poly, m_bed_printable_area);
|
||||
const Polygon *largest = nullptr;
|
||||
double best_area = 0.;
|
||||
for (const Polygon &p : clipped) {
|
||||
double a = std::abs(p.area());
|
||||
if (a > best_area) { best_area = a; largest = &p; }
|
||||
}
|
||||
m_extruder_printable_areas[i] = largest ? *largest : std::move(extruder_poly);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const Polygon *GCodeWriter::active_printable_area() const
|
||||
{
|
||||
if (const Extruder *e = this->filament()) {
|
||||
size_t id = e->extruder_id();
|
||||
if (id < m_extruder_printable_areas.size() && m_extruder_printable_areas[id].points.size() >= 3)
|
||||
return &m_extruder_printable_areas[id];
|
||||
}
|
||||
if (m_bed_printable_area.points.size() >= 3)
|
||||
return &m_bed_printable_area;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool GCodeWriter::spiral_lift_fits_printable_area(const Vec2d ¢er, double radius) const
|
||||
{
|
||||
const Polygon *area = this->active_printable_area();
|
||||
if (area == nullptr)
|
||||
return true; // Boundary unknown: don't restrict (preserve previous behavior).
|
||||
|
||||
const Point c = Point::new_scale(center.x(), center.y());
|
||||
const double r_scaled = scale_(radius);
|
||||
const double r2 = r_scaled * r_scaled;
|
||||
|
||||
// The spiral traces a full circle of `radius` around `center`, so the center must lie
|
||||
// inside the printable area and every edge must be at least `radius` away from it.
|
||||
if (!area->contains(c))
|
||||
return false;
|
||||
const Points &pts = area->points;
|
||||
for (size_t i = 0, n = pts.size(); i < n; ++i)
|
||||
if (Line::distance_to_squared(c, pts[i], pts[(i + 1) % n]) < r2)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void GCodeWriter::set_extruders(std::vector<unsigned int> extruder_ids)
|
||||
@@ -731,14 +811,19 @@ std::string GCodeWriter::eager_lift(const LiftType type) {
|
||||
}
|
||||
|
||||
// BBS: spiral lift only safe with known position
|
||||
// TODO: check the arc will move within bed area
|
||||
if (type == LiftType::SpiralLift && this->is_current_position_clear()) {
|
||||
double radius = target_lift / (2 * PI * atan(filament()->travel_slope()));
|
||||
// static spiral alignment when no move in x,y plane.
|
||||
// spiral centra is a radius distance to the right (y=0)
|
||||
Vec2d ij_offset = { radius, 0 };
|
||||
if (target_lift > 0) {
|
||||
// Orca: keep the spiral inside the active extruder's printable area, otherwise
|
||||
// fall back to a normal lift to avoid colliding with the print boundary. m_pos
|
||||
// includes the plate offset, so remove it to match the printable area coordinates.
|
||||
const Vec2d spiral_center = { m_pos.x() - m_x_offset + ij_offset.x(), m_pos.y() - m_y_offset + ij_offset.y() };
|
||||
if (target_lift > 0 && this->spiral_lift_fits_printable_area(spiral_center, radius)) {
|
||||
lift_move = this->_spiral_travel_to_z(m_pos(2) + target_lift, ij_offset, "spiral lift Z");
|
||||
} else if (target_lift > 0) {
|
||||
lift_move = _travel_to_z(m_pos(2) + target_lift, "normal lift Z");
|
||||
}
|
||||
}
|
||||
//BBS: if position is unknown use normal lift
|
||||
@@ -793,7 +878,15 @@ std::string GCodeWriter::travel_to_xyz(const Vec3d &point, const std::string &co
|
||||
double radius = delta(2) / (2 * PI * atan(this->filament()->travel_slope()));
|
||||
Vec2d ij_offset = radius * delta_no_z.normalized();
|
||||
ij_offset = { -ij_offset(1), ij_offset(0) };
|
||||
slop_move = this->_spiral_travel_to_z(target(2), ij_offset, "spiral lift Z");
|
||||
// Orca: only perform the spiral lift if its full circle stays inside the
|
||||
// printable area of the active extruder, otherwise fall back to a normal
|
||||
// lift to avoid colliding with the print boundary. `source` is already in
|
||||
// bed coordinates (plate offset removed), matching the printable area.
|
||||
const Vec2d spiral_center = { source.x() + ij_offset.x(), source.y() + ij_offset.y() };
|
||||
if (this->spiral_lift_fits_printable_area(spiral_center, radius))
|
||||
slop_move = this->_spiral_travel_to_z(target(2), ij_offset, "spiral lift Z");
|
||||
else
|
||||
slop_move = _travel_to_z(target.z(), "normal lift Z");
|
||||
}
|
||||
//BBS: SlopeLift
|
||||
else if (m_to_lift_type == LiftType::SlopeLift &&
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <charconv>
|
||||
#include "Extruder.hpp"
|
||||
#include "Point.hpp"
|
||||
#include "Polygon.hpp"
|
||||
#include "PrintConfig.hpp"
|
||||
#include "GCode/CoolingBuffer.hpp"
|
||||
|
||||
@@ -132,6 +133,8 @@ public:
|
||||
const bool is_bbl_printers() const {return m_is_bbl_printers;}
|
||||
void set_is_first_layer(bool bval) { m_is_first_layer = bval; }
|
||||
GCodeFlavor get_gcode_flavor() const { return config.gcode_flavor; }
|
||||
void invalidate_acceleration() { m_last_acceleration = 0; m_last_travel_acceleration = 0; }
|
||||
void invalidate_jerk() { m_last_jerk = 0; }
|
||||
|
||||
// Returns whether this flavor supports separate print and travel acceleration.
|
||||
static bool supports_separate_travel_acceleration(GCodeFlavor flavor);
|
||||
@@ -181,6 +184,14 @@ public:
|
||||
|
||||
// Orca: slicing resolution in mm
|
||||
double m_resolution = 0.01;
|
||||
// Orca: printable area polygons (scaled, bed coordinates) used to keep spiral lifts
|
||||
// from colliding with the print boundary. m_extruder_printable_areas holds the
|
||||
// per-extruder reachable area (intersected with the bed) when a printer defines
|
||||
// different boundaries per extruder; m_bed_printable_area is the global fallback.
|
||||
// Storing full polygons (rather than a bounding box) keeps the check correct for
|
||||
// non-rectangular beds such as delta/circular printers.
|
||||
Polygon m_bed_printable_area;
|
||||
std::vector<Polygon> m_extruder_printable_areas;
|
||||
|
||||
std::string m_gcode_label_objects_start;
|
||||
std::string m_gcode_label_objects_end;
|
||||
@@ -197,6 +208,10 @@ public:
|
||||
|
||||
std::string _travel_to_z(double z, const std::string &comment);
|
||||
std::string _spiral_travel_to_z(double z, const Vec2d &ij_offset, const std::string &comment);
|
||||
// Orca: printable area of the active extruder (per-extruder when configured, otherwise the bed). Null when unknown.
|
||||
const Polygon *active_printable_area() const;
|
||||
// Orca: true if a full spiral-lift circle (center in bed coordinates, mm) fits inside the active printable area.
|
||||
bool spiral_lift_fits_printable_area(const Vec2d ¢er, double radius) const;
|
||||
std::string _retract(double length, double restart_extra, const std::string &comment);
|
||||
std::string set_acceleration_internal(Acceleration type, unsigned int acceleration);
|
||||
|
||||
|
||||
@@ -1177,6 +1177,18 @@ static bool is_volume_sinking(const indexed_triangle_set &its, const Transform3d
|
||||
|
||||
//#define MMU_SEGMENTATION_DEBUG_TOP_BOTTOM
|
||||
|
||||
double resolve_outer_wall_line_width(const PrintRegionConfig ®ion_config, const PrintObjectConfig &object_config, const PrintConfig &print_config)
|
||||
{
|
||||
// A filament id of 0 underflows, and get_at() then falls back to the first nozzle.
|
||||
const double nozzle_diameter = print_config.nozzle_diameter.get_at(region_config.outer_wall_filament_id - 1);
|
||||
ConfigOptionFloatOrPercent width = region_config.outer_wall_line_width;
|
||||
if (width.value == 0)
|
||||
width = object_config.line_width;
|
||||
if (!width.percent && width.value <= 0.)
|
||||
return Flow::auto_extrusion_width(frExternalPerimeter, float(nozzle_diameter));
|
||||
return width.get_abs_value(nozzle_diameter);
|
||||
}
|
||||
|
||||
// Returns segmentation of top and bottom layers based on painting in segmentation gizmos.
|
||||
static inline std::vector<std::vector<ExPolygons>> segmentation_top_and_bottom_layers(const PrintObject &print_object,
|
||||
const std::vector<ExPolygons> &input_expolygons,
|
||||
@@ -1347,8 +1359,7 @@ static inline std::vector<std::vector<ExPolygons>> segmentation_top_and_bottom_l
|
||||
// As this region may split existing regions, we collect statistics over all regions for color_idx == 0.
|
||||
color_idx == 0 || config.outer_wall_filament_id == int(color_idx)) {
|
||||
//BBS: the extrusion line width is outer wall rather than inner wall
|
||||
const double nozzle_diameter = print_object.print()->config().nozzle_diameter.get_at(0);
|
||||
double outer_wall_line_width = config.get_abs_value("outer_wall_line_width", nozzle_diameter);
|
||||
double outer_wall_line_width = resolve_outer_wall_line_width(config, print_object.config(), print_object.print()->config());
|
||||
out.extrusion_width = std::max<float>(out.extrusion_width, outer_wall_line_width);
|
||||
out.top_shell_layers = std::max<int>(out.top_shell_layers, config.top_shell_layers);
|
||||
out.bottom_shell_layers = std::max<int>(out.bottom_shell_layers, config.bottom_shell_layers);
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace Slic3r {
|
||||
class ExPolygon;
|
||||
class ModelVolume;
|
||||
class PrintObject;
|
||||
class PrintConfig;
|
||||
class PrintObjectConfig;
|
||||
class PrintRegionConfig;
|
||||
class FacetsAnnotation;
|
||||
|
||||
using ExPolygons = std::vector<ExPolygon>;
|
||||
@@ -52,6 +55,9 @@ std::vector<std::vector<ExPolygons>> multi_material_segmentation_by_painting(con
|
||||
// Returns fuzzy skin segmentation based on painting in fuzzy skin segmentation gizmo
|
||||
std::vector<std::vector<ExPolygons>> fuzzy_skin_segmentation_by_painting(const PrintObject &print_object, const std::function<void()> &throw_on_cancel_callback);
|
||||
|
||||
// Effective outer-wall line width for a region, resolved against its own nozzle with PrintRegion::flow's fallback.
|
||||
double resolve_outer_wall_line_width(const PrintRegionConfig ®ion_config, const PrintObjectConfig &object_config, const PrintConfig &print_config);
|
||||
|
||||
} // namespace Slic3r
|
||||
|
||||
namespace boost::polygon {
|
||||
|
||||
@@ -1203,7 +1203,7 @@ static std::vector<std::string> s_Preset_print_options{
|
||||
"post_process",
|
||||
"slicing_pipeline_plugin",
|
||||
"plugins",
|
||||
"plugin_config_overrides",
|
||||
"print_plugin_config_overrides",
|
||||
"process_change_extrusion_role_gcode",
|
||||
"min_length_factor",
|
||||
"wall_maximum_resolution",
|
||||
@@ -1376,9 +1376,9 @@ static std::vector<std::string> s_Preset_filament_options {/*"filament_colour",
|
||||
"filament_ramming_travel_time", "filament_ramming_travel_time_nc",
|
||||
"filament_pre_cooling_temperature", "filament_pre_cooling_temperature_nc",
|
||||
"filament_preheat_temperature_delta", "filament_retract_length_nc",
|
||||
"filament_change_length_nc", "filament_prime_volume_nc",
|
||||
"filament_change_length_nc", "filament_prime_volume", "filament_prime_volume_nc",
|
||||
"long_retractions_when_ec", "retraction_distances_when_ec",
|
||||
"plugin_config_overrides",
|
||||
"filament_plugin_config_overrides",
|
||||
//ams chamber
|
||||
"filament_dev_ams_drying_ams_limitations", "filament_dev_ams_drying_temperature", "filament_dev_ams_drying_time", "filament_dev_ams_drying_heat_distortion_temperature",
|
||||
"filament_dev_chamber_drying_bed_temperature", "filament_dev_chamber_drying_time",
|
||||
@@ -1430,7 +1430,7 @@ static std::vector<std::string> s_Preset_printer_options {
|
||||
// Fast-purge printer flag + device/firmware-facing per-variant extruder-change
|
||||
// deretraction speed (unconsumed by the slicer; carried by H2D/A2L/X2D/P2S machine profiles).
|
||||
"support_fast_purge_mode", "deretract_speed_extruder_change",
|
||||
"plugin_config_overrides"
|
||||
"printer_plugin_config_overrides"
|
||||
};
|
||||
|
||||
static std::vector<std::string> s_Preset_sla_print_options {
|
||||
@@ -1542,6 +1542,15 @@ const std::vector<std::string>& Preset::printer_options()
|
||||
return s_opts;
|
||||
}
|
||||
|
||||
const char* Preset::plugin_overrides_key(Type type)
|
||||
{
|
||||
switch (type) {
|
||||
case TYPE_PRINTER: return "printer_plugin_config_overrides";
|
||||
case TYPE_FILAMENT: return "filament_plugin_config_overrides";
|
||||
default: return "print_plugin_config_overrides";
|
||||
}
|
||||
}
|
||||
|
||||
PresetCollection::PresetCollection(Preset::Type type, const std::vector<std::string> &keys, const Slic3r::StaticPrintConfig &defaults, const std::string &default_name) :
|
||||
m_type(type),
|
||||
m_edited_preset(type, "", false),
|
||||
|
||||
@@ -407,6 +407,11 @@ public:
|
||||
// Printer machine limits, those are contained in printer_options().
|
||||
static const std::vector<std::string>& machine_limits_options();
|
||||
|
||||
// Option key holding this preset type's plugin capability overrides. Each type has its own key so
|
||||
// the values survive the merge into a single full config; print is the fallback for the types with
|
||||
// no plugin-backed options.
|
||||
static const char* plugin_overrides_key(Type type);
|
||||
|
||||
static const std::vector<std::string>& sla_printer_options();
|
||||
static const std::vector<std::string>& sla_material_options();
|
||||
static const std::vector<std::string>& sla_print_options();
|
||||
|
||||
+87
-19
@@ -285,6 +285,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|
||||
steps.emplace_back(psSkirtBrim);
|
||||
} else if (
|
||||
opt_key == "slicing_pipeline_plugin"
|
||||
|| opt_key == "print_plugin_config_overrides"
|
||||
|| opt_key == "initial_layer_print_height"
|
||||
|| opt_key == "nozzle_diameter"
|
||||
|| opt_key == "filament_shrink"
|
||||
@@ -3605,7 +3606,8 @@ std::vector<std::set<int>> Print::get_physical_unprintable_filaments(const std::
|
||||
return physical_unprintables;
|
||||
|
||||
auto get_unprintable_extruder_id = [&](unsigned int filament_idx) -> int {
|
||||
int status = m_config.filament_printable.values[filament_idx];
|
||||
// filament_printable may be shorter than the filament count; get_at() clamps.
|
||||
int status = m_config.filament_printable.get_at(filament_idx);
|
||||
for (int i = 0; i < extruder_num; ++i) {
|
||||
if (!(status >> i & 1)) {
|
||||
return i;
|
||||
@@ -4017,6 +4019,8 @@ void Print::_make_wipe_tower()
|
||||
m_wipe_tower_data.tool_ordering.empty() ? 0.f : m_wipe_tower_data.tool_ordering.back().print_z, m_wipe_tower_data.tool_ordering.all_extruders());
|
||||
wipe_tower.set_has_tpu_filament(this->has_tpu_filament());
|
||||
wipe_tower.set_filament_map(this->get_filament_maps());
|
||||
// Vortek H2C: pass nozzle-level map for carousel rotation detection in tool_change_new()
|
||||
wipe_tower.set_filament_nozzle_map(this->get_filament_nozzle_maps());
|
||||
// Feed the has_filament_switcher device flag (develop-only dynamic key, read defensively from
|
||||
// the full config — no shipping profile sets it) and the shared printable bed used by the PETG
|
||||
// pre-extrusion offset clamp. Both are inert unless has_filament_switcher is set.
|
||||
@@ -4052,14 +4056,32 @@ void Print::_make_wipe_tower()
|
||||
multi_extruder_flush.emplace_back(wipe_volumes);
|
||||
}
|
||||
|
||||
// Use NozzleStatusRecorder for per-carousel-slot tracking (BBS pattern).
|
||||
// The original Orca code tracked per-extruder (2 slots), which collapsed all
|
||||
// carousel filaments into one slot and caused massive redundant AMS flushing.
|
||||
auto group_result = get_layered_nozzle_group_result();
|
||||
MultiNozzleUtils::NozzleStatusRecorder nozzle_recorder;
|
||||
// Fallback (group_result == null) per-physical-nozzle tracking, matching the original
|
||||
// pre-port behavior: remembers the last filament loaded in each physical nozzle slot.
|
||||
std::vector<unsigned int> nozzle_cur_filament_ids(nozzle_nums, (unsigned int) -1);
|
||||
|
||||
std::vector<int>filament_maps = get_filament_maps();
|
||||
int layer_idx = -1;
|
||||
|
||||
std::vector<unsigned int> nozzle_cur_filament_ids(nozzle_nums, -1);
|
||||
unsigned int current_filament_id = m_wipe_tower_data.tool_ordering.first_extruder();
|
||||
size_t cur_nozzle_id = filament_maps[current_filament_id] - 1;
|
||||
nozzle_cur_filament_ids[cur_nozzle_id] = current_filament_id;
|
||||
// Initialize NozzleStatusRecorder with the first filament's carousel slot
|
||||
if (group_result) {
|
||||
auto nozzle = group_result->get_nozzle_for_filament(current_filament_id, layer_idx);
|
||||
if (nozzle)
|
||||
nozzle_recorder.set_nozzle_status(nozzle->group_id, current_filament_id, nozzle->extruder_id);
|
||||
} else {
|
||||
size_t cur_nozzle_id = filament_maps[current_filament_id] - 1;
|
||||
nozzle_cur_filament_ids[cur_nozzle_id] = current_filament_id;
|
||||
}
|
||||
|
||||
for (auto& layer_tools : m_wipe_tower_data.tool_ordering.layer_tools()) { // for all layers
|
||||
++layer_idx;
|
||||
|
||||
if (!layer_tools.has_wipe_tower) continue;
|
||||
bool first_layer = &layer_tools == &m_wipe_tower_data.tool_ordering.front();
|
||||
wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, current_filament_id, current_filament_id);
|
||||
@@ -4070,30 +4092,76 @@ void Print::_make_wipe_tower()
|
||||
if (filament_id == current_filament_id)
|
||||
continue;
|
||||
|
||||
int nozzle_id = filament_maps[filament_id] - 1;
|
||||
unsigned int pre_filament_id = nozzle_cur_filament_ids[nozzle_id];
|
||||
|
||||
float volume_to_purge = 0;
|
||||
if (pre_filament_id != (unsigned int)(-1) && pre_filament_id != filament_id) {
|
||||
volume_to_purge = multi_extruder_flush[nozzle_id][pre_filament_id][filament_id];
|
||||
// Fast purge mode uses flush_multiplier_fast; Default is inert.
|
||||
float flush_multiplier = (m_config.prime_volume_mode == PrimeVolumeMode::pvmFast) ? m_config.flush_multiplier_fast.get_at(nozzle_id)
|
||||
: m_config.flush_multiplier.get_at(nozzle_id);
|
||||
volume_to_purge *= flush_multiplier;
|
||||
volume_to_purge = pre_filament_id == -1 ? 0 :
|
||||
layer_tools.wiping_extrusions().mark_wiping_extrusions(*this, current_filament_id, filament_id, volume_to_purge);
|
||||
|
||||
// Per-carousel-slot purge tracking via NozzleStatusRecorder
|
||||
if (group_result) {
|
||||
auto nozzle_info = group_result->get_nozzle_for_filament(filament_id, layer_idx);
|
||||
if (nozzle_info) {
|
||||
int extruder_id = nozzle_info->extruder_id;
|
||||
int nozzle_id = nozzle_info->group_id;
|
||||
int prev_nozzle_filament = nozzle_recorder.get_filament_in_nozzle(nozzle_id);
|
||||
|
||||
if (!nozzle_recorder.is_nozzle_empty(nozzle_id) &&
|
||||
static_cast<int>(filament_id) != prev_nozzle_filament) {
|
||||
volume_to_purge = multi_extruder_flush[extruder_id][prev_nozzle_filament][filament_id];
|
||||
// Fast purge mode uses flush_multiplier_fast; Default is inert.
|
||||
float flush_multiplier = (m_config.prime_volume_mode == PrimeVolumeMode::pvmFast)
|
||||
? m_config.flush_multiplier_fast.get_at(extruder_id)
|
||||
: m_config.flush_multiplier.get_at(extruder_id);
|
||||
volume_to_purge *= flush_multiplier;
|
||||
volume_to_purge = layer_tools.wiping_extrusions().mark_wiping_extrusions(
|
||||
*this, current_filament_id, filament_id, volume_to_purge);
|
||||
}
|
||||
nozzle_recorder.set_nozzle_status(nozzle_id, filament_id, extruder_id);
|
||||
}
|
||||
} else {
|
||||
// Fallback: original Orca per-physical-nozzle path (non-carousel printers).
|
||||
// Flush source is the last filament that occupied THIS nozzle, guarded so the
|
||||
// first use of a nozzle incurs no flush.
|
||||
int nozzle_id = filament_maps[filament_id] - 1;
|
||||
unsigned int pre_filament_id = nozzle_cur_filament_ids[nozzle_id];
|
||||
if (pre_filament_id != (unsigned int) -1 && pre_filament_id != filament_id) {
|
||||
volume_to_purge = multi_extruder_flush[nozzle_id][pre_filament_id][filament_id];
|
||||
float flush_multiplier = (m_config.prime_volume_mode == PrimeVolumeMode::pvmFast)
|
||||
? m_config.flush_multiplier_fast.get_at(nozzle_id)
|
||||
: m_config.flush_multiplier.get_at(nozzle_id);
|
||||
volume_to_purge *= flush_multiplier;
|
||||
volume_to_purge = layer_tools.wiping_extrusions().mark_wiping_extrusions(
|
||||
*this, current_filament_id, filament_id, volume_to_purge);
|
||||
}
|
||||
nozzle_cur_filament_ids[nozzle_id] = filament_id;
|
||||
}
|
||||
|
||||
//During the filament change, the extruder will extrude an extra length of grab_length for the corresponding detection, so the purge can reduce this length.
|
||||
float grab_purge_volume = m_config.grab_length.get_at(nozzle_id) * 2.4; //(diameter/2)^2*PI=2.4
|
||||
int grab_extruder_id = filament_maps[filament_id] - 1;
|
||||
float grab_purge_volume = m_config.grab_length.get_at(grab_extruder_id) * 2.4; //(diameter/2)^2*PI=2.4
|
||||
volume_to_purge = std::max(0.f, volume_to_purge - grab_purge_volume);
|
||||
|
||||
// Saving mode reduces the prime volume to 15 mm3; Default is inert.
|
||||
float prime_volume = (m_config.prime_volume_mode == PrimeVolumeMode::pvmSaving) ? 15.f : (float) m_config.prime_volume;
|
||||
// Select prime volume per-filament: nozzle change (carousel rotation) uses
|
||||
// filament_prime_volume_nc, filament change (same nozzle slot) uses filament_prime_volume.
|
||||
float wipe_volume_ec = filament_id < m_config.filament_prime_volume.values.size()
|
||||
? m_config.filament_prime_volume.values[filament_id]
|
||||
: (float) m_config.prime_volume;
|
||||
float wipe_volume_nc = filament_id < m_config.filament_prime_volume_nc.values.size()
|
||||
? m_config.filament_prime_volume_nc.values[filament_id]
|
||||
: (float) m_config.prime_volume;
|
||||
|
||||
float prime_volume = wipe_volume_ec;
|
||||
if (group_result) {
|
||||
bool is_nozzle_change = group_result->are_filaments_same_extruder(current_filament_id, filament_id, layer_idx) &&
|
||||
!group_result->are_filaments_same_nozzle(current_filament_id, filament_id, layer_idx);
|
||||
if (is_nozzle_change) {
|
||||
prime_volume = wipe_volume_nc;
|
||||
}
|
||||
}
|
||||
if (m_config.prime_volume_mode == PrimeVolumeMode::pvmSaving) {
|
||||
prime_volume = 15.f;
|
||||
}
|
||||
|
||||
wipe_tower.plan_toolchange((float)layer_tools.print_z, (float)layer_tools.wipe_tower_layer_height, current_filament_id, filament_id,
|
||||
prime_volume, volume_to_purge);
|
||||
current_filament_id = filament_id;
|
||||
nozzle_cur_filament_ids[nozzle_id] = filament_id;
|
||||
}
|
||||
layer_tools.wiping_extrusions().ensure_perimeters_infills_order(*this);
|
||||
|
||||
|
||||
@@ -331,6 +331,8 @@ CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(PrintSequence)
|
||||
static t_config_enum_values s_keys_map_PrintOrder{
|
||||
{ "default", int(PrintOrder::Default) },
|
||||
{ "as_obj_list", int(PrintOrder::AsObjectList)},
|
||||
{ "best_of", int(PrintOrder::BestOfStrategies)},
|
||||
{ "snake", int(PrintOrder::Snake)},
|
||||
};
|
||||
CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(PrintOrder)
|
||||
|
||||
@@ -1081,16 +1083,21 @@ void PrintConfigDef::init_common_params()
|
||||
def->set_default_value(new ConfigOptionString());
|
||||
}
|
||||
|
||||
def = this->add("plugin_config_overrides", coString);
|
||||
def->label = L("Capabilities");
|
||||
def->tooltip = L("Configuration for the plugin capabilities this preset uses, overriding the global "
|
||||
"Capabilities configuration. Stored as a raw JSON array and edited through the dialog "
|
||||
"behind the button, never typed in directly.");
|
||||
// Never shown as a text field: GUIType::plugin_config renders a button that opens PluginsConfigDialog.
|
||||
def->gui_type = ConfigOptionDef::GUIType::plugin_config;
|
||||
def->mode = comAdvanced;
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
def->set_default_value(new ConfigOptionString(""));
|
||||
// One key per preset type (Preset::plugin_overrides_key), so the print, printer and filament
|
||||
// overrides don't clobber each other when the presets merge into one full config. No handle_legacy
|
||||
// migration from the shared "plugin_config_overrides" they replace: it only ever shipped in
|
||||
// nightlies. Never a text field — GUIType::plugin_config renders a button opening PluginsConfigDialog.
|
||||
for (const char* key : {"print_plugin_config_overrides", "printer_plugin_config_overrides", "filament_plugin_config_overrides"}) {
|
||||
def = this->add(key, coString);
|
||||
def->label = L("Capabilities");
|
||||
def->tooltip = L("Configuration for the plugin capabilities this preset uses, overriding the global "
|
||||
"Capabilities configuration. Stored as a raw JSON array and edited through the dialog "
|
||||
"behind the button, never typed in directly.");
|
||||
def->gui_type = ConfigOptionDef::GUIType::plugin_config;
|
||||
def->mode = comAdvanced;
|
||||
def->cli = ConfigOptionDef::nocli;
|
||||
def->set_default_value(new ConfigOptionString(""));
|
||||
}
|
||||
}
|
||||
|
||||
void PrintConfigDef::init_fff_params()
|
||||
@@ -1994,12 +2001,30 @@ void PrintConfigDef::init_fff_params()
|
||||
|
||||
def = this->add("print_order", coEnum);
|
||||
def->label = L("Intra-layer order");
|
||||
def->tooltip = L("Print order within a single layer.");
|
||||
def->tooltip = L("Order in which object instances are visited within a single layer, which controls how much "
|
||||
"travel is spent moving between them.\n\n"
|
||||
"Default: nearest-neighbor chaining, refined with 2-opt and crossing removal. A good general "
|
||||
"choice.\n"
|
||||
"As object list: instances are printed in the same order as the object list, without any path "
|
||||
"optimization. Use it when you need a predictable, manually controlled order.\n"
|
||||
"Best of all (shortest path): every strategy is evaluated and the shortest one is used. The "
|
||||
"object instance order is decided once for the whole print, while the ordering of individual "
|
||||
"islands is decided per layer, so different layers may end up using different strategies. "
|
||||
"Slightly slower to slice.\n"
|
||||
"Snake: serpentine row-by-row traversal, refined with 2-opt. Well suited to regular grids of "
|
||||
"many small parts.\n\n"
|
||||
"With multiple filaments or tools in the same layer, minimizing tool changes takes priority: "
|
||||
"objects are grouped by filament first and this setting only orders the instances within each "
|
||||
"filament group, so the overall sequence may not look like the shortest path across the plate.");
|
||||
def->enum_keys_map = &ConfigOptionEnum<PrintOrder>::get_enum_values();
|
||||
def->enum_values.push_back("default");
|
||||
def->enum_values.push_back("as_obj_list");
|
||||
def->enum_values.push_back("best_of");
|
||||
def->enum_values.push_back("snake");
|
||||
def->enum_labels.push_back(L("Default"));
|
||||
def->enum_labels.push_back(L("As object list"));
|
||||
def->enum_labels.push_back(L("Best of all (shortest path)"));
|
||||
def->enum_labels.push_back(L("Snake"));
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionEnum<PrintOrder>(PrintOrder::Default));
|
||||
|
||||
@@ -5624,6 +5649,7 @@ void PrintConfigDef::init_fff_params()
|
||||
// Orca:
|
||||
def = this->add("retract_after_wipe", coPercents);
|
||||
def->label = L("Retract amount after wipe");
|
||||
// xgettext:no-c-format, no-boost-format
|
||||
def->tooltip = L("The length of fast retraction after wipe, relative to retraction length.\n"
|
||||
"The value will be clamped by 100% minus the retract amount before the wipe value.");
|
||||
def->sidetext = "%";
|
||||
@@ -7384,7 +7410,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->tooltip = L("The flush multiplier used in fast purge mode.");
|
||||
def->set_default_value(new ConfigOptionFloats{1.2});
|
||||
|
||||
// BBS
|
||||
// Orca: used by the generic (Type2) wipe tower; also the fallback for filament_prime_volume on Type1.
|
||||
def = this->add("prime_volume", coFloat);
|
||||
def->label = L("Prime volume");
|
||||
def->tooltip = L("This is the volume of material to prime the extruder with on the tower.");
|
||||
@@ -8030,6 +8056,16 @@ void PrintConfigDef::init_fff_params()
|
||||
def->mode = comDevelop;
|
||||
def->set_default_value(new ConfigOptionBool(false));
|
||||
|
||||
// Used by the Type1 wipe tower: filament_prime_volume on a filament change,
|
||||
// filament_prime_volume_nc on a hotend/nozzle change. Type2 uses prime_volume instead.
|
||||
def = this->add("filament_prime_volume", coFloats);
|
||||
def->label = L("Filament change");
|
||||
def->tooltip = L("The volume of material required to prime the extruder on the tower, excluding a hotend change.");
|
||||
def->sidetext = L("mm³");
|
||||
def->min = 1.0;
|
||||
def->mode = comSimple;
|
||||
def->set_default_value(new ConfigOptionFloats{45.});
|
||||
|
||||
def = this->add("filament_prime_volume_nc", coFloats);
|
||||
def->label = L("Hotend change");
|
||||
def->tooltip = L("The volume of material required to prime the extruder for a hotend change on the tower.");
|
||||
@@ -9050,7 +9086,7 @@ void PrintConfigDef::handle_legacy(t_config_option_key &opt_key, std::string &va
|
||||
"retraction_distance_when_cut",
|
||||
"internal_bridge_support_thickness", "top_area_threshold", "reduce_wall_solid_infill","filament_load_time","filament_unload_time",
|
||||
"smooth_coefficient", "overhang_totally_speed", "silent_mode",
|
||||
"overhang_speed_classic", "filament_prime_volume",
|
||||
"overhang_speed_classic",
|
||||
"anisotropic_surfaces", // superseded by top_surface_fill_order / bottom_surface_fill_order
|
||||
};
|
||||
|
||||
|
||||
@@ -214,6 +214,8 @@ enum class PrintOrder
|
||||
{
|
||||
Default,
|
||||
AsObjectList,
|
||||
BestOfStrategies, // run all custom strategies, pick the shortest total path
|
||||
Snake, // snake-like row traversal (back-and-forth) + 2-opt
|
||||
Count,
|
||||
};
|
||||
|
||||
@@ -1780,6 +1782,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
|
||||
((ConfigOptionString, filename_format))
|
||||
((ConfigOptionStrings, post_process))
|
||||
((ConfigOptionStrings, slicing_pipeline_plugin))
|
||||
((ConfigOptionString, print_plugin_config_overrides))
|
||||
((ConfigOptionString, printer_model))
|
||||
((ConfigOptionFloat, resolution))
|
||||
((ConfigOptionFloats, retraction_minimum_travel))
|
||||
@@ -1841,6 +1844,7 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
|
||||
// BBS: wipe tower is only used for priming
|
||||
((ConfigOptionFloat, prime_volume))
|
||||
// Nozzle-change (nc) prime volume + pre-heat delta
|
||||
((ConfigOptionFloats, filament_prime_volume))
|
||||
((ConfigOptionFloats, filament_prime_volume_nc))
|
||||
((ConfigOptionFloatsNullable, filament_preheat_temperature_delta))
|
||||
((ConfigOptionFloats, flush_multiplier))
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "KDTreeIndirect.hpp"
|
||||
#include "MutablePriorityQueue.hpp"
|
||||
#include "Print.hpp"
|
||||
#include "GCode/OrderingStrategies.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
@@ -1103,7 +1104,7 @@ std::vector<size_t> chain_expolygons(const ExPolygons &input_exploy) {
|
||||
return chain_points(points);
|
||||
}
|
||||
|
||||
std::vector<size_t> chain_points(const Points &points, Point *start_near)
|
||||
std::vector<size_t> chain_points(const Points &points, const Point *start_near)
|
||||
{
|
||||
auto segment_end_point = [&points](size_t idx, bool /* first_point */) -> const Point& { return points[idx]; };
|
||||
std::vector<std::pair<size_t, bool>> ordered = chain_segments_greedy<Point, decltype(segment_end_point)>(segment_end_point, points.size(), start_near);
|
||||
@@ -1111,9 +1112,26 @@ std::vector<size_t> chain_points(const Points &points, Point *start_near)
|
||||
out.reserve(ordered.size());
|
||||
for (auto &segment_and_reversal : ordered)
|
||||
out.emplace_back(segment_and_reversal.first);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
std::vector<size_t> chain_points_with_postprocessing(const Points &points, const Point *start_near)
|
||||
{
|
||||
std::vector<size_t> path = chain_points(points, start_near);
|
||||
// Alternate 2-opt and crossing removal until convergence.
|
||||
// 2-opt can create new crossings, and crossing removal can create new
|
||||
// opportunities for 2-opt improvement. Break early if neither improves.
|
||||
for (int iter = 0; iter < 3; ++iter) {
|
||||
bool improved = tsp_2opt_improve(path, points);
|
||||
improved |= tsp_remove_crossings(path, points);
|
||||
if (!improved) break;
|
||||
}
|
||||
if (start_near == nullptr)
|
||||
tsp_rotate_minimize_closing(path, points);
|
||||
return path;
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
// #define DEBUG_SVG_OUTPUT
|
||||
#endif /* NDEBUG */
|
||||
@@ -2025,12 +2043,13 @@ std::vector<const PrintInstance*> chain_print_object_instances(const std::vector
|
||||
instances.emplace_back(i, j);
|
||||
}
|
||||
}
|
||||
auto segment_end_point = [&object_reference_points](size_t idx, bool /* first_point */) -> const Point& { return object_reference_points[idx]; };
|
||||
std::vector<std::pair<size_t, bool>> ordered = chain_segments_greedy<Point, decltype(segment_end_point)>(segment_end_point, instances.size(), start_near);
|
||||
// Order objects using nearest neighbor + post-processing (crossing removal + 2-opt).
|
||||
std::vector<size_t> path = chain_points_with_postprocessing(object_reference_points, start_near);
|
||||
|
||||
std::vector<const PrintInstance*> out;
|
||||
out.reserve(instances.size());
|
||||
for (auto& segment_and_reversal : ordered) {
|
||||
const std::pair<size_t, size_t>& inst = instances[segment_and_reversal.first];
|
||||
out.reserve(path.size());
|
||||
for (size_t idx : path) {
|
||||
const std::pair<size_t, size_t>& inst = instances[idx];
|
||||
out.emplace_back(&print_objects[inst.first]->instances()[inst.second]);
|
||||
}
|
||||
return out;
|
||||
|
||||
@@ -15,7 +15,9 @@ namespace Slic3r {
|
||||
using PolyNodes = std::vector<PolyNode*, PointsAllocator<PolyNode*>>;
|
||||
}
|
||||
|
||||
std::vector<size_t> chain_points(const Points &points, Point *start_near = nullptr);
|
||||
std::vector<size_t> chain_points(const Points &points, const Point *start_near = nullptr);
|
||||
// Variant with post-processing (crossing removal + 2-opt) for object ordering.
|
||||
std::vector<size_t> chain_points_with_postprocessing(const Points &points, const Point *start_near = nullptr);
|
||||
std::vector<size_t> chain_expolygons(const ExPolygons &input_exploy);
|
||||
|
||||
std::vector<std::pair<size_t, bool>> chain_extrusion_entities(std::vector<ExtrusionEntity*> &entities, const Point *start_near = nullptr);
|
||||
|
||||
@@ -65,6 +65,15 @@ std::pair<SupportGeneratorLayersPtr, SupportGeneratorLayersPtr> generate_interfa
|
||||
const bool smooth_supports = support_params.support_style != smsGrid;
|
||||
SupportGeneratorLayersPtr &interface_layers = base_and_interface_layers.first;
|
||||
SupportGeneratorLayersPtr &base_interface_layers = base_and_interface_layers.second;
|
||||
// The user-facing interface layer counts include the contact layer. Internally,
|
||||
// contact layers are generated separately, so only the remaining layers are
|
||||
// projected into intermediate interface/base-interface layers here.
|
||||
const size_t num_top_interface_layers = support_params.has_top_contacts ? support_params.num_top_interface_layers - 1 : 0;
|
||||
const size_t num_bottom_interface_layers = support_params.has_bottom_contacts ? support_params.num_bottom_interface_layers - 1 : 0;
|
||||
const size_t num_top_base_interface_layers = std::min(support_params.num_top_base_interface_layers, num_top_interface_layers);
|
||||
const size_t num_bottom_base_interface_layers = std::min(support_params.num_bottom_base_interface_layers, num_bottom_interface_layers);
|
||||
const size_t num_top_interface_layers_only = num_top_interface_layers - num_top_base_interface_layers;
|
||||
const size_t num_bottom_interface_layers_only = num_bottom_interface_layers - num_bottom_base_interface_layers;
|
||||
|
||||
interface_layers.assign(intermediate_layers.size(), nullptr);
|
||||
if (support_params.has_base_interfaces())
|
||||
@@ -124,6 +133,8 @@ std::pair<SupportGeneratorLayersPtr, SupportGeneratorLayersPtr> generate_interfa
|
||||
};
|
||||
tbb::parallel_for(tbb::blocked_range<int>(0, int(intermediate_layers.size())),
|
||||
[&bottom_contacts, &top_contacts, &top_interface_layers, &top_base_interface_layers, &intermediate_layers, &insert_layer, &support_params,
|
||||
num_top_interface_layers, num_bottom_interface_layers, num_top_base_interface_layers, num_bottom_base_interface_layers,
|
||||
num_top_interface_layers_only, num_bottom_interface_layers_only,
|
||||
snug_supports, &interface_layers, &base_interface_layers](const tbb::blocked_range<int>& range) {
|
||||
// Gather the top / bottom contact layers intersecting with num_interface_layers resp. num_interface_layers_only intermediate layers above / below
|
||||
// this intermediate layer.
|
||||
@@ -142,16 +153,16 @@ std::pair<SupportGeneratorLayersPtr, SupportGeneratorLayersPtr> generate_interfa
|
||||
Polygons polygons_top_contact_projected_base;
|
||||
Polygons polygons_bottom_contact_projected_interface;
|
||||
Polygons polygons_bottom_contact_projected_base;
|
||||
if (support_params.num_top_interface_layers > 0) {
|
||||
if (num_top_interface_layers > 0) {
|
||||
// Top Z coordinate of a slab, over which we are collecting the top / bottom contact surfaces
|
||||
coordf_t top_z = intermediate_layers[std::min(num_intermediate - 1, idx_intermediate_layer + int(support_params.num_top_interface_layers) - 1)]->print_z;
|
||||
coordf_t top_inteface_z = std::numeric_limits<coordf_t>::max();
|
||||
if (support_params.num_top_base_interface_layers > 0)
|
||||
coordf_t top_z = intermediate_layers[std::min(num_intermediate - 1, idx_intermediate_layer + int(num_top_interface_layers) - 1)]->print_z;
|
||||
coordf_t top_interface_z = std::numeric_limits<coordf_t>::max();
|
||||
if (num_top_base_interface_layers > 0)
|
||||
// Some top base interface layers will be generated.
|
||||
top_inteface_z = support_params.num_top_interface_layers_only() == 0 ?
|
||||
top_interface_z = num_top_interface_layers_only == 0 ?
|
||||
// Only base interface layers to generate.
|
||||
- std::numeric_limits<coordf_t>::max() :
|
||||
intermediate_layers[std::min(num_intermediate - 1, idx_intermediate_layer + int(support_params.num_top_interface_layers_only()) - 1)]->print_z;
|
||||
intermediate_layers[std::min(num_intermediate - 1, idx_intermediate_layer + int(num_top_interface_layers_only) - 1)]->print_z;
|
||||
// Move idx_top_contact_first up until above the current print_z.
|
||||
idx_top_contact_first = idx_higher_or_equal(top_contacts, idx_top_contact_first, [&intermediate_layer](const SupportGeneratorLayer *layer){ return layer->print_z >= intermediate_layer.print_z; }); // - EPSILON
|
||||
// Collect the top contact areas above this intermediate layer, below top_z.
|
||||
@@ -160,22 +171,22 @@ std::pair<SupportGeneratorLayersPtr, SupportGeneratorLayersPtr> generate_interfa
|
||||
//FIXME maybe this adds one interface layer in excess?
|
||||
if (top_contact_layer.bottom_z - EPSILON > top_z)
|
||||
break;
|
||||
polygons_append(top_contact_layer.bottom_z - EPSILON > top_inteface_z ? polygons_top_contact_projected_base : polygons_top_contact_projected_interface,
|
||||
polygons_append(top_contact_layer.bottom_z - EPSILON > top_interface_z ? polygons_top_contact_projected_base : polygons_top_contact_projected_interface,
|
||||
// For snug supports, project the overhang polygons covering the whole overhang, so that they will merge without a gap with support polygons of the other layers.
|
||||
// For grid supports, merging of support regions will be performed by the projection into grid.
|
||||
snug_supports ? *top_contact_layer.overhang_polygons : top_contact_layer.polygons);
|
||||
}
|
||||
}
|
||||
if (support_params.num_bottom_interface_layers > 0) {
|
||||
if (num_bottom_interface_layers > 0) {
|
||||
// Bottom Z coordinate of a slab, over which we are collecting the top / bottom contact surfaces
|
||||
coordf_t bottom_z = intermediate_layers[std::max(0, idx_intermediate_layer - int(support_params.num_bottom_interface_layers) + 1)]->bottom_z;
|
||||
coordf_t bottom_z = intermediate_layers[std::max(0, idx_intermediate_layer - int(num_bottom_interface_layers) + 1)]->bottom_z;
|
||||
coordf_t bottom_interface_z = - std::numeric_limits<coordf_t>::max();
|
||||
if (support_params.num_bottom_base_interface_layers > 0)
|
||||
if (num_bottom_base_interface_layers > 0)
|
||||
// Some bottom base interface layers will be generated.
|
||||
bottom_interface_z = support_params.num_bottom_interface_layers_only() == 0 ?
|
||||
bottom_interface_z = num_bottom_interface_layers_only == 0 ?
|
||||
// Only base interface layers to generate.
|
||||
std::numeric_limits<coordf_t>::max() :
|
||||
intermediate_layers[std::max(0, idx_intermediate_layer - int(support_params.num_bottom_interface_layers_only()))]->bottom_z;
|
||||
intermediate_layers[std::max(0, idx_intermediate_layer - int(num_bottom_interface_layers_only))]->bottom_z;
|
||||
// Move idx_bottom_contact_first up until touching bottom_z.
|
||||
idx_bottom_contact_first = idx_higher_or_equal(bottom_contacts, idx_bottom_contact_first, [bottom_z](const SupportGeneratorLayer *layer){ return layer->print_z >= bottom_z - EPSILON; });
|
||||
// Collect the top contact areas above this intermediate layer, below top_z.
|
||||
@@ -1563,13 +1574,17 @@ void generate_support_toolpaths(
|
||||
// Pointer to the 1st layer interface filler.
|
||||
auto filler_first_layer = filler_first_layer_ptr ? filler_first_layer_ptr.get() : filler_interface.get();
|
||||
// Filler for the 1st layer interface, if different from filler_interface.
|
||||
auto filler_raft_contact_ptr = std::unique_ptr<Fill>(range.begin() == n_raft_layers && config.support_interface_top_layers.value == 0 ?
|
||||
const bool top_interfaces_enabled = support_params.num_top_interface_layers > 0;
|
||||
const bool bottom_interfaces_enabled = support_params.num_bottom_interface_layers > 0;
|
||||
const coordf_t base_interface_density = top_interfaces_enabled || !bottom_interfaces_enabled ?
|
||||
support_params.top_interface_density : support_params.bottom_interface_density;
|
||||
auto filler_raft_contact_ptr = std::unique_ptr<Fill>(range.begin() == n_raft_layers && !top_interfaces_enabled ?
|
||||
Fill::new_from_type(support_params.raft_interface_fill_pattern) : nullptr);
|
||||
// Pointer to the 1st layer interface filler.
|
||||
auto filler_raft_contact = filler_raft_contact_ptr ? filler_raft_contact_ptr.get() : filler_interface.get();
|
||||
// Filler for the base interface (to be used for soluble interface / non soluble base, to produce non soluble interface layer below soluble interface layer).
|
||||
auto filler_base_interface = std::unique_ptr<Fill>(base_interface_layers.empty() ? nullptr :
|
||||
Fill::new_from_type(support_params.top_interface_density > 0.95 || support_params.with_sheath ? ipRectilinear : ipSupportBase));
|
||||
Fill::new_from_type(base_interface_density > 0.95 || support_params.with_sheath ? ipRectilinear : ipSupportBase));
|
||||
auto filler_support = std::unique_ptr<Fill>(Fill::new_from_type(support_params.base_fill_pattern));
|
||||
filler_interface->set_bounding_box(bbox_object);
|
||||
if (filler_first_layer_ptr)
|
||||
@@ -1583,10 +1598,7 @@ void generate_support_toolpaths(
|
||||
{
|
||||
SupportLayer &support_layer = *support_layers[support_layer_id];
|
||||
LayerCache &layer_cache = layer_caches[support_layer_id];
|
||||
const float support_interface_angle = (config.support_interface_pattern == smipRectilinearInterlaced) ?
|
||||
support_params.raft_interface_angle(support_layer.interface_id()) :
|
||||
((support_params.support_style == smsGrid || config.support_interface_pattern == smipRectilinear) ?
|
||||
support_params.interface_angle : support_params.raft_interface_angle(support_layer.interface_id()));
|
||||
const float support_interface_angle = support_params.support_interface_angle(support_layer.interface_id());
|
||||
|
||||
// Find polygons with the same print_z.
|
||||
SupportGeneratorLayerExtruded &bottom_contact_layer = layer_cache.bottom_contact_layer;
|
||||
@@ -1619,7 +1631,9 @@ void generate_support_toolpaths(
|
||||
bool raft_layer = slicing_params.interface_raft_layers && top_contact_layer.layer && is_approx(top_contact_layer.layer->print_z, slicing_params.raft_contact_top_z);
|
||||
// ORCA: Organic tree uses projected contacts to build the interface stack; avoid extra bottom-contact extrusion.
|
||||
const bool organic_tree = support_params.support_style == SupportMaterialStyle::smsTreeOrganic;
|
||||
if (config.support_interface_top_layers == 0) {
|
||||
const bool top_interfaces = support_params.num_top_interface_layers > 0;
|
||||
const bool bottom_interfaces = support_params.num_bottom_interface_layers > 0;
|
||||
if (!top_interfaces) {
|
||||
// If no top interface layers were requested, we treat the contact layer exactly as a generic base layer.
|
||||
// Don't merge the raft contact layer though.
|
||||
if (support_params.can_merge_support_regions && ! raft_layer) {
|
||||
@@ -1642,15 +1656,29 @@ void generate_support_toolpaths(
|
||||
if (top_contact_layer.could_merge(interface_layer) && ! raft_layer)
|
||||
top_contact_layer.merge(std::move(interface_layer));
|
||||
}
|
||||
if ((config.support_interface_top_layers == 0 || config.support_interface_bottom_layers == 0) && support_params.can_merge_support_regions) {
|
||||
if (!bottom_interfaces && support_params.can_merge_support_regions) {
|
||||
if (base_layer.could_merge(bottom_contact_layer))
|
||||
base_layer.merge(std::move(bottom_contact_layer));
|
||||
else if (base_layer.empty() && ! bottom_contact_layer.empty() && ! bottom_contact_layer.layer->bridging)
|
||||
base_layer = std::move(bottom_contact_layer);
|
||||
} else if (bottom_contact_layer.could_merge(top_contact_layer) && ! raft_layer) {
|
||||
top_contact_layer.merge(std::move(bottom_contact_layer));
|
||||
if (top_interfaces && bottom_interfaces) {
|
||||
top_contact_layer.merge(std::move(bottom_contact_layer));
|
||||
} else if (bottom_interfaces) {
|
||||
top_contact_layer.set_polygons_to_extrude(
|
||||
diff(top_contact_layer.polygons_to_extrude(), bottom_contact_layer.polygons_to_extrude()));
|
||||
} else {
|
||||
bottom_contact_layer.set_polygons_to_extrude(
|
||||
diff(bottom_contact_layer.polygons_to_extrude(), top_contact_layer.polygons_to_extrude()));
|
||||
}
|
||||
} else if (bottom_contact_layer.could_merge(interface_layer) && ! organic_tree) {
|
||||
bottom_contact_layer.merge(std::move(interface_layer));
|
||||
const bool interface_layer_is_bottom = interface_layer.layer->layer_type == SupporLayerType::BottomInterface;
|
||||
if (bottom_interfaces && interface_layer_is_bottom) {
|
||||
bottom_contact_layer.merge(std::move(interface_layer));
|
||||
} else {
|
||||
bottom_contact_layer.set_polygons_to_extrude(
|
||||
diff(bottom_contact_layer.polygons_to_extrude(), interface_layer.polygons_to_extrude()));
|
||||
}
|
||||
}
|
||||
|
||||
// Orca: For organic trees the support-material regions are generated from
|
||||
@@ -1730,12 +1758,12 @@ void generate_support_toolpaths(
|
||||
interface_as_base ? ExtrusionRole::erSupportMaterial : ExtrusionRole::erSupportMaterialInterface, interface_flow);
|
||||
}
|
||||
};
|
||||
const bool top_interfaces = support_params.num_top_interface_layers > 0;
|
||||
const bool bottom_interfaces = top_interfaces && support_params.num_bottom_interface_layers > 0;
|
||||
extrude_interface(top_contact_layer, raft_layer ? InterfaceLayerType::RaftContact : top_interfaces ? InterfaceLayerType::TopContact : InterfaceLayerType::InterfaceAsBase);
|
||||
if (!organic_tree)
|
||||
extrude_interface(bottom_contact_layer, bottom_interfaces ? InterfaceLayerType::BottomContact : InterfaceLayerType::InterfaceAsBase);
|
||||
extrude_interface(interface_layer, top_interfaces ? InterfaceLayerType::Interface : InterfaceLayerType::InterfaceAsBase);
|
||||
const bool interface_layer_enabled = !interface_layer.empty() &&
|
||||
(interface_layer.layer->layer_type == SupporLayerType::BottomInterface ? bottom_interfaces : top_interfaces);
|
||||
extrude_interface(interface_layer, interface_layer_enabled ? InterfaceLayerType::Interface : InterfaceLayerType::InterfaceAsBase);
|
||||
// Base interface layers under soluble interfaces
|
||||
if ( ! base_interface_layer.empty() && ! base_interface_layer.polygons_to_extrude().empty()) {
|
||||
Fill *filler = filler_base_interface.get();
|
||||
@@ -1745,7 +1773,7 @@ void generate_support_toolpaths(
|
||||
Flow interface_flow = support_params.support_material_flow.with_height(float(base_interface_layer.layer->height));
|
||||
filler->angle = support_interface_angle;
|
||||
filler->spacing = support_params.support_material_interface_flow.spacing();
|
||||
filler->link_max_length = coord_t(scale_(filler->spacing * link_max_length_factor / support_params.top_interface_density));
|
||||
filler->link_max_length = coord_t(scale_(filler->spacing * link_max_length_factor / base_interface_density));
|
||||
fill_expolygons_generate_paths(
|
||||
// Destination
|
||||
base_interface_layer.extrusions,
|
||||
@@ -1753,7 +1781,7 @@ void generate_support_toolpaths(
|
||||
// Regions to fill
|
||||
union_safety_offset_ex(base_interface_layer.polygons_to_extrude()),
|
||||
// Filler and its parameters
|
||||
filler, float(support_params.top_interface_density),
|
||||
filler, float(base_interface_density),
|
||||
// Extrusion parameters
|
||||
ExtrusionRole::erSupportMaterial, interface_flow);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ struct SupportParameters {
|
||||
|
||||
{
|
||||
this->num_top_interface_layers = std::max(0, object_config.support_interface_top_layers.value);
|
||||
this->num_bottom_interface_layers = number_of_support_interface_bottom_layers(object_config);
|
||||
this->num_bottom_interface_layers = std::max(0, number_of_support_interface_bottom_layers(object_config));
|
||||
this->has_top_contacts = num_top_interface_layers > 0;
|
||||
this->has_bottom_contacts = num_bottom_interface_layers > 0;
|
||||
// BBS: if support interface and support base do not use the same filament, add a base layer to improve their adhesion
|
||||
@@ -46,15 +46,15 @@ struct SupportParameters {
|
||||
if (non_soluble_base_top) { // ORCA: Try to support soluble dense interfaces with non-soluble dense interfaces.
|
||||
this->num_top_base_interface_layers = size_t(std::min(int(num_top_interface_layers) / 2, 2));
|
||||
} else {
|
||||
this->num_top_base_interface_layers =
|
||||
(different_support_interface_filament && this->zero_gap_interface_top) ? 1 : 0;
|
||||
// Keep at least one configured layer on the interface filament.
|
||||
this->num_top_base_interface_layers = different_support_interface_filament && num_top_interface_layers > 1 ? 1 : 0;
|
||||
}
|
||||
|
||||
if (non_soluble_base_bottom) { // ORCA: Try to support soluble dense interfaces with non-soluble dense interfaces.
|
||||
this->num_bottom_base_interface_layers = size_t(std::min(int(num_bottom_interface_layers) / 2, 2));
|
||||
} else {
|
||||
this->num_bottom_base_interface_layers =
|
||||
(different_support_interface_filament && this->zero_gap_interface_bottom) ? 1 : 0;
|
||||
// Keep at least one configured layer on the interface filament.
|
||||
this->num_bottom_base_interface_layers = different_support_interface_filament && num_bottom_interface_layers > 1 ? 1 : 0;
|
||||
}
|
||||
}
|
||||
this->first_layer_flow = Slic3r::support_material_1st_layer_flow(&object, float(slicing_params.first_print_layer_height));
|
||||
@@ -74,7 +74,7 @@ struct SupportParameters {
|
||||
for (auto layer : object.layers())
|
||||
this->support_layer_height_min = std::min(this->support_layer_height_min, std::max(0.01, layer->height));
|
||||
|
||||
if (object_config.support_interface_top_layers.value == 0) {
|
||||
if (this->num_top_interface_layers == 0 && this->num_bottom_interface_layers == 0) {
|
||||
// No interface layers allowed, print everything with the base support pattern.
|
||||
this->support_material_interface_flow = this->support_material_flow;
|
||||
}
|
||||
@@ -120,8 +120,8 @@ struct SupportParameters {
|
||||
this->raft_interface_density = std::min(1., this->raft_interface_flow.spacing() / raft_interface_spacing);
|
||||
this->support_spacing = object_config.support_base_pattern_spacing.value + this->support_material_flow.spacing();
|
||||
this->support_density = std::min(1., this->support_material_flow.spacing() / this->support_spacing);
|
||||
if (object_config.support_interface_top_layers.value == 0) {
|
||||
// No interface layers allowed, print everything with the base support pattern.
|
||||
if (this->num_top_interface_layers == 0) {
|
||||
// No top interface layers allowed; keep unused top interface parameters aligned with base support.
|
||||
this->top_interface_spacing = this->support_spacing;
|
||||
this->top_interface_density = this->support_density;
|
||||
}
|
||||
@@ -133,16 +133,20 @@ struct SupportParameters {
|
||||
this->support_density > 0.95 || this->with_sheath ? ipRectilinear : ipSupportBase;
|
||||
this->interface_fill_pattern = (this->top_interface_density > 0.95 ? ipRectilinear : ipSupportBase);
|
||||
this->raft_interface_fill_pattern = this->raft_interface_density > 0.95 ? ipRectilinear : ipSupportBase;
|
||||
const coordf_t contact_interface_density = this->num_top_interface_layers > 0 ?
|
||||
this->top_interface_density : this->bottom_interface_density;
|
||||
const bool zero_gap_contact_interface = this->num_top_interface_layers > 0 ?
|
||||
this->zero_gap_interface_top : this->zero_gap_interface_bottom;
|
||||
if (object_config.support_interface_pattern == smipGrid)
|
||||
this->contact_fill_pattern = ipGrid;
|
||||
else if (object_config.support_interface_pattern == smipRectilinearInterlaced)
|
||||
this->contact_fill_pattern = ipRectilinear;
|
||||
else
|
||||
this->contact_fill_pattern =
|
||||
(object_config.support_interface_pattern == smipAuto && this->zero_gap_interface_top) ||
|
||||
(object_config.support_interface_pattern == smipAuto && zero_gap_contact_interface) ||
|
||||
object_config.support_interface_pattern == smipConcentric ?
|
||||
ipConcentric :
|
||||
(this->top_interface_density > 0.95 ? ipRectilinear : ipSupportBase);
|
||||
(contact_interface_density > 0.95 ? ipRectilinear : ipSupportBase);
|
||||
|
||||
this->raft_angle_1st_layer = 0.f;
|
||||
this->raft_angle_base = 0.f;
|
||||
@@ -188,6 +192,7 @@ struct SupportParameters {
|
||||
std::numeric_limits<double>::max();
|
||||
|
||||
support_style = object_config.support_style;
|
||||
support_interface_pattern = object_config.support_interface_pattern;
|
||||
if (support_style != smsDefault) {
|
||||
if ((support_style == smsSnug || support_style == smsGrid) && is_tree(object_config.support_type)) support_style = smsDefault;
|
||||
if ((support_style == smsTreeSlim || support_style == smsTreeStrong || support_style == smsTreeHybrid || support_style == smsTreeOrganic) &&
|
||||
@@ -211,9 +216,9 @@ struct SupportParameters {
|
||||
bool has_top_contacts;
|
||||
// Is there at least a bottom contact layer extruded below support base?
|
||||
bool has_bottom_contacts;
|
||||
// Number of top interface layers without counting the contact layer.
|
||||
// User-configured number of top interface layers, including the contact layer.
|
||||
size_t num_top_interface_layers;
|
||||
// Number of bottom interface layers without counting the contact layer.
|
||||
// User-configured number of bottom interface layers, including the contact layer.
|
||||
size_t num_bottom_interface_layers;
|
||||
// Number of top base interface layers.
|
||||
size_t num_top_base_interface_layers;
|
||||
@@ -235,7 +240,7 @@ struct SupportParameters {
|
||||
Flow support_material_interface_flow;
|
||||
// Flow at the bottom interfaces and contacts.
|
||||
Flow support_material_bottom_interface_flow;
|
||||
// Flow at raft inteface & contact layers.
|
||||
// Flow at raft interface & contact layers.
|
||||
Flow raft_interface_flow;
|
||||
coordf_t support_extrusion_width;
|
||||
// Is merging of regions allowed? Could the interface & base support regions be printed with the same extruder?
|
||||
@@ -262,6 +267,7 @@ struct SupportParameters {
|
||||
// Density of the base support layers.
|
||||
coordf_t support_density;
|
||||
SupportMaterialStyle support_style = smsDefault;
|
||||
SupportMaterialInterfacePattern support_interface_pattern = smipAuto;
|
||||
|
||||
// Pattern of the sparse infill including sparse raft layers.
|
||||
InfillPattern base_fill_pattern;
|
||||
@@ -280,9 +286,33 @@ struct SupportParameters {
|
||||
float raft_angle_base;
|
||||
float raft_angle_interface;
|
||||
|
||||
// Produce a raft interface angle for a given SupportLayer::interface_id()
|
||||
// Produce a +/-45deg alternating raft interface angle for a given SupportLayer::interface_id().
|
||||
float raft_interface_angle(size_t interface_id) const
|
||||
{ return this->raft_angle_interface + ((interface_id & 1) ? float(- M_PI / 4.) : float(+ M_PI / 4.)); }
|
||||
{ return this->raft_angle_interface + ((interface_id & 1) ? float(- M_PI_4) : float(+ M_PI_4)); }
|
||||
|
||||
// Produce support interface angle for a given SupportLayer::interface_id().
|
||||
// Angle will be shifted/rotated based on interface pattern.
|
||||
float support_interface_angle(size_t interface_id) const
|
||||
{
|
||||
float angle;
|
||||
|
||||
switch (this->support_interface_pattern) {
|
||||
case SupportMaterialInterfacePattern::smipRectilinear:
|
||||
angle = support_style == SupportMaterialStyle::smsSnug ? this->interface_angle - float(M_PI_4) : this->interface_angle;
|
||||
break;
|
||||
case SupportMaterialInterfacePattern::smipRectilinearInterlaced:
|
||||
angle = this->interface_angle + ((interface_id & 1) ? float(M_PI_4) : float(-M_PI_4));
|
||||
break;
|
||||
case SupportMaterialInterfacePattern::smipGrid:
|
||||
angle = this->base_angle;
|
||||
break;
|
||||
default:
|
||||
angle = this->interface_angle;
|
||||
break;
|
||||
}
|
||||
|
||||
return angle;
|
||||
}
|
||||
|
||||
bool independent_layer_height = false;
|
||||
const double thresh_big_overhang = Slic3r::sqr(scale_(10));
|
||||
|
||||
@@ -469,7 +469,7 @@ void TreeModelVolumes::calculateCollision(const coord_t radius, const LayerIndex
|
||||
});
|
||||
|
||||
// 2) Sum over top / bottom ranges.
|
||||
const bool processing_last_mesh = outline_idx == layer_outline_indices.size();
|
||||
const bool processing_last_mesh = outline_idx == layer_outline_indices.back();
|
||||
tbb::parallel_for(tbb::blocked_range<LayerIndex>(data.begin(), data.end()),
|
||||
[&collision_areas_offsetted, &outlines, &machine_border = m_machine_border, &anti_overhang = m_anti_overhang, radius,
|
||||
xy_distance, z_distance_bottom_layers, z_distance_top_layers, min_resolution = m_min_resolution, &data, processing_last_mesh, &throw_on_cancel]
|
||||
|
||||
@@ -1511,7 +1511,9 @@ void TreeSupport::generate_toolpaths()
|
||||
// ORCA: reset interface Fill state per area group to keep angles deterministic.
|
||||
filler_interface->fixed_angle = false;
|
||||
filler_interface->layer_id = size_t(-1);
|
||||
filler_interface->angle = base_support_angle + M_PI_2; // default interface angle is perpendicular to support angle
|
||||
filler_Roof1stLayer->fixed_angle = false;
|
||||
filler_Roof1stLayer->layer_id = size_t(-1);
|
||||
filler_interface->angle = m_support_params.support_interface_angle(area_group.interface_id);
|
||||
if (area_group.type != SupportLayer::BaseType) {
|
||||
// interface
|
||||
if (layer_id == 0) {
|
||||
@@ -1537,8 +1539,10 @@ void TreeSupport::generate_toolpaths()
|
||||
fill_params.density = interface_density;
|
||||
// Note: spacing means the separation between two lines as if they are tightly extruded
|
||||
filler_Roof1stLayer->spacing = interface_flow.spacing();
|
||||
filler_Roof1stLayer->angle = base_support_angle;
|
||||
filler_Roof1stLayer->angle = m_support_params.support_interface_angle(area_group.interface_id);
|
||||
fill_params.dont_sort = true;
|
||||
filler_Roof1stLayer->fixed_angle = (m_object_config->support_interface_pattern == smipRectilinearInterlaced ||
|
||||
m_object_config->support_interface_pattern == smipRectilinear);
|
||||
Flow interface_base_flow = interface_as_base ? support_flow : interface_flow;
|
||||
ExtrusionRole interface_role = interface_as_base ? erSupportMaterial : erSupportMaterialInterface;
|
||||
// generate a perimeter first to support interface better
|
||||
@@ -1556,18 +1560,11 @@ void TreeSupport::generate_toolpaths()
|
||||
fill_params.density = bottom_interface_density;
|
||||
filler_interface->spacing = interface_flow.spacing();
|
||||
|
||||
if (m_object_config->support_interface_pattern == smipGrid) {
|
||||
filler_interface->angle = base_support_angle;
|
||||
fill_params.dont_sort = true;
|
||||
}
|
||||
|
||||
if (m_object_config->support_interface_pattern == smipRectilinearInterlaced) {
|
||||
// ORCA: explicit 0/90 alternation for rectilinear interlaced interfaces.
|
||||
filler_interface->fixed_angle = true;
|
||||
filler_interface->angle = base_support_angle + ((area_group.interface_id & 1) * M_PI_2);
|
||||
fill_params.dont_sort = true;
|
||||
}
|
||||
fill_params.dont_sort = (m_object_config->support_interface_pattern == smipGrid ||
|
||||
m_object_config->support_interface_pattern == smipRectilinearInterlaced);
|
||||
|
||||
filler_interface->fixed_angle = (m_object_config->support_interface_pattern == smipRectilinearInterlaced ||
|
||||
m_object_config->support_interface_pattern == smipRectilinear);
|
||||
|
||||
Flow interface_base_flow = interface_as_base ? support_flow : interface_flow;
|
||||
ExtrusionRole interface_role = interface_as_base ? erSupportMaterial : erSupportMaterialInterface;
|
||||
@@ -1579,17 +1576,11 @@ void TreeSupport::generate_toolpaths()
|
||||
fill_params.density = interface_density;
|
||||
filler_interface->spacing = interface_flow.spacing();
|
||||
|
||||
if (m_object_config->support_interface_pattern == smipGrid) {
|
||||
filler_interface->angle = base_support_angle;
|
||||
fill_params.dont_sort = true;
|
||||
}
|
||||
fill_params.dont_sort = (m_object_config->support_interface_pattern == smipGrid ||
|
||||
m_object_config->support_interface_pattern == smipRectilinearInterlaced);
|
||||
|
||||
if (m_object_config->support_interface_pattern == smipRectilinearInterlaced) {
|
||||
// ORCA: explicit 0/90 alternation for rectilinear interlaced interfaces.
|
||||
filler_interface->fixed_angle = true;
|
||||
filler_interface->angle = base_support_angle + ((area_group.interface_id & 1) * M_PI_2);
|
||||
fill_params.dont_sort = true;
|
||||
}
|
||||
filler_interface->fixed_angle = (m_object_config->support_interface_pattern == smipRectilinearInterlaced ||
|
||||
m_object_config->support_interface_pattern == smipRectilinear);
|
||||
|
||||
Flow interface_base_flow = interface_as_base ? support_flow : interface_flow;
|
||||
ExtrusionRole interface_role = interface_as_base ? erSupportMaterial : erSupportMaterialInterface;
|
||||
@@ -2014,6 +2005,9 @@ void TreeSupport::draw_circles()
|
||||
// generate areas
|
||||
const coordf_t layer_height = config.layer_height.value;
|
||||
const size_t top_interface_layers = m_support_params.num_top_interface_layers;
|
||||
const int top_base_interface_layers = std::min<int>(
|
||||
int(m_support_params.num_top_base_interface_layers),
|
||||
top_interface_layers > 0 ? int(top_interface_layers) - 1 : 0);
|
||||
const size_t bottom_interface_layers = number_of_support_interface_bottom_layers(config);
|
||||
const double nozzle_diameter = m_object->print()->config().nozzle_diameter.get_at(0);
|
||||
const coordf_t line_width = config.get_abs_value("support_line_width", nozzle_diameter);
|
||||
@@ -2054,12 +2048,14 @@ void TreeSupport::draw_circles()
|
||||
|
||||
ExPolygons& base_areas = ts_layer->base_areas;
|
||||
ExPolygons& roof_areas = ts_layer->roof_areas;
|
||||
ExPolygons roof_base_areas;
|
||||
ExPolygons& roof_1st_layer = ts_layer->roof_1st_layer;
|
||||
ExPolygons& floor_areas = ts_layer->floor_areas;
|
||||
ExPolygons& roof_gap_areas = ts_layer->roof_gap_areas;
|
||||
coordf_t max_layers_above_base = 0;
|
||||
coordf_t max_layers_above_roof = 0;
|
||||
coordf_t max_layers_above_roof1 = 0;
|
||||
size_t first_base_roof_area = 0;
|
||||
bool floor_interface_as_base = false;
|
||||
bool has_circle_node = false;
|
||||
bool need_extra_wall = false;
|
||||
@@ -2094,8 +2090,6 @@ void TreeSupport::draw_circles()
|
||||
break;
|
||||
|
||||
const SupportNode& node = *p_node;
|
||||
// ORCA: Cap top interface height in mm based on per-node support layer height.
|
||||
const coordf_t top_interface_height = coordf_t(top_interface_layers) * node.height;
|
||||
ExPolygons area;
|
||||
// Generate directly from overhang polygon if one of the following is true:
|
||||
// 1) node is a normal part of hybrid support
|
||||
@@ -2159,18 +2153,16 @@ void TreeSupport::draw_circles()
|
||||
|
||||
if (obj_layer_nr>0 && node.distance_to_top < 0)
|
||||
append(roof_gap_areas, area);
|
||||
// ORCA: Roof1stLayer must also fit inside the mm cap.
|
||||
else if (obj_layer_nr > 0 && node.support_roof_layers_below == 1 &&
|
||||
(node.dist_mm_to_top - this->top_z_distance) < top_interface_height + EPSILON && node.is_sharp_tail==false)
|
||||
node.is_sharp_tail == false)
|
||||
{
|
||||
append(roof_1st_layer, area);
|
||||
max_layers_above_roof1 = std::max(max_layers_above_roof1, node.dist_mm_to_top);
|
||||
}
|
||||
// ORCA: Roof layers must also fit inside the mm cap.
|
||||
else if (obj_layer_nr > 0 && node.support_roof_layers_below > 1 &&
|
||||
(node.dist_mm_to_top - this->top_z_distance) < top_interface_height + EPSILON && node.is_sharp_tail == false)
|
||||
node.is_sharp_tail == false)
|
||||
{
|
||||
append(roof_areas, area);
|
||||
append(node.support_roof_layers_below <= top_base_interface_layers ? roof_base_areas : roof_areas, area);
|
||||
max_layers_above_roof = std::max(max_layers_above_roof, node.dist_mm_to_top);
|
||||
}
|
||||
else
|
||||
@@ -2184,9 +2176,17 @@ void TreeSupport::draw_circles()
|
||||
//m_object->print()->set_status(65, (boost::format( _u8L("Support: generate polygons at layer %d")) % layer_nr).str());
|
||||
|
||||
// join roof segments
|
||||
roof_areas = diff_clipped(offset2_ex(roof_areas, line_width_scaled, -line_width_scaled), get_collision(false));
|
||||
roof_areas = diff_clipped(closing_ex(roof_areas, line_width_scaled), get_collision(false));
|
||||
roof_areas = intersection_ex(roof_areas, m_machine_border);
|
||||
roof_1st_layer = diff_clipped(offset2_ex(roof_1st_layer, line_width_scaled, -line_width_scaled), get_collision(false));
|
||||
roof_base_areas = diff_clipped(closing_ex(roof_base_areas, line_width_scaled), get_collision(false));
|
||||
roof_base_areas = intersection_ex(roof_base_areas, m_machine_border);
|
||||
if (!roof_base_areas.empty() && !roof_areas.empty())
|
||||
roof_base_areas = diff_ex(roof_base_areas,
|
||||
ClipperUtils::clip_clipper_polygons_with_subject_bbox(roof_areas, get_extents(roof_base_areas)));
|
||||
|
||||
first_base_roof_area = roof_areas.size();
|
||||
append(roof_areas, std::move(roof_base_areas));
|
||||
roof_1st_layer = diff_clipped(closing_ex(roof_1st_layer, line_width_scaled), get_collision(false));
|
||||
|
||||
// roof_1st_layer and roof_areas may intersect, so need to subtract roof_areas from roof_1st_layer
|
||||
roof_1st_layer = diff_ex(roof_1st_layer, ClipperUtils::clip_clipper_polygons_with_subject_bbox(roof_areas,get_extents(roof_1st_layer)));
|
||||
@@ -2366,9 +2366,11 @@ void TreeSupport::draw_circles()
|
||||
area_groups.back().need_infill = overlaps({ expoly }, area_poly);
|
||||
area_groups.back().need_extra_wall = need_extra_wall && !area_groups.back().need_infill;
|
||||
}
|
||||
for (auto& expoly : ts_layer->roof_areas) {
|
||||
for (size_t roof_idx = 0; roof_idx < ts_layer->roof_areas.size(); ++roof_idx) {
|
||||
auto &expoly = ts_layer->roof_areas[roof_idx];
|
||||
//if (area(expoly) < SQ(scale_(1))) continue;
|
||||
area_groups.emplace_back(&expoly, SupportLayer::RoofType, max_layers_above_roof);
|
||||
area_groups.back().interface_as_base = roof_idx >= first_base_roof_area;
|
||||
}
|
||||
for (auto &expoly : ts_layer->floor_areas) {
|
||||
//if (area(expoly) < SQ(scale_(1))) continue;
|
||||
@@ -2378,6 +2380,7 @@ void TreeSupport::draw_circles()
|
||||
for (auto &expoly : ts_layer->roof_1st_layer) {
|
||||
//if (area(expoly) < SQ(scale_(1))) continue;
|
||||
area_groups.emplace_back(&expoly, SupportLayer::Roof1stLayer, max_layers_above_roof1);
|
||||
area_groups.back().interface_as_base = top_base_interface_layers > 0;
|
||||
}
|
||||
|
||||
for (auto &area_group : area_groups) {
|
||||
@@ -2406,7 +2409,6 @@ void TreeSupport::draw_circles()
|
||||
}
|
||||
});
|
||||
// ORCA: normalize interface_id sequencing to follow printed interface layers only.
|
||||
const int top_base_layers = int(m_support_params.num_top_base_interface_layers);
|
||||
const bool interlaced = m_object_config->support_interface_pattern == smipRectilinearInterlaced;
|
||||
int roof_interface_id = 0;
|
||||
int floor_interface_id = 0;
|
||||
@@ -2425,7 +2427,6 @@ void TreeSupport::draw_circles()
|
||||
if (area_group.type == SupportLayer::RoofType || area_group.type == SupportLayer::Roof1stLayer) {
|
||||
if (interlaced)
|
||||
area_group.interface_id = roof_interface_id;
|
||||
area_group.interface_as_base = top_base_layers > 0 && roof_interface_id < top_base_layers;
|
||||
has_roof_interface = true;
|
||||
} else if (area_group.type == SupportLayer::FloorType) {
|
||||
if (interlaced)
|
||||
@@ -2897,7 +2898,7 @@ void TreeSupport::drop_nodes()
|
||||
node_parent->merged_neighbours.push_front(node_parent == p_node ? neighbour : p_node);
|
||||
const bool to_buildplate = !is_inside_ex(get_collision(0, obj_layer_nr_next), next_position);
|
||||
SupportNode* next_node = m_ts_data->create_node(next_position, node_parent->distance_to_top + 1, obj_layer_nr_next,
|
||||
node_parent->support_roof_layers_below - (node_parent->distance_to_top > 0 ? 1 : 0),
|
||||
node_parent->support_roof_layers_below - (node_parent->distance_to_top >= 0 ? 1 : 0),
|
||||
to_buildplate, node_parent, print_z_next, height_next);
|
||||
get_max_move_dist(next_node);
|
||||
m_ts_data->m_mutex.lock();
|
||||
@@ -2949,7 +2950,7 @@ void TreeSupport::drop_nodes()
|
||||
for(auto& overhang:overhangs_next) {
|
||||
Point next_pt = overhang.contour.centroid();
|
||||
SupportNode *next_node = m_ts_data->create_node(next_pt, p_node->distance_to_top + 1, obj_layer_nr_next,
|
||||
p_node->support_roof_layers_below - (p_node->distance_to_top > 0 ? 1 : 0),
|
||||
p_node->support_roof_layers_below - (p_node->distance_to_top >= 0 ? 1 : 0),
|
||||
to_buildplate, p_node, print_z_next, height_next);
|
||||
next_node->max_move_dist = 0;
|
||||
next_node->overhang = std::move(overhang);
|
||||
@@ -3096,7 +3097,7 @@ void TreeSupport::drop_nodes()
|
||||
auto next_collision = get_collision(0, obj_layer_nr_next);
|
||||
const bool to_buildplate = !is_inside_ex(m_ts_data->m_layer_outlines[obj_layer_nr_next], next_layer_vertex);
|
||||
SupportNode * next_node = m_ts_data->create_node(next_layer_vertex, node.distance_to_top + 1, obj_layer_nr_next,
|
||||
node.support_roof_layers_below - (node.distance_to_top > 0 ? 1 : 0),
|
||||
node.support_roof_layers_below - (node.distance_to_top >= 0 ? 1 : 0),
|
||||
to_buildplate, p_node, print_z_next, height_next);
|
||||
// don't increase radius if next node will collide partially with the object (STUDIO-7883)
|
||||
to_outside = projection_onto(next_collision, next_node->position);
|
||||
@@ -3376,21 +3377,6 @@ std::vector<LayerHeightData> TreeSupport::plan_layer_heights()
|
||||
}
|
||||
}
|
||||
|
||||
// ORCA: Recompute support_roof_layers_below from remaining interface height (independent heights).
|
||||
const int top_layers = m_object->config().support_interface_top_layers.value;
|
||||
if (m_support_params.independent_layer_height && top_layers > 0) {
|
||||
const coordf_t interface_height_mm = coordf_t(top_layers) * m_slicing_params.layer_height;
|
||||
for (int layer_nr = 0; layer_nr < contact_nodes.size(); layer_nr++) {
|
||||
if (contact_nodes[layer_nr].empty()) continue;
|
||||
for (SupportNode *node : contact_nodes[layer_nr]) {
|
||||
if (node->height <= EPSILON) continue;
|
||||
const coordf_t remaining_mm = interface_height_mm - (node->dist_mm_to_top - this->top_z_distance);
|
||||
const int layers_fit = remaining_mm < -EPSILON ? 0 : int(std::floor((remaining_mm + EPSILON) / node->height));
|
||||
node->support_roof_layers_below = std::min(layers_fit, top_layers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// log layer_heights
|
||||
for (size_t i = 0; i < layer_heights.size(); i++) {
|
||||
//if (layer_heights[i].height > EPSILON)
|
||||
@@ -3498,7 +3484,7 @@ void TreeSupport::generate_contact_points()
|
||||
if (force_add || !already_inserted.count(hash_pos)) {
|
||||
already_inserted.emplace(hash_pos);
|
||||
bool to_buildplate = true;
|
||||
size_t roof_layers = add_interface ? (support_roof_layers > 0 ? support_roof_layers - 1 : 0) : 0; // subtract 1 because the contact node itself counts as one layer
|
||||
size_t roof_layers = add_interface ? support_roof_layers : 0;
|
||||
// add a new node as a virtual node which acts as the invisible gap between support and object
|
||||
// distance_to_top=-1: it's virtual
|
||||
// print_z=object_layer->bottom_z: it directly contacts the bottom
|
||||
|
||||
@@ -706,7 +706,7 @@ static std::optional<std::pair<Point, size_t>> polyline_sample_next_point_at_dis
|
||||
filler->spacing = flow.spacing();
|
||||
filler->angle = roof ?
|
||||
//fixme support_layer.interface_id() instead of layer_idx
|
||||
(support_params.interface_angle + (layer_idx & 1) ? float(- M_PI / 4.) : float(+ M_PI / 4.)) :
|
||||
(support_params.interface_angle + ((layer_idx & 1) ? float(- M_PI_4) : float(+ M_PI_4))) :
|
||||
support_params.base_angle;
|
||||
|
||||
// ORCA: use top-specific interface density after separating top/bottom settings.
|
||||
|
||||
@@ -62,7 +62,7 @@ struct TreeSupportMeshGroupSettings {
|
||||
this->support_line_width = support_material_flow(&print_object, config.layer_height).scaled_width();
|
||||
this->support_roof_line_width = support_material_interface_flow(&print_object, config.layer_height).scaled_width();
|
||||
const int bottom_interface_layers = number_of_support_interface_bottom_layers(config);
|
||||
this->support_bottom_enable = config.support_interface_top_layers.value > 0 && bottom_interface_layers > 0;
|
||||
this->support_bottom_enable = bottom_interface_layers > 0;
|
||||
this->support_bottom_height = this->support_bottom_enable ?
|
||||
bottom_interface_layers * this->layer_height :
|
||||
0;
|
||||
@@ -705,7 +705,7 @@ public:
|
||||
SupportGeneratorLayersPtr& top_contacts_mutable() { return this->top_contacts; }
|
||||
|
||||
public:
|
||||
// Insert the contact layer and some of the inteface and base interface layers below.
|
||||
// Insert the contact layer and some of the interface and base interface layers below.
|
||||
void add_roofs(std::vector<Polygons> &&new_roofs, const size_t insert_layer_idx)
|
||||
{
|
||||
if (! new_roofs.empty()) {
|
||||
|
||||
@@ -51,4 +51,9 @@
|
||||
// Enable extension of tool position imgui dialog to show actual speed profile
|
||||
#define ENABLE_ACTUAL_SPEED_DEBUG 1
|
||||
|
||||
// Disable layout inspector for public release
|
||||
#if BBL_RELEASE_TO_PUBLIC
|
||||
#define WXINSPECTOR_DISABLE
|
||||
#endif
|
||||
|
||||
#endif // _prusaslicer_technologies_h_
|
||||
|
||||
@@ -771,6 +771,7 @@ CustomGCode::Info CalibPressureAdvancePattern::generate_custom_gcodes(const Dyna
|
||||
}
|
||||
}
|
||||
|
||||
gcode << m_writer.reset_e();
|
||||
gcode << m_writer.set_pressure_advance(m_params.start);
|
||||
gcode << "; end pressure advance pattern for layer\n";
|
||||
|
||||
|
||||
+16
-4
@@ -35,17 +35,29 @@ struct Calib_Params
|
||||
{
|
||||
Calib_Params() : mode(CalibMode::Calib_None){};
|
||||
int extruder_id = 0;
|
||||
double start, end, step;
|
||||
bool print_numbers;
|
||||
double freqStartX, freqEndX, freqStartY, freqEndY;
|
||||
int test_model;
|
||||
double start = 0.0, end = 1.0, step = 0.1;
|
||||
bool print_numbers = false;
|
||||
double freqStartX = 0.0, freqEndX = 1.0, freqStartY = 0.0, freqEndY = 1.0;
|
||||
int test_model = 0;
|
||||
std::string shaper_type;
|
||||
std::vector<double> accelerations;
|
||||
std::vector<double> speeds;
|
||||
// Resolved layer height for the VFA tower (0 = auto: nozzle_diameter / 2). Each speed block is a
|
||||
// fixed number of layers tall, so this also determines the physical block height / tower height.
|
||||
double vfa_layer_height = 0.0;
|
||||
// Scale the calibration model to the nozzle diameter and set the layer height accordingly (temp tower / VFA).
|
||||
// When false the 0.4 mm / 0.2 mm reference model is printed as-is.
|
||||
bool nozzle_based_resize = true;
|
||||
|
||||
CalibMode mode;
|
||||
};
|
||||
|
||||
// Number of printed layers per speed block in the VFA tower. The base model has 5 mm blocks designed
|
||||
// for a 0.2 mm layer height (0.4 mm nozzle), i.e. 25 layers per block.
|
||||
static constexpr int vfa_layers_per_block = 25;
|
||||
static constexpr double vfa_base_block_height = 5.0;
|
||||
static constexpr double vfa_base_nozzle_diameter = 0.4;
|
||||
|
||||
enum FlowRatioCalibrationType {
|
||||
COMPLETE_CALIBRATION = 0,
|
||||
FINE_CALIBRATION,
|
||||
|
||||
@@ -752,6 +752,11 @@ set(SLIC3R_GUI_SOURCES
|
||||
Utils/WxFontUtils.hpp
|
||||
Utils/FileTransferUtils.cpp
|
||||
Utils/FileTransferUtils.hpp
|
||||
Utils/wxInspectorPlugins/DPIAwarePlugin.hpp
|
||||
Utils/wxInspectorPlugins/DPIAwarePlugin.cpp
|
||||
Utils/wxInspectorPlugins/CustomWidgetsPlugin.hpp
|
||||
Utils/wxInspectorPlugins/CustomWidgetsPlugin.cpp
|
||||
Utils/wxInspectorPlugins/Registration.hpp
|
||||
)
|
||||
|
||||
add_subdirectory(GUI/DeviceCore)
|
||||
|
||||
@@ -736,7 +736,7 @@ wxBoxSizer* AMSDryCtrWin::create_guide_right_section(wxPanel* parent)
|
||||
|
||||
m_back_button = create_button(
|
||||
parent,
|
||||
wxString::FromUTF8(_CTX_utf8(L_CONTEXT("Back", "amsdrying"), "amsdrying")),
|
||||
wxString::FromUTF8(_u8L_CONTEXT(L_CONTEXT("Back", "amsdrying"), "amsdrying")),
|
||||
wxColour("#F8F8F8"), // Background color - light gray
|
||||
wxColour("#D0D0D0"), // Border color - gray
|
||||
*wxBLACK // Text color - black
|
||||
|
||||
@@ -2100,7 +2100,7 @@ void AmsReplaceMaterialDialog::create()
|
||||
m_top_line->SetBackgroundColour(wxColour(166, 169, 170));
|
||||
m_main_sizer->Add(m_top_line, 0, wxEXPAND, 0);
|
||||
|
||||
m_nozzle_btn_panel = new SwitchBoard(this, _L("Left"), _L("Right"), wxSize(FromDIP(126), FromDIP(26)));
|
||||
m_nozzle_btn_panel = new SwitchBoard(this, _L_CONTEXT("Left", "Nozzle position"), _L_CONTEXT("Right", "Nozzle position"), wxSize(FromDIP(126), FromDIP(26)));
|
||||
m_nozzle_btn_panel->Hide();
|
||||
m_nozzle_btn_panel->Connect(wxCUSTOMEVT_SWITCH_POS, wxCommandEventHandler(AmsReplaceMaterialDialog::on_nozzle_selected), NULL, this);
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ PingCodeBindDialog::PingCodeBindDialog(Plater* plater /*= nullptr*/)
|
||||
|
||||
|
||||
|
||||
SetSizer(sizer_main);
|
||||
SetSizerAndFit(sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
|
||||
@@ -670,7 +670,7 @@ PingCodeBindDialog::~PingCodeBindDialog() {
|
||||
m_sizer_main->Add(m_sw_bind_failed_info, 0, wxALIGN_CENTER, 0);
|
||||
m_sizer_main->Add(m_simplebook, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, ButtonProps::ChoiceButtonGap());
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
Centre(wxBOTH);
|
||||
@@ -992,7 +992,7 @@ UnBindMachineDialog::UnBindMachineDialog(Plater *plater /*= nullptr*/)
|
||||
m_sizer_main->Add(m_sizer_button, 0, wxALIGN_RIGHT | wxRIGHT, ButtonProps::ChoiceButtonGap());
|
||||
m_sizer_main->Add(0, 0, 0, wxTOP, FromDIP(20));
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
Centre(wxBOTH);
|
||||
|
||||
@@ -632,9 +632,8 @@ EditCalibrationHistoryDialog::EditCalibrationHistoryDialog(wxWindow
|
||||
|
||||
main_sizer->Add(top_panel, 1, wxEXPAND | wxALL, FromDIP(20));
|
||||
|
||||
SetSizer(main_sizer);
|
||||
SetSizerAndFit(main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
CenterOnParent();
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
@@ -910,9 +909,8 @@ NewCalibrationHistoryDialog::NewCalibrationHistoryDialog(wxWindow *parent, const
|
||||
|
||||
main_sizer->Add(top_panel, 1, wxEXPAND | wxALL, FromDIP(20));
|
||||
|
||||
SetSizer(main_sizer);
|
||||
SetSizerAndFit(main_sizer);
|
||||
Layout();
|
||||
Fit();
|
||||
CenterOnParent();
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
@@ -162,7 +162,7 @@ CalibrationDialog::CalibrationDialog(Plater *plater)
|
||||
body_panel->Layout();
|
||||
|
||||
m_sizer_main->Add(body_panel, 0, wxEXPAND | wxALL, FromDIP(25));
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
|
||||
|
||||
@@ -112,9 +112,8 @@ CloneDialog::CloneDialog(wxWindow *parent)
|
||||
|
||||
v_sizer->Add(bottom_sizer, 0, wxEXPAND);
|
||||
|
||||
this->SetSizer(v_sizer);
|
||||
this->SetSizerAndFit(v_sizer);
|
||||
this->Layout();
|
||||
v_sizer->Fit(this);
|
||||
|
||||
wxGetApp().UpdateDlgDarkUI(this);
|
||||
|
||||
|
||||
@@ -80,9 +80,8 @@ ConnectPrinterDialog::ConnectPrinterDialog(wxWindow *parent, wxWindowID id, cons
|
||||
|
||||
main_sizer->Add(sizer_top);
|
||||
|
||||
this->SetSizer(main_sizer);
|
||||
this->SetSizerAndFit(main_sizer);
|
||||
this->Layout();
|
||||
this->Fit();
|
||||
CentreOnParent();
|
||||
|
||||
m_textCtrl_code->Bind(wxEVT_TEXT, &ConnectPrinterDialog::on_input_enter, this);
|
||||
|
||||
@@ -558,6 +558,7 @@ namespace Slic3r
|
||||
}
|
||||
else
|
||||
{
|
||||
Slic3r::GUI::wxGetApp().reset_unsigned_plugin_warning();
|
||||
if (m_agent)
|
||||
{
|
||||
if (it->second->connection_type() != "lan" || it->second->connection_type().empty())
|
||||
@@ -591,6 +592,7 @@ namespace Slic3r
|
||||
}
|
||||
|
||||
selected_machine = dev_id;
|
||||
record_user_last_machine(selected_machine);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -853,21 +855,39 @@ namespace Slic3r
|
||||
}
|
||||
}
|
||||
|
||||
void DeviceManager::record_user_last_machine(const std::string& dev_id)
|
||||
{
|
||||
if (Slic3r::GUI::wxGetApp().app_config) {
|
||||
Slic3r::GUI::wxGetApp().app_config->set("user_last_selected_machine", dev_id);
|
||||
}
|
||||
}
|
||||
|
||||
std::string DeviceManager::get_user_last_machine() const
|
||||
{
|
||||
if (Slic3r::GUI::wxGetApp().app_config) {
|
||||
const auto& user_last_machine = Slic3r::GUI::wxGetApp().app_config->get("user_last_selected_machine");
|
||||
if (!user_last_machine.empty()) {
|
||||
return user_last_machine;
|
||||
} else if (m_agent) {
|
||||
return m_agent->get_user_selected_machine();
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
void DeviceManager::load_last_machine()
|
||||
{
|
||||
// Get all available machines, include cloud machines and lan machines that have access right
|
||||
auto all_machines = get_my_machine_list();
|
||||
if (all_machines.empty())
|
||||
return;
|
||||
|
||||
// Then connect to the machine we last selected if available
|
||||
const std::string last_monitor_machine = m_agent ? m_agent->get_user_selected_machine() : "";
|
||||
const auto last_machine = all_machines.find(last_monitor_machine);
|
||||
if (last_machine != all_machines.end()) {
|
||||
this->set_selected_machine(last_machine->second->get_dev_id());
|
||||
if (userMachineList.empty()) return;
|
||||
else if (userMachineList.size() == 1) {
|
||||
this->set_selected_machine(userMachineList.begin()->second->get_dev_id());
|
||||
} else {
|
||||
// If not, then select the first available one
|
||||
this->set_selected_machine(all_machines.begin()->second->get_dev_id());
|
||||
const auto& last_monitor_machine = get_user_last_machine();
|
||||
if (userMachineList.find(last_monitor_machine) != userMachineList.end()) {
|
||||
set_selected_machine(last_monitor_machine);
|
||||
} else {
|
||||
this->set_selected_machine(userMachineList.begin()->second->get_dev_id());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ public:
|
||||
MachineObject* get_selected_machine();
|
||||
bool set_selected_machine(std::string dev_id);
|
||||
|
||||
void record_user_last_machine(const std::string& dev_id);
|
||||
std::string get_user_last_machine() const;
|
||||
|
||||
// local machine
|
||||
void set_local_selected_machine(std::string dev_id) { local_selected_machine = dev_id; };
|
||||
MachineObject* get_local_selected_machine() const { return get_local_machine(local_selected_machine); }
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <boost/log/trivial.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/format.hpp>
|
||||
|
||||
#include "nlohmann/json.hpp"
|
||||
|
||||
|
||||
@@ -637,7 +637,7 @@ ReselectMachineDialog::ReselectMachineDialog(wxWindow* parent)
|
||||
|
||||
wxBoxSizer* okGroupSizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
UiAMSSlot* amsSlotOK= new UiAMSSlot(statusBar, colourOK, wxString("Ax\nPLA"), DataStatusType::OK, wxID_ANY, wxDefaultPosition, wxSize(FromDIP(58), FromDIP(90)), 1.0, 1.0);
|
||||
wxStaticText* okLabel = new wxStaticText(statusBar, wxID_ANY, _CTX(L_CONTEXT("OK", "FilamentTrack"), "FilamentTrack"));
|
||||
wxStaticText* okLabel = new wxStaticText(statusBar, wxID_ANY, _L_CONTEXT(L_CONTEXT("OK", "FilamentTrack"), "FilamentTrack"));
|
||||
okLabel->SetFont(wxGetApp().normal_font());
|
||||
okLabel->SetForegroundColour(wxColour("#6B6B6B"));
|
||||
|
||||
|
||||
@@ -112,9 +112,8 @@ DownloadProgressDialog::DownloadProgressDialog(wxString title)
|
||||
m_simplebook_status->AddPage(m_panel_download_failed, wxEmptyString, false);
|
||||
m_simplebook_status->AddPage(m_panel_install_failed, wxEmptyString, false);
|
||||
|
||||
SetSizer(m_sizer_main);
|
||||
SetSizerAndFit(m_sizer_main);
|
||||
Layout();
|
||||
Fit();
|
||||
CentreOnParent();
|
||||
|
||||
Bind(wxEVT_CLOSE_WINDOW, &DownloadProgressDialog::on_close, this);
|
||||
|
||||
@@ -239,7 +239,7 @@ void ExtrusionCalibration::create()
|
||||
m_button_save_result->SetStyle(ButtonStyle::Confirm, ButtonType::Choice);
|
||||
m_button_save_result->Bind(wxEVT_BUTTON, &ExtrusionCalibration::on_click_save, this);
|
||||
|
||||
m_button_last_step = new Button(m_step_2_panel, _CTX("Back", "Navigation")); // Back for english
|
||||
m_button_last_step = new Button(m_step_2_panel, _L_CONTEXT("Back", "Navigation")); // Back for english
|
||||
m_button_last_step->SetStyle(ButtonStyle::Regular, ButtonType::Choice);
|
||||
m_button_last_step->Bind(wxEVT_BUTTON, &ExtrusionCalibration::on_click_last, this);
|
||||
|
||||
@@ -261,7 +261,7 @@ void ExtrusionCalibration::create()
|
||||
top_sizer->Add(FromDIP(24), 0);
|
||||
top_sizer->Add(sizer_main, 1, wxEXPAND);
|
||||
top_sizer->Add(FromDIP(24), 0);
|
||||
SetSizer(top_sizer);
|
||||
SetSizerAndFit(top_sizer);
|
||||
|
||||
// set default nozzle
|
||||
m_comboBox_nozzle_dia->SetSelection(1);
|
||||
@@ -271,7 +271,6 @@ void ExtrusionCalibration::create()
|
||||
set_step(1);
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
|
||||
m_k_val->GetTextCtrl()->Bind(wxEVT_TEXT_ENTER, [this](wxCommandEvent& e) {
|
||||
input_value_finish();
|
||||
|
||||
+16
-10
@@ -1043,14 +1043,14 @@ void TextCtrl::propagate_value()
|
||||
|
||||
void TextCtrl::set_value(const boost::any& value, bool change_event/* = false*/) {
|
||||
m_disable_change_event = !change_event;
|
||||
|
||||
if (m_opt.nullable) {
|
||||
const bool m_is_na_val = value.empty() || (boost::any_cast<wxString>(value) == _(L("N/A")));
|
||||
if (!m_is_na_val)
|
||||
m_last_meaningful_value = value;
|
||||
text_ctrl()->SetValue(boost::any_cast<wxString>(value)); // BBS
|
||||
}
|
||||
else
|
||||
text_ctrl()->SetValue(value.empty() ? "" : boost::any_cast<wxString>(value)); // BBS // BBS: null value
|
||||
|
||||
text_ctrl()->SetValue(value.empty() ? wxString() : boost::any_cast<wxString>(value));
|
||||
m_disable_change_event = false;
|
||||
|
||||
if (!change_event) {
|
||||
@@ -1187,18 +1187,24 @@ void CheckBox::set_value(const boost::any& value, bool change_event)
|
||||
m_disable_change_event = !change_event;
|
||||
if (m_opt.nullable) {
|
||||
const bool is_value_unsigned_char = value.type() == typeid(unsigned char);
|
||||
bool bool_value = false;
|
||||
|
||||
m_is_na_val = value.empty() || (is_value_unsigned_char &&
|
||||
boost::any_cast<unsigned char>(value) == ConfigOptionBoolsNullable::nil_value());
|
||||
if (!m_is_na_val)
|
||||
m_last_meaningful_value = is_value_unsigned_char ? value : static_cast<unsigned char>(boost::any_cast<bool>(value));
|
||||
|
||||
const auto bool_value = is_value_unsigned_char ?
|
||||
boost::any_cast<unsigned char>(value) != 0 :
|
||||
boost::any_cast<bool>(value);
|
||||
dynamic_cast<::CheckBox*>(window)->SetValue(m_is_na_val ? false : bool_value); // BBS
|
||||
if (!m_is_na_val) {
|
||||
bool_value = is_value_unsigned_char ?
|
||||
boost::any_cast<unsigned char>(value) != 0 :
|
||||
boost::any_cast<bool>(value);
|
||||
m_last_meaningful_value = is_value_unsigned_char ? value : static_cast<unsigned char>(bool_value);
|
||||
}
|
||||
|
||||
dynamic_cast<::CheckBox*>(window)->SetValue(bool_value);
|
||||
}
|
||||
else if (!value.empty()) // BBS: null value
|
||||
else if (!value.empty()){ // BBS: null value
|
||||
dynamic_cast<::CheckBox*>(window)->SetValue(boost::any_cast<bool>(value)); // BBS
|
||||
}
|
||||
|
||||
dynamic_cast<::CheckBox*>(window)->SetHalfChecked(value.empty());
|
||||
m_disable_change_event = false;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void FilamentMapManualPanel::OnTimer(wxTimerEvent &)
|
||||
m_suggestion_panel->Hide();
|
||||
} else {
|
||||
m_errors->SetLabel(wxString::Format(_L("Error: %s extruder has no available %s nozzle, current group result is invalid."),
|
||||
invalid_eid == 0 ? _L("Left") : _L("Right"),
|
||||
invalid_eid == 0 ? _L_CONTEXT("Left", "Nozzle position") : _L_CONTEXT("Right", "Nozzle position"),
|
||||
invalid_nozzle == NozzleVolumeType::nvtStandard ? _L("Standard") : _L("High Flow")));
|
||||
// Re-wrap: wrapping only applies to the label text present when Wrap is called,
|
||||
// and the label was empty at construction time.
|
||||
|
||||
@@ -105,9 +105,8 @@ FilamentPickerDialog::FilamentPickerDialog(wxWindow *parent, const wxString& fil
|
||||
container_sizer->Add(main_sizer, 1, wxEXPAND | wxALL, FromDIP(10));
|
||||
container_sizer->Add(dlg_btns, 0, wxEXPAND);
|
||||
|
||||
SetSizer(container_sizer);
|
||||
SetSizerAndFit(container_sizer);
|
||||
Layout();
|
||||
container_sizer->Fit(this);
|
||||
|
||||
// Position the dialog relative to the parent window
|
||||
if (GetParent()) {
|
||||
|
||||
@@ -4268,7 +4268,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
||||
};
|
||||
|
||||
auto append_print = [&imgui, imperial_units](const ColorRGBA& color, const std::array<float, 4>& offsets, const Times& times, std::pair<double, double> used_filament) {
|
||||
imgui.text(_CTX_utf8("Print", "Noun"));
|
||||
imgui.text(_u8L_CONTEXT("Print", "Noun"));
|
||||
ImGui::SameLine();
|
||||
|
||||
float icon_size = ImGui::GetTextLineHeight();
|
||||
@@ -4302,7 +4302,7 @@ void GCodeViewer::render_legend(float &legend_height, int canvas_width, int canv
|
||||
for (const PartialTime& item : partial_times) {
|
||||
switch (item.type)
|
||||
{
|
||||
case PartialTime::EType::Print: { labels.push_back(_CTX_utf8("Print", "Noun")); break; }
|
||||
case PartialTime::EType::Print: { labels.push_back(_u8L_CONTEXT("Print", "Noun")); break; }
|
||||
case PartialTime::EType::Pause: { labels.push_back(_u8L("Pause")); break; }
|
||||
case PartialTime::EType::ColorChange: { labels.push_back(_u8L("Color change")); break; }
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ void GLCanvas3D::LayersEditing::render_variable_layer_height_dialog(GLCanvas3D&
|
||||
ImGui::SetCursorPosX(input_align);
|
||||
ImGui::BBLDragFloat("##adaptive_input", &m_adaptive_quality, 0.05f, 0.0f, 0.0f, "%.2f");
|
||||
|
||||
if (imgui.button(_L("Smooth")))
|
||||
if (imgui.button(_L_CONTEXT("Smooth", "Mesh action")))
|
||||
wxPostEvent((wxEvtHandler*)canvas.get_wxglcanvas(), HeightProfileSmoothEvent(EVT_GLCANVAS_SMOOTH_LAYER_HEIGHT_PROFILE, m_smooth_params));
|
||||
ImGui::SameLine();
|
||||
text_align = std::max(text_align, ImGui::GetCursorPosX());
|
||||
@@ -6047,12 +6047,12 @@ void GLCanvas3D::_render_3d_navigator()
|
||||
strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_X], "Y"); // ORCA use uppercase to match text on tranform widgets
|
||||
strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_Y], "Z"); // ORCA use uppercase to match text on tranform widgets
|
||||
strcpy(style.AxisLabels[ImGuizmo::Axis::Axis_Z], "X"); // ORCA use uppercase to match text on tranform widgets
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_FRONT], _utf8("Front").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_BACK], _CTX_utf8("Back", "Camera View").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_TOP], _utf8("Top").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_BOTTOM], _utf8("Bottom").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_LEFT], _CTX_utf8("Left", "Camera View").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_RIGHT], _CTX_utf8("Right", "Camera View").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_FRONT], _u8L_CONTEXT("Front", "Camera View").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_BACK], _u8L_CONTEXT("Back", "Camera View").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_TOP], _u8L_CONTEXT("Top", "Camera View").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_BOTTOM], _u8L_CONTEXT("Bottom", "Camera View").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_LEFT], _u8L_CONTEXT("Left", "Camera View").c_str());
|
||||
strcpy(style.FaceLabels[ImGuizmo::FACES::FACE_RIGHT], _u8L_CONTEXT("Right", "Camera View").c_str());
|
||||
|
||||
float sc = get_scale();
|
||||
#ifdef WIN32
|
||||
|
||||
+35
-20
@@ -96,6 +96,7 @@
|
||||
#include "../Utils/PresetUpdater.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
#include "../Utils/Process.hpp"
|
||||
#include "../Utils/wxInspectorPlugins/Registration.hpp"
|
||||
#include "../Utils/MacDarkMode.hpp"
|
||||
#include "../Utils/Http.hpp"
|
||||
#include "../Utils/InstanceID.hpp"
|
||||
@@ -2637,7 +2638,6 @@ void GUI_App::on_start_subscribe_again(std::string dev_id)
|
||||
|
||||
if ( (dev_id == obj->get_dev_id()) && obj->is_connecting() && obj->subscribe_counter > 0) {
|
||||
obj->subscribe_counter--;
|
||||
if(wxGetApp().getAgent()) wxGetApp().getAgent()->set_user_selected_machine(dev_id);
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": dev_id=" << obj->get_dev_id();
|
||||
}
|
||||
});
|
||||
@@ -2836,6 +2836,9 @@ bool GUI_App::on_init_inner()
|
||||
|
||||
::Label::initSysFont();
|
||||
|
||||
// Register wxInspector plugins for Orca custom controls
|
||||
RegisterOrcaInspectorPlugins();
|
||||
|
||||
// Set initialization of image handlers before any UI actions - See GH issue #7469
|
||||
wxInitAllImageHandlers();
|
||||
#ifdef NDEBUG
|
||||
@@ -3705,13 +3708,13 @@ bool GUI_App::on_init_network(bool try_backup)
|
||||
}
|
||||
} else {
|
||||
BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << ": on_init_network, load dll failed";
|
||||
// A failed install can leave the config naming a build that never made it to
|
||||
// disk (download_plugin() adopts the downloaded version up front so that
|
||||
// install_plugin() can name the library after it). If the whitelisted latest
|
||||
// is still installed, fall back to it instead of dropping the user into the
|
||||
// re-download flow without networking.
|
||||
// A failed install can leave the config naming a build that never made it to disk;
|
||||
// fall back to the installed latest instead of dropping the user into the re-download
|
||||
// flow. Only when the configured library is genuinely absent, though - a pinned series
|
||||
// that is on disk but failed to load once must keep its pin, not be rewritten for good.
|
||||
std::string latest = get_latest_network_version();
|
||||
if (config_version != latest && BBLNetworkPlugin::versioned_library_exists(latest)) {
|
||||
if (config_version != latest && !BBLNetworkPlugin::versioned_library_exists(config_version)
|
||||
&& BBLNetworkPlugin::versioned_library_exists(latest)) {
|
||||
BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": falling back to installed " << latest;
|
||||
config_version = latest;
|
||||
app_config->set_network_plugin_version(latest);
|
||||
@@ -3815,7 +3818,14 @@ bool GUI_App::on_init_network(bool try_backup)
|
||||
m_user_manager = new Slic3r::UserManager();
|
||||
}
|
||||
|
||||
if (should_load_networking_plugin && m_networking_compatible && !use_legacy_network_plugin()) {
|
||||
// A version pinned to something other than the latest series is a deliberate choice, so it
|
||||
// is exempt from the upgrade prompt the same way the legacy pin already is - otherwise the
|
||||
// dialog reappears on every launch for as long as the pin is held.
|
||||
const std::string pinned_version = app_config->get_network_plugin_version();
|
||||
const bool pinned_to_older_series = !pinned_version.empty() &&
|
||||
network_plugin_series(pinned_version) != network_plugin_series(get_latest_network_version());
|
||||
|
||||
if (should_load_networking_plugin && m_networking_compatible && !pinned_to_older_series) {
|
||||
app_config->clear_remind_network_update_later();
|
||||
|
||||
if (has_network_update_available()) {
|
||||
@@ -6127,18 +6137,23 @@ bool GUI_App::process_network_msg(std::string dev_id, std::string msg)
|
||||
}
|
||||
else if (msg == "unsigned_studio") {
|
||||
BOOST_LOG_TRIVIAL(info) << "process_network_msg, unsigned_studio";
|
||||
MessageDialog
|
||||
msg_dlg(nullptr,
|
||||
_L("To use OrcaSlicer with Bambu Lab printers, you need to enable LAN mode and Developer mode on your printer.\n\n"
|
||||
"Please go to your printer's settings and:\n"
|
||||
"1. Turn on LAN mode\n"
|
||||
"2. Enable Developer mode\n\n"
|
||||
"Developer mode allows the printer to work exclusively through local network access, "
|
||||
"enabling full functionality with OrcaSlicer."),
|
||||
_L("Network Plug-in Restriction"), wxAPPLY | wxOK);
|
||||
m_show_error_msgdlg = true;
|
||||
msg_dlg.ShowModal();
|
||||
m_show_error_msgdlg = false;
|
||||
// Plugin re-emits this on every subscribe retry; latch it so it shows
|
||||
// once per connection episode.
|
||||
if (!m_show_error_msgdlg && !m_unsigned_plugin_warning_shown) {
|
||||
m_unsigned_plugin_warning_shown = true;
|
||||
MessageDialog
|
||||
msg_dlg(nullptr,
|
||||
_L("To use OrcaSlicer with Bambu Lab printers, you need to enable LAN mode and Developer mode on your printer.\n\n"
|
||||
"Please go to your printer's settings and:\n"
|
||||
"1. Turn on LAN mode\n"
|
||||
"2. Enable Developer mode\n\n"
|
||||
"Developer mode allows the printer to work exclusively through local network access, "
|
||||
"enabling full functionality with OrcaSlicer."),
|
||||
_L("Network Plug-in Restriction"), wxAPPLY | wxOK);
|
||||
m_show_error_msgdlg = true;
|
||||
msg_dlg.ShowModal();
|
||||
m_show_error_msgdlg = false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user