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