Skip to content

Commit

Permalink
gui: adding ability to select items from tcl based on coordinate
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Gadfort <peter.gadfort.civ@army.mil>
  • Loading branch information
gadfort committed Oct 13, 2021
1 parent 0987e80 commit 20b38ba
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/gui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ gui::selection_add_insts name_regex
Options description:
- ``name_regex`` regular expression of the instance names to add.

To add items at a specific point or in an area:

```
gui::select_at x y
gui::select_at x y append
gui::select_at x0 y0 x1 y1
gui::select_at x0 y0 x1 y1 append
```

Options description:
- ``x, y`` point in the layout area in microns.
- ``x0, y0`` first corner of the layout area in microns.
- ``x1, y1`` second corner of the layout area in microns.
- ``append`` if ``true`` (the default value) append the new selections to the current selection list, else replace the selection list with the new selections.

To clear the current set of selected items:

```
Expand Down
2 changes: 2 additions & 0 deletions src/gui/include/gui/gui.h
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,8 @@ class Gui
void addInstToHighlightSet(const char* name, int highlight_group = 0);
void addNetToHighlightSet(const char* name, int highlight_group = 0);

void selectAt(const odb::Rect& area, bool append = true);

std::string addRuler(int x0, int y0, int x1, int y1, const std::string& label = "", const std::string& name = "");
void deleteRuler(const std::string& name);

Expand Down
5 changes: 5 additions & 0 deletions src/gui/src/gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,11 @@ void Gui::addNetToHighlightSet(const char* name, int highlight_group)
main_window->addHighlighted(selection_set, highlight_group);
}

void Gui::selectAt(const odb::Rect& area, bool append)
{
main_window->getLayoutViewer()->selectArea(area, append);
}

std::string Gui::addRuler(int x0, int y0, int x1, int y1, const std::string& label, const std::string& name)
{
return main_window->addRuler(x0, y0, x1, y1, label, name);
Expand Down
14 changes: 14 additions & 0 deletions src/gui/src/gui.i
Original file line number Diff line number Diff line change
Expand Up @@ -470,5 +470,19 @@ const std::string get_selection_property(const std::string& prop_name)
}
}

void select_at(double x0, double y0, double x1, double y1, bool append = true)
{
if (!check_gui("select_at")) {
return;
}
auto gui = gui::Gui::get();
gui->selectAt(make_rect(x0, y0, x1, y1), append);
}

void select_at(double x, double y, bool append = true)
{
select_at(x, y, x, y, append);
}

%} // inline

8 changes: 8 additions & 0 deletions src/gui/src/layoutViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,6 +886,14 @@ void LayoutViewer::selectAt(odb::Rect region, std::vector<Selected>& selections)
}
}

void LayoutViewer::selectArea(const odb::Rect& area, bool append)
{
if (!append) {
emit selected(Selected()); // remove previous selections
}
emit addSelected(selectAt(area));
}

SelectionSet LayoutViewer::selectAt(odb::Rect region)
{
std::vector<Selected> selections;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/src/layoutViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,8 @@ class LayoutViewer : public QWidget, public odb::dbBlockCallBackObj
void startRulerBuild();
void cancelRulerBuild();

void selectArea(const odb::Rect& area, bool append);

private:
struct Boxes
{
Expand Down

0 comments on commit 20b38ba

Please sign in to comment.