Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions openroad/gpl/src/graphicsImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1079,7 +1079,7 @@ void GraphicsImpl::saveLabeledImageImpl(std::string_view path,
odb::Rect bbox = pbc_->db()->getChip()->getBlock()->getBBox()->getBox();

if (!heatmap_control.empty()) {
gui->setDisplayControlsVisible(std::string(heatmap_control), true);
gui->setRendererControl(std::string(heatmap_control), true);
}

static int label_id = 0;
Expand All @@ -1090,7 +1090,7 @@ void GraphicsImpl::saveLabeledImageImpl(std::string_view path,
gui->deleteLabel(label_name);

if (!heatmap_control.empty()) {
gui->setDisplayControlsVisible(std::string(heatmap_control), false);
gui->setRendererControl(std::string(heatmap_control), false);
}

gui->clearSelections();
Expand Down Expand Up @@ -1122,7 +1122,7 @@ void GraphicsImpl::gifEnd(int key)

void GraphicsImpl::setDisplayControl(std::string_view name, bool value)
{
web::Gui::get()->setDisplayControlsVisible(std::string(name), value);
web::Gui::get()->setRendererControl(std::string(name), value);
}

} // namespace gpl
12 changes: 12 additions & 0 deletions openroad/gui/src/displayControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,6 +1221,18 @@ bool DisplayControls::checkControlByPath(const std::string& path,
return false;
}

std::vector<std::string> DisplayControls::controlPaths()
{
std::map<std::string, QStandardItem*> controls;
collectControls(model_->invisibleRootItem(), kVisible, controls);
std::vector<std::string> paths;
paths.reserve(controls.size());
for (const auto& [path, item] : controls) {
paths.push_back(path);
}
return paths;
}

void DisplayControls::collectControls(
const QStandardItem* parent,
Column column,
Expand Down
2 changes: 2 additions & 0 deletions openroad/gui/src/displayControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ class DisplayControls : public QDockWidget,
Qt::CheckState value);
void setControlByPath(const std::string& path, const QColor& color);
bool checkControlByPath(const std::string& path, bool is_visible);
// The paths of the controls with a visible box, sorted.
std::vector<std::string> controlPaths();

void registerRenderer(web::Renderer* renderer);
void unregisterRenderer(web::Renderer* renderer);
Expand Down
5 changes: 5 additions & 0 deletions openroad/gui/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@ class QtGuiBackend : public GuiBackend
main_window->getControls()->restore();
}

std::vector<std::string> displayControlPaths() override
{
return main_window->getControls()->controlPaths();
}

