QPainterPath CurveGraphicsItem::obtainCurvePath() const {
    if (useMidPoint_) {
    return obtainCurvePath(getStartPoint(), getMidPoint()) + 
        obtainCurvePath(getMidPoint(), getEndPoint());    
    } else {
        return obtainCurvePath(getStartPoint(), getEndPoint());
    }
}
void LinkConnectionGraphicsItem::updateShape() {
    QPointF inRight = inLink_->getRightPos();
    QPointF inLeft = inLink_->getLeftPos();
    QPointF outRight = outLink_->getRightPos();
    QPointF outLeft = outLink_->getLeftPos();

    QPointF start;
    QPointF stop;

    if (outLeft.x() < inRight.x()) {
        start = outLeft;
        stop = inRight;
    } else if (outRight.x() > inLeft.x()) {
        start = outRight;
        stop = inLeft;
    } else {
        start = outLeft;
        stop = inLeft;
    }

    QPointF topLeft = QPointF(std::min(start.x(), stop.x()), std::min(start.y(), stop.y()));
    QPointF bottomRight = QPointF(std::max(start.x(), stop.x()), std::max(start.y(), stop.y()));
    rect_ = QRectF(topLeft.x() - 30, topLeft.y() - 10, bottomRight.x() - topLeft.x() + 70,
                   bottomRight.y() - topLeft.y() + 20);

    path_ = obtainCurvePath();

    prepareGeometryChange();
}
void CurveGraphicsItem::updateShape() {   
    path_ = obtainCurvePath();

    QRectF p = path_.boundingRect();
    rect_ = QRectF(p.topLeft() - QPointF(5, 5), p.size() + QSizeF(10, 10));

    prepareGeometryChange();
}
void LinkGraphicsItem::updateShape() {
    prepareGeometryChange();

    QPointF topLeft =
        QPointF(std::min(startPoint_.x(), endPoint_.x()), std::min(startPoint_.y(), endPoint_.y()));
    rect_ = QRectF(topLeft.x() - 40.0, topLeft.y() - 10.0,
                   std::abs(startPoint_.x() - endPoint_.x()) + 80.0,
                   std::abs(startPoint_.y() - endPoint_.y()) + 20.0);

    path_ = obtainCurvePath();
}