Repository navigation
web: a script view for gui:: commands with no Qt window - #11943
jorge-ferreira-pii wants to merge 7 commits into
Conversation
gui.i and gui.tcl now build without Qt too, so a script can call the gui:: commands in any build; with no window they still log GUI-0001. Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
With no Qt window, the display controls act on a copy of the Qt display-control tree kept by the web viewer, with the same paths and defaults. Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
|
This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size. |
There was a problem hiding this comment.
Code Review
This pull request enables GUI Tcl commands (such as display controls and fit) to function in builds without Qt by introducing a server-side ScriptView and DisplayControlTree that mirror the Qt display-control tree's paths and defaults. It also refactors renderer controls into a dedicated RendererControls class shared between the script view and the web viewer. Feedback was provided to optimize the site visibility default computation in DisplayControlTree::addDesignRows to avoid redundant map lookups and erasures inside nested loops.
| // DisplayControls::libInit: a site starts as Rows is when it is added. | ||
| for (odb::dbLib* lib : db->getLibs()) { | ||
| for (odb::dbSite* site : lib->getSites()) { | ||
| const std::string path = std::string(kRows) + "/" + site->getName(); | ||
| if (leaves_.contains(path)) { | ||
| continue; | ||
| } | ||
| bool on = true; | ||
| if (const Leaf* rows = find(kRows)) { | ||
| on = rows->visible.value_or(false); | ||
| } else { | ||
| for (const auto& [other, leaf] : leaves_) { | ||
| if (other.starts_with(std::string(kRows) + "/")) { | ||
| on = on && leaf.visible.value_or(false); | ||
| } | ||
| } | ||
| } | ||
| leaves_.erase(kRows); | ||
| addLeaf(path, {.visible = on, .selectable = on}); | ||
| } | ||
| } |
There was a problem hiding this comment.
The site visibility default value on and the removal of the kRows leaf can be computed once before the loops. Currently, they are computed and erased repeatedly inside the nested loops, which results in redundant map lookups, string prefix checks, and an
// DisplayControls::libInit: a site starts as Rows is when it is added.
bool on = true;
if (const Leaf* rows = find(kRows)) {
on = rows->visible.value_or(false);
leaves_.erase(kRows);
} else {
for (const auto& [other, leaf] : leaves_) {
if (other.starts_with(std::string(kRows) + "/")) {
on = on && leaf.visible.value_or(false);
}
}
}
for (odb::dbLib* lib : db->getLibs()) {
for (odb::dbSite* site : lib->getSites()) {
const std::string path = std::string(kRows) + "/" + site->getName();
if (leaves_.contains(path)) {
continue;
}
addLeaf(path, {.visible = on, .selectable = on});
}
}Rows' default for new sites is worked out once, a renderer control's color is reported as ignored, and RendererControls::check takes the default for a path it has no value for. Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
…ipt-view Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
The web server's fixes took those IDs on master. Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
…ript-view Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Master took those IDs while this was in review. Signed-off-by: Jorge Ferreira <jorge.ferreira@precisioninno.com>
Part 2 of 9 for #11488. On top of PR #11942.
With no Qt window, gui::set_display_controls, gui::check_display_controls, gui::save_display_controls, gui::restore_display_controls and gui::fit now work. They act on a copy of the Qt Display Controls panel kept by the web viewer, with the same control names and the same defaults as Qt. A new test compares that copy with the real Qt panel, control by control.
The on/off switches of the debug renderers (placement, routing, and so on) are now one shared set for Tcl and for the browser, so a script and the viewer always agree.