HAL
gui_api.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2019 Ruhr University Bochum, Chair for Embedded Security. All Rights reserved.
4 // Copyright (c) 2019 Marc Fyrbiak, Sebastian Wallat, Max Hoffmann ("ORIGINAL AUTHORS"). All rights reserved.
5 // Copyright (c) 2021 Max Planck Institute for Security and Privacy. All Rights reserved.
6 // Copyright (c) 2021 Jörn Langheinrich, Julian Speith, Nils Albartus, René Walendy, Simon Klix ("ORIGINAL AUTHORS"). All Rights reserved.
7 //
8 // Permission is hereby granted, free of charge, to any person obtaining a copy
9 // of this software and associated documentation files (the "Software"), to deal
10 // in the Software without restriction, including without limitation the rights
11 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 // copies of the Software, and to permit persons to whom the Software is
13 // furnished to do so, subject to the following conditions:
14 //
15 // The above copyright notice and this permission notice shall be included in all
16 // copies or substantial portions of the Software.
17 //
18 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24 // SOFTWARE.
25 
26 #pragma once
27 
28 #include "hal_core/netlist/gate.h"
29 #include "hal_core/netlist/net.h"
32 
33 
34 #include <QObject>
35 #include <QSet>
36 #include <tuple>
37 #include <vector>
38 #include <optional>
39 
40 namespace hal
41 {
42  namespace GuiApiClasses {
43 
44  class View{
45  public:
57  static int isolateInNew(const std::vector<Module*> modules, const std::vector<Gate*> gates);
65  static bool deleteView(int id);
75  static bool addTo(int id, const std::vector<Module*> modules, const std::vector<Gate*> gates);
85  static bool removeFrom(int id, const std::vector<Module*> modules, const std::vector<Gate*> gates);
94  static bool setName(int id, const std::string& name);
102  static int getId(const std::string& name);
110  static std::string getName(int id);
118  static std::vector<Module*> getModules(int id);
126  static std::vector<Gate*> getGates(int id);
135  static std::vector<u32> getIds(const std::vector<Module*> modules, const std::vector<Gate*> gates);
144  static bool foldModule(int view_id, Module* module);
153  static bool unfoldModule(int view_id, Module* module);
154 
158  };
159 
160  static ModuleGateIdPair getValidObjects(int viewId, const std::vector<Module*>, const std::vector<Gate*>);
161  static GridPlacement* getGridPlacement(int viewId);
162  static bool setGridPlacement(int viewId, GridPlacement* gp);
163 
171  static u32 getCurrentDirectory();
179  static void setCurrentDirectory(u32 id);
187  static u32 createNewDirectory(const std::string& name);
193  static void deleteDirectory(u32 id);
202  static void moveView(u32 viewId, std::optional<u32> destinationDirectoryId, std::optional<int> row);
211  static void moveDirectory(u32 directoryId, std::optional<u32> destinationDirectoryId, std::optional<int> row);
212 
221  static std::optional<std::vector<u32>> getChildDirectories(u32 directoryId);
222 
231  static std::optional<std::vector<u32>> getChildViews(u32 directoryId);
232 
241  static int isolateModuleToModulePathInNewView(u32 fromModId, u32 toModId);
242  };
243  }
244 
245 
257  class GuiApi : public QObject
258  {
259  Q_OBJECT
260 
261  public:
265  GuiApi();
266 
272  std::vector<u32> getSelectedGateIds();
273 
279  std::vector<u32> getSelectedNetIds();
280 
287  std::vector<u32> getSelectedModuleIds();
288 
296  std::tuple<std::vector<u32>, std::vector<u32>, std::vector<u32>> getSelectedItemIds();
297 
303  std::vector<Gate*> getSelectedGates();
304 
310  std::vector<Net*> getSelectedNets();
311 
317  std::vector<Module*> getSelectedModules();
318 
325  std::tuple<std::vector<Gate*>, std::vector<Net*>, std::vector<Module*>> getSelectedItems();
326 
338  void selectGate(u32 gate_id, bool clear_current_selection = true, bool navigate_to_selection = true);
339 
351  void selectGate(const std::vector<u32>& gate_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
352 
364  void selectGate(Gate* gate, bool clear_current_selection = true, bool navigate_to_selection = true);
365 
377  void selectGate(const std::vector<Gate*>& gates, bool clear_current_selection = true, bool navigate_to_selection = true);
378 
390  void selectNet(u32 netId, bool clear_current_selection = true, bool navigate_to_selection = true);
391 
403  void selectNet(const std::vector<u32>& net_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
404 
416  void selectNet(Net* net, bool clear_current_selection = true, bool navigate_to_selection = true);
417 
429  void selectNet(const std::vector<Net*>& nets, bool clear_current_selection = true, bool navigate_to_selection = true);
430 
442  void selectModule(u32 module_id, bool clear_current_selection = true, bool navigate_to_selection = true);
443 
455  void selectModule(const std::vector<u32>& module_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
456 
468  void selectModule(Module* module, bool clear_current_selection = true, bool navigate_to_selection = true);
469 
481  void selectModule(const std::vector<Module*>& modules, bool clear_current_selection = true, bool navigate_to_selection = true);
482 
494  void select(Gate* gate, bool clear_current_selection = true, bool navigate_to_selection = true);
495 
507  void select(Net* net, bool clear_current_selection = true, bool navigate_to_selection = true);
508 
520  void select(Module* module, bool clear_current_selection = true, bool navigate_to_selection = true);
521 
533  void select(const std::vector<Gate*>& gates, bool clear_current_selection = true, bool navigate_to_selection = true);
534 
546  void select(const std::vector<Net*>& nets, bool clear_current_selection = true, bool navigate_to_selection = true);
547 
559  void select(const std::vector<Module*>& modules, bool clear_current_selection = true, bool navigate_to_selection = true);
560 
574  void select(const std::vector<u32>& gate_ids, const std::vector<u32>& net_ids, const std::vector<u32>& module_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
575 
589  void select(const std::vector<Gate*>& gates, const std::vector<Net*>& nets, const std::vector<Module*>& modules, bool clear_current_selection = true, bool navigate_to_selection = true);
590 
596  void deselectGate(u32 gate_id);
597 
603  void deselectGate(const std::vector<u32>& gate_ids);
604 
610  void deselectGate(Gate* gate);
611 
617  void deselectGate(const std::vector<Gate*>& gates);
618 
624  void deselectNet(u32 netId);
625 
631  void deselectNet(const std::vector<u32>& net_ids);
632 
638  void deselectNet(Net* net);
639 
645  void deselectNet(const std::vector<Net*>& nets);
646 
652  void deselectModule(u32 module_id);
653 
659  void deselectModule(const std::vector<u32>& module_ids);
660 
667 
673  void deselectModule(const std::vector<Module*>& modules);
674 
678  void deselectAllItems();
679 
685  void deselect(Gate* gate);
686 
692  void deselect(Net* net);
693 
699  void deselect(Module* module);
700 
706  void deselect(const std::vector<Gate*>& gates);
707 
713  void deselect(const std::vector<Net*>& nets);
714 
720  void deselect(const std::vector<Module*>& modules);
721 
729  void deselect(const std::vector<u32>& gate_ids, const std::vector<u32>& net_ids, const std::vector<u32>& module_ids);
730 
738  void deselect(const std::vector<Gate*>& gates, const std::vector<Net*>& nets, const std::vector<Module*>& modules);
739 
740 
741  Q_SIGNALS:
746  };
747 }
Definition: gate.h:58
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 int isolateModuleToModulePathInNewView(u32 fromModId, u32 toModId)
Definition: gui_api.cpp:449
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
static ModuleGateIdPair getValidObjects(int viewId, const std::vector< Module * >, const std::vector< Gate * >)
Definition: gui_api.cpp:855
Interface to interact with the gui itself.
Definition: gui_api.h:258
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 navigationRequested()
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
Definition: net.h:58
const Module * module(const Gate *g, const NodeBoxes &boxes)
quint32 u32
Net * net
std::string name
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS