BasicBlockWidget::BasicBlockWidget(const QString& name, BasicBlock * block,
Mainwindow * mainwindow)
- : width(270), height(45)
- , _widget("", this)
- , _table(NULL), name(name)
+ : width(270), height(45), name(name)
+ , _widget("", this), _table(NULL)
, block(block), mainwindow(mainwindow) {
next[0] = NULL; next[1] = NULL;
+ _widget.setPos(5, 20);
_widget.setTextInteractionFlags(Qt::TextSelectableByMouse|
Qt::LinksAccessibleByMouse);
- _widget.setPos(5, 20);
-
if (width < 250) width = 250;
}
if (width < 250) width = 250;
}
+
+void BasicBlockWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget) {
+ painter->fillRect(0, 0, width, height, QColor(0xcc, 0xcc, 0xff, 0xff));
+ painter->setPen(QColor(0x00, 0x00, 0xff, 0xff));
+ painter->drawRect(0, 0, width, height);
+ painter->drawText(5, 15, name);
+}
+
+QRectF BasicBlockWidget::boundingRect() const {
+ qreal penWidth = 1;
+ QRectF result(- penWidth / 2, - penWidth / 2,
+ width + penWidth, height + penWidth);
+ return result;
+}
+
+std::array<QPointF, 3> BasicBlockWidget::getExits() const {
+ return { { mapToScene(QPointF( width/3, height)),
+ mapToScene(QPointF( width/2, height)),
+ mapToScene(QPointF(2*width/3, height)) } };
+}
+
BasicBlockWidget(const QString& name, BasicBlock * block, Mainwindow * mainwindow);
void addItem(uint8_t* bytes, size_t num_bytes, QString line, const QString& href);
+ void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
+ QWidget *widget);
+ QRectF boundingRect() const;
+ std::array<QPointF, 3> getExits() const;
- QRectF boundingRect() const {
- qreal penWidth = 1;
- QRectF result(- penWidth / 2, - penWidth / 2,
- width + penWidth, height + penWidth);
- return result;
- }
-
- void mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
- QGraphicsItem::mouseMoveEvent(event);
- scene()->update();
- }
-
- QPointF getEntry() const {
- return mapToScene(QPointF(width/2, 0));
- }
+ void mouseMoveEvent(QGraphicsSceneMouseEvent * event)
+ { QGraphicsItem::mouseMoveEvent(event); scene()->update(); }
- std::array<QPointF, 3> getExits() const {
- return { { mapToScene(QPointF( width/3, height)),
- mapToScene(QPointF( width/2, height)),
- mapToScene(QPointF(2*width/3, height)) } };
- }
+ QPointF getEntry() const
+ { return mapToScene(QPointF(width/2, 0)); }
- void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
- QWidget *widget) {
- painter->fillRect(0, 0, width, height, QColor(0xcc, 0xcc, 0xff, 0xff));
- painter->setPen(QColor(0x00, 0x00, 0xff, 0xff));
- painter->drawRect(0, 0, width, height);
- painter->drawText(5, 15, name);
- }
+ void addPrevious(BasicBlockWidget * widget)
+ { previous.push_back(widget); }
- void addPrevious(BasicBlockWidget * widget) {
- previous.push_back(widget);
- }
+ void addNext(BasicBlockWidget * left, BasicBlockWidget * right)
+ { next[0] = left; next[1] = right; }
- void addNext(BasicBlockWidget * left, BasicBlockWidget * right) {
- next[0] = left;
- next[1] = right;
- }
+ BasicBlockWidget ** getNext()
+ { return next; }
- BasicBlockWidget ** getNext() {
- return next;
- }
-
- QString getName() const {
- return name;
- }
+ QString getName() const
+ { return name; }
private:
uint32_t width, height;
+ QString name;
QGraphicsTextItem _widget;
QTextTable* _table;
- QString name;
- BasicBlock * block;
- Mainwindow * mainwindow;
+ BasicBlock* block;
+ Mainwindow* mainwindow;
std::vector<BasicBlockWidget*> previous;
BasicBlockWidget* next[2];
};