HAL  v4.5.0-124-g47ab54673
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
python_gui_api_bindings.cpp
Go to the documentation of this file.
1 #pragma GCC diagnostic push
2 #pragma GCC diagnostic ignored "-Wshadow"
3 #pragma GCC diagnostic ignored "-Wself-assign-overloaded"
4 #ifdef COMPILER_CLANG
5 #pragma clang diagnostic ignored "-Wnested-anon-types"
6 #pragma clang diagnostic ignored "-Wshadow-field-in-constructor-modified"
7 #endif
8 
10 
11 #include "pybind11/operators.h"
12 #include "pybind11/pybind11.h"
13 #include "pybind11/stl.h"
14 #include "pybind11/stl_bind.h"
15 #include "pybind11/functional.h"
16 
17 #include "gui/gui_globals.h"
18 #include "gui/gui_api/gui_api.h"
20 
21 #pragma GCC diagnostic pop
22 
23 namespace hal{
24 
25 namespace py = pybind11;
26 #ifdef PYBIND11_MODULE
27 
28 PYBIND11_MODULE(hal_gui, m)
29 {
30  m.doc() = "hal python bindings";
31 #else
33  {
34  py::module m("hal_gui", "hal gui python bindings");
35 #endif // ifdef PYBIND11_MODULE
36 
37  auto py_console = m.def_submodule("console", R"(
38  GUI Console
39  )");
40 
41  py_console.def("clear", []() -> void { gPythonContext->scheduleClear(); });
42  py_console.def("reset", []() -> void { gPythonContext->scheduleReset(); });
43 
44  //m.def("history", []() -> void { g_console->printHistory(g_console->m_cmdColor); });
45 
46  py::module m2 = py_console.def_submodule("redirector", "redirector");
47  m2.def("write_stdout", [](std::string s) -> void { gPythonContext->forwardStdout(QString::fromStdString(s)); });
48  m2.def("write_stderr", [](std::string s) -> void { gPythonContext->forwardError(QString::fromStdString(s)); });
49  m2.def("thread_stdout", [](std::string s) -> void { if (gPythonContext->pythonThread()) gPythonContext->pythonThread()->handleStdout(QString::fromStdString(s)); });
50  m2.def("thread_stderr", [](std::string s) -> void { if (gPythonContext->pythonThread()) gPythonContext->pythonThread()->handleError(QString::fromStdString(s)); });
51  m2.def("thread_stdin", [](std::string s) -> std::string { return (gPythonContext->pythonThread()
53  :std::string());});
54  auto gui_input = m.def_submodule("gui_input", R"(
55  GUI Input Widgets
56  )");
57  gui_input.def("inputString", [](std::string prompt = std::string("Please enter value"), std::string defval = std::string()) ->
58  std::string { return (gPythonContext->pythonThread()
60  :std::string());});
61  gui_input.def("inputNumber", [](std::string prompt = std::string("Please enter number"), int defval = 0) ->
62  int { return (gPythonContext->pythonThread()
64  :0);});
65  gui_input.def("inputGate", [](std::string prompt = std::string("Please select gate")) ->
66  Gate* { return (gPythonContext->pythonThread()
68  :nullptr);});
69  gui_input.def("inputModule", [](std::string prompt = std::string("Please select module")) ->
70  Module* { return (gPythonContext->pythonThread()
72  :nullptr);});
73  gui_input.def("inputFilename", [](std::string prompt = std::string("Please select filename"), std::string filetype = std::string()) ->
74  std::string { return (gPythonContext->pythonThread()
76  :std::string());});
77  gui_input.def("wait_for_menu_selection", []() -> void {
80 
81  py::class_<GuiApi> py_gui_api(m, "GuiApi", R"(GUI API)");
82 
83  py::class_<GridPlacement>(py_gui_api,"GridPlacement",R"(
84  Helper class to determine placement of nodes on gui grid.
85  )")
86 
87  .def(py::init<>(), R"(
88  Constructor for empty placement hash.
89  )")
90 
91  .def("setGatePosition", &GridPlacement::setGatePosition, py::arg("gateId"), py::arg("point"), py::arg("swap") = false, R"(
92  Set position for gate identified by ID.
93 
94  :param int gateId: Gate ID.
95  :param tuple(int,int) pos: New position.
96  :param bool swap: set the swap of positions of the nodes
97  )")
98 
99  .def("setModulePosition", &GridPlacement::setModulePosition, py::arg("moduleId"), py::arg("point"), py::arg("swap") = false, R"(
100  Set position for module identified by ID.
101 
102  :param int moduleId: Module ID.
103  :param tuple(int,int) pos: New position.
104  :param bool swap: set the swap of positions of the nodes
105  )")
106 
107  .def("gatePosition", &GridPlacement::gatePosition, py::arg("gateId"), R"(
108  Query position for gate identified by ID.
109 
110  :param int gateId: Gate ID.
111  :returns: Position of gate or ``None`` if gate not found in hash.
112  :rtype: tuple(int,int) or None
113  )")
114 
115  .def("modulePosition", &GridPlacement::modulePosition, py::arg("moduleId"), R"(
116  Query position for module identified by ID.
117 
118  :param int moduleId: Module ID.
119  :returns: Position of module or ``None`` if module not found in hash.
120  :rtype: tuple(int,int) or None
121  )");
122 
123  py::class_<GuiApiClasses::View>(py_gui_api, "View")
124  .def_static("isolateInNew", &GuiApiClasses::View::isolateInNew, py::arg("modules"), py::arg("gates"),R"(
125  Isolates given modules and gates into a new view
126 
127  :param list[hal_py.module] modules: List of modules to be added.
128  :param list[hal_py.Gate] gates: List of gates to be added.
129  :returns: ID of created view or the existing one if view is exclusively bound to a module.
130  :rtype: int
131 )")
132  .def_static("rename", &GuiApiClasses::View::setName, py::arg("id"), py::arg("name"),R"(
133  Renames the view specified by the given ID.
134 
135  :param int viewId: ID of the view.
136  :param string name: New unique name.
137  :returns: ``True`` on success, ``False`` otherwise.
138  :rtype: bool
139 )")
140  .def_static("addTo", &GuiApiClasses::View::addTo, py::arg("id"), py::arg("modules"), py::arg("gates"),R"(
141  Adds the given modules and gates to the view specified by the ID.
142 
143  :param int viewId: ID of the view.
144  :param list[hal.py.module] modules: Modules to be added.
145  :param list[hal.py.Gate] gates: Gates to be added.
146  :returns: ``True`` on success, ``False`` otherwise.
147  :rtype: bool
148 )")
149  .def_static("deleteView", &GuiApiClasses::View::deleteView, py::arg("id"),R"(
150  Deletes the view specified by the ID.
151 
152  :param int viewId: ID of the view.
153  :returns: ``True`` on success, ``False`` otherwise.
154  :rtype: bool
155  )")
156  .def_static("removeFrom", &GuiApiClasses::View::removeFrom, py::arg("id"), py::arg("modules"), py::arg("gates"),R"(
157  Removes the given modules and gates from the view specified by the ID.
158 
159  :param int viewId: ID of the view.
160  :param list[hal.py.module] modules: Modules to be removed.
161  :param list[hal.py.Gate] gates: Gates to be removed.
162  :returns: ``True`` on success, ``False`` otherwise.
163  :rtype: bool
164 )")
165  .def_static("getId", &GuiApiClasses::View::getId, py::arg("name"),R"(
166  Returns the ID of the view with the given name if existing.
167 
168  :param string name: Name of the view.
169  :returns: ID of the specified view or 0 if none is found.
170  :rtype: int
171 )")
172  .def_static("getName", &GuiApiClasses::View::getName, py::arg("id"), R"(
173  Returns the name of the view with the given ID if existing.
174 
175  :param int viewId: ID of the view.
176  :returns: Name of the view specified by the ID or empty string if none is found.
177  :rtype: string
178 )")
179  .def_static("getModules", &GuiApiClasses::View::getModules, py::arg("id"), R"(
180  Returns all modules attached to the view.
181 
182  :param int viewId: ID of the view.
183  :returns: List of the attached modules.
184  :rtype: list[hal.py.module]
185 )")
186  .def_static("getGates", &GuiApiClasses::View::getGates, py::arg("id"),R"(
187  Returns all gates attached to the view
188 
189  :param int viewId: ID of the view.
190  :returns: List of the attached gates.
191  :rtype: list[hal.py.Gate]
192 )")
193  .def_static("getIds", &GuiApiClasses::View::getIds, py::arg("modules"), py::arg("gates"),R"(
194  Returns the ID of each View containing at least the given modules and gates.
195 
196  :param list[hal.py.module] modules: Required modules.
197  :param list[hal.py.Gate] gates: Required gates.
198  :returns: List of ID of views which contains modules and gates.
199  :rtype: list[int]
200 )")
201  .def_static("unfoldModule", &GuiApiClasses::View::unfoldModule, py::arg("view_id"), py::arg("module"), R"(
202  Unfold a specific module. Hides the module, shows submodules and gates
203 
204  :param int viewId: ID of the view.
205  :param Module* module: module to unfold
206  :returns: ``True`` on success, ``False`` otherwise.
207  :rtype: bool
208 )")
209  .def_static("foldModule", &GuiApiClasses::View::foldModule, py::arg("view_id"), py::arg("module"), R"(
210  Fold a specific module. Hides the submodules and gates, shows the specific module
211 
212  :param int viewId: ID of the view.
213  :param Module* module: module to fold
214  :returns: ``True`` on success, ``False`` otherwise.
215  :rtype: bool
216 )")
217  .def_static("getGridPlacement", &GuiApiClasses::View::getGridPlacement, py::arg("view_id"), R"(
218  Get positions of all nodes in the view specified by id
219 
220  :param int viewId: ID of the view.
221  :returns: GridPlacement of the specified view.
222  :rtype: GridPlacement
223 )")
224  .def_static("setGridPlacement", &GuiApiClasses::View::setGridPlacement, py::arg("view_id"), py::arg("grid placement"), R"(
225  Set grid placement to the view specified by id
226 
227  :param int viewId ID of the view.
228  :param GridPlacement* gp: grid placement.
229  :rtype: bool
230 )")
231  .def_static("getCurrentDirectory", &GuiApiClasses::View::getCurrentDirectory,R"(
232  Gets the CurrentDirectory.
233 
234  :returns: ID of the current directory. 0, if it's the top level directory.
235  :rtype: int
236 )")
237  .def_static("setCurrentDirectory", &GuiApiClasses::View::setCurrentDirectory, py::arg("id"), R"(
238  Sets the CurrentDirectory.
239 
240  :param int id ID of the new current directory.
241 )")
242  .def_static("createNewDirectory", &GuiApiClasses::View::createNewDirectory, py::arg("name"), R"(
243  Creates a new directory under the current directory.
244 
245  :param string name: Name of the new directory.
246  :returns: ID of the new directory.
247  :rtype: int
248 )")
249  .def_static("deleteDirectory", &GuiApiClasses::View::deleteDirectory, py::arg("id"), R"(
250  Deletes the directory specified by a given id.
251 
252  :param int id: ID of the directory to delete.
253 )")
254  .def_static("moveView", &GuiApiClasses::View::moveView, py::arg("viewId"), py::arg("destinationDirectoryId") = py::none(), py::arg("row") = py::none(), R"(
255  Moves a view to a directory.
256 
257  :param int viewId: ID of the view to move.
258  :param int destinationDirectoryId: ID of the destination directory to which the view will be moved.
259  If ``None``, the view is instead moved to the current directory.
260  :param int row: The row index in the parent directory, where the view will be inserted.
261 )")
262  .def_static("moveDirectory", &GuiApiClasses::View::moveDirectory, py::arg("directoryId"), py::arg("destinationDirectoryId") = py::none(), py::arg("row") = py::none(), R"(
263  Moves a directory under another directory.
264 
265  :param int directoryId: ID of the directory to move.
266  :param int destinationDirectoryId: ID of the destination directory to which the directory will be moved.
267  If ``None``, the directory is instead moved to the current directory.
268  :param int row: The row index in the parent directory, where the directory will be inserted.
269 )")
270  .def_static("getChildDirectories", &GuiApiClasses::View::getChildDirectories, py::arg("directoryId"), R"(
271  Returns the ids of all direct child directories of a given directory.
272 
273  :param int directoryId: ID of the parent directory, whose direct children will be returned
274  :returns: List of the ids of all direct child directories of the specified directory.
275  Returns ``None``, if the given directory does not exist.
276  :rtype: list[int]|None
277 )")
278  .def_static("getChildViews", &GuiApiClasses::View::getChildViews, py::arg("directoryId"), R"(
279  Returns the ids of all direct child views of a given directory.
280 
281  :param int directoryId: ID of the parent directory, whose direct children will be returned
282  :returns: List of the ids of all direct child views of the specified directory.
283  Returns ``None``, if the given directory does not exist.
284  :rtype: list[int]|None
285 )");
286 
287 
288  py_gui_api.def("getSelectedGateIds", &GuiApi::getSelectedGateIds, R"(
289  Get the gate ids of currently selected gates in the graph view of the GUI.
290 
291  :returns: List of the ids of the currently selected gates.
292  :rtype: list[int]
293 )");
294 
295  py_gui_api.def("getSelectedNetIds", &GuiApi::getSelectedNetIds, R"(
296  Get the net ids of currently selected nets in the graph view of the GUI.
297 
298  :returns: List of the ids of the currently selected nets.
299  :rtype: list[int]
300 )");
301 
302  py_gui_api.def("getSelectedModuleIds", &GuiApi::getSelectedModuleIds, R"(
303  Get the module ids of currently selected modules in the graph view of the GUI.
304 
305  :returns: List of the ids of the currently selected modules.
306  :rtype: list[int]
307 )");
308 
309  py_gui_api.def("getSelectedItemIds", &GuiApi::getSelectedItemIds, R"(
310  Get all item ids of the currently selected items in the graph view of the GUI.
311 
312  :returns: Tuple of lists of the currently selected items.
313  :rtype: tuple(int, int, int)
314 )");
315 
316  py_gui_api.def("getSelectedGates", &GuiApi::getSelectedGates, borrowed(), R"(
317  Get the gates which are currently selected in the graph view of the GUI.
318 
319  :returns: List of currently selected gates.
320  :rtype: list[hal_py.Gate]
321 )");
322 
323  py_gui_api.def("getSelectedNets", &GuiApi::getSelectedNets, borrowed(), R"(
324  Get the nets which are currently selected in the graph view of the GUI.
325 
326  :returns: List of currently selected nets.
327  :rtype: list[hal_py.Net]
328 )");
329 
330  py_gui_api.def("getSelectedModules", &GuiApi::getSelectedModules, borrowed(), R"(
331  Get the modules which are currently selected in the graph view of the GUI.
332 
333  :returns: List of currently selected modules.
334  :rtype: list[hal_py.Module]
335 )");
336 
337  py_gui_api.def("getSelectedItems", &GuiApi::getSelectedItems, borrowed(), R"(
338  Get all selected items which are currently selected in the graph view of the GUI.
339 
340  :returns: Tuple of currently selected items.
341  :rtype: tuple(hal_py.Gate, hal_py.Net, hal_py.Module)
342 )");
343 
344  py_gui_api.def("selectGate", py::overload_cast<u32, bool, bool>(&GuiApi::selectGate), py::arg("gate_id"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
345  Select the gate with id 'gate_id' in the graph view of the GUI.
346  If 'clear_current_selection' is ``False``, the gate with the id 'gate_id' will be added to the currently existing selection.
347  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
348 
349  :param int gate_id: The gate id of the gate to be selected.
350  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the gate.
351  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
352 )");
353 
354  py_gui_api.def("selectGate", py::overload_cast<Gate*, bool, bool>(&GuiApi::selectGate), py::arg("gate"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
355  Select the gate in the graph view of the GUI.
356  If 'clear_current_selection' is ``False``, the gate will be added to the currently existing selection.
357  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
358 
359  :param hal_py.Gate gate: The gate to be selected.
360  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the gate.
361  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
362 )");
363 
364  py_gui_api.def("selectGate", py::overload_cast<const std::vector<u32>&, bool, bool>(&GuiApi::selectGate), py::arg("gate_ids"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
365  Select the gates with the ids in list 'gate_ids' in the graph view of the GUI.
366  If 'clear_current_selection' is ``False``, the gate with the id 'gate_id' will be added to the currently existing selection.
367  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
368 
369  :param list[int] gate_ids: List of gate ids of the gates to be selected.
370  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the gates.
371  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
372 )");
373 
374  py_gui_api.def("selectGate", py::overload_cast<const std::vector<Gate*>&, bool, bool>(&GuiApi::selectGate), py::arg("gates"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
375  Select the gates in the graph view of the GUI.
376  If 'clear_current_selection' is ``False``, the gates will be added to the currently existing selection.
377  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
378 
379  :param list[hal_py.Gate] gates: The gates to be selected.
380  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the gates.
381  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
382 )");
383 
384  py_gui_api.def("selectNet", py::overload_cast<u32, bool, bool>(&GuiApi::selectNet), py::arg("mNetId"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
385  Select the net with id 'mNetId' in the graph view of the GUI.
386  If 'clear_current_selection' is ``False``, the net with the id 'mNetId' will be added to the currently existing selection.
387  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
388 
389  :param int mNetId: The net id of the net to be selected.
390  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the net.
391  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
392 )");
393 
394  py_gui_api.def("selectNet", py::overload_cast<Net*, bool, bool>(&GuiApi::selectNet), py::arg("net"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
395  Select the net in the graph view of the GUI.
396  If 'clear_current_selection' is ``False``, the net will be added to the currently existing selection.
397  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
398 
399  :param hal_py.Net net: The net to be selected.
400  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the net.
401  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
402 )");
403 
404  py_gui_api.def("selectNet", py::overload_cast<const std::vector<u32>&, bool, bool>(&GuiApi::selectNet), py::arg("net_ids"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
405  Select the nets with the ids in list 'net_ids' in the graph view of the GUI.
406  If 'clear_current_selection' is ``False``, the net with the id 'mNetId' will be added to the currently existing selection.
407  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
408 
409  :param list[int] net_ids: List of net ids of the nets to be selected.
410  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the nets.
411  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
412 )");
413 
414  py_gui_api.def("selectNet", py::overload_cast<const std::vector<Net*>&, bool, bool>(&GuiApi::selectNet), py::arg("nets"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
415  Select the nets in the graph view of the GUI.
416  If 'clear_current_selection' is ``False``, the nets will be added to the currently existing selection.
417  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
418 
419  :param list[hal_py.Net] nets: The nets to be selected.
420  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the nets.
421  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
422 )");
423 
424  py_gui_api.def("selectModule", py::overload_cast<u32, bool, bool>(&GuiApi::selectModule), py::arg("module_id"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
425  Select the module with id 'module_id' in the graph view of the GUI.
426  If 'clear_current_selection' is ``False``, the module with the id 'module_id' will be added to the currently existing selection.
427  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
428 
429  :param int module_id: The module id of the module to be selected.
430  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the module.
431  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
432 )");
433 
434  py_gui_api.def("selectModule", py::overload_cast<Module*, bool, bool>(&GuiApi::selectModule), py::arg("module"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
435  Select the module in the graph view of the GUI.
436  If 'clear_current_selection' is ``False``, the module will be added to the currently existing selection.
437  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
438 
439  :param hal_py.module module: The module to be selected.
440  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the module.
441  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
442 )");
443 
444  py_gui_api.def("selectModule", py::overload_cast<const std::vector<u32>&, bool, bool>(&GuiApi::selectModule), py::arg("module_ids"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
445  Select the modules with the ids in list 'module_ids' in the graph view of the GUI.
446  If 'clear_current_selection' is ``False``, the module with the id 'module_id' will be added to the currently existing selection.
447  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
448 
449  :param list[int] module_ids: List of module ids of the modules to be selected.
450  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the modules.
451  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
452 )");
453 
454  py_gui_api.def("selectModule", py::overload_cast<const std::vector<Module*>&, bool, bool>(&GuiApi::selectModule), py::arg("modules"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
455  Select the modules in the graph view of the GUI.
456  If 'clear_current_selection' is ``False``, the modules will be added to the currently existing selection.
457  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
458 
459  :param list[hal_py.module] modules: The modules to be selected.
460  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the modules.
461  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
462 )");
463 
464  py_gui_api.def("select", py::overload_cast<Gate*, bool, bool>(&GuiApi::select), py::arg("gate"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
465  Select the gate in the graph view of the GUI.
466  If 'clear_current_selection' is ``False``, the gate will be added to the currently existing selection.
467  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
468 
469  :param hal_py.Gate gate: The gate to be selected.
470  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the gate.
471  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
472 )");
473 
474  py_gui_api.def("select", py::overload_cast<Net*, bool, bool>(&GuiApi::select), py::arg("net"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
475  Select the net in the graph view of the GUI.
476  If 'clear_current_selection' is ``False``, the net will be added to the currently existing selection.
477  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
478 
479  :param hal_py.Net net: The net to be selected.
480  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the net.
481  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
482 )");
483 
484  py_gui_api.def("select", py::overload_cast<Module*, bool, bool>(&GuiApi::select), py::arg("module"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
485  Select the module in the graph view of the GUI.
486  If 'clear_current_selection' is ``False``, the module will be added to the currently existing selection.
487  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
488 
489  :param hal_py.module module: The module to be selected.
490  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the module.
491  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
492 )");
493 
494  py_gui_api.def("select", py::overload_cast<const std::vector<Gate*>&, bool, bool>(&GuiApi::select), py::arg("gates"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
495  Select the gates in the graph view of the GUI.
496  If 'clear_current_selection' is ``False``, the gates will be added to the currently existing selection.
497  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
498 
499  :param list[hal_py.Gate] gates: The gates to be selected.
500  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the gates.
501  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
502 )");
503 
504  py_gui_api.def("select", py::overload_cast<const std::vector<Net*>&, bool, bool>(&GuiApi::select), py::arg("nets"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
505  Select the nets in the graph view of the GUI.
506  If 'clear_current_selection' is ``False``, the nets will be added to the currently existing selection.
507  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
508 
509  :param list[hal_py.Net] nets: The nets to be selected.
510  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the nets.
511  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
512 )");
513 
514  py_gui_api.def("select", py::overload_cast<const std::vector<Module*>&, bool, bool>(&GuiApi::select), py::arg("modules"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
515  Select the modules in the graph view of the GUI.
516  If 'clear_current_selection' is ``False``, the modules will be added to the currently existing selection.
517  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
518 
519  :param list[hal_py.module] modules: The modules to be selected.
520  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the modules.
521  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
522 )");
523 
524  py_gui_api.def("select", py::overload_cast<const std::vector<u32>&, const std::vector<u32>&, const std::vector<u32>&, bool, bool>(&GuiApi::select), py::arg("gate_ids"), py::arg("net_ids"), py::arg("module_ids"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
525  Select the gates, nets and modules with the passed ids in the graph view of the GUI.
526  If 'clear_current_selection' is ``False``, the gates, nets and modules will be added to the currently existing selection.
527  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
528 
529  :param list[hal_py.Gate] gates: The ids of the gates to be selected.
530  :param list[hal_py.Net] nets: The ids of the nets to be selected.
531  :param list[hal_py.module] modules: The ids of the modules to be selected.
532  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the modules.
533  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
534 )");
535 
536  py_gui_api.def("select", py::overload_cast<const std::vector<Gate*>&, const std::vector<Net*>&, const std::vector<Module*>&, bool, bool>(&GuiApi::select), py::arg("gates"), py::arg("nets"), py::arg("modules"), py::arg("clear_current_selection") = true, py::arg("navigate_to_selection") = true, R"(
537  Select the gates, nets and modules in the graph view of the GUI.
538  If 'clear_current_selection' is ``False``, the gates, nets and modules will be added to the currently existing selection.
539  If 'navigate_to_selection' is ``False``, the graph view will not modify the graph view camera position to fit all selected items.
540 
541  :param list[hal_py.Gate] gates: The gates to be selected.
542  :param list[hal_py.Net] nets: The nets to be selected.
543  :param list[hal_py.module] modules: The modules to be selected.
544  :param bool clear_current_selection: Determines if the previous selection gets cleared before the selection of the modules.
545  :param bool navigate_to_selection: Determines if the graph view scrolls and zooms to show all selected items.
546 )");
547 
548  py_gui_api.def("deselectGate", py::overload_cast<u32>(&GuiApi::deselectGate), py::arg("gate_id"), R"(
549  Deselect the gate with id 'gate_id' in the graph view of the GUI.
550 
551  :param int gate_id: The gate id of the gate to be selected.
552 )");
553 
554  py_gui_api.def("deselectGate", py::overload_cast<Gate*>(&GuiApi::deselectGate), py::arg("gate"), R"(
555  Deselect the gate in the graph view of the GUI.
556 
557  :param hal_py.Gate gate: The gate to be deselected.
558 )");
559 
560  py_gui_api.def("deselectGate", py::overload_cast<const std::vector<u32>&>(&GuiApi::deselectGate), py::arg("gate_ids"), R"(
561  Deselect the gates with the ids in list 'gate_ids' in the graph view of the GUI.
562 
563  :param list[int] gate_ids: List of gate ids of the gates to be deselected.
564 )");
565 
566  py_gui_api.def("deselectGate", py::overload_cast<const std::vector<Gate*>&>(&GuiApi::deselectGate), py::arg("gates"), R"(
567  Deselect the gates in the graph view of the GUI.
568 
569  :param list[hal_py.Gate] gates: The gates to be deselected.
570 )");
571 
572  py_gui_api.def("deselectNet", py::overload_cast<u32>(&GuiApi::deselectNet), py::arg("mNetId"), R"(
573  Deselect the net with id 'mNetId' in the graph view of the GUI.
574 
575  :param int mNetId: The net id of the net to be selected.
576 )");
577 
578  py_gui_api.def("deselectNet", py::overload_cast<Net*>(&GuiApi::deselectNet), py::arg("net"), R"(
579  Deselect the net in the graph view of the GUI.
580 
581  :param hal_py.Net Net: The net to be deselected.
582 )");
583 
584  py_gui_api.def("deselectNet", py::overload_cast<const std::vector<u32>&>(&GuiApi::deselectNet), py::arg("net_ids"), R"(
585  Deselect the nets with the ids in list 'net_ids' in the graph view of the GUI.
586 
587  :param list[int] net_ids: List of net ids of the nets to be deselected.
588 )");
589 
590  py_gui_api.def("deselectNet", py::overload_cast<const std::vector<Net*>&>(&GuiApi::deselectNet), py::arg("nets"), R"(
591  Deselect the nets in the graph view of the GUI.
592 
593  :param list[hal_py.Net] nets: The nets to be deselected.
594 )");
595 
596  py_gui_api.def("deselectModule", py::overload_cast<u32>(&GuiApi::deselectModule), py::arg("module_id"), R"(
597  Deselect the module with id 'module_id' in the graph view of the GUI.
598 
599  :param int module_id: The module id of the module to be selected.
600 )");
601 
602  py_gui_api.def("deselectModule", py::overload_cast<Module*>(&GuiApi::deselectModule), py::arg("module"), R"(
603  Deselect the module in the graph view of the GUI.
604 
605  :param hal_py.module module: The module to be deselected.
606 )");
607 
608  py_gui_api.def("deselectModule", py::overload_cast<const std::vector<u32>&>(&GuiApi::deselectModule), py::arg("module_ids"), R"(
609  Deselect the modules with the ids in list 'module_ids' in the graph view of the GUI.
610 
611  :param list[int] module_ids: List of module ids of the modules to be deselected.
612 )");
613 
614  py_gui_api.def("deselectModule", py::overload_cast<const std::vector<Module*>&>(&GuiApi::deselectModule), py::arg("modules"), R"(
615  Deselect the modules in the graph view of the GUI.
616 
617  :param list[hal_py.module] modules: The modules to be deselected.
618 )");
619 
620  py_gui_api.def("deselect", py::overload_cast<Gate*>(&GuiApi::deselect), py::arg("gate"), R"(
621  Deselect the gate in the graph view of the GUI.
622 
623  :param hal_py.Gate gate: The gate to be deselected.
624 )");
625 
626  py_gui_api.def("deselect", py::overload_cast<Net*>(&GuiApi::deselect), py::arg("net"), R"(
627  Deselect the net in the graph view of the GUI.
628 
629  :param hal_py.Net Net: The net to be deselected.
630 )");
631 
632  py_gui_api.def("deselect", py::overload_cast<Module*>(&GuiApi::deselect), py::arg("module"), R"(
633  Deselect the module in the graph view of the GUI.
634 
635  :param hal_py.module module: The module to be deselected.
636 )");
637 
638  py_gui_api.def("deselect", py::overload_cast<const std::vector<Gate*>&>(&GuiApi::deselect), py::arg("gates"), R"(
639  Deselect the gates in the graph view of the GUI.
640 
641  :param list[hal_py.Gate] gates: The gates to be deselected.
642 )");
643 
644  py_gui_api.def("deselect", py::overload_cast<const std::vector<Net*>&>(&GuiApi::deselect), py::arg("nets"), R"(
645  Deselect the nets in the graph view of the GUI.
646 
647  :param list[hal_py.Net] nets: The nets to be deselected.
648 )");
649 
650  py_gui_api.def("deselect", py::overload_cast<const std::vector<Module*>&>(&GuiApi::deselect), py::arg("modules"), R"(
651  Deselect the modules in the graph view of the GUI.
652 
653  :param list[hal_py.module] modules: The modules to be deselected.
654 )");
655 
656  py_gui_api.def("deselect", py::overload_cast<const std::vector<u32>&, const std::vector<u32>&, const std::vector<u32>&>(&GuiApi::deselect), py::arg("gate_ids"), py::arg("net_ids"), py::arg("module_ids"), R"(
657  Deselect the gates, nets and modules with the passed ids in the graph view of the GUI.
658 
659  :param list[hal_py.Gate] gates: The ids of the gates to be deselected.
660  :param list[hal_py.Net] nets: The ids of the nets to be deselected.
661  :param list[hal_py.module] modules: The ids of the modules to be deselected.
662 )");
663 
664  py_gui_api.def("deselect", py::overload_cast<const std::vector<Gate*>&, const std::vector<Net*>&, const std::vector<Module*>&>(&GuiApi::deselect), py::arg("gates"), py::arg("nets"), py::arg("modules"), R"(
665  Deselect the gates, nets and modules in the graph view of the GUI.
666 
667  :param list[hal_py.Gate] gates: The gates to be deselected.
668  :param list[hal_py.Net] nets: The nets to be deselected.
669  :param list[hal_py.module] modules: The modules to be deselected.
670 )");
671 
672  py_gui_api.def("deselectAllItems", py::overload_cast<>(&GuiApi::deselectAllItems), R"(
673  Deselect all gates, nets and modules in the graph view of the GUI.
674 )");
675 
676 
677 
678 #ifndef PYBIND11_MODULE
679  return m.ptr();
680 #endif // PYBIND11_MODULE
681  }
682 }
Definition: gate.h:58
std::pair< int, int > * gatePosition(u32 gateId) const
Definition: gui_def.h:194
std::pair< int, int > * modulePosition(u32 moduleId) const
Definition: gui_def.h:200
void setGatePosition(u32 gateId, std::pair< int, int >p, bool swap=false)
Definition: gui_def.h:149
void setModulePosition(u32 moduleId, std::pair< int, int >p, bool swap=false)
Definition: gui_def.h:172
static bool foldModule(int view_id, Module *module)
Definition: gui_api.cpp:824
static void deleteDirectory(u32 id)
Definition: gui_api.cpp:1022
static bool unfoldModule(int view_id, Module *module)
Definition: gui_api.cpp:805
static void moveDirectory(u32 directoryId, std::optional< u32 > destinationDirectoryId, std::optional< int > row)
Definition: gui_api.cpp:1053
static int getId(const std::string &name)
Definition: gui_api.cpp:689
static bool removeFrom(int id, const std::vector< Module * > modules, const std::vector< Gate * > gates)
Definition: gui_api.cpp:633
static int isolateInNew(const std::vector< Module * > modules, const std::vector< Gate * > gates)
Definition: gui_api.cpp:509
static bool setName(int id, const std::string &name)
Definition: gui_api.cpp:670
static void moveView(u32 viewId, std::optional< u32 > destinationDirectoryId, std::optional< int > row)
Definition: gui_api.cpp:1032
static std::string getName(int id)
Definition: gui_api.cpp:704
static GridPlacement * getGridPlacement(int viewId)
Definition: gui_api.cpp:981
static bool setGridPlacement(int viewId, GridPlacement *gp)
Definition: gui_api.cpp:988
static u32 createNewDirectory(const std::string &name)
Definition: gui_api.cpp:1014
static std::vector< Gate * > getGates(int id)
Definition: gui_api.cpp:726
static std::optional< std::vector< u32 > > getChildDirectories(u32 directoryId)
Definition: gui_api.cpp:1087
static bool addTo(int id, const std::vector< Module * > modules, const std::vector< Gate * > gates)
Definition: gui_api.cpp:594
static std::optional< std::vector< u32 > > getChildViews(u32 directoryId)
Definition: gui_api.cpp:1096
static bool deleteView(int id)
Definition: gui_api.cpp:579
static std::vector< Module * > getModules(int id)
Definition: gui_api.cpp:713
static void setCurrentDirectory(u32 id)
Definition: gui_api.cpp:1008
static std::vector< u32 > getIds(const std::vector< Module * > modules, const std::vector< Gate * > gates)
Definition: gui_api.cpp:739
static u32 getCurrentDirectory()
Definition: gui_api.cpp:995
void deselectNet(u32 netId)
Definition: gui_api.cpp:336
void deselectModule(u32 module_id)
Definition: gui_api.cpp:374
std::vector< u32 > getSelectedNetIds()
Definition: gui_api.cpp:38
std::tuple< std::vector< Gate * >, std::vector< Net * >, std::vector< Module * > > getSelectedItems()
Definition: gui_api.cpp:77
void deselectAllItems()
Definition: gui_api.cpp:444
std::vector< u32 > getSelectedModuleIds()
Definition: gui_api.cpp:43
std::vector< Gate * > getSelectedGates()
Definition: gui_api.cpp:53
std::vector< Net * > getSelectedNets()
Definition: gui_api.cpp:61
void deselect(Gate *gate)
Definition: gui_api.cpp:402
void selectNet(u32 netId, bool clear_current_selection=true, bool navigate_to_selection=true)
Definition: gui_api.cpp:149
void select(Gate *gate, bool clear_current_selection=true, bool navigate_to_selection=true)
Definition: gui_api.cpp:235
std::vector< u32 > getSelectedGateIds()
Definition: gui_api.cpp:33
std::vector< Module * > getSelectedModules()
Definition: gui_api.cpp:69
std::tuple< std::vector< u32 >, std::vector< u32 >, std::vector< u32 > > getSelectedItemIds()
Definition: gui_api.cpp:48
void selectModule(u32 module_id, bool clear_current_selection=true, bool navigate_to_selection=true)
Definition: gui_api.cpp:200
void selectGate(u32 gate_id, bool clear_current_selection=true, bool navigate_to_selection=true)
Definition: gui_api.cpp:98
void deselectGate(u32 gate_id)
Definition: gui_api.cpp:298
PythonThread * pythonThread() const
void forwardError(const QString &output)
void forwardStdout(const QString &output)
Gate * handleGateInput(const QString &prompt)
void handleStdout(const QString &output) override
std::string handleStringInput(const QString &prompt, const QString &defval)
int handleNumberInput(const QString &prompt, int defval)
bool getInput(InputType type, QString prompt, QVariant defaultValue)
std::string handleConsoleInput(const QString &prompt)
Module * handleModuleInput(const QString &prompt)
void handleError(const QString &output) override
std::string handleFilenameInput(const QString &prompt, const QString &filetype)
const Module * module(const Gate *g, const NodeBoxes &boxes)
Definition: defines.h:45
PYBIND11_PLUGIN(hal_py)
PythonContext * gPythonContext
Definition: plugin_gui.cpp:89
QString fromStdString(const std::string &str)