2019-01-24 17:13:04 +00:00
|
|
|
#ifndef OVERVIEWVIEW_H
|
|
|
|
#define OVERVIEWVIEW_H
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QPainter>
|
|
|
|
#include <QRect>
|
|
|
|
#include "widgets/GraphView.h"
|
|
|
|
|
|
|
|
class OverviewView : public GraphView
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
signals:
|
2019-02-07 20:39:37 +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-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief a rect on Overview to show where you are on Graph
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
QRectF rangeRect;
|
|
|
|
|
2019-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief offset for the rect which is put when either of the scrollbar of
|
|
|
|
* Graph is not visible.
|
|
|
|
*/
|
|
|
|
qreal h_offset = 0;
|
|
|
|
qreal v_offset = 0;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* \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
|
|
|
|
*/
|
|
|
|
void setData(int baseWidth, int baseHeight, std::unordered_map<ut64, GraphBlock> baseBlocks);
|
|
|
|
|
|
|
|
public slots:
|
2019-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief refresh the view and adjust the scale
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void refreshView();
|
|
|
|
|
|
|
|
private slots:
|
2019-02-07 20:39:37 +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-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief mousePressEvent to start moving the rect.
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
2019-02-07 20:39:37 +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-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief mouseMoveEvent to move the rect.
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
|
|
|
|
private:
|
2019-02-07 20:39:37 +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-02-07 20:39:37 +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-02-07 20:39:37 +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-02-07 20:39:37 +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-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief override the paintEvent to draw the rect on Overview
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void paintEvent(QPaintEvent *event) override;
|
|
|
|
|
2019-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief apply scale properly on the view
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
void adjustScale();
|
|
|
|
|
2019-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief if the mouse is in the rect in Overview.
|
2019-02-03 07:54:28 +00:00
|
|
|
*/
|
|
|
|
bool mouseContainsRect(QMouseEvent *event);
|
|
|
|
|
2019-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief base background color changing depending on the theme
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
QColor disassemblyBackgroundColor;
|
|
|
|
|
2019-02-07 20:39:37 +00:00
|
|
|
/*
|
|
|
|
* \brief color for each node changing depending on the theme
|
2019-01-24 17:13:04 +00:00
|
|
|
*/
|
|
|
|
QColor graphNodeColor;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // OVERVIEWVIEW_H
|