HAL  v4.5.0-83-g30c8f0afc
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
graph_widget.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"
29 
30 #include "gui/gui_globals.h"
31 #include "gui/gui_def.h"
33 
34 #include <deque>
35 
36 namespace hal
37 {
38  class WidgetOverlay;
39  class GraphContext;
40  class GraphGraphicsView;
41  class SpinnerWidget;
42  class SettingsItemSpinbox;
43  class GraphNavigationWidget;
44  class AbstractBusyIndicator;
45  class CommentWidget;
46 
54  class GraphWidget : public ContentWidget
55  {
56  Q_OBJECT
57 
58  public:
65  explicit GraphWidget(GraphContext* context, QWidget* parent = nullptr);
66 
70  ~GraphWidget();
71 
77  GraphContext* getContext() const;
78 
83  void handleSceneAvailable();
89 
94 
98  void storeViewport();
99 
106 
110  void ensureSelectionVisible();
111 
117  void showProgress(int percent, const QString& text=QString());
118 
123  void showComments(const Node& nd);
124 
125  void showBusy(int percent, const QString& text);
126 
127  void focusGate(u32 gateId);
128  void focusNet(u32 netId);
129  void focusModule(u32 moduleId);
130  static void pluginProgressIndicator(int percent, const std::string& msg);
131 
132  protected:
139  void keyPressEvent(QKeyEvent* event) override;
140 
141  private Q_SLOTS:
142  void handleNavigationJumpRequested(const Node& origin, const u32 via_net, const QSet<u32>& to_gates, const QSet<u32>& to_modules);
143  void handleModuleDoubleClicked(const u32 id);
144  void resetFocus();
145  void hideOverlay();
146 
147  private:
148  void handleNavigationLeftRequest();
149  void handleNavigationRightRequest();
150  void handleNavigationUpRequest();
151  void handleNavigationDownRequest();
152 
153  void substituteByVisibleModules(const QSet<u32>& gates, const QSet<u32>& modules, QSet<u32>& insert_gates, QSet<u32>& insert_modules,
154  QSet<u32>& remove_gates, QSet<u32>& remove_modules) const;
155 
156  void handleEnterModuleRequested(const u32 id);
157 
158  void ensureItemsVisible(const QSet<u32>& gates, const QSet<u32>& modules);
159 
160  void focusRect(QRectF targetRect, bool applyCenterFix);
161 
162  bool hasFocusedItem(SelectionRelay::Subfocus navigateDirection) const;
163 
164  GraphGraphicsView* mView;
165  GraphContext* mContext;
166 
167  WidgetOverlay* mOverlay;
168  GraphNavigationWidget* mNavigationWidgetV3;
169  AbstractBusyIndicator* mProgressBar;
170 
171  SpinnerWidget* mSpinnerWidget;
172  CommentWidget* mCommentWidget;
173 
174  u32 mCurrentExpansion;
175 
176  QRectF mRectAfterFocus;
177  QRectF mLastTargetRect;
178 
182  class StoreViewport
183  {
184  public:
185  bool mValid;
186  QRectF mRect;
187  QPair<QPoint,QPointF> mGrid;
188  StoreViewport() : mValid(false) {;}
189  };
190 
191  QRectF restoreViewport(bool reset = true);
192 
193  StoreViewport mStoreViewport;
194 
195  static SettingsItemSpinbox* sSettingAnimationDuration;
196 
197  static GraphWidget* sInstance;
198 
199  };
200 }
Abstract class for Widgets within HAL's ContentArea.
Logical container for modules, gates, and nets.
Definition: graph_context.h:55
A view to display the rendered graph (needs a GraphicsScene).
Wraps a GraphContext and a GraphGraphicsView.
Definition: graph_widget.h:55
GraphWidget(GraphContext *context, QWidget *parent=nullptr)
void ensureSelectionVisible()
void keyPressEvent(QKeyEvent *event) override
void handleSceneUnavailable()
void showBusy(int percent, const QString &text)
GraphContext * getContext() const
void showProgress(int percent, const QString &text=QString())
static void pluginProgressIndicator(int percent, const std::string &msg)
void handleSceneAvailable()
void focusGate(u32 gateId)
void focusModule(u32 moduleId)
GraphGraphicsView * view()
void showComments(const Node &nd)
void focusNet(u32 netId)
void handleContextAboutToBeDeleted()
The Node class object represents a module or a gate.
Definition: gui_def.h:61
A SettingsItem that represents a spinbox.
A loading wheel.
Container for a QWidget that overlays another one.
uint32_t u32
Definition: defines.h:41
Definition: defines.h:45
std::string origin
Q_OBJECTQ_OBJECT
Q_SLOTSQ_SLOTS
QObject * parent() const const
virtual bool event(QEvent *event) override