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);
230  static std::optional<std::vector<u32>> getChildViews(u32 directoryId);
231  };
232  }
233 
234 
246  class GuiApi : public QObject
247  {
248  Q_OBJECT
249 
250  public:
254  GuiApi();
255 
261  std::vector<u32> getSelectedGateIds();
262 
268  std::vector<u32> getSelectedNetIds();
269 
276  std::vector<u32> getSelectedModuleIds();
277 
285  std::tuple<std::vector<u32>, std::vector<u32>, std::vector<u32>> getSelectedItemIds();
286 
292  std::vector<Gate*> getSelectedGates();
293 
299  std::vector<Net*> getSelectedNets();
300 
306  std::vector<Module*> getSelectedModules();
307 
314  std::tuple<std::vector<Gate*>, std::vector<Net*>, std::vector<Module*>> getSelectedItems();
315 
327  void selectGate(u32 gate_id, bool clear_current_selection = true, bool navigate_to_selection = true);
328 
340  void selectGate(const std::vector<u32>& gate_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
341 
353  void selectGate(Gate* gate, bool clear_current_selection = true, bool navigate_to_selection = true);
354 
366  void selectGate(const std::vector<Gate*>& gates, bool clear_current_selection = true, bool navigate_to_selection = true);
367 
379  void selectNet(u32 netId, bool clear_current_selection = true, bool navigate_to_selection = true);
380 
392  void selectNet(const std::vector<u32>& net_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
393 
405  void selectNet(Net* net, bool clear_current_selection = true, bool navigate_to_selection = true);
406 
418  void selectNet(const std::vector<Net*>& nets, bool clear_current_selection = true, bool navigate_to_selection = true);
419 
431  void selectModule(u32 module_id, bool clear_current_selection = true, bool navigate_to_selection = true);
432 
444  void selectModule(const std::vector<u32>& module_ids, bool clear_current_selection = true, bool navigate_to_selection = true);
445 
457  void selectModule(Module* module, bool clear_current_selection = true, bool navigate_to_selection = true);
458 
470  void selectModule(const std::vector<Module*>& modules, bool clear_current_selection = true, bool navigate_to_selection = true);
471 
483  void select(Gate* gate, bool clear_current_selection = true, bool navigate_to_selection = true);
484 
496  void select(Net* net, bool clear_current_selection = true, bool navigate_to_selection = true);
497 
509  void select(Module* module, bool clear_current_selection = true, bool navigate_to_selection = true);
510 
522  void select(const std::vector<Gate*>& gates, bool clear_current_selection = true, bool navigate_to_selection = true);
523 
535  void select(const std::vector<Net*>& nets, bool clear_current_selection = true, bool navigate_to_selection = true);
536 
548  void select(const std::vector<Module*>& modules, bool clear_current_selection = true, bool navigate_to_selection = true);
549 
563  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);
564 
578  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);
579 
585  void deselectGate(u32 gate_id);
586 
592  void deselectGate(const std::vector<u32>& gate_ids);
593 
599  void deselectGate(Gate* gate);
600 
606  void deselectGate(const std::vector<Gate*>& gates);
607 
613  void deselectNet(u32 netId);
614 
620  void deselectNet(const std::vector<u32>& net_ids);
621 
627  void deselectNet(Net* net);
628 
634  void deselectNet(const std::vector<Net*>& nets);
635 
641  void deselectModule(u32 module_id);
642 
648  void deselectModule(const std::vector<u32>& module_ids);
649 
656 
662  void deselectModule(const std::vector<Module*>& modules);
663 
667  void deselectAllItems();
668 
674  void deselect(Gate* gate);
675 
681  void deselect(Net* net);
682 
688  void deselect(Module* module);
689 
695  void deselect(const std::vector<Gate*>& gates);
696 
702  void deselect(const std::vector<Net*>& nets);
703 
709  void deselect(const std::vector<Module*>& modules);
710 
718  void deselect(const std::vector<u32>& gate_ids, const std::vector<u32>& net_ids, const std::vector<u32>& module_ids);
719 
727  void deselect(const std::vector<Gate*>& gates, const std::vector<Net*>& nets, const std::vector<Module*>& modules);
728 
729 
730  Q_SIGNALS:
735  };
736 }
Definition: gate.h:58
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
static ModuleGateIdPair getValidObjects(int viewId, const std::vector< Module * >, const std::vector< Gate * >)
Definition: gui_api.cpp:795
Interface to interact with the gui itself.
Definition: gui_api.h:247
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 navigationRequested()
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
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