HAL
graph_context_manager.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/defines.h"
30 
31 #include <QObject>
32 #include <QStringList>
33 #include <QVector>
34 
35 namespace hal
36 {
37  class Gate;
38  class Module;
39  class Net;
40 
41  class GraphContext;
42  class GraphLayouter;
43  class GraphShader;
44  class GraphContext;
45  class ContextDirectory;
46 
47  class ContextTreeModel;
48  class SettingsItemCheckbox;
49 
60  {
61  Q_OBJECT
62 
63  public:
68 
77  GraphContext* createNewContext(const QString& name, u32 parentId = 0);
78 
79  ContextDirectory* createNewDirectory(const QString &name, u32 parentId = 0);
80 
88  void openModuleInView(u32 moduleId, bool unfold);
89 
95  void openGateInView(u32 gateId);
96 
102  void openNetEndpointsInView(u32 netId);
103 
111  void renameGraphContextAction(GraphContext* ctx, const QString& newName);
112 
120  void renameContextDirectoryAction(ContextDirectory* ctxDir, const QString& newName);
121 
122 
129  void deleteGraphContext(GraphContext* ctx);
130 
137 
144  GraphContext* getCleanContext(const QString& name) const;
145  GraphContext* getContextById(u32 id) const;
146 
147 
148  u32 getParentId(u32 childId, bool isDirectory) const;
149 
150  bool moveItem(u32 itemId, bool isDirectory, u32 parentId, int row = -1);
151 
153 
160 
167  bool contextWithNameExists(const QString& name) const;
168 
174  QString nextViewName(const QString& prefix) const;
175 
181  void handleModuleCreated(Module* m) const;
182 
189  void handleModuleRemoved(Module* m);
190 
196  void handleModuleNameChanged(Module* m) const;
197 
203  void handleModuleTypeChanged(Module* m) const;
204 
210  void handleModuleColorChanged(Module* m) const;
211  //void handle_module_parent_changed(Module* m) const;
219  void handleModuleSubmoduleAdded(Module* m, const u32 added_module) const;
220 
228  void handleModuleSubmoduleRemoved(Module* m, const u32 removed_module);
229 
237  void handleModuleGateAssigned(Module* m, const u32 inserted_gate) const;
238 
246  void handleModuleGateRemoved(Module* m, const u32 removed_gate);
247 
254  void handleModulePortsChanged(Module* m, PinEvent pev, u32 pgid);
255 
262  void handleGateRemoved(Gate* g) const;
263 
270  void handleGateNameChanged(Gate* g) const;
271 
278  void handleNetCreated(Net* n) const;
279 
286  void handleNetRemoved(Net* n) const;
293  void handleNetNameChanged(Net* n) const;
294 
302  void handleNetSourceAdded(Net* n, const u32 src_gate_id) const;
303 
311  void handleNetSourceRemoved(Net* n, const u32 src_gate_id) const;
312 
320  void handleNetDestinationAdded(Net* n, const u32 dst_gate_id) const;
321 
329  void handleNetDestinationRemoved(Net* n, const u32 dst_gate_id) const;
330 
337  void handleMarkedGlobalInput(u32 mNetId);
338 
345  void handleMarkedGlobalOutput(u32 mNetId);
346 
353  void handleUnmarkedGlobalInput(u32 mNetId);
354 
361  void handleUnmarkedGlobalOutput(u32 mNetId);
362 
369  void setContextId(GraphContext* ctx, u32 ctxId);
370 
379  GraphLayouter* getDefaultLayouter(GraphContext* const context) const;
380 
389  GraphShader* getDefaultShader(GraphContext* const context) const;
390 
397 
401  void clear();
402 
403  bool handleSaveTriggered(const QString& filename);
404 
410  GraphContext* restoreFromFile(const QString &filename);
411 
413  {
414  return QString("view %1").arg(mMaxContextId + 1);
415  }
416 
418 
420  Q_SIGNALS:
426  void contextCreated(GraphContext* context);
427 
433  void contextRenamed(GraphContext* context);
434 
442 
449 
457 
458 
459 
460  private:
461  // QVector<GraphContext*> mGraphContexts;
462 
463  ContextTreeModel* mContextTreeModel;
464  u32 mMaxContextId;
465  void dump(const QString& title, u32 mid, u32 xid) const;
466  SettingsItemCheckbox* mSettingDebugGrid;
467  SettingsItemCheckbox* mSettingDumpJunction;
468  SettingsItemCheckbox* mSettingParseLayout;
469  SettingsItemCheckbox* mSettingLayoutBoxes;
470  };
471 } // namespace hal
Base model for the ContextManagerWidget to manage GraphContexts.
Definition: gate.h:58
Logical container for modules, gates, and nets.
Definition: graph_context.h:55
User interface to manage all GraphContexts.
void contextRenamed(GraphContext *context)
void handleModuleNameChanged(Module *m) const
void renameContextDirectoryAction(ContextDirectory *ctxDir, const QString &newName)
QString nextViewName(const QString &prefix) const
GraphContext * createNewContext(const QString &name, u32 parentId=0)
void handleMarkedGlobalOutput(u32 mNetId)
void renameGraphContextAction(GraphContext *ctx, const QString &newName)
void deleteContextDirectory(ContextDirectory *ctxDir)
void setContextId(GraphContext *ctx, u32 ctxId)
void handleNetNameChanged(Net *n) const
void handleModuleTypeChanged(Module *m) const
GraphContext * getContextById(u32 id) const
bool handleSaveTriggered(const QString &filename)
ContextTreeModel * getContextTreeModel() const
GraphContext * getContextByExclusiveModuleId(u32 module_id) const
void handleMarkedGlobalInput(u32 mNetId)
u32 getParentId(u32 childId, bool isDirectory) const
void handleNetDestinationRemoved(Net *n, const u32 dst_gate_id) const
GraphContext * getCleanContext(const QString &name) const
void handleGateRemoved(Gate *g) const
void handleModuleGateAssigned(Module *m, const u32 inserted_gate) const
bool contextWithNameExists(const QString &name) const
void handleNetSourceRemoved(Net *n, const u32 src_gate_id) const
void handleUnmarkedGlobalOutput(u32 mNetId)
GraphLayouter * getDefaultLayouter(GraphContext *const context) const
void handleUnmarkedGlobalInput(u32 mNetId)
void handleNetDestinationAdded(Net *n, const u32 dst_gate_id) const
void contextCreated(GraphContext *context)
void deleteGraphContext(GraphContext *ctx)
static SettingsItemCheckbox * sSettingPanOnMiddleButton
static SettingsItemCheckbox * sSettingNetGroupingToPins
ContextDirectory * createNewDirectory(const QString &name, u32 parentId=0)
void handleModuleCreated(Module *m) const
void handleModuleSubmoduleAdded(Module *m, const u32 added_module) const
void handleModulePortsChanged(Module *m, PinEvent pev, u32 pgid)
void handleModuleGateRemoved(Module *m, const u32 removed_gate)
bool moveItem(u32 itemId, bool isDirectory, u32 parentId, int row=-1)
void handleModuleColorChanged(Module *m) const
GraphShader * getDefaultShader(GraphContext *const context) const
void directoryRenamed(ContextDirectory *directory)
GraphContext * restoreFromFile(const QString &filename)
void openModuleInView(u32 moduleId, bool unfold)
void handleModuleSubmoduleRemoved(Module *m, const u32 removed_module)
void deletingDirectory(ContextDirectory *directory)
void handleNetSourceAdded(Net *n, const u32 src_gate_id) const
ContextDirectory * getDirectoryById(u32 id) const
void handleGateNameChanged(Gate *g) const
QVector< GraphContext * > getContexts() const
void deletingContext(GraphContext *context)
Base class for all specific layouters.
Base class to store and update visual information about the graph.
Definition: graph_shader.h:47
Definition: net.h:58
A SettingsItem representing a Checkbox.
PinEvent
Definition: pin_event.h:42
n
Definition: test.py:6
quint32 u32
std::string name
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const