2019-01-24 17:13:04 +00:00
|
|
|
#ifndef OVERVIEWVIEW_H
|
|
|
|
#define OVERVIEWVIEW_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QRect>
|
|
|
|
#include "widgets/GraphView.h"
|
2019-04-04 05:54:42 +00:00
|
|
|
#include "widgets/DisassemblerGraphView.h"
|
2019-01-24 17:13:04 +00:00
|
|
|
|
|
|
|
class OverviewView : public GraphView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
signals:
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief signal when mouse is pressed or moved so that
|
2019-01-24 17:13:04 +00:00
|
|
|
* Graph can refresh its contents corresponded with Overview
|
|
|
|
*/
|
|
|
|
void mouseMoved();
|
|
|
|
|
|
|
|
public:
|
|
|
|
OverviewView(QWidget *parent);
|
|
|
|
~OverviewView() override;
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief Graph access this function to set minimum set of the data
|
2019-01-24 17:13:04 +00:00
|
|
|
* @param baseWidth width of Graph when it computed the blocks
|
|
|
|
* @param baseHeigh height of Graph when it computed the blocks
|
|
|
|
* @param baseBlocks computed blocks passed by Graph
|
2019-04-04 05:54:42 +00:00
|
|
|
* @param baseEdgeConfigurations computed by DisassamblerGraphview
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
2019-04-04 05:54:42 +00:00
|
|
|
void setData(int baseWidth, int baseHeight, std::unordered_map<ut64, GraphBlock> baseBlocks,
|
|
|
|
DisassemblerGraphView::EdgeConfigurationMapping baseEdgeConfigurations);
|
2019-01-24 17:13:04 +00:00
|
|
|
|
|
|
|
public slots:
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
2019-03-12 07:37:10 +00:00
|
|
|
* @brief scale and center all nodes in, then run update
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void refreshView();
|
|
|
|
|
|
|
|
private slots:
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief update Colors.
|
2019-01-24 17:13:04 +00:00
|
|
|
* for example this will be called when the theme is changed.
|
|
|
|
*/
|
|
|
|
void colorsUpdatedSlot();
|
|
|
|
|
|
|
|
protected:
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief mousePressEvent to start moving the rect.
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief mouseReleaseEvent to tell not to move the rect anymore.
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief mouseMoveEvent to move the rect.
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief override this to prevent scrolling
|
2019-02-16 17:17:11 +00:00
|
|
|
*/
|
|
|
|
void wheelEvent(QWheelEvent *event) override;
|
2019-01-24 17:13:04 +00:00
|
|
|
|
2019-04-08 06:59:16 +00:00
|
|
|
/**
|
|
|
|
* @brief override the paintEvent to draw the rect on Overview
|
|
|
|
*/
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
2019-01-24 17:13:04 +00:00
|
|
|
private:
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief this will be handled in mouse events to move the rect properly
|
2019-01-24 17:13:04 +00:00
|
|
|
* along with the mouse.
|
|
|
|
*/
|
|
|
|
bool mouseActive = false;
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief save the initial distance
|
2019-01-24 17:13:04 +00:00
|
|
|
* between the point where the mouse was pressed and the point of the rect
|
|
|
|
* so as to change the rect point properly along with mouse.
|
|
|
|
*/
|
|
|
|
QPointF initialDiff;
|
|
|
|
|
2019-04-14 12:18:24 +00:00
|
|
|
/**
|
|
|
|
* @brief a rect on Overview to show where you are on Graph
|
|
|
|
*/
|
|
|
|
QRectF rangeRect;
|
|
|
|
|
2019-03-12 07:37:10 +00:00
|
|
|
/**
|
|
|
|
* @brief calculate the scale to fit the all nodes in and center them in the viewport
|
|
|
|
*/
|
|
|
|
void scaleAndCenter();
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief draw the computed blocks passed by Graph
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
virtual void drawBlock(QPainter &p, GraphView::GraphBlock &block) override;
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief override the edgeConfiguration so as to
|
2019-01-24 17:13:04 +00:00
|
|
|
* adjust the width of the edges by the scale
|
|
|
|
* @return EdgeConfiguration
|
|
|
|
*/
|
|
|
|
virtual GraphView::EdgeConfiguration edgeConfiguration(GraphView::GraphBlock &from,
|
|
|
|
GraphView::GraphBlock *to) override;
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief base background color changing depending on the theme
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
QColor disassemblyBackgroundColor;
|
|
|
|
|
2019-03-06 20:30:39 +00:00
|
|
|
/**
|
|
|
|
* @brief color for each node changing depending on the theme
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
QColor graphNodeColor;
|
2019-04-04 05:54:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief edgeConfigurations edge styles computed by DisassemblerGraphView
|
|
|
|
*/
|
|
|
|
DisassemblerGraphView::EdgeConfigurationMapping edgeConfigurations;
|
2019-04-14 12:18:24 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
QRectF getRangeRect() { return rangeRect; }
|
|
|
|
void setRangeRect(QRectF rect);
|
2019-01-24 17:13:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OVERVIEWVIEW_H
|