Skip to content

Commit

Permalink
add option to change calculation of magnitude of edges
Browse files Browse the repository at this point in the history
  • Loading branch information
sandsmark committed Mar 2, 2016
1 parent f0970f8 commit 03e70ee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions hivewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include <QMouseEvent>

HiveWidget::HiveWidget(QWidget *parent)
: QOpenGLWidget(parent)
: QOpenGLWidget(parent),
m_scaleEdgeMax(true)
{
setMouseTracking(true);
}
Expand Down Expand Up @@ -182,8 +183,13 @@ void HiveWidget::calculate()
double otherMagnitude = hypot(otherX - cx, otherY - cy);
double averageRadians = atan2(((nodeY - cy) + (otherY - cy))/2, ((nodeX - cx) + (otherX - cx))/2);

// double averageMagnitude = (magnitude + otherMagnitude) / 2;
double averageMagnitude = qMax(magnitude, otherMagnitude);
double averageMagnitude;
if (m_scaleEdgeMax) {
averageMagnitude = qMax(magnitude, otherMagnitude);
} else {
averageMagnitude = (magnitude + otherMagnitude) / 2;
}

QPointF controlPoint(cos(averageRadians) * averageMagnitude + cx, sin(averageRadians) * averageMagnitude + cy);

QLinearGradient gradient(m_positions[node], m_positions[otherNode]);
Expand Down
1 change: 1 addition & 0 deletions hivewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class HiveWidget : public QOpenGLWidget
QMap<QString, QColor> m_colors;
QMap<QString, QPoint> m_positions;
QString m_closest;
bool m_scaleEdgeMax;
};

#endif // HIVEWIDGET_H

0 comments on commit 03e70ee

Please sign in to comment.