void addFocusNet(odb::dbNet* net) override
{
main_window->getLayoutTabs()->addFocusNet(net);
Expand Down
35 changes: 28 additions & 7 deletions openroad/gui/src/gui.i
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,21 @@

%{
#include <optional>
#include <string>
#include <vector>

#include "ord/OpenRoad.hh"
#include "utl/Logger.h"
#include "gui/gui.h"

using utl::GUI;

bool check_gui(const char* command)
// With any_viewer, the script view serves the command when no Qt window is
// up; otherwise it needs the window.
bool check_gui(const char* command, bool any_viewer = false)
{
auto logger = ord::OpenRoad::openRoad()->getLogger();
if (!web::Gui::hasUI()) {
if (!(any_viewer ? web::Gui::hasViewer() : web::Gui::hasUI())) {
logger->info(GUI, 1, "Command {} is not usable in non-GUI mode", command);
return false;
}
Expand Down Expand Up @@ -71,6 +75,14 @@ namespace std {

%rename(pause) gui_pause;

%typemap(out) std::vector<std::string> {
Tcl_Obj* list = Tcl_NewListObj(0, nullptr);
for (const std::string& item : *(&$1)) {
Tcl_ListObjAppendElement(interp, list, Tcl_NewStringObj(item.c_str(), item.size()));
}
Tcl_SetObjResult(interp, list);
}

%inline %{

bool enabled()
Expand Down Expand Up @@ -295,7 +307,7 @@ void design_created()

void fit()
{
if (!check_gui("fit")) {
if (!check_gui("fit", true)) {
return;
}
auto gui = web::Gui::get();
Expand Down Expand Up @@ -390,7 +402,7 @@ void clear_highlights(int highlight_group = 0)

void set_display_controls(const char* name, const char* display_type, const char* value)
{
if (!check_gui("set_display_controls")) {
if (!check_gui("set_display_controls", true)) {
return;
}
auto gui = web::Gui::get();
Expand Down Expand Up @@ -421,7 +433,7 @@ void set_display_controls(const char* name, const char* display_type, const char

bool check_display_controls(const char* name, const char* display_type)
{
if (!check_gui("check_display_controls")) {
if (!check_gui("check_display_controls", true)) {
return false;
}
auto gui = web::Gui::get();
Expand All @@ -446,7 +458,7 @@ bool check_display_controls(const char* name, const char* display_type)

void save_display_controls()
{
if (!check_gui("set_display_controls")) {
if (!check_gui("save_display_controls", true)) {
return;
}
auto gui = web::Gui::get();
Expand All @@ -455,13 +467,22 @@ void save_display_controls()

void restore_display_controls()
{
if (!check_gui("restore_display_controls")) {
if (!check_gui("restore_display_controls", true)) {
return;
}
auto gui = web::Gui::get();
gui->restoreDisplayControls();
}

// The paths set_display_controls can name, as a Tcl list.
std::vector<std::string> display_control_paths()
{
if (!check_gui("display_control_paths", true)) {
return {};
}
return web::Gui::get()->displayControlPaths();
}

const std::string create_toolbar_button(const char* name, const char* text, const char* script, bool echo)
{
if (!check_gui("create_toolbar_button")) {
Expand Down
12 changes: 12 additions & 0 deletions openroad/gui/test/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,26 @@ package(features = ["layering_check"])
ALL_TESTS = [
"supported",
"clocktree_virtual_clock",
"display_controls_parity",
"dump_heatmap_headless",
"no_window",
"save_animated_gif_headless",
"save_image_headless",
"select_name_patterns",
]

# Exercise the Qt gui, so they need it built in.
QT_TESTS = [
"clocktree_virtual_clock",
"display_controls_parity",
"save_animated_gif_headless",
"save_image_headless",
"select_name_patterns",
]

PASSFAIL_TESTS = [
"clocktree_virtual_clock",
"display_controls_parity",
"dump_heatmap_headless",
"no_window",
"save_animated_gif_headless",
Expand Down Expand Up @@ -49,6 +60,7 @@ filegroup(
check_log = False if test_name in PASSFAIL_TESTS else True,
check_passfail = True if test_name in PASSFAIL_TESTS else False,
data = [":test_resources"],
openroad = "//:openroad-qt" if test_name in QT_TESTS else "//:openroad",
visibility = ["//visibility:public"],
)
for test_name in ALL_TESTS
Expand Down
4 changes: 2 additions & 2 deletions openroad/gui/test/clocktree_virtual_clock.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ set openroad_test_dir [file normalize [file join $script_dir .. .. .. test]]
source [file join $openroad_test_dir helpers.tcl]

if { ![gui::supported] } {
# Built without the GUI; nothing to exercise.
puts "pass"
# Registered only where the Qt gui is built in.
puts "fail: OpenROAD was built without the Qt gui"
} else {
if { ![info exists ::env(QT_QPA_PLATFORM)] } {
set ::env(QT_QPA_PLATFORM) offscreen
Expand Down
73 changes: 73 additions & 0 deletions openroad/gui/test/display_controls_parity.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# With no Qt window, gui::set_display_controls acts on the web viewer's
# script view, which keeps its own copy of the Qt display-control tree. This
# checks that copy against the real one: the same paths, and the same
# defaults.

set script_dir [file dirname [info script]]
set openroad_test_dir [file normalize [file join $script_dir .. .. .. test]]

source [file join $openroad_test_dir helpers.tcl]

proc fail { msg } {
puts "fail: $msg"
exit 0
}

# Path -> default visibility for every control the current viewer has.
proc control_defaults { } {
set defaults [dict create]
foreach path [gui::display_control_paths] {
dict set defaults $path [gui::check_display_controls $path visible]
}
return $defaults
}

if { ![gui::supported] } {
# Registered only where the Qt gui is built in, so no tree to compare with
# is a failure.
fail "OpenROAD was built without the Qt gui"
} else {
if { ![info exists ::env(QT_QPA_PLATFORM)] } {
set ::env(QT_QPA_PLATFORM) offscreen
}

suppress_message ODB 127
suppress_message ODB 128
suppress_message ODB 130
suppress_message ODB 131
suppress_message ODB 132
suppress_message ODB 133
suppress_message ODB 134
suppress_message ODB 227

read_lef [file join $openroad_test_dir Nangate45 Nangate45.lef]
read_def [file join $openroad_test_dir gcd_nangate45.def]

set web [control_defaults]
# Without the saved settings, so the window starts from its defaults.
set ::qt {}
gui::show {
set ::qt [control_defaults]
gui::hide
} false false

if { [dict size $::qt] == 0 } {
fail "the Qt gui reported no controls"
}
foreach path [dict keys $::qt] {
if { ![dict exists $web $path] } {
fail "missing without a window: $path"
}
if { [dict get $web $path] != [dict get $::qt $path] } {
fail "$path defaults to [dict get $web $path] without a window, \
[dict get $::qt $path] in Qt"
}
}
foreach path [dict keys $web] {
if { ![dict exists $::qt $path] } {
fail "not in the Qt gui: $path"
}
}

puts "pass"
}
18 changes: 16 additions & 2 deletions openroad/gui/test/no_window.tcl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# With no Qt window, in a build with or without Qt, the gui:: commands exist,
# and the ones that need a window log GUI-0001 rather than fail.
# With no Qt window, in a build with or without Qt, the gui:: commands exist
# and answer: the display controls act on the web viewer's script view, and
# the commands that need a window log GUI-0001 rather than fail.

set script_dir [file dirname [info script]]
set openroad_test_dir [file normalize [file join $script_dir .. .. .. test]]
Expand Down Expand Up @@ -44,9 +45,22 @@ gui::clear_highlights -1
gui::clear_selections
gui::fit
gui::set_display_controls "*" visible false
if { [gui::check_display_controls "Nets/Power" visible] } {
fail "Nets/Power is still visible after hiding everything"
}
gui::set_display_controls "Nets/*" visible true
if { ![gui::check_display_controls "Nets/Power" visible] } {
fail "Nets/* did not reach Nets/Power"
}
gui::show_widget "Clock Tree Viewer"
gui::hide_widget "Clock Tree Viewer"
gui::restore_display_controls
if { ![gui::check_display_controls "Layers/metal1" visible] } {
fail "restore did not bring Layers/metal1 back"
}
if { [catch { gui::set_display_controls "Bogus/*" visible true }] == 0 } {
fail "an unknown control was accepted"
}

if { ![gui::supported] } {
# Without Qt, save_image renders with the web viewer.
Expand Down
4 changes: 2 additions & 2 deletions openroad/gui/test/save_animated_gif_headless.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ proc gif_header { path } {
}

if { ![gui::supported] } {
# Built without the GUI; nothing to exercise.
puts "pass"
# Registered only where the Qt gui is built in.
puts "fail: OpenROAD was built without the Qt gui"
} else {
if { ![info exists ::env(QT_QPA_PLATFORM)] } {
set ::env(QT_QPA_PLATFORM) offscreen
Expand Down
4 changes: 2 additions & 2 deletions openroad/gui/test/save_image_headless.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ proc png_size { path } {
}

if { ![gui::supported] } {
# Built without the GUI; nothing to exercise.
puts "pass"
# Registered only where the Qt gui is built in.
puts "fail: OpenROAD was built without the Qt gui"
} else {
if { ![info exists ::env(QT_QPA_PLATFORM)] } {
set ::env(QT_QPA_PLATFORM) offscreen
Expand Down
6 changes: 6 additions & 0 deletions openroad/web/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ cc_library(
srcs = [
"src/asset_gzip.cpp",
"src/clock_tree_report.cpp",
"src/display_control_tree.cpp",
"src/font_atlas.h",
"src/font_data.cpp",
"src/font_data.h",
Expand All @@ -210,9 +211,11 @@ cc_library(
"src/group_report.h",
"src/hierarchy_report.cpp",
"src/module_color_palette.h",
"src/renderer_controls.cpp",
"src/report_html.cpp",
"src/request_dispatcher.h",
"src/request_handler.cpp",
"src/script_view.cpp",
"src/search.cpp",
"src/search.h",
"src/tile_generator.cpp",
Expand All @@ -234,7 +237,10 @@ cc_library(
# If these are meant to be used in tests with specific dependencies,
# these should be put (together with their *.cpp files) into separate
# libraries, with visibility for the //openroad/web/test path (see :color).
"src/display_control_tree.h",
"src/glyph_cache.h",
"src/renderer_controls.h",
"src/script_view.h",
"src/tile_generator.h",
"src/timing_report.h",
"src/web_chart.h",
Expand Down
10 changes: 10 additions & 0 deletions openroad/web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ field and the value is `true` or `false`.
| Key | Default | Description |
| --- | ------- | ----------- |
| `stdcells` | true | Standard cells |
| `std_physical` | `stdcells` | Liberty cells with no ports, such as decaps |
| `std_other` | `stdcells` | Cells with no Liberty cell that are not core masters |
| `macros` | true | Macros |
| `routing` | true | Signal routing |
| `special_nets` | true | Power/ground straps |
Expand Down Expand Up @@ -467,6 +469,14 @@ whichever one synced last.
Because Tcl commands typed into the browser console run on the server, this is
normally invoked from the viewer's own console after arranging the panel.

This command is not `gui::save_display_controls`. With no Qt window open,
`gui::set_display_controls`, `gui::check_display_controls`,
`gui::save_display_controls`, `gui::restore_display_controls` and `gui::fit`
act on a copy of the Qt display-control tree kept on the server, with the
same paths and defaults. That copy works in a build without Qt and needs no
running server, but it is separate from what a browser shows. Of the colors,
only `Misc/Background` is kept there.

### Restore Display Controls

Apply a previously saved display-controls file to every connected viewer.
Expand Down
Loading
Loading