feat: add node edges
This commit is contained in:
@@ -1,29 +1,39 @@
|
||||
#pragma once
|
||||
#include <QGraphicsItem>
|
||||
#include <QPainter>
|
||||
#include "gui/network/SocketGraphic.h"
|
||||
#include "gui/network/NodeEdgeGraphic.h"
|
||||
#include <iostream>
|
||||
|
||||
class NodeGraphic
|
||||
: public QGraphicsItem
|
||||
{
|
||||
public:
|
||||
NodeGraphic(QGraphicsItem *parent = nullptr);
|
||||
QRectF boundingRect() const override
|
||||
{
|
||||
qreal penWidth = 6;
|
||||
return QRectF(-10 - penWidth / 2, -10 - penWidth / 2,
|
||||
20 + penWidth, 20 + penWidth);
|
||||
}
|
||||
QRectF boundingRect() const override;
|
||||
|
||||
SocketGraphic* getInput(int indx) const;
|
||||
SocketGraphic* getOutput(int indx) const;
|
||||
|
||||
void addEdge(NodeEdgeGraphic* edge);
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||
|
||||
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override
|
||||
{
|
||||
QPen greenPen = QPen(Qt::green);
|
||||
greenPen.setWidth(6);
|
||||
painter->setPen(greenPen);
|
||||
|
||||
painter->drawRoundedRect(-10, -10, 20, 20, 5, 5);
|
||||
}
|
||||
|
||||
private:
|
||||
QGraphicsTextItem* title_;
|
||||
void initSockets();
|
||||
std::vector<SocketGraphic*> inputs_;
|
||||
std::vector<SocketGraphic*> outputs_;
|
||||
|
||||
std::vector<NodeEdgeGraphic*> edges_;
|
||||
|
||||
std::string title_="";
|
||||
int maxTitleLen_=10;
|
||||
QRectF bodyRect_;
|
||||
int socketSize_ = 1;
|
||||
int inputSocketCnt_=0;
|
||||
int outputSocketCnt_=0;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user