HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
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 
78  GraphContext* createNewContext(const QString& name, u32 parentId = 0);
79 
80  ContextDirectory* createNewDirectory(const QString &name, u32 parentId = 0);
81 
89  void openModuleInView(u32 moduleId, bool unfold);
90 
96  void openGateInView(u32 gateId);
97 
103  void openNetEndpointsInView(u32 netId);
104 
112  void renameGraphContextAction(GraphContext* ctx, const QString& newName);
113 
121  void renameContextDirectoryAction(ContextDirectory* ctxDir, const QString& newName);
122 
123 
130  void deleteGraphContext(GraphContext* ctx);
131 
138 
145  GraphContext* getCleanContext(const QString& name) const;
146  GraphContext* getContextById(u32 id) const;
147 
148 
149  u32 getParentId(u32 childId, bool isDirectory) const;
150 
151  bool moveItem(u32 itemId, bool isDirectory, u32 parentId, int row = -1);
152 
154 
161 
168  bool contextWithNameExists(const QString& name) const;
169 
175  QString nextViewName(const QString& prefix) const;
176 
182  void handleModuleCreated(Module* m) const;
183 
190  void handleModuleRemoved(Module* m);
191 
197  void handleModuleNameChanged(Module* m) const;
198 
204  void handleModuleTypeChanged(Module* m) const;
205 
211  void handleModuleColorChanged(Module* m) const;
212  //void handle_module_parent_changed(Module* m) const;
220  void handleModuleSubmoduleAdded(Module* m, const u32 added_module) const;
221 
229  void handleModuleSubmoduleRemoved(Module* m, const u32 removed_module);
230 
238  void handleModuleGateAssigned(Module* m, const u32 inserted_gate) const;
239 
247  void handleModuleGateRemoved(Module* m, const u32 removed_gate);
248 
257  void handleModulePortsChanged(Module* m, PinEvent pev, u32 pgid);
258 
265  void handleGateRemoved(Gate* g) const;
266 
273  void handleGateNameChanged(Gate* g) const;
274 
281  void handleNetCreated(Net* n) const;
282 
289  void handleNetRemoved(Net* n) const;
296  void handleNetNameChanged(Net* n) const;
297 
305  void handleNetSourceAdded(Net* n, const u32 src_gate_id) const;
306 
314  void handleNetSourceRemoved(Net* n, const u32 src_gate_id) const;
315 
323  void handleNetDestinationAdded(Net* n, const u32 dst_gate_id) const;
324 
332  void handleNetDestinationRemoved(Net* n, const u32 dst_gate_id) const;
333 
340  void handleMarkedGlobalInput(u32 mNetId);
341 
348  void handleMarkedGlobalOutput(u32 mNetId);
349 
356  void handleUnmarkedGlobalInput(u32 mNetId);
357 
364  void handleUnmarkedGlobalOutput(u32 mNetId);
365 
372  void setContextId(GraphContext* ctx, u32 ctxId);
373 
382  GraphLayouter* getDefaultLayouter(GraphContext* const context) const;
383 
392  GraphShader* getDefaultShader(GraphContext* const context) const;
393 
400 
404  void clear();
405 
406  bool handleSaveTriggered(const QString& filename);
407 
413  GraphContext* restoreFromFile(const QString &filename);
414 
416  {
417  return QString("view %1").arg(mMaxContextId + 1);
418  }
419 
421 
423 
425  Q_SIGNALS:
431  void contextCreated(GraphContext* context);
432 
438  void contextRenamed(GraphContext* context);
439 
447 
454 
462 
463 
464 
465  private:
466  // QVector<GraphContext*> mGraphContexts;
467 
468  ContextTreeModel* mContextTreeModel;
469  u32 mMaxContextId;
470  void dump(const QString& title, u32 mid, u32 xid) const;
471  SettingsItemCheckbox* mSettingDebugGrid;
472  SettingsItemCheckbox* mSettingDumpJunction;
473  SettingsItemCheckbox* mSettingParseLayout;
474  SettingsItemCheckbox* mSettingLayoutBoxes;
475  };
476 } // 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
static SettingsItemCheckbox * sSettingLayoutOnEveryChange
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.
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45
PinEvent
Definition: pin_event.h:42
std::string name
Q_OBJECTQ_OBJECT
Q_SIGNALSQ_SIGNALS
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const