fix: edge bounds
This commit is contained in:
@@ -13,8 +13,7 @@ FloatingEdgeGraphic::FloatingEdgeGraphic(SocketGraphic* socket1, QGraphicsItem *
|
||||
|
||||
QRectF FloatingEdgeGraphic::boundingRect() const
|
||||
{
|
||||
// TODO: fix
|
||||
auto boundRect = QRect(10,10,10,10);
|
||||
auto boundRect = QRectF(socket1_->scenePos(), floatPos_).normalized();
|
||||
return boundRect;
|
||||
}
|
||||
|
||||
@@ -22,6 +21,7 @@ void FloatingEdgeGraphic::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
||||
{
|
||||
// auto pen = QPen("white");
|
||||
|
||||
std::cout << "draw\n";
|
||||
QLinearGradient gradient(socket1_->scenePos(), floatPos_);
|
||||
gradient.setColorAt(0.0, QColor(255, 255, 255, 255));
|
||||
gradient.setColorAt(1.0, QColor(255, 255, 255, 50));
|
||||
@@ -34,5 +34,10 @@ void FloatingEdgeGraphic::paint(QPainter *painter, const QStyleOptionGraphicsIte
|
||||
|
||||
}
|
||||
|
||||
void FloatingEdgeGraphic::setFloatPos(QPointF floatPos) { floatPos_ = floatPos; }
|
||||
void FloatingEdgeGraphic::setFloatPos(QPointF floatPos) {
|
||||
std::cout << "moving" << floatPos.x() << " " << floatPos.y() << "\n";
|
||||
prepareGeometryChange();
|
||||
floatPos_ = floatPos;
|
||||
update();
|
||||
}
|
||||
|
||||
|
||||
@@ -77,8 +77,8 @@ void Network::socketClicked(SocketGraphic* socket, QMouseEvent *event)
|
||||
{
|
||||
std::cout << "creating floating edge\n";
|
||||
floatingEdge_ = new FloatingEdgeGraphic(socket);
|
||||
floatingEdge_->setFloatPos(view_->mapToScene(event->pos()));
|
||||
scene_->addItem(floatingEdge_);
|
||||
floatingEdge_->setFloatPos(view_->mapToScene(event->pos()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,6 @@ void Network::mouseMoved(QMouseEvent *event)
|
||||
if(floatingEdge_)
|
||||
{
|
||||
floatingEdge_->setFloatPos(view_->mapToScene(event->pos()));
|
||||
floatingEdge_->update();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ NodeEdgeGraphic::NodeEdgeGraphic(SocketGraphic* socket1, SocketGraphic* socket2,
|
||||
|
||||
QRectF NodeEdgeGraphic::boundingRect() const
|
||||
{
|
||||
auto boundRect = QRect(10,10,10,10);
|
||||
auto boundRect = QRectF(socket1_->scenePos(), socket2_->scenePos());
|
||||
return boundRect;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user