#include <vector>
#include <cassert>
#include <tuple>
+#include <array>
class BasicBlockWidget : public QGraphicsItem
{
public:
- BasicBlockWidget(const QString& name, BasicBlock * block);
+ BasicBlockWidget(const QString& name, BasicBlock * block);
void addItem(uint8_t* bytes, size_t num_bytes, const QString& line);
- QRectF boundingRect() const {
- qreal penWidth = 1;
+ QRectF boundingRect() const {
+ qreal penWidth = 1;
QRectF result(- penWidth / 2, - penWidth / 2,
- width + penWidth, height + penWidth);
- return result;
- }
+ width + penWidth, height + penWidth);
+ return result;
+ }
void mouseMoveEvent(QGraphicsSceneMouseEvent * event) {
QGraphicsItem::mouseMoveEvent(event);
- scene()->update();
+ scene()->update();
}
QPointF getEntry() const {
return mapToScene(QPointF(width/2, 0));
}
- std::array<QPointF, 3> getExits() const {
- return { { mapToScene(QPointF( width/3, height)),
+ std::array<QPointF, 3> getExits() const {
+ return { { mapToScene(QPointF( width/3, height)),
mapToScene(QPointF( width/2, height)),
mapToScene(QPointF(2*width/3, height)) } };
- }
+ }
- 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);
- if (_widget.rowCount() != 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);
+ if (_widget.text() != "")
_widget.render(painter, QPoint(5, 20));
- }
+ }
void addPrevious(BasicBlockWidget * widget) {
previous.push_back(widget);
next[1] = right;
}
- BasicBlockWidget ** getNext() {
- return next;
- }
+ BasicBlockWidget ** getNext() {
+ return next;
+ }
private:
- uint32_t width, height;
- QTableWidget _widget;
+ uint32_t width, height;
+ QLabel _widget;
QString name;
BasicBlock * block;
std::vector<BasicBlockWidget*> previous;