mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-20 06:50:40 -04:00
Reverted to Forum Msgs back to before formatting.
Made self appear in center of NetworkView git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@850 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
e32a96f5fe
commit
02583ad232
4 changed files with 91 additions and 843 deletions
|
@ -42,6 +42,7 @@
|
|||
#include "edge.h"
|
||||
#include "node.h"
|
||||
#include "graphwidget.h"
|
||||
#include <math.h>
|
||||
|
||||
Node::Node(GraphWidget *graphWidget, uint32_t t, std::string id_in, std::string n)
|
||||
: graph(graphWidget), ntype(t), id(id_in), name(n),
|
||||
|
@ -87,8 +88,9 @@ void Node::calculateForces()
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Now subtract all forces pulling items together
|
||||
double weight = (edgeList.size() + 1) * 10;
|
||||
double weight = sqrt(edgeList.size() + 1) * 10;
|
||||
foreach (Edge *edge, edgeList) {
|
||||
QPointF pos;
|
||||
if (edge->sourceNode() == this)
|
||||
|
@ -98,14 +100,25 @@ void Node::calculateForces()
|
|||
xvel += pos.x() / weight;
|
||||
yvel += pos.y() / weight;
|
||||
}
|
||||
|
||||
|
||||
// push away from edges too.
|
||||
QRectF sceneRect = scene()->sceneRect();
|
||||
int mid_x = (sceneRect.left() + sceneRect.right()) / 2;
|
||||
int mid_y = (sceneRect.top() + sceneRect.bottom()) / 2;
|
||||
|
||||
if (qAbs(xvel) < 0.1 && qAbs(yvel) < 0.1)
|
||||
xvel = yvel = 0;
|
||||
|
||||
QRectF sceneRect = scene()->sceneRect();
|
||||
newPos = pos() + QPointF(xvel, yvel);
|
||||
newPos.setX(qMin(qMax(newPos.x(), sceneRect.left() + 10), sceneRect.right() - 10));
|
||||
newPos.setY(qMin(qMax(newPos.y(), sceneRect.top() + 10), sceneRect.bottom() - 10));
|
||||
|
||||
if (ntype == ELASTIC_NODE_TYPE_OWN)
|
||||
{
|
||||
/* own one always goes in the middle */
|
||||
newPos.setX(mid_x);
|
||||
newPos.setY(mid_y);
|
||||
}
|
||||
}
|
||||
|
||||
bool Node::advance()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue